< prev index next >

src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/parser/Parser.java

Print this page




 517                 break;
 518             }
 519         }
 520     }
 521 
 522     /**
 523      * Set up a new block.
 524      *
 525      * @return New block.
 526      */
 527     private ParserContextBlockNode newBlock() {
 528         return lc.push(new ParserContextBlockNode(token));
 529     }
 530 
 531     private ParserContextFunctionNode createParserContextFunctionNode(final IdentNode ident, final long functionToken, final FunctionNode.Kind kind, final int functionLine, final List<IdentNode> parameters) {
 532         // Build function name.
 533         final StringBuilder sb = new StringBuilder();
 534 
 535         final ParserContextFunctionNode parentFunction = lc.getCurrentFunction();
 536         if (parentFunction != null && !parentFunction.isProgram()) {
 537             sb.append(parentFunction.getName()).append('$');
 538         }
 539 
 540         assert ident.getName() != null;
 541         sb.append(ident.getName());
 542 
 543         final String name = namespace.uniqueName(sb.toString());
 544         assert parentFunction != null || name.equals(PROGRAM.symbolName()) : "name = " + name;
 545 
 546         int flags = 0;
 547         if (isStrictMode) {
 548             flags |= FunctionNode.IS_STRICT;
 549         }
 550         if (parentFunction == null) {
 551             flags |= FunctionNode.IS_PROGRAM;
 552         }
 553 
 554         final ParserContextFunctionNode functionNode = new ParserContextFunctionNode(functionToken, ident, name, namespace, functionLine, kind, parameters);
 555         functionNode.setFlag(flags);
 556         return functionNode;
 557     }




 517                 break;
 518             }
 519         }
 520     }
 521 
 522     /**
 523      * Set up a new block.
 524      *
 525      * @return New block.
 526      */
 527     private ParserContextBlockNode newBlock() {
 528         return lc.push(new ParserContextBlockNode(token));
 529     }
 530 
 531     private ParserContextFunctionNode createParserContextFunctionNode(final IdentNode ident, final long functionToken, final FunctionNode.Kind kind, final int functionLine, final List<IdentNode> parameters) {
 532         // Build function name.
 533         final StringBuilder sb = new StringBuilder();
 534 
 535         final ParserContextFunctionNode parentFunction = lc.getCurrentFunction();
 536         if (parentFunction != null && !parentFunction.isProgram()) {
 537             sb.append(parentFunction.getName()).append(CompilerConstants.NESTED_FUNCTION_SEPARATOR.symbolName());
 538         }
 539 
 540         assert ident.getName() != null;
 541         sb.append(ident.getName());
 542 
 543         final String name = namespace.uniqueName(sb.toString());
 544         assert parentFunction != null || name.equals(PROGRAM.symbolName()) : "name = " + name;
 545 
 546         int flags = 0;
 547         if (isStrictMode) {
 548             flags |= FunctionNode.IS_STRICT;
 549         }
 550         if (parentFunction == null) {
 551             flags |= FunctionNode.IS_PROGRAM;
 552         }
 553 
 554         final ParserContextFunctionNode functionNode = new ParserContextFunctionNode(functionToken, ident, name, namespace, functionLine, kind, parameters);
 555         functionNode.setFlag(flags);
 556         return functionNode;
 557     }


< prev index next >