Class CompileContext

java.lang.Object
com.hypixel.hytale.server.npc.util.expression.compile.CompileContext
All Implemented Interfaces:
Parser.ParsedTokenConsumer

public class CompileContext extends Object implements Parser.ParsedTokenConsumer
Helper class for compiling an expression to an instruction list.
  • Constructor Details

    • CompileContext

      public CompileContext()
    • CompileContext

      public CompileContext(Scope scope)
  • Method Details

    • getScope

      public Scope getScope()
    • getOperandStack

      @Nonnull public Stack<AST> getOperandStack()
    • getExecutionContext

      @Nonnull public ExecutionContext getExecutionContext()
    • compile

      public ValueType compile(@Nonnull String expression, Scope compileScope, boolean fullResolve)
      Compile a JavaScript style expression string to an instruction list.
      Parameters:
      expression - String to compile
      compileScope - The symbol table to use
      fullResolve - If true symbol lookups are resolved directly with suppliers from the scope else lookup instructions are created
      Returns:
      The return type of the expression (instruction can be read with getInstructions())
    • compile

      public ValueType compile(@Nonnull String expression, Scope compileScope, boolean fullResolve, List<ExecutionContext.Instruction> instructions)
      Compile a JavaScript style expression string to an instruction list.
      Parameters:
      expression - String to compile
      compileScope - The symbol table to use
      fullResolve - If true symbol lookups are resolved directly with suppliers from the scope else lookup instructions are created
      instructions - list to store instructions too (will be cleared)
      Returns:
      The return type of the expression (instruction can be read with getInstructions())
    • compile

      public ValueType compile(@Nonnull String expression, boolean fullResolve)
      Compile a JavaScript style expression string to an instruction list.
      Parameters:
      expression - String to compile
      fullResolve - If true symbol lookups are resolved directly with suppliers from the scope else lookup instructions are created
      Returns:
      The return type of the expression (instruction can be read with getInstructions())
    • getInstructions

      public List<ExecutionContext.Instruction> getInstructions()
    • setInstructions

      public void setInstructions(List<ExecutionContext.Instruction> instructionList)
    • getResultType

      public ValueType getResultType()
    • getAsOperand

      @Nullable public ExecutionContext.Operand getAsOperand()
    • checkResultType

      public void checkResultType(ValueType type)
    • pushOperand

      public void pushOperand(@Nonnull Parser.ParsedToken parsedToken)
      Description copied from interface: Parser.ParsedTokenConsumer
      Process a single operand (identifier, number or string)
      Specified by:
      pushOperand in interface Parser.ParsedTokenConsumer
      Parameters:
      parsedToken - ParsedToken with operand
    • processOperator

      public void processOperator(@Nonnull Parser.ParsedToken operator) throws ParseException
      Description copied from interface: Parser.ParsedTokenConsumer
      Process a single operator.
      Specified by:
      processOperator in interface Parser.ParsedTokenConsumer
      Parameters:
      operator - ParsedToken with operator
      Throws:
      ParseException - In case of parser or lexer error
    • processFunction

      public void processFunction(int argumentCount) throws ParseException
      Description copied from interface: Parser.ParsedTokenConsumer
      Process a function call.

      The function name precedes the arguments on operand stack.

      Specified by:
      processFunction in interface Parser.ParsedTokenConsumer
      Parameters:
      argumentCount - number of arguments passed to function
      Throws:
      ParseException
    • processTuple

      public void processTuple(@Nonnull Parser.ParsedToken openingToken, int argumentCount)
      Description copied from interface: Parser.ParsedTokenConsumer
      Process a tuple.
      Specified by:
      processTuple in interface Parser.ParsedTokenConsumer
      Parameters:
      argumentCount - number of arguments passed to function
    • done

      public void done()
      Description copied from interface: Parser.ParsedTokenConsumer
      Called when expression parsed completely.
      Specified by:
      done in interface Parser.ParsedTokenConsumer