Class CodeGenerator

java.lang.Object
org.htmlunit.corejs.javascript.Icode
org.htmlunit.corejs.javascript.CodeGenerator

class CodeGenerator extends Icode
Generates bytecode for the Interpreter.
  • Field Details

    • MIN_LABEL_TABLE_SIZE

      private static final int MIN_LABEL_TABLE_SIZE
      See Also:
    • MIN_FIXUP_TABLE_SIZE

      private static final int MIN_FIXUP_TABLE_SIZE
      See Also:
    • compilerEnv

      private CompilerEnvirons compilerEnv
    • itsInFunctionFlag

      private boolean itsInFunctionFlag
    • itsInTryFlag

      private boolean itsInTryFlag
    • itsData

      private InterpreterData itsData
    • scriptOrFn

      private ScriptNode scriptOrFn
    • iCodeTop

      private int iCodeTop
    • stackDepth

      private int stackDepth
    • lineNumber

      private int lineNumber
    • doubleTableTop

      private int doubleTableTop
    • strings

      private ObjToIntMap strings
    • bigInts

      private ObjToIntMap bigInts
    • localTop

      private int localTop
    • labelTable

      private int[] labelTable
    • labelTableTop

      private int labelTableTop
    • fixupTable

      private long[] fixupTable
    • fixupTableTop

      private int fixupTableTop
    • literalIds

      private ObjArray literalIds
    • exceptionTableTop

      private int exceptionTableTop
    • ECF_TAIL

      private static final int ECF_TAIL
      See Also:
  • Constructor Details

    • CodeGenerator

      CodeGenerator()
  • Method Details

    • compile

      public InterpreterData compile(CompilerEnvirons compilerEnv, ScriptNode tree, String encodedSource, boolean returnFunction)
    • generateFunctionICode

      private void generateFunctionICode()
    • generateICodeFromTree

      private void generateICodeFromTree(Node tree)
    • generateNestedFunctions

      private void generateNestedFunctions()
    • generateRegExpLiterals

      private void generateRegExpLiterals()
    • generateTemplateLiterals

      private void generateTemplateLiterals()
    • updateLineNumber

      private void updateLineNumber(Node node)
    • badTree

      private static RuntimeException badTree(Node node)
    • visitStatement

      private void visitStatement(Node node, int initialStackDepth)
    • visitExpression

      private void visitExpression(Node node, int contextFlags)
    • generateCallFunAndThis

      private void generateCallFunAndThis(Node left)
    • visitIncDec

      private void visitIncDec(Node node, Node child)
    • visitLiteral

      private void visitLiteral(Node node, Node child)
    • visitTemplateLiteral

      private void visitTemplateLiteral(Node node)
    • visitArrayComprehension

      private void visitArrayComprehension(Node node, Node initStmt, Node expr)
    • getLocalBlockRef

      private static int getLocalBlockRef(Node node)
    • getTargetLabel

      private int getTargetLabel(Node target)
    • markTargetLabel

      private void markTargetLabel(Node target)
    • addGoto

      private void addGoto(Node target, int gotoOp)
    • fixLabelGotos

      private void fixLabelGotos()
    • addBackwardGoto

      private void addBackwardGoto(int gotoOp, int jumpPC)
    • resolveForwardGoto

      private void resolveForwardGoto(int fromPC)
    • resolveGoto

      private void resolveGoto(int fromPC, int jumpPC)
    • addToken

      private void addToken(int token)
    • addIcode

      private void addIcode(int icode)
    • addUint8

      private void addUint8(int value)
    • addUint16

      private void addUint16(int value)
    • addInt

      private void addInt(int i)
    • getDoubleIndex

      private int getDoubleIndex(double num)
    • addGotoOp

      private void addGotoOp(int gotoOp)
    • addVarOp

      private void addVarOp(int op, int varIndex)
    • addStringOp

      private void addStringOp(int op, String str)
    • addIndexOp

      private void addIndexOp(int op, int index)
    • addStringPrefix

      private void addStringPrefix(String str)
    • addBigInt

      private void addBigInt(BigInteger n)
    • addIndexPrefix

      private void addIndexPrefix(int index)
    • addExceptionHandler

      private void addExceptionHandler(int icodeStart, int icodeEnd, int handlerStart, boolean isFinally, int exceptionObjectLocal, int scopeLocal)
    • increaseICodeCapacity

      private byte[] increaseICodeCapacity(int extraSize)
    • stackChange

      private void stackChange(int change)
    • allocLocal

      private int allocLocal()
    • releaseLocal

      private void releaseLocal(int localSlot)