Class JavaScriptTranslator
java.lang.Object
com.oracle.js.parser.ir.visitor.TranslatorNodeVisitor<LexicalContext,JavaScriptNode>
com.oracle.truffle.js.parser.JavaScriptTranslator
public final class JavaScriptTranslator
extends TranslatorNodeVisitor<LexicalContext,JavaScriptNode>
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final ScriptOrModulestatic final Stringprotected final JSContextstatic final Stringstatic final JavaScriptNode[]protected final NodeFactorystatic final Stringstatic final Stringstatic final Stringstatic final Stringprotected final intprotected final com.oracle.truffle.api.source.Sourceprotected final intstatic final com.oracle.truffle.api.strings.TruffleStringstatic final com.oracle.truffle.api.strings.TruffleStringFields inherited from class com.oracle.js.parser.ir.visitor.TranslatorNodeVisitor
lc -
Method Summary
Modifier and TypeMethodDescriptionaddGeneratorStateSlot(JSFrameDescriptor functionFrameDescriptor, com.oracle.truffle.api.frame.FrameSlotKind slotKind) enterAccessNode(AccessNode accessNode) Callback for entering an AccessNodeenterBinaryNode(BinaryNode binaryNode) Callback for entering a BinaryNodeenterBlock(Block block) Callback for entering a BlockenterBlockExpression(BlockExpression blockExpression) Callback for entering a BlockExpressionenterBlockStatement(BlockStatement blockStatement) Callback for entering a BlockStatemententerBreakNode(BreakNode breakNode) Callback for entering a BreakNodeenterCallNode(CallNode callNode) Callback for entering a CallNodeenterClassNode(ClassNode classNode) Callback for entering a ClassNodeenterContinueNode(ContinueNode continueNode) Callback for entering a ContinueNodeenterDebuggerNode(DebuggerNode debuggerNode) Callback for entering a DebuggerNodeprotected JavaScriptNodeenterDefault(Node node) Override this method to do a double inheritance pattern, e.g.enterEmptyNode(EmptyNode emptyNode) Callback for entering an EmptyNodeenterExpressionStatement(ExpressionStatement expressionStatement) Callback for entering an ExpressionStatemententerForNode(ForNode forNode) Callback for entering a ForNodeenterFunctionNode(FunctionNode functionNode) Callback for entering a FunctionNodeenterIdentNode(IdentNode identNode) Callback for entering an IdentNodeenterIfNode(IfNode ifNode) Callback for entering an IfNodeenterIndexNode(IndexNode indexNode) Callback for entering an IndexNodeCallback for entering aJoinPredecessorExpression.enterLabelNode(LabelNode labelNode) Callback for entering a LabelNodeenterLiteralNode(LiteralNode<?> literalNode) Callback for entering a LiteralNodeenterObjectNode(ObjectNode objectNode) Callback for entering an ObjectNodeenterParameterNode(ParameterNode paramNode) Callback for entering a ParameterNodeenterReturnNode(ReturnNode returnNode) Callback for entering a ReturnNodeenterSwitchNode(SwitchNode switchNode) Callback for entering a SwitchNodeenterTemplateLiteralNode(TemplateLiteralNode templateLiteralNode) Callback for entering a TemplateLiteralNodeenterTernaryNode(TernaryNode ternaryNode) Callback for entering a TernaryNodeenterThrowNode(ThrowNode throwNode) Callback for entering a ThrowNodeenterTryNode(TryNode tryNode) Callback for entering a TryNodeenterUnaryNode(UnaryNode unaryNode) Callback for entering a UnaryNodeenterVarNode(VarNode varNode) Callback for entering a VarNodeenterWhileNode(WhileNode whileNode) Callback for entering a WhileNodeenterWithNode(WithNode withNode) Callback for entering a WithNodeprotected com.oracle.truffle.js.parser.GraalJSTranslatornewTranslator(Environment env, LexicalContext savedLC) protected final JavaScriptNodeprotected final JavaScriptNodetransformFunction(FunctionNode functionNode) static ScriptNodetranslateEvalScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, DirectEvalContext directEval, ScriptOrModule activeScriptOrModule) static ScriptNodetranslateFunction(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, boolean isParentStrict, FunctionNode rootNode) static ScriptNodetranslateFunction(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, int prologLength, boolean isParentStrict, FunctionNode rootNode) static ScriptNodetranslateInlineScript(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, boolean isParentStrict, ScriptOrModule activeScriptOrModule) static JSModuleDatatranslateModule(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source) static ScriptNodetranslateScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, String prologue, String epilogue) static ScriptNodetranslateScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, String prologue, String epilogue, List<String> argumentNames) Methods inherited from class com.oracle.js.parser.ir.visitor.TranslatorNodeVisitor
enterCaseNode, enterCatchNode, enterClassElement, enterErrorNode, enterExportNode, enterExportSpecifierNode, enterFromNode, enterImportClauseNode, enterImportNode, enterImportSpecifierNode, enterNamedExportsNode, enterNamedImportsNode, enterNameSpaceImportNode, enterPropertyNode, getLexicalContext
-
Field Details
-
SUPER_CALLED_TWICE
public static final com.oracle.truffle.api.strings.TruffleString SUPER_CALLED_TWICE -
UNSUPPORTED_REFERENCE_TO_SUPER
public static final com.oracle.truffle.api.strings.TruffleString UNSUPPORTED_REFERENCE_TO_SUPER -
LINE__
- See Also:
-
FILE__
- See Also:
-
DIR__
- See Also:
-
IMPORT
- See Also:
-
IMPORT_META
- See Also:
-
ARGUMENTS
- See Also:
-
EMPTY_NODE_ARRAY
-
context
-
factory
-
source
protected final com.oracle.truffle.api.source.Source source -
argumentNames
-
sourceLength
protected final int sourceLength -
prologLength
protected final int prologLength -
activeScriptOrModule
-
-
Method Details
-
translateScript
public static ScriptNode translateScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, String prologue, String epilogue) -
translateScript
public static ScriptNode translateScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, String prologue, String epilogue, List<String> argumentNames) -
translateEvalScript
public static ScriptNode translateEvalScript(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source, boolean isParentStrict, DirectEvalContext directEval, ScriptOrModule activeScriptOrModule) -
translateInlineScript
public static ScriptNode translateInlineScript(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, boolean isParentStrict, ScriptOrModule activeScriptOrModule) -
translateFunction
public static ScriptNode translateFunction(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, boolean isParentStrict, FunctionNode rootNode) -
translateFunction
public static ScriptNode translateFunction(NodeFactory factory, JSContext context, Environment env, com.oracle.truffle.api.source.Source source, int prologLength, boolean isParentStrict, FunctionNode rootNode) -
translateModule
public static JSModuleData translateModule(NodeFactory factory, JSContext context, com.oracle.truffle.api.source.Source source) -
newTranslator
protected com.oracle.truffle.js.parser.GraalJSTranslator newTranslator(Environment env, LexicalContext savedLC) -
transform
-
transformFunction
-
enterFunctionNode
Description copied from class:TranslatorNodeVisitorCallback for entering a FunctionNode- Overrides:
enterFunctionNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
functionNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterReturnNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ReturnNode- Overrides:
enterReturnNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
returnNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterBlock
Description copied from class:TranslatorNodeVisitorCallback for entering a Block- Overrides:
enterBlockin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
block- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterBlockStatement
Description copied from class:TranslatorNodeVisitorCallback for entering a BlockStatement- Overrides:
enterBlockStatementin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
blockStatement- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterLiteralNode
Description copied from class:TranslatorNodeVisitorCallback for entering a LiteralNode- Overrides:
enterLiteralNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
literalNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterIdentNode
Description copied from class:TranslatorNodeVisitorCallback for entering an IdentNode- Overrides:
enterIdentNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
identNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterVarNode
Description copied from class:TranslatorNodeVisitorCallback for entering a VarNode- Overrides:
enterVarNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
varNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterWhileNode
Description copied from class:TranslatorNodeVisitorCallback for entering a WhileNode- Overrides:
enterWhileNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
whileNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterForNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ForNode- Overrides:
enterForNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
forNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterLabelNode
Description copied from class:TranslatorNodeVisitorCallback for entering a LabelNode- Overrides:
enterLabelNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
labelNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterBreakNode
Description copied from class:TranslatorNodeVisitorCallback for entering a BreakNode- Overrides:
enterBreakNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
breakNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterContinueNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ContinueNode- Overrides:
enterContinueNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
continueNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterIfNode
Description copied from class:TranslatorNodeVisitorCallback for entering an IfNode- Overrides:
enterIfNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
ifNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterTernaryNode
Description copied from class:TranslatorNodeVisitorCallback for entering a TernaryNode- Overrides:
enterTernaryNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
ternaryNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterUnaryNode
Description copied from class:TranslatorNodeVisitorCallback for entering a UnaryNode- Overrides:
enterUnaryNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
unaryNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
addGeneratorStateSlot
public JSFrameSlot addGeneratorStateSlot(JSFrameDescriptor functionFrameDescriptor, com.oracle.truffle.api.frame.FrameSlotKind slotKind) -
enterCallNode
Description copied from class:TranslatorNodeVisitorCallback for entering a CallNode- Overrides:
enterCallNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
callNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterBinaryNode
Description copied from class:TranslatorNodeVisitorCallback for entering a BinaryNode- Overrides:
enterBinaryNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
binaryNode- the node- Returns:
- processed node
-
enterAccessNode
Description copied from class:TranslatorNodeVisitorCallback for entering an AccessNode- Overrides:
enterAccessNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
accessNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterIndexNode
Description copied from class:TranslatorNodeVisitorCallback for entering an IndexNode- Overrides:
enterIndexNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
indexNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterObjectNode
Description copied from class:TranslatorNodeVisitorCallback for entering an ObjectNode- Overrides:
enterObjectNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
objectNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterTryNode
Description copied from class:TranslatorNodeVisitorCallback for entering a TryNode- Overrides:
enterTryNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
tryNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterThrowNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ThrowNode- Overrides:
enterThrowNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
throwNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterSwitchNode
Description copied from class:TranslatorNodeVisitorCallback for entering a SwitchNode- Overrides:
enterSwitchNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
switchNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterEmptyNode
Description copied from class:TranslatorNodeVisitorCallback for entering an EmptyNode- Overrides:
enterEmptyNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
emptyNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterWithNode
Description copied from class:TranslatorNodeVisitorCallback for entering a WithNode- Overrides:
enterWithNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
withNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterTemplateLiteralNode
Description copied from class:TranslatorNodeVisitorCallback for entering a TemplateLiteralNode- Overrides:
enterTemplateLiteralNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
templateLiteralNode- the node
-
enterDebuggerNode
Description copied from class:TranslatorNodeVisitorCallback for entering a DebuggerNode- Overrides:
enterDebuggerNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
debuggerNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterExpressionStatement
Description copied from class:TranslatorNodeVisitorCallback for entering an ExpressionStatement- Overrides:
enterExpressionStatementin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
expressionStatement- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterJoinPredecessorExpression
Description copied from class:TranslatorNodeVisitorCallback for entering aJoinPredecessorExpression.- Overrides:
enterJoinPredecessorExpressionin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
expr- the join predecessor expression- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterClassNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ClassNode- Overrides:
enterClassNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
classNode- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterBlockExpression
Description copied from class:TranslatorNodeVisitorCallback for entering a BlockExpression- Overrides:
enterBlockExpressionin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
blockExpression- the node- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-
enterParameterNode
Description copied from class:TranslatorNodeVisitorCallback for entering a ParameterNode- Overrides:
enterParameterNodein classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
paramNode- the node
-
enterDefault
Description copied from class:TranslatorNodeVisitorOverride this method to do a double inheritance pattern, e.g. avoid usingif (x instanceof NodeTypeA) { ... } else if (x instanceof NodeTypeB) { ... } else { ... }Use a NodeVisitor instead, and this method contents forms the else case.- Overrides:
enterDefaultin classTranslatorNodeVisitor<LexicalContext,JavaScriptNode> - Parameters:
node- the node to visit- Returns:
- true if traversal should continue and node children be traversed, false otherwise
-