Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(81)

Side by Side Diff: src/parsing/parser.cc

Issue 2510873005: A decimal integer literal with a leading 0 is now an error in strict mode. (Closed)
Patch Set: implementation without error message changes Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 760 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 this->scope()->SetLanguageMode(info->language_mode()); 771 this->scope()->SetLanguageMode(info->language_mode());
772 ParseStatementList(body, Token::EOS, &ok); 772 ParseStatementList(body, Token::EOS, &ok);
773 } 773 }
774 774
775 // The parser will peek but not consume EOS. Our scope logically goes all 775 // The parser will peek but not consume EOS. Our scope logically goes all
776 // the way to the EOS, though. 776 // the way to the EOS, though.
777 scope->set_end_position(scanner()->peek_location().beg_pos); 777 scope->set_end_position(scanner()->peek_location().beg_pos);
778 778
779 if (ok && is_strict(language_mode())) { 779 if (ok && is_strict(language_mode())) {
780 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 780 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
781 CheckDecimalLiteralWithLeadingZero(beg_pos,
782 scanner()->location().end_pos);
783 } 781 }
784 if (ok && is_sloppy(language_mode())) { 782 if (ok && is_sloppy(language_mode())) {
785 // TODO(littledan): Function bindings on the global object that modify 783 // TODO(littledan): Function bindings on the global object that modify
786 // pre-existing bindings should be made writable, enumerable and 784 // pre-existing bindings should be made writable, enumerable and
787 // nonconfigurable if possible, whereas this code will leave attributes 785 // nonconfigurable if possible, whereas this code will leave attributes
788 // unchanged if the property already exists. 786 // unchanged if the property already exists.
789 InsertSloppyBlockFunctionVarBindings(scope); 787 InsertSloppyBlockFunctionVarBindings(scope);
790 } 788 }
791 if (ok) { 789 if (ok) {
792 CheckConflictingVarDeclarations(scope, &ok); 790 CheckConflictingVarDeclarations(scope, &ok);
(...skipping 1943 matching lines...) Expand 10 before | Expand all | Expand 10 after
2736 2734
2737 // Validate function name. We can do this only after parsing the function, 2735 // Validate function name. We can do this only after parsing the function,
2738 // since the function can declare itself strict. 2736 // since the function can declare itself strict.
2739 language_mode = scope->language_mode(); 2737 language_mode = scope->language_mode();
2740 CheckFunctionName(language_mode, function_name, function_name_validity, 2738 CheckFunctionName(language_mode, function_name, function_name_validity,
2741 function_name_location, CHECK_OK); 2739 function_name_location, CHECK_OK);
2742 2740
2743 if (is_strict(language_mode)) { 2741 if (is_strict(language_mode)) {
2744 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), 2742 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
2745 CHECK_OK); 2743 CHECK_OK);
2746 CheckDecimalLiteralWithLeadingZero(scope->start_position(),
2747 scope->end_position());
2748 } 2744 }
2749 CheckConflictingVarDeclarations(scope, CHECK_OK); 2745 CheckConflictingVarDeclarations(scope, CHECK_OK);
2750 } // DiscardableZoneScope goes out of scope. 2746 } // DiscardableZoneScope goes out of scope.
2751 2747
2752 FunctionLiteral::ParameterFlag duplicate_parameters = 2748 FunctionLiteral::ParameterFlag duplicate_parameters =
2753 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters 2749 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters
2754 : FunctionLiteral::kNoDuplicateParameters; 2750 : FunctionLiteral::kNoDuplicateParameters;
2755 2751
2756 // Note that the FunctionLiteral needs to be created in the main Zone again. 2752 // Note that the FunctionLiteral needs to be created in the main Zone again.
2757 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( 2753 FunctionLiteral* function_literal = factory()->NewFunctionLiteral(
(...skipping 2688 matching lines...) Expand 10 before | Expand all | Expand 10 after
5446 5442
5447 return final_loop; 5443 return final_loop;
5448 } 5444 }
5449 5445
5450 #undef CHECK_OK 5446 #undef CHECK_OK
5451 #undef CHECK_OK_VOID 5447 #undef CHECK_OK_VOID
5452 #undef CHECK_FAILED 5448 #undef CHECK_FAILED
5453 5449
5454 } // namespace internal 5450 } // namespace internal
5455 } // namespace v8 5451 } // namespace v8
OLDNEW
« no previous file with comments | « src/messages.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698