T - annotation typepublic abstract class AbstractProtelisAST<T> extends java.lang.Object implements ProtelisAST<T>, WithBytecode
ProtelisAST.| Modifier | Constructor and Description |
|---|---|
protected |
AbstractProtelisAST(Metadata metadata,
java.util.List<ProtelisAST<?>> branch) |
protected |
AbstractProtelisAST(Metadata metadata,
ProtelisAST<?>... branch) |
| Modifier and Type | Method and Description |
|---|---|
protected java.lang.String |
branchesToString() |
protected java.lang.String |
branchesToString(java.lang.CharSequence separator,
java.lang.CharSequence prefix,
java.lang.CharSequence postfix)
Returns a
String representing the branches of this tree with the
specified format. |
T |
eval(ExecutionContext context)
Evaluates the program using the passed
ExecutionContext. |
protected abstract T |
evaluate(ExecutionContext context)
Evaluates this AST node.
|
protected void |
forEach(java.util.function.Consumer<? super ProtelisAST<?>> action)
Facility to run lambdas across all the branches.
|
protected void |
forEachWithIndex(java.util.function.BiConsumer<java.lang.Integer,? super ProtelisAST<?>> action)
Facility to run lambdas across all the branches.
|
ProtelisAST<?> |
getBranch(int i) |
java.util.List<ProtelisAST<?>> |
getBranches() |
protected int |
getBranchesNumber() |
Metadata |
getMetadata() |
java.lang.String |
getName() |
protected boolean |
isNullable() |
protected static java.lang.String |
stringFor(ProtelisAST<?> tree)
A String representation of an
ProtelisAST. |
java.lang.String |
toString() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetBytecodeprotected AbstractProtelisAST(Metadata metadata, ProtelisAST<?>... branch)
metadata - A Metadata object containing information about the code that generated this AST node.branch - the branches for this treeprotected AbstractProtelisAST(Metadata metadata, java.util.List<ProtelisAST<?>> branch)
metadata - A Metadata object containing information about the code that generated this AST node.branch - the branches for this treeprotected final java.lang.String branchesToString()
String representing the branches of this tree, in the
format (b1, b2, ..., bn).protected final java.lang.String branchesToString(java.lang.CharSequence separator,
java.lang.CharSequence prefix,
java.lang.CharSequence postfix)
String representing the branches of this tree with the
specified format.separator - the separator CharSequenceprefix - the prefixpostfix - the postfixString representing the branches of this tree with the
specified format.public final T eval(ExecutionContext context)
ProtelisASTExecutionContext.eval in interface ProtelisAST<T>context - the execution contextprotected abstract T evaluate(ExecutionContext context)
AbstractProtelisAST takes care of storing the necessary metadata.context - the execution contextprotected final void forEach(java.util.function.Consumer<? super ProtelisAST<?>> action)
action - the Consumer to executeprotected boolean isNullable()
protected final void forEachWithIndex(java.util.function.BiConsumer<java.lang.Integer,? super ProtelisAST<?>> action)
action - the Consumer to executepublic final ProtelisAST<?> getBranch(int i)
getBranch in interface ProtelisAST<T>i - the indexpublic final java.util.List<ProtelisAST<?>> getBranches()
getBranches in interface ProtelisAST<T>protected final int getBranchesNumber()
public final Metadata getMetadata()
getMetadata in interface ProtelisAST<T>Metadata object containing information about the code that generated this AST node.public java.lang.String getName()
getName in interface ProtelisAST<T>public java.lang.String toString()
toString in class java.lang.Objectprotected static final java.lang.String stringFor(ProtelisAST<?> tree)
ProtelisAST. Itree - the tree to stringifygetName()