| java.lang.Object org.mozilla.javascript.IRFactory
IRFactory | final class IRFactory (Code) | | This class allows the creation of nodes, and follows the Factory pattern.
See Also: Node author: Mike McCabe author: Norris Boyd |
Method Summary | |
void | addChildToBack(Node parent, Node child) Add a child to the back of the given node. | void | addSwitchCase(Node switchBlock, Node caseExpression, Node statements) If caseExpression argument is null it indicate default label. | void | closeSwitch(Node switchBlock) | Node | createArrayLiteral(ObjArray elems, int skipCount, int destructuringLen) | Node | createAssignment(int assignType, Node left, Node right) | Node | createBinary(int nodeType, Node left, Node right) | Node | createBlock(int lineno) | Node | createBreak(Node breakStatement, int lineno) | Node | createCallOrNew(int nodeType, Node child) | Node | createCatch(String varName, Node catchCond, Node stmts, int lineno) | Node | createCondExpr(Node cond, Node ifTrue, Node ifFalse) | Node | createContinue(Node loop, int lineno) | Node | createDebugger(int lineno) | Node | createDefaultNamespace(Node expr, int lineno) | Node | createDestructuringAssignment(int type, Node left, Node right) Given a destructuring assignment with a left hand side parsed
as an array or object literal and a right hand side expression,
rewrite as a series of assignments to the variables defined in
left from property accesses to the expression on the right. | Node | createDoWhile(Node loop, Node body, Node cond) | public Node | createDotQuery(Node obj, Node body, int lineno) | Node | createElementGet(Node target, String namespace, Node elem, int memberTypeFlags) | Node | createExprStatement(Node expr, int lineno) | Node | createExprStatementNoReturn(Node expr, int lineno) | Node | createFor(Node loop, Node init, Node test, Node incr, Node body) | Node | createForIn(int declType, Node loop, Node lhs, Node obj, Node body, boolean isForEach) For .. | FunctionNode | createFunction(String name) | Node | createIf(Node cond, Node ifTrue, Node ifFalse, int lineno) | Node | createIncDec(int nodeType, boolean post, Node child) | Node | createLabel(int lineno) | Node | createLabeledStatement(Node labelArg, Node statement) | Node | createLeaf(int nodeType) | Node | createLoopNode(Node loopLabel, int lineno) Create loop node. | Node | createName(String name) | Node | createNumber(double number) | Node | createObjectLiteral(ObjArray elems) Object Literals
createObjectLiteral rewrites its argument as object
creation plus object property entries, so later compiler
stages don't need to know about object literals. | Node | createPropertyGet(Node target, String namespace, String name, int memberTypeFlags) | Node | createRegExp(int regexpIndex) | Node | createReturn(Node expr, int lineno) | Node | createScopeNode(int token, int lineno) Create a node that can be used to hold lexically scoped variable
definitions (via let declarations). | ScriptOrFnNode | createScript() | Node | createString(String string) | Node | createSwitch(Node expr, int lineno) Statement leaf nodes. | Node | createThrow(Node expr, int lineno) | 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
... | Node | createUnary(int nodeType, Node child) | Node | createUseLocal(Node localBlock) | Node | createVariables(int token, int lineno) | Node | createWhile(Node loop, Node cond, Node body) | Node | createWith(Node obj, Node body, int lineno) | Node | createYield(Node child, int lineno) | Node | getLabelLoop(Node label) | Node | initFunction(FunctionNode fnNode, int functionIndex, Node statements, int functionType) | void | initScript(ScriptOrFnNode scriptNode, Node body) |
addChildToBack | void addChildToBack(Node parent, Node child)(Code) | | Add a child to the back of the given node. This function
breaks the Factory abstraction, but it removes a requirement
from implementors of Node.
|
addSwitchCase | void addSwitchCase(Node switchBlock, Node caseExpression, Node statements)(Code) | | If caseExpression argument is null it indicate default label.
|
closeSwitch | void closeSwitch(Node switchBlock)(Code) | | |
createArrayLiteral | Node createArrayLiteral(ObjArray elems, int skipCount, int destructuringLen)(Code) | | |
createBlock | Node createBlock(int lineno)(Code) | | Statement block
Creates the empty statement block
Must make subsequent calls to add statements to the node
|
createBreak | Node createBreak(Node breakStatement, int lineno)(Code) | | Break (possibly labeled)
|
createCatch | Node createCatch(String varName, Node catchCond, Node stmts, int lineno)(Code) | | Catch clause of try/catch/finally
Parameters: varName - the name of the variable to bind to the exception Parameters: catchCond - the condition under which to catch the exception.May be null if no condition is given. Parameters: stmts - the statements in the catch clause Parameters: lineno - the starting line number of the catch clause |
createContinue | Node createContinue(Node loop, int lineno)(Code) | | Continue (possibly labeled)
|
createDebugger | Node createDebugger(int lineno)(Code) | | Debugger
|
createDefaultNamespace | Node createDefaultNamespace(Node expr, int lineno)(Code) | | |
createDestructuringAssignment | Node createDestructuringAssignment(int type, Node left, Node right)(Code) | | Given a destructuring assignment with a left hand side parsed
as an array or object literal and a right hand side expression,
rewrite as a series of assignments to the variables defined in
left from property accesses to the expression on the right.
Parameters: type - declaration type: Token.VAR or Token.LET or -1 Parameters: left - array or object literal containing NAME nodes forvariables to assign Parameters: right - expression to assign from expression that performs a series of assignments tothe variables defined in left |
createExprStatement | Node createExprStatement(Node expr, int lineno)(Code) | | |
createExprStatementNoReturn | Node createExprStatementNoReturn(Node expr, int lineno)(Code) | | |
createIncDec | Node createIncDec(int nodeType, boolean post, Node child)(Code) | | |
createLabel | Node createLabel(int lineno)(Code) | | Label
|
createLabeledStatement | Node createLabeledStatement(Node labelArg, Node statement)(Code) | | Label
|
createLeaf | Node createLeaf(int nodeType)(Code) | | Leaf
|
createLoopNode | Node createLoopNode(Node loopLabel, int lineno)(Code) | | Create loop node. The parser will later call
createWhile|createDoWhile|createFor|createForIn
to finish loop generation.
|
createNumber | Node createNumber(double number)(Code) | | Number (for literals)
|
createObjectLiteral | Node createObjectLiteral(ObjArray elems)(Code) | | Object Literals
createObjectLiteral rewrites its argument as object
creation plus object property entries, so later compiler
stages don't need to know about object literals.
|
createRegExp | Node createRegExp(int regexpIndex)(Code) | | Regular expressions
|
createScopeNode | Node createScopeNode(int token, int lineno)(Code) | | Create a node that can be used to hold lexically scoped variable
definitions (via let declarations).
Parameters: token - the token of the node to create Parameters: lineno - line number of source the created node |
createSwitch | Node createSwitch(Node expr, int lineno)(Code) | | Statement leaf nodes.
|
createTryCatchFinally | Node createTryCatchFinally(Node tryBlock, Node catchBlocks, Node finallyBlock, int lineno)(Code) | | 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.
|
createVariables | Node createVariables(int token, int lineno)(Code) | | |
initScript | void initScript(ScriptOrFnNode scriptNode, Node body)(Code) | | Script (for associating file/url names with toplevel scripts.)
|
|
|