Class IRFactory


  • public final class IRFactory
    extends Parser
    This class rewrites the parse tree into an IR suitable for codegen.
    See Also:
    Node
    • Method Detail

      • transformTree

        public ScriptNode transformTree​(AstRoot root)
        Transforms the tree into a lower-level IR suitable for codegen. Optionally generates the encoded source.
      • arrayCompTransformHelper

        private Node arrayCompTransformHelper​(ArrayComprehension node,
                                              java.lang.String arrayName)
      • transformArrayLiteral

        private Node transformArrayLiteral​(ArrayLiteral node)
      • transformAssignment

        private Node transformAssignment​(Assignment node)
      • transformBlock

        private Node transformBlock​(AstNode node)
      • transformDoLoop

        private Node transformDoLoop​(DoLoop loop)
      • transformElementGet

        private Node transformElementGet​(ElementGet node)
      • transformForInLoop

        private Node transformForInLoop​(ForInLoop loop)
      • transformForLoop

        private Node transformForLoop​(ForLoop loop)
      • transformFunctionCall

        private Node transformFunctionCall​(FunctionCall node)
      • transformLetNode

        private Node transformLetNode​(LetNode node)
      • transformLiteral

        private Node transformLiteral​(AstNode node)
      • transformName

        private Node transformName​(Name node)
      • transformObjectLiteral

        private Node transformObjectLiteral​(ObjectLiteral node)
      • getPropKey

        private java.lang.Object getPropKey​(Node id)
      • transformPropertyGet

        private Node transformPropertyGet​(PropertyGet node)
      • transformWhileLoop

        private Node transformWhileLoop​(WhileLoop loop)
      • transformYield

        private Node transformYield​(Yield node)
      • transformXmlLiteral

        private Node transformXmlLiteral​(XmlLiteral node)
      • transformXmlMemberGet

        private Node transformXmlMemberGet​(XmlMemberGet node)
      • transformXmlRef

        private Node transformXmlRef​(XmlRef node)
      • transformXmlRef

        private Node transformXmlRef​(Node pn,
                                     XmlRef node,
                                     int memberTypeFlags)
      • transformDefaultXmlNamepace

        private Node transformDefaultXmlNamepace​(UnaryExpression node)
      • addSwitchCase

        private static void addSwitchCase​(Node switchBlock,
                                          Node caseExpression,
                                          Node statements)
        If caseExpression argument is null it indicates a default label.
      • closeSwitch

        private static void closeSwitch​(Node switchBlock)
      • createExprStatementNoReturn

        private static Node createExprStatementNoReturn​(Node expr,
                                                        int lineno)
      • createString

        private static Node createString​(java.lang.String string)
      • createCatch

        private Node createCatch​(java.lang.String varName,
                                 Node catchCond,
                                 Node stmts,
                                 int lineno)
        Catch clause of try/catch/finally
        Parameters:
        varName - the name of the variable to bind to the exception
        catchCond - the condition under which to catch the exception. May be null if no condition is given.
        stmts - the statements in the catch clause
        lineno - the starting line number of the catch clause
      • initFunction

        private static Node initFunction​(FunctionNode fnNode,
                                         int functionIndex,
                                         Node statements,
                                         int functionType)
      • createLoopNode

        private Scope createLoopNode​(Node loopLabel,
                                     int lineno)
        Create loop node. The code generator will later call createWhile|createDoWhile|createFor|createForIn to finish loop generation.
      • createLoop

        private static Node createLoop​(Jump loop,
                                       int loopType,
                                       Node body,
                                       Node cond,
                                       Node init,
                                       Node incr)
      • 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

        private Node createTryCatchFinally​(Node tryBlock,
                                           Node catchBlocks,
                                           Node finallyBlock,
                                           int lineno)
        Try/Catch/Finally The 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

        private Node createWith​(Node obj,
                                Node body,
                                int lineno)
      • createIf

        private static Node createIf​(Node cond,
                                     Node ifTrue,
                                     Node ifFalse,
                                     int lineno)
      • createCondExpr

        private static Node createCondExpr​(Node cond,
                                           Node ifTrue,
                                           Node ifFalse)
      • createUnary

        private static Node createUnary​(int nodeType,
                                        Node child)
      • createCallOrNew

        private Node createCallOrNew​(int nodeType,
                                     Node child)
      • createIncDec

        private static Node createIncDec​(int nodeType,
                                         boolean post,
                                         Node child)
      • createPropertyGet

        private Node createPropertyGet​(Node target,
                                       java.lang.String namespace,
                                       java.lang.String name,
                                       int memberTypeFlags)
      • createElementGet

        private Node createElementGet​(Node target,
                                      java.lang.String namespace,
                                      Node elem,
                                      int memberTypeFlags)
        Parameters:
        target - the node before the LB
        namespace - optional namespace
        elem - the node in the brackets
        memberTypeFlags - E4X flags
      • createMemberRefGet

        private Node createMemberRefGet​(Node target,
                                        java.lang.String namespace,
                                        Node elem,
                                        int memberTypeFlags)
      • createBinary

        private static Node createBinary​(int nodeType,
                                         Node left,
                                         Node right)
      • createAssignment

        private Node createAssignment​(int assignType,
                                      Node left,
                                      Node right)
      • createUseLocal

        private static Node createUseLocal​(Node localBlock)
      • makeJump

        private static Jump makeJump​(int type,
                                     Node target)
      • makeReference

        private static Node makeReference​(Node node)
      • isAlwaysDefinedBoolean

        private static int isAlwaysDefinedBoolean​(Node node)
      • isDestructuring

        boolean isDestructuring​(Node n)
      • decompile

        void decompile​(AstNode node)
      • decompileArrayLiteral

        void decompileArrayLiteral​(ArrayLiteral node)
      • decompileObjectLiteral

        void decompileObjectLiteral​(ObjectLiteral node)
      • decompilePropertyGet

        void decompilePropertyGet​(PropertyGet node)
      • decompileElementGet

        void decompileElementGet​(ElementGet node)