OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 "src/parsing/parser.h" | 5 #include "src/parsing/parser.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "src/api.h" | 9 #include "src/api.h" |
10 #include "src/ast/ast-expression-rewriter.h" | 10 #include "src/ast/ast-expression-rewriter.h" |
(...skipping 773 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
784 this->scope()->SetLanguageMode(info->language_mode()); | 784 this->scope()->SetLanguageMode(info->language_mode()); |
785 ParseStatementList(body, Token::EOS, &ok); | 785 ParseStatementList(body, Token::EOS, &ok); |
786 } | 786 } |
787 | 787 |
788 // The parser will peek but not consume EOS. Our scope logically goes all | 788 // The parser will peek but not consume EOS. Our scope logically goes all |
789 // the way to the EOS, though. | 789 // the way to the EOS, though. |
790 scope->set_end_position(scanner()->peek_location().beg_pos); | 790 scope->set_end_position(scanner()->peek_location().beg_pos); |
791 | 791 |
792 if (ok && is_strict(language_mode())) { | 792 if (ok && is_strict(language_mode())) { |
793 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); | 793 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); |
794 CheckDecimalLiteralWithLeadingZero(beg_pos, | |
795 scanner()->location().end_pos); | |
796 } | 794 } |
797 if (ok && is_sloppy(language_mode())) { | 795 if (ok && is_sloppy(language_mode())) { |
798 // TODO(littledan): Function bindings on the global object that modify | 796 // TODO(littledan): Function bindings on the global object that modify |
799 // pre-existing bindings should be made writable, enumerable and | 797 // pre-existing bindings should be made writable, enumerable and |
800 // nonconfigurable if possible, whereas this code will leave attributes | 798 // nonconfigurable if possible, whereas this code will leave attributes |
801 // unchanged if the property already exists. | 799 // unchanged if the property already exists. |
802 InsertSloppyBlockFunctionVarBindings(scope); | 800 InsertSloppyBlockFunctionVarBindings(scope); |
803 } | 801 } |
804 if (ok) { | 802 if (ok) { |
805 CheckConflictingVarDeclarations(scope, &ok); | 803 CheckConflictingVarDeclarations(scope, &ok); |
(...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2702 | 2700 |
2703 // Validate function name. We can do this only after parsing the function, | 2701 // Validate function name. We can do this only after parsing the function, |
2704 // since the function can declare itself strict. | 2702 // since the function can declare itself strict. |
2705 language_mode = scope->language_mode(); | 2703 language_mode = scope->language_mode(); |
2706 CheckFunctionName(language_mode, function_name, function_name_validity, | 2704 CheckFunctionName(language_mode, function_name, function_name_validity, |
2707 function_name_location, CHECK_OK); | 2705 function_name_location, CHECK_OK); |
2708 | 2706 |
2709 if (is_strict(language_mode)) { | 2707 if (is_strict(language_mode)) { |
2710 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), | 2708 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), |
2711 CHECK_OK); | 2709 CHECK_OK); |
2712 CheckDecimalLiteralWithLeadingZero(scope->start_position(), | |
2713 scope->end_position()); | |
2714 } | 2710 } |
2715 CheckConflictingVarDeclarations(scope, CHECK_OK); | 2711 CheckConflictingVarDeclarations(scope, CHECK_OK); |
2716 } // DiscardableZoneScope goes out of scope. | 2712 } // DiscardableZoneScope goes out of scope. |
2717 | 2713 |
2718 FunctionLiteral::ParameterFlag duplicate_parameters = | 2714 FunctionLiteral::ParameterFlag duplicate_parameters = |
2719 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters | 2715 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters |
2720 : FunctionLiteral::kNoDuplicateParameters; | 2716 : FunctionLiteral::kNoDuplicateParameters; |
2721 | 2717 |
2722 // Note that the FunctionLiteral needs to be created in the main Zone again. | 2718 // Note that the FunctionLiteral needs to be created in the main Zone again. |
2723 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 2719 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
(...skipping 2697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5421 | 5417 |
5422 return final_loop; | 5418 return final_loop; |
5423 } | 5419 } |
5424 | 5420 |
5425 #undef CHECK_OK | 5421 #undef CHECK_OK |
5426 #undef CHECK_OK_VOID | 5422 #undef CHECK_OK_VOID |
5427 #undef CHECK_FAILED | 5423 #undef CHECK_FAILED |
5428 | 5424 |
5429 } // namespace internal | 5425 } // namespace internal |
5430 } // namespace v8 | 5426 } // namespace v8 |
OLD | NEW |