2419 final long functionToken = token;
2420 final int functionLine = line;
2421 // FUNCTION is tested in caller.
2422 next();
2423
2424 IdentNode name = null;
2425
2426 if (type == IDENT || isNonStrictModeIdent()) {
2427 name = getIdent();
2428 verifyStrictIdent(name, "function name");
2429 } else if (isStatement) {
2430 // Nashorn extension: anonymous function statements
2431 if (env._no_syntax_extensions) {
2432 expect(IDENT);
2433 }
2434 }
2435
2436 // name is null, generate anonymous name
2437 boolean isAnonymous = false;
2438 if (name == null) {
2439 final String tmpName = "_L" + source.getLine(Token.descPosition(token));
2440 name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
2441 isAnonymous = true;
2442 }
2443
2444 expect(LPAREN);
2445 final List<IdentNode> parameters = formalParameterList();
2446 expect(RPAREN);
2447
2448 FunctionNode functionNode = functionBody(functionToken, name, parameters, FunctionNode.Kind.NORMAL);
2449
2450 if (isStatement) {
2451 if (topLevel) {
2452 functionNode = functionNode.setFlag(lc, FunctionNode.IS_DECLARED);
2453 } else if (isStrictMode) {
2454 throw error(JSErrorType.SYNTAX_ERROR, AbstractParser.message("strict.no.func.decl.here"), functionToken);
2455 } else if (env._function_statement == ScriptEnvironment.FunctionStatementBehavior.ERROR) {
2456 throw error(JSErrorType.SYNTAX_ERROR, AbstractParser.message("no.func.decl.here"), functionToken);
2457 } else if (env._function_statement == ScriptEnvironment.FunctionStatementBehavior.WARNING) {
2458 warning(JSErrorType.SYNTAX_ERROR, AbstractParser.message("no.func.decl.here.warn"), functionToken);
2459 }
|
2419 final long functionToken = token;
2420 final int functionLine = line;
2421 // FUNCTION is tested in caller.
2422 next();
2423
2424 IdentNode name = null;
2425
2426 if (type == IDENT || isNonStrictModeIdent()) {
2427 name = getIdent();
2428 verifyStrictIdent(name, "function name");
2429 } else if (isStatement) {
2430 // Nashorn extension: anonymous function statements
2431 if (env._no_syntax_extensions) {
2432 expect(IDENT);
2433 }
2434 }
2435
2436 // name is null, generate anonymous name
2437 boolean isAnonymous = false;
2438 if (name == null) {
2439 final String tmpName = "_L" + functionLine;
2440 name = new IdentNode(functionToken, Token.descPosition(functionToken), tmpName);
2441 isAnonymous = true;
2442 }
2443
2444 expect(LPAREN);
2445 final List<IdentNode> parameters = formalParameterList();
2446 expect(RPAREN);
2447
2448 FunctionNode functionNode = functionBody(functionToken, name, parameters, FunctionNode.Kind.NORMAL);
2449
2450 if (isStatement) {
2451 if (topLevel) {
2452 functionNode = functionNode.setFlag(lc, FunctionNode.IS_DECLARED);
2453 } else if (isStrictMode) {
2454 throw error(JSErrorType.SYNTAX_ERROR, AbstractParser.message("strict.no.func.decl.here"), functionToken);
2455 } else if (env._function_statement == ScriptEnvironment.FunctionStatementBehavior.ERROR) {
2456 throw error(JSErrorType.SYNTAX_ERROR, AbstractParser.message("no.func.decl.here"), functionToken);
2457 } else if (env._function_statement == ScriptEnvironment.FunctionStatementBehavior.WARNING) {
2458 warning(JSErrorType.SYNTAX_ERROR, AbstractParser.message("no.func.decl.here.warn"), functionToken);
2459 }
|