static int LibGFX_recursetree( | int | | node, | | AST_Node | ** | tempmap, | | AST_RawOpcodeMap | * | rawmap, | | int | | maxnode | ) |
|
recursive helper function for building a tree from an opcode map
This function takes the current root, and the list of pregenerated nodes, then fills in the node in question if it hasn’t been visited yet, silently return when the node is reachable from two sides, and complain if a cyclic dependency was detected or if the opcode map contains bogus data.
upon succesful return, the node requested is converted in a proper acyclic graph, with all properties set accordingly. upon failure, the states are undefined, except that node->children may have got a valid pointer assigned. it is required that node->children = NULL and node->refcount = 0 upon entry because cleanup becomes impossible otherwise. (this function does not do it) also, node->operatorindex must be correctly set for each node in tempmap
in
node | the current operator index |
tempmap | a list of pregenerated node pointers for each entry |
rawmap | the original raw opcode map |
maxnode | the amount of nodes preallocated, used in bounds checking |
out
return | 0 on success, 1 on failure. |
<libgfx_errormsg> | altered on failure. |