public abstract class AbstractConversionWorker extends AbstractPatternWorker
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
PEER_ID
Common key for AST peerid
|
resolver
Modifier | Constructor and Description |
---|---|
protected |
AbstractConversionWorker()
Default constructor.
|
Modifier and Type | Method and Description |
---|---|
static void |
crossReferencePeerAsts(Aast ast1,
Aast ast2)
Cross reference two ASTs with one another as peers.
|
static long |
getClosestPeerId(Aast ast)
Search the specified AST node and up each ancestor node in the path
to the root to find the first instance of the 'peerid' annotation.
|
static java.lang.Long |
getParentPeer(Aast ast)
Simple helper to return the peer ID annotation from the passed-in
node's parent.
|
static void |
initializeAst(Aast ast,
int type,
java.lang.String text,
Aast parent,
AstSymbolResolver resolver)
Initialize a newly created AST.
|
static void |
initializeAst(Aast ast,
int type,
java.lang.String text,
Aast parent,
AstSymbolResolver resolver,
int index)
Initialize a newly created AST.
|
static void |
initializeRootAst(Aast ast,
java.io.File file,
AstSymbolResolver resolver)
Worker routine to centralize initialization of a new AST that is a
root node.
|
static void |
initializeRootAst(Aast ast,
java.lang.String filename,
AstSymbolResolver resolver)
Worker routine to centralize initialization of a new AST that is a root node.
|
finish, getCopy, getLibrary, getSource, initialize, registerTree, resolveConstant, setLibrary, visitAst
public static final java.lang.String PEER_ID
protected AbstractConversionWorker()
public static void initializeAst(Aast ast, int type, java.lang.String text, Aast parent, AstSymbolResolver resolver)
This method always adds the node as the last child of the given parent.
ast
- AST which is to be initialized.type
- The token type for the AST.text
- The text for the AST.parent
- The parent AST node or null
.resolver
- AST symbol resolver if available, else null
.public static void initializeAst(Aast ast, int type, java.lang.String text, Aast parent, AstSymbolResolver resolver, int index)
ast
- AST which is to be initialized.type
- The token type for the AST.text
- The text for the AST.parent
- The parent AST node or null
.resolver
- AST symbol resolver if available, else null
.index
- 0 to insert as the first child, -1 to insert as the last
child or a 0-based index to specify an exact child index
at which to insert the new child. All current children at
that index or at a greater index, are moved right. If the
index is greater than the current number of children, the
new child will be added at the end.public static void initializeRootAst(Aast ast, java.io.File file, AstSymbolResolver resolver)
AstManager
and set into the AST.ast
- AST which is the root node to be initialized.file
- The file in which to persist the new AST.resolver
- The current instance of the AstSymbolResolver
in use or
null
.public static void initializeRootAst(Aast ast, java.lang.String filename, AstSymbolResolver resolver)
AstManager
and set into the AST.ast
- AST which is the root node to be initialized.filename
- The file in which to persist the new AST. Can be real or virtual (i.e. the file
can be never persisted into the file system, the name is used to map some ID to
the AST).resolver
- The current instance of the AstSymbolResolver
in use or null
.public static void crossReferencePeerAsts(Aast ast1, Aast ast2)
ast1
- AST to be cross-referenced with ast2
.ast2
- AST to be cross-referenced with ast1
.public static java.lang.Long getParentPeer(Aast ast)
ast
- The source or target node to operate upon.null
if
either the parent or the parent's peerid
annotation do not exist.public static long getClosestPeerId(Aast ast)