OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "src/allocation.h" | 7 #include "src/allocation.h" |
8 #include "src/base/logging.h" | 8 #include "src/base/logging.h" |
9 #include "src/conversions-inl.h" | 9 #include "src/conversions-inl.h" |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
343 is_generator ? FunctionKind::kGeneratorFunction | 343 is_generator ? FunctionKind::kGeneratorFunction |
344 : FunctionKind::kNormalFunction, | 344 : FunctionKind::kNormalFunction, |
345 pos, FunctionLiteral::DECLARATION, | 345 pos, FunctionLiteral::DECLARATION, |
346 FunctionLiteral::NORMAL_ARITY, CHECK_OK); | 346 FunctionLiteral::NORMAL_ARITY, CHECK_OK); |
347 return Statement::FunctionDeclaration(); | 347 return Statement::FunctionDeclaration(); |
348 } | 348 } |
349 | 349 |
350 | 350 |
351 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) { | 351 PreParser::Statement PreParser::ParseClassDeclaration(bool* ok) { |
352 Expect(Token::CLASS, CHECK_OK); | 352 Expect(Token::CLASS, CHECK_OK); |
| 353 if (!allow_harmony_sloppy() && strict_mode() == SLOPPY) { |
| 354 ReportMessage("sloppy_lexical"); |
| 355 *ok = false; |
| 356 return Statement::Default(); |
| 357 } |
| 358 |
353 int pos = position(); | 359 int pos = position(); |
354 bool is_strict_reserved = false; | 360 bool is_strict_reserved = false; |
355 Identifier name = | 361 Identifier name = |
356 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); | 362 ParseIdentifierOrStrictReservedWord(&is_strict_reserved, CHECK_OK); |
357 ParseClassLiteral(name, scanner()->location(), is_strict_reserved, pos, | 363 ParseClassLiteral(name, scanner()->location(), is_strict_reserved, pos, |
358 CHECK_OK); | 364 CHECK_OK); |
359 return Statement::Default(); | 365 return Statement::Default(); |
360 } | 366 } |
361 | 367 |
362 | 368 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
505 Consume(Token::COLON); | 511 Consume(Token::COLON); |
506 return ParseStatement(ok); | 512 return ParseStatement(ok); |
507 // Preparsing is disabled for extensions (because the extension details | 513 // Preparsing is disabled for extensions (because the extension details |
508 // aren't passed to lazily compiled functions), so we don't | 514 // aren't passed to lazily compiled functions), so we don't |
509 // accept "native function" in the preparser. | 515 // accept "native function" in the preparser. |
510 } | 516 } |
511 // Parsed expression statement. | 517 // Parsed expression statement. |
512 // Detect attempts at 'let' declarations in sloppy mode. | 518 // Detect attempts at 'let' declarations in sloppy mode. |
513 if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY && | 519 if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY && |
514 expr.IsIdentifier() && expr.AsIdentifier().IsLet()) { | 520 expr.IsIdentifier() && expr.AsIdentifier().IsLet()) { |
515 ReportMessage("lexical_strict_mode", NULL); | 521 ReportMessage("sloppy_lexical", NULL); |
516 *ok = false; | 522 *ok = false; |
517 return Statement::Default(); | 523 return Statement::Default(); |
518 } | 524 } |
519 ExpectSemicolon(CHECK_OK); | 525 ExpectSemicolon(CHECK_OK); |
520 return Statement::ExpressionStatement(expr); | 526 return Statement::ExpressionStatement(expr); |
521 } | 527 } |
522 | 528 |
523 | 529 |
524 PreParser::Statement PreParser::ParseIfStatement(bool* ok) { | 530 PreParser::Statement PreParser::ParseIfStatement(bool* ok) { |
525 // IfStatement :: | 531 // IfStatement :: |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
726 ParseStatement(CHECK_OK); | 732 ParseStatement(CHECK_OK); |
727 return Statement::Default(); | 733 return Statement::Default(); |
728 } | 734 } |
729 } | 735 } |
730 } | 736 } |
731 | 737 |
732 // Parsed initializer at this point. | 738 // Parsed initializer at this point. |
733 // Detect attempts at 'let' declarations in sloppy mode. | 739 // Detect attempts at 'let' declarations in sloppy mode. |
734 if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY && | 740 if (peek() == Token::IDENTIFIER && strict_mode() == SLOPPY && |
735 is_let_identifier_expression) { | 741 is_let_identifier_expression) { |
736 ReportMessage("lexical_strict_mode", NULL); | 742 ReportMessage("sloppy_lexical", NULL); |
737 *ok = false; | 743 *ok = false; |
738 return Statement::Default(); | 744 return Statement::Default(); |
739 } | 745 } |
740 Expect(Token::SEMICOLON, CHECK_OK); | 746 Expect(Token::SEMICOLON, CHECK_OK); |
741 | 747 |
742 if (peek() != Token::SEMICOLON) { | 748 if (peek() != Token::SEMICOLON) { |
743 ParseExpression(true, CHECK_OK); | 749 ParseExpression(true, CHECK_OK); |
744 } | 750 } |
745 Expect(Token::SEMICOLON, CHECK_OK); | 751 Expect(Token::SEMICOLON, CHECK_OK); |
746 | 752 |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
991 Expect(Token::RBRACE, CHECK_OK); | 997 Expect(Token::RBRACE, CHECK_OK); |
992 | 998 |
993 return Expression::Default(); | 999 return Expression::Default(); |
994 } | 1000 } |
995 | 1001 |
996 | 1002 |
997 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { | 1003 PreParser::Expression PreParser::ParseV8Intrinsic(bool* ok) { |
998 // CallRuntime :: | 1004 // CallRuntime :: |
999 // '%' Identifier Arguments | 1005 // '%' Identifier Arguments |
1000 Expect(Token::MOD, CHECK_OK); | 1006 Expect(Token::MOD, CHECK_OK); |
1001 if (!allow_natives_syntax()) { | 1007 if (!allow_natives()) { |
1002 *ok = false; | 1008 *ok = false; |
1003 return Expression::Default(); | 1009 return Expression::Default(); |
1004 } | 1010 } |
1005 // Allow "eval" or "arguments" for backward compatibility. | 1011 // Allow "eval" or "arguments" for backward compatibility. |
1006 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); | 1012 ParseIdentifier(kAllowEvalOrArguments, CHECK_OK); |
1007 ParseArguments(ok); | 1013 ParseArguments(ok); |
1008 | 1014 |
1009 return Expression::Default(); | 1015 return Expression::Default(); |
1010 } | 1016 } |
1011 | 1017 |
1012 #undef CHECK_OK | 1018 #undef CHECK_OK |
1013 | 1019 |
1014 | 1020 |
1015 } } // v8::internal | 1021 } } // v8::internal |
OLD | NEW |