• Home
  • Raw
  • Download

Lines Matching full:tree

4 // starting point for your own tree. Though it is often easier just to tag things on
5 // to the user pointer in the tree unless you are building a different type
41 static pANTLR3_COMMON_TOKEN getToken (pANTLR3_BASE_TREE tree);
42 static pANTLR3_BASE_TREE dupNode (pANTLR3_BASE_TREE tree);
43 static ANTLR3_BOOLEAN isNilNode (pANTLR3_BASE_TREE tree);
44 static ANTLR3_UINT32 getType (pANTLR3_BASE_TREE tree);
45 static pANTLR3_STRING getText (pANTLR3_BASE_TREE tree);
46 static ANTLR3_UINT32 getLine (pANTLR3_BASE_TREE tree);
47 static ANTLR3_UINT32 getCharPositionInLine (pANTLR3_BASE_TREE tree);
48 static pANTLR3_STRING toString (pANTLR3_BASE_TREE tree);
49 static pANTLR3_BASE_TREE getParent (pANTLR3_BASE_TREE tree);
50 static void setParent (pANTLR3_BASE_TREE tree, pANTLR3_BASE_TREE parent);
51 static void setChildIndex (pANTLR3_BASE_TREE tree, ANTLR3_INT32 i);
52 static ANTLR3_INT32 getChildIndex (pANTLR3_BASE_TREE tree);
53 static void createChildrenList (pANTLR3_BASE_TREE tree);
54 static void reuse (pANTLR3_BASE_TREE tree);
60 static pANTLR3_BASE_TREE newFromTree (pANTLR3_ARBORETUM factory, pANTLR3_COMMON_TREE tree);
171 pANTLR3_COMMON_TREE tree; in newPoolTree() local
175 tree = (pANTLR3_COMMON_TREE)factory->nilStack->peek(factory->nilStack); in newPoolTree()
177 if (tree != NULL) in newPoolTree()
185 return (pANTLR3_BASE_TREE)tree; in newPoolTree()
188 // See if we need a new tree pool before allocating a new tree in newPoolTree()
204 tree = factory->pools[factory->thisPool] + factory->nextTree; in newPoolTree()
209 antlr3SetCTAPI(tree); in newPoolTree()
214 tree->factory = factory; in newPoolTree()
215 tree->baseTree.strFactory = factory->unTruc.baseTree.strFactory; in newPoolTree()
217 // The super points to the common tree so we must override the one used by in newPoolTree()
218 // by the pre-built tree as otherwise we will always poitn to the same initial in newPoolTree()
219 // common tree and we might spend 3 hours trying to debug why - this would never in newPoolTree()
222 tree->baseTree.super = tree; in newPoolTree()
227 return &(tree->baseTree); in newPoolTree()
232 newFromTree(pANTLR3_ARBORETUM factory, pANTLR3_COMMON_TREE tree) in newFromTree() argument
243 // Pick up the payload we had in the supplied tree in newFromTree()
245 ((pANTLR3_COMMON_TREE)(newTree->super))->token = tree->token; in newFromTree()
246 newTree->u = tree->baseTree.u; // Copy any user pointer in newFromTree()
263 // Pick up the payload we had in the supplied tree in newFromToken()
285 // We now JUST free the pools because the C runtime CommonToken based tree in factoryClose()
308 antlr3SetCTAPI(pANTLR3_COMMON_TREE tree) in antlr3SetCTAPI() argument
310 // Init base tree in antlr3SetCTAPI()
312 antlr3BaseTreeNew(&(tree->baseTree)); in antlr3SetCTAPI()
318 tree->baseTree.super = tree; in antlr3SetCTAPI()
320 // Common tree overrides in antlr3SetCTAPI()
322 tree->baseTree.isNilNode = isNilNode; in antlr3SetCTAPI()
323 tree->baseTree.toString = toString; in antlr3SetCTAPI()
324 tree->baseTree.dupNode = (void *(*)(pANTLR3_BASE_TREE))(dupNode); in antlr3SetCTAPI()
325 tree->baseTree.getLine = getLine; in antlr3SetCTAPI()
326 tree->baseTree.getCharPositionInLine = getCharPositionInLine; in antlr3SetCTAPI()
327 tree->baseTree.toString = toString; in antlr3SetCTAPI()
328 tree->baseTree.getType = getType; in antlr3SetCTAPI()
329 tree->baseTree.getText = getText; in antlr3SetCTAPI()
330 tree->baseTree.getToken = getToken; in antlr3SetCTAPI()
331 tree->baseTree.getParent = getParent; in antlr3SetCTAPI()
332 tree->baseTree.setParent = setParent; in antlr3SetCTAPI()
333 tree->baseTree.setChildIndex = setChildIndex; in antlr3SetCTAPI()
334 tree->baseTree.getChildIndex = getChildIndex; in antlr3SetCTAPI()
335 tree->baseTree.createChildrenList = createChildrenList; in antlr3SetCTAPI()
336 tree->baseTree.reuse = reuse; in antlr3SetCTAPI()
337 tree->baseTree.free = NULL; // Factory trees have no free function in antlr3SetCTAPI()
338 tree->baseTree.u = NULL; // Initialize user pointer in antlr3SetCTAPI()
340 tree->baseTree.children = NULL; in antlr3SetCTAPI()
342 tree->token = NULL; // No token as yet in antlr3SetCTAPI()
343 tree->startIndex = 0; in antlr3SetCTAPI()
344 tree->stopIndex = 0; in antlr3SetCTAPI()
345 tree->parent = NULL; // No parent yet in antlr3SetCTAPI()
346 tree->childIndex = -1; in antlr3SetCTAPI()
358 pANTLR3_COMMON_TREE tree; in antlr3CommonTreeNew() local
359 tree = (pANTLR3_COMMON_TREE)ANTLR3_CALLOC(1, sizeof(ANTLR3_COMMON_TREE)); in antlr3CommonTreeNew()
361 if (tree == NULL) in antlr3CommonTreeNew()
366 antlr3SetCTAPI(tree); in antlr3CommonTreeNew()
368 return tree; in antlr3CommonTreeNew()
383 //Pick up the payload we had in the supplied tree in antlr3CommonTreeNewFromToken()
393 createChildrenList (pANTLR3_BASE_TREE tree) in createChildrenList() argument
395tree->children = ((pANTLR3_COMMON_TREE)(tree->super))->factory->vFactory->newVector(((pANTLR3_COMM… in createChildrenList()
400 getToken (pANTLR3_BASE_TREE tree) in getToken() argument
402 // The token is the payload of the common tree or other implementor in getToken()
408 return ((pANTLR3_COMMON_TREE)(tree->super))->token; in getToken()
412 dupNode (pANTLR3_BASE_TREE tree) in dupNode() argument
414 // The node we are duplicating is in fact the common tree (that's why we are here) in dupNode()
419 theOld = (pANTLR3_COMMON_TREE)(tree->super); in dupNode()
427 isNilNode (pANTLR3_BASE_TREE tree) in isNilNode() argument
429 // This is a Nil tree if it has no payload (Token in our case) in isNilNode()
431 if (((pANTLR3_COMMON_TREE)(tree->super))->token == NULL) in isNilNode()
442 getType (pANTLR3_BASE_TREE tree) in getType() argument
446 theTree = (pANTLR3_COMMON_TREE)(tree->super); in getType()
459 getText (pANTLR3_BASE_TREE tree) in getText() argument
461 return tree->toString(tree); in getText()
464 static ANTLR3_UINT32 getLine (pANTLR3_BASE_TREE tree) in getLine() argument
469 cTree = (pANTLR3_COMMON_TREE)(tree->super); in getLine()
475 if (tree->getChildCount(tree) > 0) in getLine()
479 child = (pANTLR3_BASE_TREE)tree->getChild(tree, 0); in getLine()
487 static ANTLR3_UINT32 getCharPositionInLine (pANTLR3_BASE_TREE tree) in getCharPositionInLine() argument
491 token = ((pANTLR3_COMMON_TREE)(tree->super))->token; in getCharPositionInLine()
495 if (tree->getChildCount(tree) > 0) in getCharPositionInLine()
499 child = (pANTLR3_BASE_TREE)tree->getChild(tree, 0); in getCharPositionInLine()
508 static pANTLR3_STRING toString (pANTLR3_BASE_TREE tree) in toString() argument
510 if (tree->isNilNode(tree) == ANTLR3_TRUE) in toString()
514 nilNode = tree->strFactory->newPtr(tree->strFactory, (pANTLR3_UINT8)"nil", 3); in toString()
519 …return ((pANTLR3_COMMON_TREE)(tree->super))->token->getText(((pANTLR3_COMMON_TREE)(tree->super))->… in toString()
523 getParent (pANTLR3_BASE_TREE tree) in getParent() argument
525 if (((pANTLR3_COMMON_TREE)(tree->super))->parent == NULL) in getParent()
527 return & (((pANTLR3_COMMON_TREE)(tree->super))->parent->baseTree); in getParent()
531 setParent (pANTLR3_BASE_TREE tree, pANTLR3_BASE_TREE parent) in setParent() argument
533 …((pANTLR3_COMMON_TREE)(tree->super))->parent = parent == NULL ? NULL : ((pANTLR3_COMMON_TREE)(pare… in setParent()
537 setChildIndex (pANTLR3_BASE_TREE tree, ANTLR3_INT32 i) in setChildIndex() argument
539 ((pANTLR3_COMMON_TREE)(tree->super))->childIndex = i; in setChildIndex()
542 getChildIndex (pANTLR3_BASE_TREE tree ) in getChildIndex() argument
544 return ((pANTLR3_COMMON_TREE)(tree->super))->childIndex; in getChildIndex()
547 /** Clean up any child vector that the tree might have, so it can be reused,
551 reuse (pANTLR3_BASE_TREE tree) in reuse() argument
555 cTree = (pANTLR3_COMMON_TREE)(tree->super); in reuse()
565 cTree->factory->nilStack->push(cTree->factory->nilStack, tree, NULL); in reuse()