Java Code Examples for jdk.nashorn.internal.ir.FunctionNode#getBody()
The following examples show how to use
jdk.nashorn.internal.ir.FunctionNode#getBody() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AssignSymbols.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 2
Source File: FindScopeDepths.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 3
Source File: AssignSymbols.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 4
Source File: FindScopeDepths.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 5
Source File: AssignSymbols.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 6
Source File: FindScopeDepths.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 7
Source File: AssignSymbols.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 8
Source File: FindScopeDepths.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 9
Source File: AssignSymbols.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 10
Source File: FindScopeDepths.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 11
Source File: AssignSymbols.java From hottub with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 12
Source File: FindScopeDepths.java From hottub with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }
Example 13
Source File: AssignSymbols.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
private FunctionNode createSyntheticInitializers(final FunctionNode functionNode) { final List<VarNode> syntheticInitializers = new ArrayList<>(2); // Must visit the new var nodes in the context of the body. We could also just set the new statements into the // block and then revisit the entire block, but that seems to be too much double work. final Block body = functionNode.getBody(); lc.push(body); try { if (functionNode.usesSelfSymbol()) { // "var fn = :callee" syntheticInitializers.add(createSyntheticInitializer(functionNode.getIdent(), CALLEE, functionNode)); } if (functionNode.needsArguments()) { // "var arguments = :arguments" syntheticInitializers.add(createSyntheticInitializer(createImplicitIdentifier(ARGUMENTS_VAR.symbolName()), ARGUMENTS, functionNode)); } if (syntheticInitializers.isEmpty()) { return functionNode; } for(final ListIterator<VarNode> it = syntheticInitializers.listIterator(); it.hasNext();) { it.set((VarNode)it.next().accept(this)); } } finally { lc.pop(body); } final List<Statement> stmts = body.getStatements(); final List<Statement> newStatements = new ArrayList<>(stmts.size() + syntheticInitializers.size()); newStatements.addAll(syntheticInitializers); newStatements.addAll(stmts); return functionNode.setBody(lc, body.setStatements(lc, newStatements)); }
Example 14
Source File: FindScopeDepths.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
static Block findBodyBlock(final LexicalContext lc, final FunctionNode fn, final Block block) { final Iterator<Block> iter = lc.getBlocks(block); while (iter.hasNext()) { final Block next = iter.next(); if (fn.getBody() == next) { return next; } } return null; }