Package org.htmlunit.corejs.javascript
Class IRFactory
java.lang.Object
org.htmlunit.corejs.javascript.IRFactory
This class rewrites the parse tree into an IR suitable for codegen.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final intprivate static final intprivate static final intprivate static final intprivate static final intprivate Parser -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate static voidaddSwitchCase(Node switchBlock, Node caseExpression, Node statements) If caseExpression argument is null it indicates a default label.private NodearrayCompTransformHelper(ArrayComprehension node, String arrayName) private static voidcloseSwitch(Node switchBlock) private NodecreateAssignment(int assignType, Node left, Node right) private static NodecreateBinary(int nodeType, Node left, Node right) private NodecreateCallOrNew(int nodeType, Node child) private NodecreateCatch(Node varName, Node catchCond, Node stmts, int lineno) Catch clause of try/catch/finallyprivate static NodecreateCondExpr(Node cond, Node ifTrue, Node ifFalse) private NodecreateElementGet(Node target, String namespace, Node elem, int memberTypeFlags) private static NodecreateExprStatementNoReturn(Node expr, int lineno) private static Nodeprivate NodecreateForIn(int declType, Node loop, Node lhs, Node obj, Node body, boolean isForEach, boolean isForOf) Generate IR for a for..in loop.private static Nodeprivate static NodecreateIncDec(int nodeType, boolean post, Node child) private static Nodeprivate ScopecreateLoopNode(Node loopLabel, int lineno) Create loop node.private NodecreateMemberRefGet(Node target, String namespace, Node elem, int memberTypeFlags) private NodecreatePropertyGet(Node target, String namespace, String name, int memberTypeFlags) private static NodecreateString(String string) private NodecreateTryCatchFinally(Node tryBlock, Node catchBlocks, Node finallyBlock, int lineno) Try/Catch/Finallyprivate static NodecreateUnary(int nodeType, Node child) private static NodecreateUseLocal(Node localBlock) private NodecreateWith(Node obj, Node body, int lineno) (package private) void(package private) void(package private) void(package private) Node(package private) void(package private) voidprivate Nodeprivate ObjectgetPropKey(Node id) private static NodeinitFunction(FunctionNode fnNode, int functionIndex, Node statements, int functionType) private static intisAlwaysDefinedBoolean(Node node) (package private) booleanprivate static Jumpprivate static NodemakeReference(Node node) private Nodeprivate Nodeprivate Nodeprivate AstNodetransformAssignmentLeft(Assignment node, AstNode left, AstNode right) private NodetransformBigInt(BigIntLiteral node) private NodetransformBlock(AstNode node) private NodetransformBreak(BreakStatement node) private Nodeprivate Nodeprivate Nodeprivate NodetransformDoLoop(DoLoop loop) private Nodeprivate Nodeprivate NodetransformForInLoop(ForInLoop loop) private NodetransformForLoop(ForLoop loop) private Nodeprivate Nodeprivate Nodeprivate Nodeprivate Nodeprivate Nodeprivate NodetransformLetNode(LetNode node) private NodetransformLiteral(AstNode node) private NodetransformName(Name node) private Nodeprivate NodetransformNumber(NumberLiteral node) private Nodeprivate Nodeprivate Nodeprivate NodetransformRegExp(RegExpLiteral node) private Nodeprivate NodetransformScript(ScriptNode node) private NodetransformString(StringLiteral node) private Nodeprivate Nodeprivate Nodeprivate NodetransformThrow(ThrowStatement node) transformTree(AstRoot root, String sourceString) Transforms the tree into a lower-level IR suitable for codegen.private NodetransformTry(TryStatement node) private Nodeprivate Nodeprivate Nodeprivate Nodeprivate NodetransformWhileLoop(WhileLoop loop) private NodetransformWith(WithStatement node) private Nodeprivate Nodeprivate NodetransformXmlRef(XmlRef node) private NodetransformXmlRef(Node pn, XmlRef node, int memberTypeFlags) private NodetransformYield(Yield node)
-
Field Details
-
LOOP_DO_WHILE
private static final int LOOP_DO_WHILE- See Also:
-
LOOP_WHILE
private static final int LOOP_WHILE- See Also:
-
LOOP_FOR
private static final int LOOP_FOR- See Also:
-
ALWAYS_TRUE_BOOLEAN
private static final int ALWAYS_TRUE_BOOLEAN- See Also:
-
ALWAYS_FALSE_BOOLEAN
private static final int ALWAYS_FALSE_BOOLEAN- See Also:
-
parser
-
-
Constructor Details
-
IRFactory
-
IRFactory
-
-
Method Details
-
transformTree
Transforms the tree into a lower-level IR suitable for codegen. Optionally generates the encoded source. -
transform
-
transformArrayComp
-
arrayCompTransformHelper
-
transformArrayLiteral
-
transformAssignment
-
transformAssignmentLeft
-
transformBigInt
-
transformBlock
-
transformBreak
-
transformCondExpr
-
transformContinue
-
transformDoLoop
-
transformElementGet
-
transformExprStmt
-
transformForInLoop
-
transformForLoop
-
transformFunction
-
transformFunctionCall
-
transformGenExpr
-
genExprTransformHelper
-
transformIf
-
transformInfix
-
transformLabeledStatement
-
transformLetNode
-
transformLiteral
-
transformName
-
transformNewExpr
-
transformNumber
-
transformObjectLiteral
-
getPropKey
-
transformParenExpr
-
transformPropertyGet
-
transformTemplateLiteral
-
transformTemplateLiteralCall
-
transformRegExp
-
transformReturn
-
transformScript
-
transformString
-
transformSwitch
-
transformThrow
-
transformTry
-
transformUnary
-
transformUpdate
-
transformVariables
-
transformVariableInitializers
-
transformWhileLoop
-
transformWith
-
transformYield
-
transformXmlLiteral
-
transformXmlMemberGet
-
transformXmlRef
-
transformXmlRef
-
transformDefaultXmlNamepace
-
addSwitchCase
If caseExpression argument is null it indicates a default label. -
closeSwitch
-
createExprStatementNoReturn
-
createString
-
createCatch
Catch clause of try/catch/finally- Parameters:
varName- the name of the variable to bind to the exceptioncatchCond- the condition under which to catch the exception. May be null if no condition is given.stmts- the statements in the catch clauselineno- the starting line number of the catch clause
-
initFunction
private static Node initFunction(FunctionNode fnNode, int functionIndex, Node statements, int functionType) -
createLoopNode
Create loop node. The code generator will later call createWhile|createDoWhile|createFor|createForIn to finish loop generation. -
createFor
-
createLoop
-
createForIn
private Node createForIn(int declType, Node loop, Node lhs, Node obj, Node body, boolean isForEach, boolean isForOf) Generate IR for a for..in loop. -
createTryCatchFinally
Try/Catch/FinallyThe IRFactory tries to express as much as possible in the tree; the responsibilities remaining for Codegen are to add the Java handlers: (Either (but not both) of TARGET and FINALLY might not be defined)
- a catch handler for javascript exceptions that unwraps the exception onto the stack and GOTOes to the catch target
- a finally handler
... and a goto to GOTO around these handlers.
-
createWith
-
createIf
-
createCondExpr
-
createUnary
-
createCallOrNew
-
createIncDec
-
createPropertyGet
-
createElementGet
- Parameters:
target- the node before the LBnamespace- optional namespaceelem- the node in the bracketsmemberTypeFlags- E4X flags
-
createMemberRefGet
-
createBinary
-
createAssignment
-
createUseLocal
-
makeJump
-
makeReference
-
isAlwaysDefinedBoolean
-
isDestructuring
-
decompileFunctionHeader
-
decompile
-
decompileArrayLiteral
-
decompileObjectLiteral
-
decompilePropertyGet
-
decompileElementGet
-