GlueGen v2.6.0-rc-20250712
GlueGen, Native Binding Generator for Java™ (public API).
com.jogamp.gluegen.cgram.TNode Class Reference

Class TNode is an implementation of the AST interface and adds many useful features: More...

Inheritance diagram for com.jogamp.gluegen.cgram.TNode:
Collaboration diagram for com.jogamp.gluegen.cgram.TNode:

Classes

class  DebugASTVisitor
 

Public Member Functions

ASTLocusTag getASTLocusTag ()
 Returns this instance's ASTLocusTag, if available, otherwise returns null. More...
 
void initialize (final Token token)
 
void initialize (final AST tr)
 
int getType ()
 Get the token type for this node. More...
 
void setType (final int ttype_)
 Set the token type for this node. More...
 
boolean getMarker ()
 Get the marker value for this node. More...
 
void setMarker (final boolean marker_)
 Set the marker value for this node. More...
 
Hashtable< String, Object > getAttributesTable ()
 get the hashtable that holds attribute values. More...
 
void setAttribute (final String attrName, final Object value)
 set an attribute in the attribute table. More...
 
Object getAttribute (final String attrName)
 lookup the attribute name in the attribute table. More...
 
int getLineNum ()
 Get the line number for this node. More...
 
int getLocalLineNum ()
 
void setLineNum (final int lineNum_)
 Set the line number for this node. More...
 
String getText ()
 Get the token text for this node. More...
 
void setText (final String text_)
 Set the token text for this node. More...
 
String getAllChildrenText (final String name)
 Returns the text for this node, its children and siblings. More...
 
TNode getLastChild ()
 return the last child of this node, or null if there is none More...
 
TNode getLastSibling ()
 return the last sibling of this node, which is this if the next sibling is null More...
 
TNode getFirstSibling ()
 return the first sibling of this node, which is this if the prev sibling is null More...
 
TNode getParent ()
 return the parent node of this node More...
 
void addSibling (final AST node)
 add the new node as a new sibling, inserting it ahead of any existing next sibling. More...
 
int numberOfChildren ()
 return the number of children of this node More...
 
void removeSelf ()
 remove this node from the tree, resetting sibling and parent pointers as necessary. More...
 
TNode getDefNode ()
 return the def node for this node More...
 
void setDefNode (final TNode n)
 set the def node for this node More...
 
TNode deepCopy ()
 return a deep copy of this node, and all sub nodes. More...
 
TNode deepCopyWithRightSiblings ()
 return a deep copy of this node, all sub nodes, and right siblings. More...
 
String toString ()
 return a short string representation of the node More...
 
void doubleLink ()
 set up reverse links between this node and its first child and its first sibling, and link those as well More...
 
TNode parentOfType (final int type)
 find first parent of the given type, return null on failure More...
 
TNode firstChildOfType (final int type)
 find the first child of the node of the given type, return null on failure More...
 
TNode firstSiblingOfType (final int type)
 find the first sibling of the node of the given type, return null on failure More...
 
ASTLocusTag getASTLocusTag ()
 Returns this instance's ASTLocusTag, if available, otherwise returns null. More...
 

Static Public Member Functions

static void setTokenVocabulary (final String s)
 Set the token vocabulary to a tokentypes class generated by antlr. More...
 
static void printTree (final AST t)
 print given tree to System.out More...
 
static String getNameForType (final int t)
 converts an int tree token type to a name. More...
 

Static Protected Member Functions

static void printASTNode (final AST t, final int indent)
 protected method that does the work of printing More...
 

Protected Attributes

int ttype
 
String text
 
int lineNum = 0
 
TNode defNode
 
TNode up
 
TNode left
 
boolean marker = false
 
Hashtable< String, Object > attributes = null
 

Detailed Description

Class TNode is an implementation of the AST interface and adds many useful features:

It is double-linked for reverse searching. (this is currently incomplete, in that method doubleLink() must be called after any changes to the tree to maintain the reverse links).

It can store a definition node (defNode), so that nodes such as scoped names can refer to the node that defines the name.

It stores line numbers for nodes.

Searches for parents and children of a tree can be done based on their type.

The tree can be printed to System.out using a lisp-style syntax.

Definition at line 38 of file TNode.java.

Member Function Documentation

◆ addSibling()

void com.jogamp.gluegen.cgram.TNode.addSibling ( final AST  node)

add the new node as a new sibling, inserting it ahead of any existing next sibling.

This method maintains double-linking. if node is null, nothing happens. If the node has siblings, then they are added in as well.

Definition at line 306 of file TNode.java.

Here is the call graph for this function:

◆ deepCopy()

TNode com.jogamp.gluegen.cgram.TNode.deepCopy ( )

return a deep copy of this node, and all sub nodes.

New tree is doubleLinked, with no parent or siblings. Marker value is not copied!

Definition at line 368 of file TNode.java.

Here is the call graph for this function:

◆ deepCopyWithRightSiblings()

TNode com.jogamp.gluegen.cgram.TNode.deepCopyWithRightSiblings ( )

return a deep copy of this node, all sub nodes, and right siblings.

New tree is doubleLinked, with no parent or left siblings. defNode is not copied

Definition at line 387 of file TNode.java.

Here is the call graph for this function:

◆ doubleLink()

void com.jogamp.gluegen.cgram.TNode.doubleLink ( )

set up reverse links between this node and its first child and its first sibling, and link those as well

Definition at line 494 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ firstChildOfType()

TNode com.jogamp.gluegen.cgram.TNode.firstChildOfType ( final int  type)

find the first child of the node of the given type, return null on failure

Definition at line 523 of file TNode.java.

Here is the call graph for this function:

◆ firstSiblingOfType()

TNode com.jogamp.gluegen.cgram.TNode.firstSiblingOfType ( final int  type)

find the first sibling of the node of the given type, return null on failure

Definition at line 534 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getAllChildrenText()

String com.jogamp.gluegen.cgram.TNode.getAllChildrenText ( final String  name)

Returns the text for this node, its children and siblings.

Implementation converts the AST LISP notation to serialized form.

Definition at line 219 of file TNode.java.

Here is the caller graph for this function:

◆ getASTLocusTag()

ASTLocusTag com.jogamp.gluegen.cgram.TNode.getASTLocusTag ( )

Returns this instance's ASTLocusTag, if available, otherwise returns null.

If source is not available, implementation returns null.

Implements com.jogamp.gluegen.ASTLocusTag.ASTLocusTagProvider.

Definition at line 57 of file TNode.java.

◆ getAttribute()

Object com.jogamp.gluegen.cgram.TNode.getAttribute ( final String  attrName)

lookup the attribute name in the attribute table.

If the value does not exist, it returns null.

Definition at line 136 of file TNode.java.

◆ getAttributesTable()

Hashtable< String, Object > com.jogamp.gluegen.cgram.TNode.getAttributesTable ( )

get the hashtable that holds attribute values.

Definition at line 119 of file TNode.java.

Here is the caller graph for this function:

◆ getDefNode()

TNode com.jogamp.gluegen.cgram.TNode.getDefNode ( )

return the def node for this node

Definition at line 354 of file TNode.java.

Here is the caller graph for this function:

◆ getFirstSibling()

TNode com.jogamp.gluegen.cgram.TNode.getFirstSibling ( )

return the first sibling of this node, which is this if the prev sibling is null

Definition at line 286 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLastChild()

TNode com.jogamp.gluegen.cgram.TNode.getLastChild ( )

return the last child of this node, or null if there is none

Definition at line 266 of file TNode.java.

Here is the call graph for this function:

◆ getLastSibling()

TNode com.jogamp.gluegen.cgram.TNode.getLastSibling ( )

return the last sibling of this node, which is this if the next sibling is null

Definition at line 276 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getLineNum()

int com.jogamp.gluegen.cgram.TNode.getLineNum ( )

Get the line number for this node.

If the line number is 0, search for a non-zero line num among children

Definition at line 145 of file TNode.java.

Here is the caller graph for this function:

◆ getLocalLineNum()

int com.jogamp.gluegen.cgram.TNode.getLocalLineNum ( )

Definition at line 155 of file TNode.java.

◆ getMarker()

boolean com.jogamp.gluegen.cgram.TNode.getMarker ( )

Get the marker value for this node.

This member is a general-use marker.

Definition at line 108 of file TNode.java.

◆ getNameForType()

static String com.jogamp.gluegen.cgram.TNode.getNameForType ( final int  t)
static

converts an int tree token type to a name.

Does this by reflecting on nsdidl.IDLTreeTokenTypes, and is dependent on how ANTLR 2.00 outputs that class.

Definition at line 481 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ getParent()

TNode com.jogamp.gluegen.cgram.TNode.getParent ( )

return the parent node of this node

Definition at line 296 of file TNode.java.

◆ getText()

String com.jogamp.gluegen.cgram.TNode.getText ( )

Get the token text for this node.

Definition at line 175 of file TNode.java.

Here is the caller graph for this function:

◆ getType()

int com.jogamp.gluegen.cgram.TNode.getType ( )

Get the token type for this node.

Definition at line 97 of file TNode.java.

Here is the caller graph for this function:

◆ initialize() [1/2]

void com.jogamp.gluegen.cgram.TNode.initialize ( final AST  tr)

Definition at line 85 of file TNode.java.

Here is the call graph for this function:

◆ initialize() [2/2]

void com.jogamp.gluegen.cgram.TNode.initialize ( final Token  token)

Definition at line 76 of file TNode.java.

Here is the call graph for this function:

◆ numberOfChildren()

int com.jogamp.gluegen.cgram.TNode.numberOfChildren ( )

return the number of children of this node

Definition at line 319 of file TNode.java.

◆ parentOfType()

TNode com.jogamp.gluegen.cgram.TNode.parentOfType ( final int  type)

find first parent of the given type, return null on failure

Definition at line 509 of file TNode.java.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ printASTNode()

static void com.jogamp.gluegen.cgram.TNode.printASTNode ( final AST  t,
final int  indent 
)
staticprotected

protected method that does the work of printing

Definition at line 432 of file TNode.java.

Here is the call graph for this function:

◆ printTree()

static void com.jogamp.gluegen.cgram.TNode.printTree ( final AST  t)
static

print given tree to System.out

Definition at line 424 of file TNode.java.

Here is the caller graph for this function:

◆ removeSelf()

void com.jogamp.gluegen.cgram.TNode.removeSelf ( )

remove this node from the tree, resetting sibling and parent pointers as necessary.

This method maintains double-linking

Definition at line 332 of file TNode.java.

◆ setAttribute()

void com.jogamp.gluegen.cgram.TNode.setAttribute ( final String  attrName,
final Object  value 
)

set an attribute in the attribute table.

Definition at line 127 of file TNode.java.

Here is the caller graph for this function:

◆ setDefNode()

void com.jogamp.gluegen.cgram.TNode.setDefNode ( final TNode  n)

set the def node for this node

Definition at line 359 of file TNode.java.

◆ setLineNum()

void com.jogamp.gluegen.cgram.TNode.setLineNum ( final int  lineNum_)

Set the line number for this node.

Definition at line 169 of file TNode.java.

◆ setMarker()

void com.jogamp.gluegen.cgram.TNode.setMarker ( final boolean  marker_)

Set the marker value for this node.

This property is a general-use boolean marker.

Definition at line 113 of file TNode.java.

◆ setText()

void com.jogamp.gluegen.cgram.TNode.setText ( final String  text_)

Set the token text for this node.

Definition at line 179 of file TNode.java.

Here is the caller graph for this function:

◆ setTokenVocabulary()

static void com.jogamp.gluegen.cgram.TNode.setTokenVocabulary ( final String  s)
static

Set the token vocabulary to a tokentypes class generated by antlr.

Definition at line 70 of file TNode.java.

Here is the caller graph for this function:

◆ setType()

void com.jogamp.gluegen.cgram.TNode.setType ( final int  ttype_)

Set the token type for this node.

Definition at line 101 of file TNode.java.

Here is the caller graph for this function:

◆ toString()

String com.jogamp.gluegen.cgram.TNode.toString ( )

return a short string representation of the node

Definition at line 406 of file TNode.java.

Member Data Documentation

◆ attributes

Hashtable<String, Object> com.jogamp.gluegen.cgram.TNode.attributes = null
protected

Definition at line 46 of file TNode.java.

◆ defNode

TNode com.jogamp.gluegen.cgram.TNode.defNode
protected

Definition at line 42 of file TNode.java.

◆ left

TNode com.jogamp.gluegen.cgram.TNode.left
protected

Definition at line 44 of file TNode.java.

◆ lineNum

int com.jogamp.gluegen.cgram.TNode.lineNum = 0
protected

Definition at line 41 of file TNode.java.

◆ marker

boolean com.jogamp.gluegen.cgram.TNode.marker = false
protected

Definition at line 45 of file TNode.java.

◆ text

String com.jogamp.gluegen.cgram.TNode.text
protected

Definition at line 40 of file TNode.java.

◆ ttype

int com.jogamp.gluegen.cgram.TNode.ttype
protected

Definition at line 39 of file TNode.java.

◆ up

TNode com.jogamp.gluegen.cgram.TNode.up
protected

Definition at line 43 of file TNode.java.


The documentation for this class was generated from the following file: