public class FunctionBuilderHelper
extends java.lang.Object
FunctionBuilder
.Constructor and Description |
---|
FunctionBuilderHelper() |
Modifier and Type | Method and Description |
---|---|
static void |
addNodeToBlock(AbstractNode node,
BasicBlock block,
AstEnv env)
Adds a node to a basic block.
|
static java.util.IdentityHashMap<BasicBlock,BasicBlock> |
cloneBlocksAndNodes(java.util.Collection<BasicBlock> origs,
FunctionAndBlockManager functionAndBlockManager)
Clones blocks, preserving their internal successor relationships.
|
static BinaryOperatorNode.Op |
getFlowGraphBinaryNonAssignmentOp(com.google.javascript.jscomp.parsing.parser.TokenType type)
Closure compiler binary operator -> TAJS flow graph operator.
|
static BinaryOperatorNode.Op |
getFlowGraphBinaryOperationFromCompoundAssignment(com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree tree)
Closure compiler compound assignments binary operator -> TAJS flow graph operator.
|
static UnaryOperatorNode.Op |
getFlowGraphUnaryNonAssignmentOp(com.google.javascript.jscomp.parsing.parser.TokenType type)
Closure compiler unary operator -> TAJS flow graph operator.
|
static BinaryOperatorNode.Op |
getPrefixPostfixOp(com.google.javascript.jscomp.parsing.parser.TokenType token)
Closure compiler prefix/postfix operator -> TAJS flow graph operator.
|
static java.lang.String |
getSource(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
Finds the source code of a tree.
|
static boolean |
isLoopStatement(com.google.javascript.jscomp.parsing.parser.trees.ParseTree statement) |
static BasicBlock |
makeBasicBlock(BasicBlock exceptionHandler,
FunctionAndBlockManager functionAndBlocksManager)
Creates a new basic block, with some exception handler.
|
static BasicBlock |
makeBasicBlock(Function fun,
FunctionAndBlockManager functionAndBlocksManager)
Creates a new basic block, for a function.
|
static BasicBlock |
makeCatchBasicBlock(BasicBlock thrower,
FunctionAndBlockManager functionAndBlocksManager)
Creates a new basic block that becomes the exception handler for the given basic block.
|
static BasicBlock |
makeJoinBasicBlock(BasicBlock trueBlock,
BasicBlock falseBlock,
FunctionAndBlockManager functionAndBlocksManager)
Creates a new basic block that joins trueBlock and falseBlock.
|
static BasicBlock |
makeJumpThroughBlock(BasicBlock exceptionHandler)
Creates a new basic block, with some exception handler.
|
static SourceLocation |
makeSourceLocation(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree,
SourceLocation.SourceLocationMaker sourceLocationMaker)
Creates a TAJS source location from the start position of given AST node.
|
static BasicBlock |
makeSuccessorBasicBlock(BasicBlock predecessor,
FunctionAndBlockManager functionAndBlocksManager)
Creates a new basic block as a successor of the given basic block.
|
static Pair<java.lang.String,java.lang.String> |
parseRegExpLiteral(com.google.javascript.jscomp.parsing.parser.LiteralToken token)
Parses the given regexp literal into a pattern and flags.
|
static boolean |
requiresOwnBlock(AbstractNode n)
Checks whether the given node is of a kind that requires its own basic block.
|
static void |
setDuplicateBlocks(java.util.Set<BasicBlock> copyBlocks,
java.util.Set<BasicBlock> seenBlocks,
java.util.Set<AbstractNode> nodesToIgnore,
BasicBlock copyBlock,
BasicBlock origBlock)
Traverses the children of the blocks and marks the duplicates
by calling
AbstractNode.setDuplicateOf(AbstractNode) . |
static AstEnv |
setupFunction(Function fun,
AstEnv env,
FunctionAndBlockManager functionAndBlocksManager)
Creates the initial basic blocks and nodes for a function.
|
static boolean |
startsWithUseStrictDirective(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
Look for 'use strict'; in the body
|
static com.google.javascript.jscomp.parsing.parser.trees.ParseTree |
stripParens(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
Skips parenthesis expressions.
|
static Pair<BasicBlock,BasicBlock> |
wireAndRegisterJumpThroughBlocks(java.util.List<JumpThroughBlocks> jumpThroughBlocks,
FunctionAndBlockManager functionAndBlocksManager)
Links together copies of the basic blocks in the given JumpThroughBlocks.
|
public static void addNodeToBlock(AbstractNode node, BasicBlock block, AstEnv env)
node
- the nodeblock
- the basic blockenv
- the current environmentpublic static java.util.IdentityHashMap<BasicBlock,BasicBlock> cloneBlocksAndNodes(java.util.Collection<BasicBlock> origs, FunctionAndBlockManager functionAndBlockManager)
origs
- the basic blocks to copypublic static BinaryOperatorNode.Op getFlowGraphBinaryNonAssignmentOp(com.google.javascript.jscomp.parsing.parser.TokenType type)
public static BinaryOperatorNode.Op getFlowGraphBinaryOperationFromCompoundAssignment(com.google.javascript.jscomp.parsing.parser.trees.BinaryOperatorTree tree)
public static UnaryOperatorNode.Op getFlowGraphUnaryNonAssignmentOp(com.google.javascript.jscomp.parsing.parser.TokenType type)
public static BinaryOperatorNode.Op getPrefixPostfixOp(com.google.javascript.jscomp.parsing.parser.TokenType token)
public static java.lang.String getSource(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
public static boolean isLoopStatement(com.google.javascript.jscomp.parsing.parser.trees.ParseTree statement)
public static BasicBlock makeBasicBlock(BasicBlock exceptionHandler, FunctionAndBlockManager functionAndBlocksManager)
public static BasicBlock makeBasicBlock(Function fun, FunctionAndBlockManager functionAndBlocksManager)
public static BasicBlock makeCatchBasicBlock(BasicBlock thrower, FunctionAndBlockManager functionAndBlocksManager)
public static BasicBlock makeJoinBasicBlock(BasicBlock trueBlock, BasicBlock falseBlock, FunctionAndBlockManager functionAndBlocksManager)
public static BasicBlock makeJumpThroughBlock(BasicBlock exceptionHandler)
public static SourceLocation makeSourceLocation(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree, SourceLocation.SourceLocationMaker sourceLocationMaker)
public static BasicBlock makeSuccessorBasicBlock(BasicBlock predecessor, FunctionAndBlockManager functionAndBlocksManager)
public static Pair<java.lang.String,java.lang.String> parseRegExpLiteral(com.google.javascript.jscomp.parsing.parser.LiteralToken token)
public static boolean requiresOwnBlock(AbstractNode n)
public static void setDuplicateBlocks(java.util.Set<BasicBlock> copyBlocks, java.util.Set<BasicBlock> seenBlocks, java.util.Set<AbstractNode> nodesToIgnore, BasicBlock copyBlock, BasicBlock origBlock)
AbstractNode.setDuplicateOf(AbstractNode)
.copyBlocks
- collection of all the copy blocksseenBlocks
- blocks already visited in the traversal (initially empty)nodesToIgnore
- nodes that should be ignoredcopyBlock
- head of the copy blocksorigBlock
- head of the original blockspublic static AstEnv setupFunction(Function fun, AstEnv env, FunctionAndBlockManager functionAndBlocksManager)
public static boolean startsWithUseStrictDirective(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
public static com.google.javascript.jscomp.parsing.parser.trees.ParseTree stripParens(com.google.javascript.jscomp.parsing.parser.trees.ParseTree tree)
public static Pair<BasicBlock,BasicBlock> wireAndRegisterJumpThroughBlocks(java.util.List<JumpThroughBlocks> jumpThroughBlocks, FunctionAndBlockManager functionAndBlocksManager)
jumpThroughBlocks
- as the blocks to operate onCopyright © 2009-2019 Aarhus University