TreeNode* alloc_binop_node(const char* op, TreeNode* arg0, TreeNode* arg1) { TreeNode* tn = alloc_tree_node(BINOP_TYPE); tn->name = lstrdup(op); tn->arg0 = arg0; tn->arg1 = arg1; return tn; }
TreeNode* alloc_bind_node(TreeNode* name, TreeNode* arg0) { assert(name->type == SYMBOL_TYPE); TreeNode *tn = alloc_tree_node(BIND_TYPE); tn->name = lstrdup((char*)name->data); tn->arg0 = arg0; return tn; }
TreeNode* alloc_call_lambda_node(TreeNode* fun, TreeNode* args, TreeNode* lambda) { TreeNode* tn = alloc_tree_node(CALL_LAMBDA_TYPE); tn->arg0 = fun; tn->arg1 = args; tn->arg2 = lambda; return tn; }
TreeNode* alloc_list_node(TreeNode* head, TreeNode* tail) { if (head == NULL) carp("Can't have null CAR in list."); TreeNode* tn = alloc_tree_node(LIST_TYPE); tn->arg0 = head; tn->arg1 = tail; return tn; }
struct tree *lookup_tree(const unsigned char *sha1) { struct object *obj = lookup_object(sha1); if (!obj) return create_object(sha1, OBJ_TREE, alloc_tree_node()); if (!obj->type) obj->type = OBJ_TREE; if (obj->type != OBJ_TREE) { error("Object %s is a %s, not a tree", sha1_to_hex(sha1), typename(obj->type)); return NULL; }
TreeNode* alloc_fun_node(const char* rtype, const char* name, TreeNode* params, TreeNode* body) { char* rcvr = 0; if (rtype) { rcvr = lstrdup(rtype); } TreeNode* tn = alloc_tree_node(FUN_TYPE); tn->name = lstrdup(name); tn->data = rcvr; tn->arg0 = params; tn->arg1 = body; return tn; }
parse_tree create_tree_node( int node_type ,int node_pos, parse_tree subnode, int condition ) { parse_tree tree; printf("Request to create a tree node\n"); tree=alloc_tree_node(); tree->node_type=node_type; tree->node_pos=node_pos; tree->node[0]=subnode; if (subnode!=NULL) { tree->no_sub_nodes=1; } else { tree->no_sub_nodes=0; } return(tree); }