AST_Attribute* read_attribute(BufferedReader* reader) { AST_Attribute* rtn = new AST_Attribute(); rtn->attr = reader->readAndInternString(); 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_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_expr* read_boolop(BufferedReader* reader) { AST_BoolOp* rtn = new AST_BoolOp(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); rtn->op_type = (AST_TYPE::AST_TYPE)reader->readByte(); readExprVector(rtn->values, 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_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_Tuple* read_tuple(BufferedReader *reader) { AST_Tuple *rtn = new AST_Tuple(); rtn->col_offset = readColOffset(reader); rtn->ctx_type = (AST_TYPE::AST_TYPE)reader->readByte(); readExprVector(rtn->elts, reader); rtn->lineno = reader->readULL(); 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_ImportFrom* read_importfrom(BufferedReader *reader) { AST_ImportFrom *rtn = new AST_ImportFrom(); rtn->col_offset = readColOffset(reader); rtn->level = reader->readULL(); rtn->lineno = reader->readULL(); rtn->module = readString(reader); readMiscVector(rtn->names, reader); 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_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_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_Dict* read_dict(BufferedReader *reader) { AST_Dict *rtn = new AST_Dict(); rtn->col_offset = readColOffset(reader); readExprVector(rtn->keys, reader); rtn->lineno = reader->readULL(); readExprVector(rtn->values, reader); assert(rtn->keys.size() == rtn->values.size()); 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_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_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_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_ClassDef* read_classdef(BufferedReader *reader) { AST_ClassDef *rtn = new AST_ClassDef(); readExprVector(rtn->bases, reader); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); readExprVector(rtn->decorator_list, reader); rtn->lineno = reader->readULL(); rtn->name = readString(reader); return rtn; }
AST_FunctionDef* read_functiondef(BufferedReader *reader) { if (VERBOSITY("parsing") >= 2) printf("reading functiondef\n"); AST_FunctionDef *rtn = new AST_FunctionDef(); rtn->args = static_cast<AST_arguments*>(readASTMisc(reader)); readStmtVector(rtn->body, reader); rtn->col_offset = readColOffset(reader); readExprVector(rtn->decorator_list, reader); rtn->lineno = reader->readULL(); rtn->name = readString(reader); return rtn; }
AST_Import* read_import(BufferedReader *reader) { AST_Import *rtn = new AST_Import(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); int num_elts = reader->readShort(); for (int i = 0; i < num_elts; i++) { AST* elt = readASTMisc(reader); assert(elt->type == AST_TYPE::alias); rtn->names.push_back(static_cast<AST_alias*>(elt)); } 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_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; }
AST_Num* read_num(BufferedReader *reader) { AST_Num *rtn = new AST_Num(); rtn->num_type = (AST_Num::NumType)reader->readByte(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); if (rtn->num_type == AST_Num::INT) { rtn->n_int = reader->readULL(); // automatic conversion to signed } else if (rtn->num_type == AST_Num::FLOAT) { rtn->n_float = reader->readDouble(); } else { RELEASE_ASSERT(0, "%d", rtn->num_type); } return rtn; }
AST_Str* read_str(BufferedReader* reader) { AST_Str* rtn = new AST_Str(); rtn->str_type = (AST_Str::StrType)reader->readByte(); rtn->col_offset = readColOffset(reader); rtn->lineno = reader->readULL(); if (rtn->str_type == AST_Str::STR) { rtn->str_data = readString(reader); } else if (rtn->str_type == AST_Str::UNICODE) { rtn->str_data = readString(reader); } else { RELEASE_ASSERT(0, "%d", rtn->str_type); } return rtn; }