| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 return pre_parser_->ParseAssignmentExpression(accept_IN, ok); | 132 return pre_parser_->ParseAssignmentExpression(accept_IN, ok); |
| 133 } | 133 } |
| 134 | 134 |
| 135 | 135 |
| 136 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { | 136 PreParserExpression PreParserTraits::ParseV8Intrinsic(bool* ok) { |
| 137 return pre_parser_->ParseV8Intrinsic(ok); | 137 return pre_parser_->ParseV8Intrinsic(ok); |
| 138 } | 138 } |
| 139 | 139 |
| 140 | 140 |
| 141 PreParser::PreParseResult PreParser::PreParseLazyFunction( | 141 PreParser::PreParseResult PreParser::PreParseLazyFunction( |
| 142 LanguageMode mode, bool is_generator, ParserRecorder* log) { | 142 StrictMode strict_mode, bool is_generator, ParserRecorder* log) { |
| 143 log_ = log; | 143 log_ = log; |
| 144 // Lazy functions always have trivial outer scopes (no with/catch scopes). | 144 // Lazy functions always have trivial outer scopes (no with/catch scopes). |
| 145 PreParserScope top_scope(scope_, GLOBAL_SCOPE); | 145 PreParserScope top_scope(scope_, GLOBAL_SCOPE); |
| 146 FunctionState top_state(&function_state_, &scope_, &top_scope); | 146 FunctionState top_state(&function_state_, &scope_, &top_scope); |
| 147 scope_->SetLanguageMode(mode); | 147 scope_->SetStrictMode(strict_mode); |
| 148 PreParserScope function_scope(scope_, FUNCTION_SCOPE); | 148 PreParserScope function_scope(scope_, FUNCTION_SCOPE); |
| 149 FunctionState function_state(&function_state_, &scope_, &function_scope); | 149 FunctionState function_state(&function_state_, &scope_, &function_scope); |
| 150 function_state.set_is_generator(is_generator); | 150 function_state.set_is_generator(is_generator); |
| 151 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); | 151 ASSERT_EQ(Token::LBRACE, scanner()->current_token()); |
| 152 bool ok = true; | 152 bool ok = true; |
| 153 int start_position = peek_position(); | 153 int start_position = peek_position(); |
| 154 ParseLazyFunctionLiteralBody(&ok); | 154 ParseLazyFunctionLiteralBody(&ok); |
| 155 if (stack_overflow()) return kPreParseStackOverflow; | 155 if (stack_overflow()) return kPreParseStackOverflow; |
| 156 if (!ok) { | 156 if (!ok) { |
| 157 ReportUnexpectedToken(scanner()->current_token()); | 157 ReportUnexpectedToken(scanner()->current_token()); |
| 158 } else { | 158 } else { |
| 159 ASSERT_EQ(Token::RBRACE, scanner()->peek()); | 159 ASSERT_EQ(Token::RBRACE, scanner()->peek()); |
| 160 if (!scope_->is_sloppy_mode()) { | 160 if (scope_->strict_mode() == STRICT) { |
| 161 int end_pos = scanner()->location().end_pos; | 161 int end_pos = scanner()->location().end_pos; |
| 162 CheckOctalLiteral(start_position, end_pos, &ok); | 162 CheckOctalLiteral(start_position, end_pos, &ok); |
| 163 } | 163 } |
| 164 } | 164 } |
| 165 return kPreParseSuccess; | 165 return kPreParseSuccess; |
| 166 } | 166 } |
| 167 | 167 |
| 168 | 168 |
| 169 // Preparsing checks a JavaScript program and emits preparse-data that helps | 169 // Preparsing checks a JavaScript program and emits preparse-data that helps |
| 170 // a later parsing to be faster. | 170 // a later parsing to be faster. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 // (Statement)* <end_token> | 217 // (Statement)* <end_token> |
| 218 | 218 |
| 219 bool directive_prologue = true; | 219 bool directive_prologue = true; |
| 220 while (peek() != end_token) { | 220 while (peek() != end_token) { |
| 221 if (directive_prologue && peek() != Token::STRING) { | 221 if (directive_prologue && peek() != Token::STRING) { |
| 222 directive_prologue = false; | 222 directive_prologue = false; |
| 223 } | 223 } |
| 224 Statement statement = ParseSourceElement(CHECK_OK); | 224 Statement statement = ParseSourceElement(CHECK_OK); |
| 225 if (directive_prologue) { | 225 if (directive_prologue) { |
| 226 if (statement.IsUseStrictLiteral()) { | 226 if (statement.IsUseStrictLiteral()) { |
| 227 scope_->SetLanguageMode(allow_harmony_scoping() ? | 227 scope_->SetStrictMode(STRICT); |
| 228 EXTENDED_MODE : STRICT_MODE); | |
| 229 } else if (!statement.IsStringLiteral()) { | 228 } else if (!statement.IsStringLiteral()) { |
| 230 directive_prologue = false; | 229 directive_prologue = false; |
| 231 } | 230 } |
| 232 } | 231 } |
| 233 } | 232 } |
| 234 return kUnknownSourceElements; | 233 return kUnknownSourceElements; |
| 235 } | 234 } |
| 236 | 235 |
| 237 | 236 |
| 238 #undef CHECK_OK | 237 #undef CHECK_OK |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 case Token::THROW: | 311 case Token::THROW: |
| 313 return ParseThrowStatement(ok); | 312 return ParseThrowStatement(ok); |
| 314 | 313 |
| 315 case Token::TRY: | 314 case Token::TRY: |
| 316 return ParseTryStatement(ok); | 315 return ParseTryStatement(ok); |
| 317 | 316 |
| 318 case Token::FUNCTION: { | 317 case Token::FUNCTION: { |
| 319 Scanner::Location start_location = scanner()->peek_location(); | 318 Scanner::Location start_location = scanner()->peek_location(); |
| 320 Statement statement = ParseFunctionDeclaration(CHECK_OK); | 319 Statement statement = ParseFunctionDeclaration(CHECK_OK); |
| 321 Scanner::Location end_location = scanner()->location(); | 320 Scanner::Location end_location = scanner()->location(); |
| 322 if (!scope_->is_sloppy_mode()) { | 321 if (strict_mode() == STRICT) { |
| 323 PreParserTraits::ReportMessageAt(start_location.beg_pos, | 322 PreParserTraits::ReportMessageAt(start_location.beg_pos, |
| 324 end_location.end_pos, | 323 end_location.end_pos, |
| 325 "strict_function", | 324 "strict_function", |
| 326 NULL); | 325 NULL); |
| 327 *ok = false; | 326 *ok = false; |
| 328 return Statement::Default(); | 327 return Statement::Default(); |
| 329 } else { | 328 } else { |
| 330 return statement; | 329 return statement; |
| 331 } | 330 } |
| 332 } | 331 } |
| (...skipping 30 matching lines...) Expand all Loading... |
| 363 | 362 |
| 364 PreParser::Statement PreParser::ParseBlock(bool* ok) { | 363 PreParser::Statement PreParser::ParseBlock(bool* ok) { |
| 365 // Block :: | 364 // Block :: |
| 366 // '{' Statement* '}' | 365 // '{' Statement* '}' |
| 367 | 366 |
| 368 // Note that a Block does not introduce a new execution scope! | 367 // Note that a Block does not introduce a new execution scope! |
| 369 // (ECMA-262, 3rd, 12.2) | 368 // (ECMA-262, 3rd, 12.2) |
| 370 // | 369 // |
| 371 Expect(Token::LBRACE, CHECK_OK); | 370 Expect(Token::LBRACE, CHECK_OK); |
| 372 while (peek() != Token::RBRACE) { | 371 while (peek() != Token::RBRACE) { |
| 373 if (scope_->is_extended_mode()) { | 372 if (FLAG_harmony_scoping && strict_mode() == STRICT) { |
| 374 ParseSourceElement(CHECK_OK); | 373 ParseSourceElement(CHECK_OK); |
| 375 } else { | 374 } else { |
| 376 ParseStatement(CHECK_OK); | 375 ParseStatement(CHECK_OK); |
| 377 } | 376 } |
| 378 } | 377 } |
| 379 Expect(Token::RBRACE, ok); | 378 Expect(Token::RBRACE, ok); |
| 380 return Statement::Default(); | 379 return Statement::Default(); |
| 381 } | 380 } |
| 382 | 381 |
| 383 | 382 |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 // | 426 // |
| 428 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' | 427 // ConstDeclaration : const ConstBinding (',' ConstBinding)* ';' |
| 429 // | 428 // |
| 430 // * It is a Syntax Error if the code that matches this production is not | 429 // * It is a Syntax Error if the code that matches this production is not |
| 431 // contained in extended code. | 430 // contained in extended code. |
| 432 // | 431 // |
| 433 // However disallowing const in sloppy mode will break compatibility with | 432 // However disallowing const in sloppy mode will break compatibility with |
| 434 // existing pages. Therefore we keep allowing const with the old | 433 // existing pages. Therefore we keep allowing const with the old |
| 435 // non-harmony semantics in sloppy mode. | 434 // non-harmony semantics in sloppy mode. |
| 436 Consume(Token::CONST); | 435 Consume(Token::CONST); |
| 437 switch (scope_->language_mode()) { | 436 if (strict_mode() == STRICT) { |
| 438 case SLOPPY_MODE: | 437 if (FLAG_harmony_scoping) { |
| 439 break; | 438 if (var_context != kSourceElement && var_context != kForStatement) { |
| 440 case STRICT_MODE: { | 439 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); |
| 440 *ok = false; |
| 441 return Statement::Default(); |
| 442 } |
| 443 require_initializer = true; |
| 444 } else { |
| 441 Scanner::Location location = scanner()->peek_location(); | 445 Scanner::Location location = scanner()->peek_location(); |
| 442 ReportMessageAt(location, "strict_const"); | 446 ReportMessageAt(location, "strict_const"); |
| 443 *ok = false; | 447 *ok = false; |
| 444 return Statement::Default(); | 448 return Statement::Default(); |
| 445 } | 449 } |
| 446 case EXTENDED_MODE: | |
| 447 if (var_context != kSourceElement && | |
| 448 var_context != kForStatement) { | |
| 449 ReportMessageAt(scanner()->peek_location(), "unprotected_const"); | |
| 450 *ok = false; | |
| 451 return Statement::Default(); | |
| 452 } | |
| 453 require_initializer = true; | |
| 454 break; | |
| 455 } | 450 } |
| 456 } else if (peek() == Token::LET) { | 451 } else if (peek() == Token::LET) { |
| 457 // ES6 Draft Rev4 section 12.2.1: | 452 // ES6 Draft Rev4 section 12.2.1: |
| 458 // | 453 // |
| 459 // LetDeclaration : let LetBindingList ; | 454 // LetDeclaration : let LetBindingList ; |
| 460 // | 455 // |
| 461 // * It is a Syntax Error if the code that matches this production is not | 456 // * It is a Syntax Error if the code that matches this production is not |
| 462 // contained in extended code. | 457 // contained in extended code. |
| 463 if (!scope_->is_extended_mode()) { | 458 // |
| 459 // TODO(rossberg): make 'let' a legal identifier in sloppy mode. |
| 460 if (!FLAG_harmony_scoping || strict_mode() == SLOPPY) { |
| 464 ReportMessageAt(scanner()->peek_location(), "illegal_let"); | 461 ReportMessageAt(scanner()->peek_location(), "illegal_let"); |
| 465 *ok = false; | 462 *ok = false; |
| 466 return Statement::Default(); | 463 return Statement::Default(); |
| 467 } | 464 } |
| 468 Consume(Token::LET); | 465 Consume(Token::LET); |
| 469 if (var_context != kSourceElement && | 466 if (var_context != kSourceElement && |
| 470 var_context != kForStatement) { | 467 var_context != kForStatement) { |
| 471 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); | 468 ReportMessageAt(scanner()->peek_location(), "unprotected_let"); |
| 472 *ok = false; | 469 *ok = false; |
| 473 return Statement::Default(); | 470 return Statement::Default(); |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 506 | 503 |
| 507 bool starts_with_identifier = peek_any_identifier(); | 504 bool starts_with_identifier = peek_any_identifier(); |
| 508 Expression expr = ParseExpression(true, CHECK_OK); | 505 Expression expr = ParseExpression(true, CHECK_OK); |
| 509 // Even if the expression starts with an identifier, it is not necessarily an | 506 // Even if the expression starts with an identifier, it is not necessarily an |
| 510 // identifier. For example, "foo + bar" starts with an identifier but is not | 507 // identifier. For example, "foo + bar" starts with an identifier but is not |
| 511 // an identifier. | 508 // an identifier. |
| 512 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { | 509 if (starts_with_identifier && expr.IsIdentifier() && peek() == Token::COLON) { |
| 513 // Expression is a single identifier, and not, e.g., a parenthesized | 510 // Expression is a single identifier, and not, e.g., a parenthesized |
| 514 // identifier. | 511 // identifier. |
| 515 ASSERT(!expr.AsIdentifier().IsFutureReserved()); | 512 ASSERT(!expr.AsIdentifier().IsFutureReserved()); |
| 516 ASSERT(scope_->is_sloppy_mode() || | 513 ASSERT(strict_mode() == SLOPPY || |
| 517 (!expr.AsIdentifier().IsFutureStrictReserved() && | 514 (!expr.AsIdentifier().IsFutureStrictReserved() && |
| 518 !expr.AsIdentifier().IsYield())); | 515 !expr.AsIdentifier().IsYield())); |
| 519 Consume(Token::COLON); | 516 Consume(Token::COLON); |
| 520 return ParseStatement(ok); | 517 return ParseStatement(ok); |
| 521 // Preparsing is disabled for extensions (because the extension details | 518 // Preparsing is disabled for extensions (because the extension details |
| 522 // aren't passed to lazily compiled functions), so we don't | 519 // aren't passed to lazily compiled functions), so we don't |
| 523 // accept "native function" in the preparser. | 520 // accept "native function" in the preparser. |
| 524 } | 521 } |
| 525 // Parsed expression statement. | 522 // Parsed expression statement. |
| 526 ExpectSemicolon(CHECK_OK); | 523 ExpectSemicolon(CHECK_OK); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 604 } | 601 } |
| 605 ExpectSemicolon(CHECK_OK); | 602 ExpectSemicolon(CHECK_OK); |
| 606 return Statement::Default(); | 603 return Statement::Default(); |
| 607 } | 604 } |
| 608 | 605 |
| 609 | 606 |
| 610 PreParser::Statement PreParser::ParseWithStatement(bool* ok) { | 607 PreParser::Statement PreParser::ParseWithStatement(bool* ok) { |
| 611 // WithStatement :: | 608 // WithStatement :: |
| 612 // 'with' '(' Expression ')' Statement | 609 // 'with' '(' Expression ')' Statement |
| 613 Expect(Token::WITH, CHECK_OK); | 610 Expect(Token::WITH, CHECK_OK); |
| 614 if (!scope_->is_sloppy_mode()) { | 611 if (strict_mode() == STRICT) { |
| 615 ReportMessageAt(scanner()->location(), "strict_mode_with"); | 612 ReportMessageAt(scanner()->location(), "strict_mode_with"); |
| 616 *ok = false; | 613 *ok = false; |
| 617 return Statement::Default(); | 614 return Statement::Default(); |
| 618 } | 615 } |
| 619 Expect(Token::LPAREN, CHECK_OK); | 616 Expect(Token::LPAREN, CHECK_OK); |
| 620 ParseExpression(true, CHECK_OK); | 617 ParseExpression(true, CHECK_OK); |
| 621 Expect(Token::RPAREN, CHECK_OK); | 618 Expect(Token::RPAREN, CHECK_OK); |
| 622 | 619 |
| 623 PreParserScope with_scope(scope_, WITH_SCOPE); | 620 PreParserScope with_scope(scope_, WITH_SCOPE); |
| 624 BlockState block_state(&scope_, &with_scope); | 621 BlockState block_state(&scope_, &with_scope); |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 } | 840 } |
| 844 | 841 |
| 845 Scanner::Location before = scanner()->peek_location(); | 842 Scanner::Location before = scanner()->peek_location(); |
| 846 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); | 843 Expression expression = ParseConditionalExpression(accept_IN, CHECK_OK); |
| 847 | 844 |
| 848 if (!Token::IsAssignmentOp(peek())) { | 845 if (!Token::IsAssignmentOp(peek())) { |
| 849 // Parsed conditional expression only (no assignment). | 846 // Parsed conditional expression only (no assignment). |
| 850 return expression; | 847 return expression; |
| 851 } | 848 } |
| 852 | 849 |
| 853 if (!scope_->is_sloppy_mode() && | 850 if (strict_mode() == STRICT && |
| 854 expression.IsIdentifier() && | 851 expression.IsIdentifier() && |
| 855 expression.AsIdentifier().IsEvalOrArguments()) { | 852 expression.AsIdentifier().IsEvalOrArguments()) { |
| 856 Scanner::Location after = scanner()->location(); | 853 Scanner::Location after = scanner()->location(); |
| 857 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, | 854 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
| 858 "strict_eval_arguments", NULL); | 855 "strict_eval_arguments", NULL); |
| 859 *ok = false; | 856 *ok = false; |
| 860 return Expression::Default(); | 857 return Expression::Default(); |
| 861 } | 858 } |
| 862 | 859 |
| 863 Token::Value op = Next(); // Get assignment operator. | 860 Token::Value op = Next(); // Get assignment operator. |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 | 934 |
| 938 Token::Value op = peek(); | 935 Token::Value op = peek(); |
| 939 if (Token::IsUnaryOp(op)) { | 936 if (Token::IsUnaryOp(op)) { |
| 940 op = Next(); | 937 op = Next(); |
| 941 ParseUnaryExpression(ok); | 938 ParseUnaryExpression(ok); |
| 942 return Expression::Default(); | 939 return Expression::Default(); |
| 943 } else if (Token::IsCountOp(op)) { | 940 } else if (Token::IsCountOp(op)) { |
| 944 op = Next(); | 941 op = Next(); |
| 945 Scanner::Location before = scanner()->peek_location(); | 942 Scanner::Location before = scanner()->peek_location(); |
| 946 Expression expression = ParseUnaryExpression(CHECK_OK); | 943 Expression expression = ParseUnaryExpression(CHECK_OK); |
| 947 if (!scope_->is_sloppy_mode() && | 944 if (strict_mode() == STRICT && |
| 948 expression.IsIdentifier() && | 945 expression.IsIdentifier() && |
| 949 expression.AsIdentifier().IsEvalOrArguments()) { | 946 expression.AsIdentifier().IsEvalOrArguments()) { |
| 950 Scanner::Location after = scanner()->location(); | 947 Scanner::Location after = scanner()->location(); |
| 951 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, | 948 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
| 952 "strict_eval_arguments", NULL); | 949 "strict_eval_arguments", NULL); |
| 953 *ok = false; | 950 *ok = false; |
| 954 } | 951 } |
| 955 return Expression::Default(); | 952 return Expression::Default(); |
| 956 } else { | 953 } else { |
| 957 return ParsePostfixExpression(ok); | 954 return ParsePostfixExpression(ok); |
| 958 } | 955 } |
| 959 } | 956 } |
| 960 | 957 |
| 961 | 958 |
| 962 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { | 959 PreParser::Expression PreParser::ParsePostfixExpression(bool* ok) { |
| 963 // PostfixExpression :: | 960 // PostfixExpression :: |
| 964 // LeftHandSideExpression ('++' | '--')? | 961 // LeftHandSideExpression ('++' | '--')? |
| 965 | 962 |
| 966 Scanner::Location before = scanner()->peek_location(); | 963 Scanner::Location before = scanner()->peek_location(); |
| 967 Expression expression = ParseLeftHandSideExpression(CHECK_OK); | 964 Expression expression = ParseLeftHandSideExpression(CHECK_OK); |
| 968 if (!scanner()->HasAnyLineTerminatorBeforeNext() && | 965 if (!scanner()->HasAnyLineTerminatorBeforeNext() && |
| 969 Token::IsCountOp(peek())) { | 966 Token::IsCountOp(peek())) { |
| 970 if (!scope_->is_sloppy_mode() && | 967 if (strict_mode() == STRICT && |
| 971 expression.IsIdentifier() && | 968 expression.IsIdentifier() && |
| 972 expression.AsIdentifier().IsEvalOrArguments()) { | 969 expression.AsIdentifier().IsEvalOrArguments()) { |
| 973 Scanner::Location after = scanner()->location(); | 970 Scanner::Location after = scanner()->location(); |
| 974 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, | 971 PreParserTraits::ReportMessageAt(before.beg_pos, after.end_pos, |
| 975 "strict_eval_arguments", NULL); | 972 "strict_eval_arguments", NULL); |
| 976 *ok = false; | 973 *ok = false; |
| 977 return Expression::Default(); | 974 return Expression::Default(); |
| 978 } | 975 } |
| 979 Next(); | 976 Next(); |
| 980 return Expression::Default(); | 977 return Expression::Default(); |
| (...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1122 } | 1119 } |
| 1123 | 1120 |
| 1124 | 1121 |
| 1125 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { | 1122 PreParser::Expression PreParser::ParseObjectLiteral(bool* ok) { |
| 1126 // ObjectLiteral :: | 1123 // ObjectLiteral :: |
| 1127 // '{' ( | 1124 // '{' ( |
| 1128 // ((IdentifierName | String | Number) ':' AssignmentExpression) | 1125 // ((IdentifierName | String | Number) ':' AssignmentExpression) |
| 1129 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) | 1126 // | (('get' | 'set') (IdentifierName | String | Number) FunctionLiteral) |
| 1130 // )*[','] '}' | 1127 // )*[','] '}' |
| 1131 | 1128 |
| 1132 ObjectLiteralChecker checker(this, scope_->language_mode()); | 1129 ObjectLiteralChecker checker(this, strict_mode()); |
| 1133 | 1130 |
| 1134 Expect(Token::LBRACE, CHECK_OK); | 1131 Expect(Token::LBRACE, CHECK_OK); |
| 1135 while (peek() != Token::RBRACE) { | 1132 while (peek() != Token::RBRACE) { |
| 1136 Token::Value next = peek(); | 1133 Token::Value next = peek(); |
| 1137 switch (next) { | 1134 switch (next) { |
| 1138 case Token::IDENTIFIER: | 1135 case Token::IDENTIFIER: |
| 1139 case Token::FUTURE_RESERVED_WORD: | 1136 case Token::FUTURE_RESERVED_WORD: |
| 1140 case Token::FUTURE_STRICT_RESERVED_WORD: { | 1137 case Token::FUTURE_STRICT_RESERVED_WORD: { |
| 1141 bool is_getter = false; | 1138 bool is_getter = false; |
| 1142 bool is_setter = false; | 1139 bool is_setter = false; |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1295 Expect(Token::LBRACE, CHECK_OK); | 1292 Expect(Token::LBRACE, CHECK_OK); |
| 1296 if (is_lazily_parsed) { | 1293 if (is_lazily_parsed) { |
| 1297 ParseLazyFunctionLiteralBody(CHECK_OK); | 1294 ParseLazyFunctionLiteralBody(CHECK_OK); |
| 1298 } else { | 1295 } else { |
| 1299 ParseSourceElements(Token::RBRACE, ok); | 1296 ParseSourceElements(Token::RBRACE, ok); |
| 1300 } | 1297 } |
| 1301 Expect(Token::RBRACE, CHECK_OK); | 1298 Expect(Token::RBRACE, CHECK_OK); |
| 1302 | 1299 |
| 1303 // Validate strict mode. We can do this only after parsing the function, | 1300 // Validate strict mode. We can do this only after parsing the function, |
| 1304 // since the function can declare itself strict. | 1301 // since the function can declare itself strict. |
| 1305 if (!scope_->is_sloppy_mode()) { | 1302 if (strict_mode() == STRICT) { |
| 1306 if (function_name.IsEvalOrArguments()) { | 1303 if (function_name.IsEvalOrArguments()) { |
| 1307 ReportMessageAt(function_name_location, "strict_eval_arguments"); | 1304 ReportMessageAt(function_name_location, "strict_eval_arguments"); |
| 1308 *ok = false; | 1305 *ok = false; |
| 1309 return Expression::Default(); | 1306 return Expression::Default(); |
| 1310 } | 1307 } |
| 1311 if (name_is_strict_reserved) { | 1308 if (name_is_strict_reserved) { |
| 1312 ReportMessageAt(function_name_location, "unexpected_strict_reserved"); | 1309 ReportMessageAt(function_name_location, "unexpected_strict_reserved"); |
| 1313 *ok = false; | 1310 *ok = false; |
| 1314 return Expression::Default(); | 1311 return Expression::Default(); |
| 1315 } | 1312 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 1344 ParseSourceElements(Token::RBRACE, ok); | 1341 ParseSourceElements(Token::RBRACE, ok); |
| 1345 log_->ResumeRecording(); | 1342 log_->ResumeRecording(); |
| 1346 if (!*ok) return; | 1343 if (!*ok) return; |
| 1347 | 1344 |
| 1348 // Position right after terminal '}'. | 1345 // Position right after terminal '}'. |
| 1349 ASSERT_EQ(Token::RBRACE, scanner()->peek()); | 1346 ASSERT_EQ(Token::RBRACE, scanner()->peek()); |
| 1350 int body_end = scanner()->peek_location().end_pos; | 1347 int body_end = scanner()->peek_location().end_pos; |
| 1351 log_->LogFunction(body_start, body_end, | 1348 log_->LogFunction(body_start, body_end, |
| 1352 function_state_->materialized_literal_count(), | 1349 function_state_->materialized_literal_count(), |
| 1353 function_state_->expected_property_count(), | 1350 function_state_->expected_property_count(), |
| 1354 scope_->language_mode()); | 1351 strict_mode()); |
| 1355 } | 1352 } |
| 1356 | 1353 |
| 1357 | 1354 |
| 1358 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { | 1355 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { |
| 1359 // CallRuntime :: | 1356 // CallRuntime :: |
| 1360 // '%' Identifier Arguments | 1357 // '%' Identifier Arguments |
| 1361 Expect(Token::MOD, CHECK_OK); | 1358 Expect(Token::MOD, CHECK_OK); |
| 1362 if (!allow_natives_syntax()) { | 1359 if (!allow_natives_syntax()) { |
| 1363 *ok = false; | 1360 *ok = false; |
| 1364 return Expression::Default(); | 1361 return Expression::Default(); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1377 int identifier_pos = position(); | 1374 int identifier_pos = position(); |
| 1378 if (scanner()->is_literal_ascii()) { | 1375 if (scanner()->is_literal_ascii()) { |
| 1379 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); | 1376 log_->LogAsciiSymbol(identifier_pos, scanner()->literal_ascii_string()); |
| 1380 } else { | 1377 } else { |
| 1381 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); | 1378 log_->LogUtf16Symbol(identifier_pos, scanner()->literal_utf16_string()); |
| 1382 } | 1379 } |
| 1383 } | 1380 } |
| 1384 | 1381 |
| 1385 | 1382 |
| 1386 } } // v8::internal | 1383 } } // v8::internal |
| OLD | NEW |