Java Code Examples for jdk.nashorn.internal.ir.FunctionNode#accept()
The following examples show how to use
jdk.nashorn.internal.ir.FunctionNode#accept() .
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: Splitter.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private static List<FunctionNode> directChildren(final FunctionNode functionNode) { final List<FunctionNode> dc = new ArrayList<>(); functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode child) { if (child == functionNode) { return true; } if (lc.getParentFunction(child) == functionNode) { dc.add(child); } return false; } }); return dc; }
Example 2
Source File: Splitter.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private static List<FunctionNode> directChildren(final FunctionNode functionNode) { final List<FunctionNode> dc = new ArrayList<>(); functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode child) { if (child == functionNode) { return true; } if (lc.getParentFunction(child) == functionNode) { dc.add(child); } return false; } }); return dc; }
Example 3
Source File: ApplySpecialization.java From jdk8u_nashorn with GNU General Public License v2.0 | 6 votes |
private boolean hasApplies(final FunctionNode functionNode) { try { functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode fn) { return fn == functionNode; } @Override public boolean enterCallNode(final CallNode callNode) { if (isApply(callNode)) { throw HAS_APPLIES; } return true; } }); } catch (final AppliesFoundException e) { return true; } log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); return false; // no applies }
Example 4
Source File: ApplySpecialization.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
private boolean hasApplies(final FunctionNode functionNode) { try { functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode fn) { return fn == functionNode; } @Override public boolean enterCallNode(final CallNode callNode) { if (isApply(callNode)) { throw HAS_APPLIES; } return true; } }); } catch (final AppliesFoundException e) { return true; } log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); return false; // no applies }
Example 5
Source File: ApplySpecialization.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
private boolean hasApplies(final FunctionNode functionNode) { try { functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode fn) { return fn == functionNode; } @Override public boolean enterCallNode(final CallNode callNode) { if (isApply(callNode)) { throw HAS_APPLIES; } return true; } }); } catch (final AppliesFoundException e) { return true; } log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); return false; // no applies }
Example 6
Source File: Splitter.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
private static List<FunctionNode> directChildren(final FunctionNode functionNode) { final List<FunctionNode> dc = new ArrayList<>(); functionNode.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { @Override public boolean enterFunctionNode(final FunctionNode child) { if (child == functionNode) { return true; } if (lc.getParentFunction(child) == functionNode) { dc.add(child); } return false; } }); return dc; }
Example 7
Source File: ApplySpecialization.java From hottub with GNU General Public License v2.0 | 6 votes |
private boolean hasApplies(final FunctionNode functionNode) { try { functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode fn) { return fn == functionNode; } @Override public boolean enterCallNode(final CallNode callNode) { if (isApply(callNode)) { throw HAS_APPLIES; } return true; } }); } catch (final AppliesFoundException e) { return true; } log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); return false; // no applies }
Example 8
Source File: Splitter.java From hottub with GNU General Public License v2.0 | 6 votes |
private static List<FunctionNode> directChildren(final FunctionNode functionNode) { final List<FunctionNode> dc = new ArrayList<>(); functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode child) { if (child == functionNode) { return true; } if (lc.getParentFunction(child) == functionNode) { dc.add(child); } return false; } }); return dc; }
Example 9
Source File: ApplySpecialization.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
private boolean hasApplies(final FunctionNode functionNode) { try { functionNode.accept(new SimpleNodeVisitor() { @Override public boolean enterFunctionNode(final FunctionNode fn) { return fn == functionNode; } @Override public boolean enterCallNode(final CallNode callNode) { if (isApply(callNode)) { throw HAS_APPLIES; } return true; } }); } catch (final AppliesFoundException e) { return true; } log.fine("There are no applies in ", DebugLogger.quote(functionNode.getName()), " - nothing to do."); return false; // no applies }
Example 10
Source File: JSONWriter.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param context context * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final Context context, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(context.getEnv(), sourceFor(name, code), new Context.ThrowErrorManager(), context.getEnv()._strict, context.getLogger(Parser.class)); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(); //symbol name is ":program", default functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 11
Source File: AstSerializer.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static FunctionNode removeInnerFunctionBodies(final FunctionNode fn) { return (FunctionNode)fn.accept(new NodeVisitor<LexicalContext>(new LexicalContext()) { @Override public Node leaveBlock(final Block block) { if (lc.isFunctionBody() && lc.getFunction(block) != lc.getOutermostFunction()) { return block.setStatements(lc, Collections.<Statement>emptyList()); } return super.leaveBlock(block); } }); }
Example 12
Source File: JSONWriter.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param context context * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final Context context, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(context.getEnv(), sourceFor(name, code), new Context.ThrowErrorManager(), context.getEnv()._strict, context.getLogger(Parser.class)); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(); //symbol name is ":program", default functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 13
Source File: JSONWriter.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param env script environment to use * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final ScriptEnvironment env, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(env, new Source(name, code), new Context.ThrowErrorManager(), env._strict); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(CompilerConstants.RUN_SCRIPT.symbolName()); functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 14
Source File: JSONWriter.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param env script environment to use * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final ScriptEnvironment env, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(env, new Source(name, code), new Context.ThrowErrorManager(), env._strict); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(CompilerConstants.RUN_SCRIPT.symbolName()); functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 15
Source File: JSONWriter.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param context context * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final Context context, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(context.getEnv(), sourceFor(name, code), new Context.ThrowErrorManager(), context.getEnv()._strict, context.getLogger(Parser.class)); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(); //symbol name is ":program", default functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 16
Source File: JSONWriter.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Returns AST as JSON compatible string. * * @param context context * @param code code to be parsed * @param name name of the code source (used for location) * @param includeLoc tells whether to include location information for nodes or not * @return JSON string representation of AST of the supplied code */ public static String parse(final Context context, final String code, final String name, final boolean includeLoc) { final Parser parser = new Parser(context.getEnv(), sourceFor(name, code), new Context.ThrowErrorManager(), context.getEnv()._strict, context.getLogger(Parser.class)); final JSONWriter jsonWriter = new JSONWriter(includeLoc); try { final FunctionNode functionNode = parser.parse(); //symbol name is ":program", default functionNode.accept(jsonWriter); return jsonWriter.getString(); } catch (final ParserException e) { e.throwAsEcmaException(); return null; } }
Example 17
Source File: CompilationPhase.java From jdk8u_nashorn with GNU General Public License v2.0 | 4 votes |
private static FunctionNode transformFunction(final FunctionNode fn, final NodeVisitor<?> visitor) { return (FunctionNode) fn.accept(visitor); }
Example 18
Source File: CompilationPhase.java From hottub with GNU General Public License v2.0 | 4 votes |
private static FunctionNode transformFunction(final FunctionNode fn, final NodeVisitor<?> visitor) { return (FunctionNode) fn.accept(visitor); }
Example 19
Source File: CompilationPhase.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static FunctionNode transformFunction(final FunctionNode fn, final NodeVisitor<?> visitor) { return (FunctionNode) fn.accept(visitor); }
Example 20
Source File: CompilationPhase.java From TencentKona-8 with GNU General Public License v2.0 | 4 votes |
private static FunctionNode transformFunction(final FunctionNode fn, final NodeVisitor<?> visitor) { return (FunctionNode) fn.accept(visitor); }