Skip to content

Expression

Package: com.hypixel.hytale.server.npc.util.expression

public class Expression

Entry point for the NPC expression evaluator. An Expression instance owns a CompileContext and an ExecutionContext and provides methods to compile expression strings into instruction lists, execute pre-compiled instructions, or evaluate an expression in a single call. The compile step uses a Lexer<Token> shared across all instances.

ModifierTypeNameDescription
private static finalLexer<Token>lexerShared lexer instance for tokenizing expression strings.
@Nonnull private finalExecutionContextexecutionContextExecution context obtained from the compile context.
@Nonnull private finalCompileContextcompileContextCompile context for parsing and type-checking expressions.
Signature
public Expression()
ModifierReturn TypeSignature
publicValueTypecompile(@Nonnull String expression, Scope scope, @Nonnull List<ExecutionContext.Instruction> instructions, boolean fullResolve)
publicValueTypecompile(@Nonnull String expression, Scope compileScope, @Nonnull List<ExecutionContext.Instruction> instructions)
@Nonnull publicExecutionContextexecute(@Nonnull List<ExecutionContext.Instruction> instructions, Scope scope)
@Nonnull publicExecutionContextexecute(@Nonnull ExecutionContext.Instruction[] instructions, Scope scope)
@Nonnull publicExecutionContextevaluate(@Nonnull String expression, Scope scope)
public staticValueTypecompileStatic(@Nonnull String expression, Scope scope, @Nonnull List<ExecutionContext.Instruction> instructions)
@Nonnull public staticLexer<Token>getLexerInstance()

compile() parses an expression string into a list of ExecutionContext.Instruction objects and returns the result type. execute() runs a pre-compiled instruction list against a Scope. evaluate() combines both steps for one-shot evaluation. The fullResolve parameter in the four-argument compile overload controls whether the compiler resolves all symbols at compile time.

  • ExecutionContext — the stack VM that runs compiled instructions
  • Scope — provides variable bindings and functions
  • ValueType — result type discriminant
Hydex is an independent community resource. Hytale is a trademark of Hypixel Studios. Hydex is not affiliated with or endorsed by Hypixel Studios.