Contents
Class AST
java.lang.Object
com.hypixel.hytale.server.npc.util.expression.compile.ast.AST
- Direct Known Subclasses:
ASTOperand, ASTOperator
The AST (=Abstract Syntax Tree) is an intermediate form of the parsed expression
suitable for high level optimisations and type checking. The AST represents a node in the expression tree
and can have a variable amount of children as operands.
Parser feeds the AST operators and operands in Reverse Polish Notation.
Does simple optimisations like constant folding on direct child nodes.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiongenCode(List<ExecutionContext.Instruction> list, Scope scope) Generate an instruction list from AST.booleandoublegetToken()intabstract booleanvoid
-
Constructor Details
-
AST
-
-
Method Details
-
getParent
-
setParent
-
getValueType
-
getToken
-
getTokenPosition
public int getTokenPosition() -
getCodeGen
-
isConstant
public abstract boolean isConstant() -
asOperand
-
getString
-
getBoolean
public boolean getBoolean() -
getNumber
public double getNumber() -
returnType
-
genCode
Generate an instruction list from AST.If provided a scope as argument any references to function and variables are resolved to suppliers/functions from this scope, making the instructions only run with the same scope/context. This makes it possible to bind instructions to a specific object and eliminates the need to update the symbol table, as values can be read directly from the bound objects(s) using the suppliers.
If the provided scope is null then variables and functions are looked up in the scope passed as argument when executing the instructions.
- Parameters:
list- List to append instructions toscope- if not null does deep resolve of variables and functions- Returns:
- Result type of expression
-