< prev index next >

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

Print this page




4694     /**
4695      * ConditionalExpression.
4696      */
4697     private Expression conditionalExpression(boolean noIn) {
4698         return expression(TERNARY.getPrecedence(), noIn);
4699     }
4700 
4701     /**
4702      * ArrowFunction.
4703      *
4704      * @param startToken start token of the ArrowParameters expression
4705      * @param functionLine start line of the arrow function
4706      * @param paramListExpr ArrowParameters expression or {@code null} for {@code ()} (empty list)
4707      */
4708     private Expression arrowFunction(final long startToken, final int functionLine, final Expression paramListExpr) {
4709         // caller needs to check that there's no LineTerminator between parameter list and arrow
4710         assert type != ARROW || checkNoLineTerminator();
4711         expect(ARROW);
4712 
4713         final long functionToken = Token.recast(startToken, ARROW);
4714         final IdentNode name = new IdentNode(functionToken, Token.descPosition(functionToken), "=>:" + functionLine);
4715         final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, FunctionNode.Kind.ARROW, functionLine, null);
4716         functionNode.setFlag(FunctionNode.IS_ANONYMOUS);
4717 
4718         lc.push(functionNode);
4719         try {
4720             ParserContextBlockNode parameterBlock = newBlock();
4721             final List<IdentNode> parameters;
4722             try {
4723                 parameters = convertArrowFunctionParameterList(paramListExpr, functionLine);
4724                 functionNode.setParameters(parameters);
4725 
4726                 if (!functionNode.isSimpleParameterList()) {
4727                     markEvalInArrowParameterList(parameterBlock);
4728                 }
4729             } finally {
4730                 restoreBlock(parameterBlock);
4731             }
4732             Block functionBody = functionBody(functionNode);
4733 
4734             functionBody = maybeWrapBodyInParameterBlock(functionBody, parameterBlock);




4694     /**
4695      * ConditionalExpression.
4696      */
4697     private Expression conditionalExpression(boolean noIn) {
4698         return expression(TERNARY.getPrecedence(), noIn);
4699     }
4700 
4701     /**
4702      * ArrowFunction.
4703      *
4704      * @param startToken start token of the ArrowParameters expression
4705      * @param functionLine start line of the arrow function
4706      * @param paramListExpr ArrowParameters expression or {@code null} for {@code ()} (empty list)
4707      */
4708     private Expression arrowFunction(final long startToken, final int functionLine, final Expression paramListExpr) {
4709         // caller needs to check that there's no LineTerminator between parameter list and arrow
4710         assert type != ARROW || checkNoLineTerminator();
4711         expect(ARROW);
4712 
4713         final long functionToken = Token.recast(startToken, ARROW);
4714         final IdentNode name = new IdentNode(functionToken, Token.descPosition(functionToken), NameCodec.encode("=>:") + functionLine);
4715         final ParserContextFunctionNode functionNode = createParserContextFunctionNode(name, functionToken, FunctionNode.Kind.ARROW, functionLine, null);
4716         functionNode.setFlag(FunctionNode.IS_ANONYMOUS);
4717 
4718         lc.push(functionNode);
4719         try {
4720             ParserContextBlockNode parameterBlock = newBlock();
4721             final List<IdentNode> parameters;
4722             try {
4723                 parameters = convertArrowFunctionParameterList(paramListExpr, functionLine);
4724                 functionNode.setParameters(parameters);
4725 
4726                 if (!functionNode.isSimpleParameterList()) {
4727                     markEvalInArrowParameterList(parameterBlock);
4728                 }
4729             } finally {
4730                 restoreBlock(parameterBlock);
4731             }
4732             Block functionBody = functionBody(functionNode);
4733 
4734             functionBody = maybeWrapBodyInParameterBlock(functionBody, parameterBlock);


< prev index next >