Node * new_CodestrNode(Node * expr, int block, VarColl * params) { int i; NEWVAR(CodestrNode, ret); init_Node(ret, pass_CodestrNode, "codestr"); ret->expr = expr; ret->node.isExpr = 1; ret->buf = new_StrBuf(); ret->block = block; ret->params = params; init_Coll(&ret->coll, 0, 0); if (params) for (i = 0; i < params->unsorted.count_of_Coll; i++) { VAR(Var, vpp, params->unsorted.items_of_Coll[i]); vpp->isCodeParam = 1; vpp->isParam = 1; } return (Node *) ret; }
Node * new_LoopExitNode(int isLoop) { NEWVAR(LoopExitNode, ret); init_Node(ret, pass_LoopExitNode, "loopexit"); ret->isLoop = isLoop; return (Node *) ret; }
Node * new_ReturnNode(Node * expr, int isExprList) { NEWVAR(ExprNode, ret); init_Node(ret, pass_ReturnNode, "return"); ret->expr = expr; ret->i = isExprList; return (Node *) ret; }
Node * new_ExprArrNode() { NEWVAR(ExprArrNode, ret); init_Node(ret, pass_ExprArrNode, "exprarr"); ret->node.isExpr = 1; ret->node.isExprList = 1; init_Coll(&(ret->coll), 0, 0); return (Node *) ret; }
Node * new_QuotNode(Node * expr) { NEWVAR(ExprNode, ret); init_Node(ret, pass_QuotNode, "quot"); ret->expr = expr; ret->node.isExpr = 1; return (Node *) ret; }
Node * new_ArrayInitNodeN(Node * exprlist, int n) { NEWVAR(ExprNode, ret); init_Node(ret, pass_ArrayInitNode, "arrayinit"); ret->node.isExpr = 1; ret->i = n; ret->expr = exprlist; ret->node.isConst = exprlist->isConst; ret->node.isArray = 1; return (Node *) ret; }
Node * new_LocalNode(Var * vp) { NEWVAR(VarNode, ret); init_Node(ret, pass_LocalNode, "local"); ret->vp = vp; ret->node.isExpr = 1; ret->node.isLval = 1; ret->node.isLocal = 1; ret->fp = curFunction; curFunction->goto_trap_of_Function++; ins_name(vp->name); return (Node *) ret; }
Node * new_CallNameNode(Node * name, Coll * argv) { int i; NEWVAR(CallNameNode, ret); init_Node(ret, pass_CallNameNode, "callname"); for (i = 0; i < argv->count_of_Coll; i++) { VAR(Node, np, argv->items_of_Coll[i]); append_Node(&ret->node, np); } ret->name = name; ret->argc = argv->count_of_Coll; curFunction->goto_trap_of_Function++; delete_Coll(argv); return (Node *) ret; }
Node * new_ArgNode(Node * expr, int byRef) { NEWVAR(ExprNode, ret); init_Node(ret, pass_ArgNode, "arg"); ret->expr = expr; ret->node.isExpr = 1; ret->node.isLval = expr->isLval; ret->node.isConst = expr->isConst; ret->i = byRef; if (byRef && expr->isConst) yyerror("reference to constant"); if (byRef && !expr->isLval) yyerror("reference to temporary object"); return (Node *) ret; }
Node * new_ForeachNode(Node * var, Node * expr, Node * list, int keys) { NEWVAR(ForNode, ret); init_Node(ret, pass_ForeachNode, "foreach"); ret->node.line = var->line; ret->node.file = var->file; ret->init = expr; ret->var = var; ret->list = list; ret->labelNo = curFunction->labelNo_of_Function; ret->keys = keys; curFunction->labelNo_of_Function += 1; curFunction->haveIf_of_Function++; return (Node *) ret; }
Node * new_SetNode(Node * obj, char *name, Node * expr) { char *s; NEWVAR(ObjNode, ret); init_Node(ret, pass_SetNode, "set"); ret->name = name; for (s = ret->name; *s; ++s) *s = toupper(*s); ret->hash = hashstr(name); ret->argc = 0; ret->obj = obj; append_Node(&ret->node, expr); curFunction->goto_trap_of_Function++; ins_name(name); return (Node *) ret; }
Node * newList_CallNode(char *name, Node * exprlist) { char *s; NEWVAR(CallNode, ret); init_Node(ret, pass_CallNode, "call"); join_Node((Node *) ret, exprlist); ret->name = name; for (s = ret->name; *s; ++s) *s = toupper(*s); ret->hash = hashstr(name); ret->argc = getCount_Node((Node *) ret); ret->isC = 1; ret->cfunc = curFunction; ins_name(name); curFunction->goto_trap_of_Function++; gettext_CallNode(ret); return (Node *) ret; }
// Build tree bottom-up static Node MakeTree(int iDepth) { Node result; if (iDepth<=0) { # ifndef GC result = calloc(1, sizeof(Node0)); # else result = GC_NEW(Node0); HOLE(); # endif /* result is implicitly initialized in both cases. */ return result; } else { Node left = MakeTree(iDepth-1); Node right = MakeTree(iDepth-1); # ifndef GC result = malloc(sizeof(Node0)); # else result = GC_NEW(Node0); HOLE(); # endif init_Node(result, left, right); return result; } }