AST_Assert* read_assert(BufferedReader* reader) { AST_Assert* rtn = new AST_Assert(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->msg = readASTExpr(reader); rtn->test = readASTExpr(reader); return rtn; }
AST_DictComp* read_dictcomp(BufferedReader* reader) { AST_DictComp* rtn = new AST_DictComp(); rtn->col_offset = readColOffset(reader); readMiscVector(rtn->generators, reader); rtn->key = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->value = readASTExpr(reader); return rtn; }
AST_IfExp* read_ifexp(BufferedReader *reader) { AST_IfExp *rtn = new AST_IfExp(); rtn->body = readASTExpr(reader); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->orelse = readASTExpr(reader); rtn->test = readASTExpr(reader); return rtn; }
AST_AugAssign* read_augassign(BufferedReader *reader) { AST_AugAssign *rtn = new AST_AugAssign(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->op_type = (AST_TYPE::AST_TYPE)reader->readByte(); rtn->target = readASTExpr(reader); rtn->value = readASTExpr(reader); return rtn; }
AST_ExceptHandler* read_excepthandler(BufferedReader* reader) { AST_ExceptHandler* rtn = new AST_ExceptHandler(); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->name = readASTExpr(reader); rtn->type = readASTExpr(reader); return rtn; }
AST_With* read_with(BufferedReader *reader) { AST_With *rtn = new AST_With(); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); rtn->context_expr = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->optional_vars = readASTExpr(reader); return rtn; }
AST_Exec* read_exec(BufferedReader* reader) { AST_Exec* rtn = new AST_Exec(); rtn->body = readASTExpr(reader); rtn->col_offset = readColOffset(reader); rtn->globals = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->locals = readASTExpr(reader); return rtn; }
AST_expr* read_binop(BufferedReader *reader) { AST_BinOp *rtn = new AST_BinOp(); rtn->col_offset = readColOffset(reader); rtn->left = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->op_type = (AST_TYPE::AST_TYPE)reader->readByte(); rtn->right = readASTExpr(reader); return rtn; }
AST_For* read_for(BufferedReader *reader) { AST_For *rtn = new AST_For(); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); rtn->iter = readASTExpr(reader); rtn->lineno = reader->readULL(); readStmtVector(rtn->orelse, reader); rtn->target = readASTExpr(reader); return rtn; }
AST_Slice* read_slice(BufferedReader *reader) { AST_Slice *rtn = new AST_Slice(); rtn->col_offset = -1; rtn->lineno = -1; rtn->lower = readASTExpr(reader); rtn->step = readASTExpr(reader); rtn->upper = readASTExpr(reader); return rtn; }
AST_Subscript* read_subscript(BufferedReader *reader) { AST_Subscript *rtn = new AST_Subscript(); rtn->col_offset = readColOffset(reader); rtn->ctx_type = (AST_TYPE::AST_TYPE)reader->readByte(); rtn->lineno = reader->readULL(); rtn->slice = readASTExpr(reader); rtn->value = readASTExpr(reader); return rtn; }
AST_comprehension* read_comprehension(BufferedReader *reader) { AST_comprehension *rtn = new AST_comprehension(); readExprVector(rtn->ifs, reader); rtn->iter = readASTExpr(reader); rtn->target = readASTExpr(reader); rtn->col_offset = -1; rtn->lineno = -1; return rtn; }
AST_Raise* read_raise(BufferedReader* reader) { AST_Raise* rtn = new AST_Raise(); // "arg0" "arg1" "arg2" are called "type", "inst", and "tback" in the python ast, // so that's the order we have to read them: rtn->col_offset = readColOffset(reader); rtn->arg1 /*inst*/ = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->arg2 /*tback*/ = readASTExpr(reader); rtn->arg0 /*type*/ = readASTExpr(reader); return rtn; }
AST_Call* read_call(BufferedReader *reader) { AST_Call *rtn = new AST_Call(); readExprVector(rtn->args, reader); rtn->col_offset = readColOffset(reader); rtn->func = readASTExpr(reader); readMiscVector(rtn->keywords, reader); rtn->kwargs = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->starargs = readASTExpr(reader); return rtn; }
AST_Return* read_return(BufferedReader *reader) { AST_Return *rtn = new AST_Return(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->value = readASTExpr(reader); return rtn; }
static void readExprVector(std::vector<AST_expr*> &vec, BufferedReader *reader) { int num_elts = reader->readShort(); if (VERBOSITY("parsing") >= 2) printf("%d elts to read\n", num_elts); for (int i = 0; i < num_elts; i++) { vec.push_back(readASTExpr(reader)); } }
AST_keyword* read_keyword(BufferedReader *reader) { AST_keyword *rtn = new AST_keyword(); rtn->arg = readString(reader); rtn->col_offset = -1; rtn->lineno = -1; rtn->value = readASTExpr(reader); return rtn; }
AST_Index* read_index(BufferedReader *reader) { AST_Index *rtn = new AST_Index(); rtn->col_offset = -1; rtn->lineno = -1; rtn->value = readASTExpr(reader); assert(rtn->value); return rtn; }
AST_Assign* read_assign(BufferedReader *reader) { AST_Assign *rtn = new AST_Assign(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); readExprVector(rtn->targets, reader); rtn->value = readASTExpr(reader); return rtn; }
AST_ListComp* read_listcomp(BufferedReader *reader) { AST_ListComp *rtn = new AST_ListComp(); rtn->col_offset = readColOffset(reader); rtn->elt = readASTExpr(reader); readMiscVector(rtn->generators, reader); rtn->lineno = reader->readULL(); return rtn; }
AST_Lambda* read_lambda(BufferedReader* reader) { AST_Lambda* rtn = new AST_Lambda(); rtn->args = ast_cast<AST_arguments>(readASTMisc(reader)); rtn->body = readASTExpr(reader); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); return rtn; }
AST_If* read_if(BufferedReader *reader) { AST_If *rtn = new AST_If(); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); readStmtVector(rtn->orelse, reader); rtn->test = readASTExpr(reader); return rtn; }
AST_UnaryOp* read_unaryop(BufferedReader *reader) { AST_UnaryOp *rtn = new AST_UnaryOp(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->op_type = (AST_TYPE::AST_TYPE)reader->readByte(); rtn->operand = readASTExpr(reader); return rtn; }
AST_Attribute* read_attribute(BufferedReader *reader) { AST_Attribute *rtn = new AST_Attribute(); rtn->attr = readString(reader); rtn->col_offset = readColOffset(reader); rtn->ctx_type = (AST_TYPE::AST_TYPE)reader->readByte(); rtn->lineno = reader->readULL(); rtn->value = readASTExpr(reader); return rtn; }
AST_Print* read_print(BufferedReader *reader) { AST_Print *rtn = new AST_Print(); rtn->col_offset = readColOffset(reader); rtn->dest = readASTExpr(reader); rtn->lineno = reader->readULL(); rtn->nl = reader->readByte(); readExprVector(rtn->values, reader); return rtn; }
AST_arguments* read_arguments(BufferedReader *reader) { if (VERBOSITY("parsing") >= 2) printf("reading arguments\n"); AST_arguments *rtn = new AST_arguments(); readExprVector(rtn->args, reader); rtn->col_offset = -1; readExprVector(rtn->defaults, reader); rtn->kwarg = readASTExpr(reader); rtn->lineno = -1; //rtn->vararg = readASTExpr(reader); rtn->vararg = readString(reader); return rtn; }
AST_expr* read_compare(BufferedReader *reader) { AST_Compare *rtn = new AST_Compare(); rtn->col_offset = readColOffset(reader); readExprVector(rtn->comparators, reader); rtn->left = readASTExpr(reader); rtn->lineno = reader->readULL(); int num_ops = reader->readShort(); assert(num_ops == rtn->comparators.size()); for (int i = 0; i < num_ops; i++) { rtn->ops.push_back((AST_TYPE::AST_TYPE)reader->readByte()); } return rtn; }