Class Frame

java.lang.Object
me.topchetoeu.j2s.runtime.Frame

public final class Frame extends Object
  • Field Details

    • KEY

      public static final me.topchetoeu.j2s.common.Key<Stack<Frame>> KEY
    • MAX_STACK_COUNT

      public static final me.topchetoeu.j2s.common.Key<Integer> MAX_STACK_COUNT
    • HIDE_STACK

      public static final me.topchetoeu.j2s.common.Key<Boolean> HIDE_STACK
    • STACK_OVERFLOW

      public static final EngineException STACK_OVERFLOW
    • captures

      public final Value[][] captures
      An array of captures from the parent function
    • locals

      public final Value[] locals
      An array of non-capture variables
    • capturables

      public final Value[][] capturables
      An array of children-captured variables
    • self

      public final Value self
    • target

      public final Value target
    • args

      public final Value[] args
    • argsVal

      public final Value argsVal
    • argsLen

      public final Value argsLen
    • isNew

      public final boolean isNew
    • tryStack

      public final Stack<Frame.TryCtx> tryStack
    • function

      public final CodeFunction function
    • env

      public final me.topchetoeu.j2s.common.Environment env
    • stack

      public Value[] stack
    • stackPtr

      public int stackPtr
    • codePtr

      public int codePtr
    • jumpFlag

      public boolean jumpFlag
    • popTryFlag

      public boolean popTryFlag
  • Constructor Details

    • Frame

      public Frame(me.topchetoeu.j2s.common.Environment env, boolean isNew, Value target, Value self, Value[] args, CodeFunction func)
  • Method Details

    • getVar

      public Value getVar(int i)
    • setVar

      public Value setVar(int i, Value val)
    • captureVar

      public Value[] captureVar(int i)
    • addTry

      public void addTry(int start, int end, int catchStart, int finallyStart)
    • peek

      public Value peek()
    • peek

      public Value peek(int offset)
    • pop

      public Value pop()
    • take

      public Value[] take(int n)
    • push

      public void push(Value val)
    • replace

      public void replace(Value val)
    • next

      public final Value next(Value value, Value returnValue, EngineException error)
      This is provided only for optimization-sike. All parameters must be null except at most one, otherwise undefined behavior
    • next

      public final Value next()
      Executes the next instruction in the frame
    • next

      public final Value next(Value value)
      Induces a value on the stack (as if it were returned by the last function call) and executes the next instruction in the frame.
      Parameters:
      value - The value to induce
    • induceError

      public final Value induceError(EngineException error)
      Induces a thrown error and executes the next instruction. Note that this is different than just throwing the error outside the function, as the function executed could have a try-catch which would otherwise handle the error
      Parameters:
      error - The error to induce
    • induceReturn

      public final Value induceReturn(Value value)
      Induces a return, as if there was a return statement before the currently executed instruction and executes the next instruction. Note that this is different than just returning the value outside the function, as the function executed could have a try-catch which would otherwise handle the error
      Parameters:
      value - The retunr value to induce
    • onPush

      public void onPush()
    • onPop

      public void onPop()
    • getValStackScope

      public ObjectValue getValStackScope()
      Gets an array proxy of the local locals
    • get

      public static Stack<Frame> get(me.topchetoeu.j2s.common.Environment env)
    • get

      public static Frame get(me.topchetoeu.j2s.common.Environment env, int i)