Java Code Examples for jdk.nashorn.internal.ir.FunctionNode#setFinish()
The following examples show how to use
jdk.nashorn.internal.ir.FunctionNode#setFinish() .
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: Parser.java From nashorn with GNU General Public License v2.0 | 6 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName) { // Make a fake token for the script. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 2
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName) { // Make a fake token for the script. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 3
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName) { // Make a fake token for the script. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 4
Source File: Parser.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 5
Source File: Parser.java From nashorn with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), RUN_SCRIPT.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 6
Source File: Parser.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 7
Source File: Parser.java From jdk8u_nashorn with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 8
Source File: Parser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), RUN_SCRIPT.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 9
Source File: Parser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), RUN_SCRIPT.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL); functionDeclarations = new ArrayList<>(); sourceElements(); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 10
Source File: Parser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 11
Source File: Parser.java From hottub with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 12
Source File: Parser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 13
Source File: Parser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 14
Source File: Parser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 15
Source File: Parser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 16
Source File: Parser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }
Example 17
Source File: Parser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * Execute parse and return the resulting function node. * Errors will be thrown and the error manager will contain information * if parsing should fail. This method is used to check if code String * passed to "Function" constructor is a valid function body or not. * * @return function node resulting from successful parse */ public FunctionNode parseFunctionBody() { try { stream = new TokenStream(); lexer = new Lexer(source, stream, scripting && !env._no_syntax_extensions); final int functionLine = line; // Set up first token (skips opening EOL.) k = -1; next(); // Make a fake token for the function. final long functionToken = Token.toDesc(FUNCTION, 0, source.getLength()); // Set up the function to append elements. FunctionNode function = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), PROGRAM.symbolName()), new ArrayList<IdentNode>(), FunctionNode.Kind.NORMAL, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(false); addFunctionDeclarations(function); functionDeclarations = null; expect(EOF); function.setFinish(source.getLength() - 1); function = restoreFunctionNode(function, token); //commit code function = function.setBody(lc, function.getBody().setNeedsScope(lc)); printAST(function); return function; } catch (final Exception e) { handleParseException(e); return null; } }
Example 18
Source File: Parser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * Program : * SourceElements? * * See 14 * * Parse the top level script. */ private FunctionNode program(final String scriptName, final boolean allowPropertyFunction) { // Make a pseudo-token for the script holding its start and length. final long functionToken = Token.toDesc(FUNCTION, Token.descPosition(Token.withDelimiter(token)), source.getLength()); final int functionLine = line; // Set up the script to append elements. FunctionNode script = newFunctionNode( functionToken, new IdentNode(functionToken, Token.descPosition(functionToken), scriptName), new ArrayList<IdentNode>(), FunctionNode.Kind.SCRIPT, functionLine); functionDeclarations = new ArrayList<>(); sourceElements(allowPropertyFunction); addFunctionDeclarations(script); functionDeclarations = null; expect(EOF); script.setFinish(source.getLength() - 1); script = restoreFunctionNode(script, token); //commit code script = script.setBody(lc, script.getBody().setNeedsScope(lc)); return script; }