Class Instruction

java.lang.Object
me.topchetoeu.j2s.common.Instruction

public class Instruction extends Object
  • Field Details

  • Method Details

    • get

      public <T> T get(int i)
    • tryStart

      public static Instruction tryStart(int catchStart, int finallyStart, int end)
      Signals the start of a protected context
      Parameters:
      catchStart - The point to witch to jump if an error has been caught
      finallyStart - The point to witch to jump after either the try or catch bodies have exited
      end - The point to which to jump after exiting the whole protected context
    • tryEnd

      public static Instruction tryEnd()
      Signifies that the current protected section (try, catch or finally) has ended
    • throwInstr

      public static Instruction throwInstr()
      Throws the top stack value
    • throwSyntax

      public static Instruction throwSyntax(SyntaxException err)
      Converts the given exception to a runtime syntax error and throws it
    • throwSyntax

      public static Instruction throwSyntax(String err)
      Converts the given exception to a runtime syntax error and throws it
    • throwSyntax

      public static Instruction throwSyntax(Location loc, String err)
      Converts the given exception to a runtime syntax error and throws it
    • delete

      public static Instruction delete()
      Performs a JS object property deletion. Operands: 1. Object to manipulate 2. Key to delete
    • ret

      public static Instruction ret()
      Returns the top stack value
    • debug

      public static Instruction debug()
      A special NOP instruction telling any debugger to pause
    • nop

      public static Instruction nop(Object... params)
      Does nothing. May be used for metadata or implementation-specific instructions that don't alter the behavior
    • call

      public static Instruction call(int argn, boolean hasSelf)
    • callNew

      public static Instruction callNew(int argn)
    • jmp

      public static Instruction jmp(int offset)
    • jmpIf

      public static Instruction jmpIf(int offset)
    • jmpIfNot

      public static Instruction jmpIfNot(int offset)
    • jmp

      public static IntFunction<Instruction> jmp(IntSupplier pos)
    • jmpIf

      public static IntFunction<Instruction> jmpIf(IntSupplier pos)
    • jmpIfNot

      public static IntFunction<Instruction> jmpIfNot(IntSupplier pos)
    • pushUndefined

      public static Instruction pushUndefined()
    • pushNull

      public static Instruction pushNull()
    • pushValue

      public static Instruction pushValue(boolean val)
    • pushValue

      public static Instruction pushValue(double val)
    • pushValue

      public static Instruction pushValue(String val)
    • globDef

      public static Instruction globDef(String name)
    • globGet

      public static Instruction globGet(String name, boolean force)
    • globSet

      public static Instruction globSet(String name, boolean keep, boolean define)
    • loadVar

      public static Instruction loadVar(int i)
    • loadThis

      public static Instruction loadThis()
    • loadArg

      public static Instruction loadArg(int i)
      Loads the given argument
      Parameters:
      i - The index of the argument to load. If -1, will get the index from the stack instead
    • loadArgsN

      public static Instruction loadArgsN()
      Pushes the amount of arguments to the stack
    • loadArgs

      public static Instruction loadArgs()
      Pushes the arguments object to the stack
    • loadCalled

      public static Instruction loadCalled()
      Loads a reference to the function being called
    • loadGlob

      public static Instruction loadGlob()
    • loadIntrinsics

      public static Instruction loadIntrinsics(String key)
    • loadError

      public static Instruction loadError()
    • loadMember

      public static Instruction loadMember()
    • loadMember

      public static Instruction loadMember(int member)
    • loadMember

      public static Instruction loadMember(String member)
    • loadFunc

      public static Instruction loadFunc(int id, String name, int[] captures)
    • loadObj

      public static Instruction loadObj()
    • loadArr

      public static Instruction loadArr(int count)
    • dup

      public static Instruction dup()
    • dup

      public static Instruction dup(int count, int offset)
    • storeVar

      public static Instruction storeVar(int i, boolean keep)
    • storeMember

      public static Instruction storeMember()
    • storeMember

      public static Instruction storeMember(boolean keep)
    • storeMember

      public static Instruction storeMember(String key)
    • storeMember

      public static Instruction storeMember(String key, boolean keep)
    • storeMember

      public static Instruction storeMember(int key)
    • storeMember

      public static Instruction storeMember(int key, boolean keep)
    • discard

      public static Instruction discard()
    • operation

      public static Instruction operation(Operation op)
    • toString

      public String toString()
      Overrides:
      toString in class Object