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

Side by Side Diff: src/parser.cc

Issue 1450193002: Rename destructuring flag to "--harmony-destructuring-bind" (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 1 month 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/parser.h ('k') | src/preparser.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/parser.h" 5 #include "src/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast.h" 8 #include "src/ast.h"
9 #include "src/ast-literal-reindexer.h" 9 #include "src/ast-literal-reindexer.h"
10 #include "src/bailout-reason.h" 10 #include "src/bailout-reason.h"
(...skipping 901 matching lines...) Expand 10 before | Expand all | Expand 10 after
912 // Parser - this makes sure that Isolate is not accidentally accessed via 912 // Parser - this makes sure that Isolate is not accidentally accessed via
913 // ParseInfo during background parsing. 913 // ParseInfo during background parsing.
914 DCHECK(!info->script().is_null() || info->source_stream() != NULL); 914 DCHECK(!info->script().is_null() || info->source_stream() != NULL);
915 set_allow_lazy(info->allow_lazy_parsing()); 915 set_allow_lazy(info->allow_lazy_parsing());
916 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); 916 set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
917 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 917 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
918 set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function); 918 set_allow_harmony_sloppy_function(FLAG_harmony_sloppy_function);
919 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let); 919 set_allow_harmony_sloppy_let(FLAG_harmony_sloppy_let);
920 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters); 920 set_allow_harmony_rest_parameters(FLAG_harmony_rest_parameters);
921 set_allow_harmony_default_parameters(FLAG_harmony_default_parameters); 921 set_allow_harmony_default_parameters(FLAG_harmony_default_parameters);
922 set_allow_harmony_destructuring(FLAG_harmony_destructuring); 922 set_allow_harmony_destructuring_bind(FLAG_harmony_destructuring_bind);
923 set_allow_strong_mode(FLAG_strong_mode); 923 set_allow_strong_mode(FLAG_strong_mode);
924 set_allow_legacy_const(FLAG_legacy_const); 924 set_allow_legacy_const(FLAG_legacy_const);
925 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions); 925 set_allow_harmony_do_expressions(FLAG_harmony_do_expressions);
926 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 926 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
927 ++feature) { 927 ++feature) {
928 use_counts_[feature] = 0; 928 use_counts_[feature] = 0;
929 } 929 }
930 if (info->ast_value_factory() == NULL) { 930 if (info->ast_value_factory() == NULL) {
931 // info takes ownership of AstValueFactory. 931 // info takes ownership of AstValueFactory.
932 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); 932 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed()));
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1068 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok); 1068 CheckStrictOctalLiteral(beg_pos, scanner()->location().end_pos, &ok);
1069 } 1069 }
1070 if (ok && is_sloppy(language_mode()) && allow_harmony_sloppy_function()) { 1070 if (ok && is_sloppy(language_mode()) && allow_harmony_sloppy_function()) {
1071 // TODO(littledan): Function bindings on the global object that modify 1071 // TODO(littledan): Function bindings on the global object that modify
1072 // pre-existing bindings should be made writable, enumerable and 1072 // pre-existing bindings should be made writable, enumerable and
1073 // nonconfigurable if possible, whereas this code will leave attributes 1073 // nonconfigurable if possible, whereas this code will leave attributes
1074 // unchanged if the property already exists. 1074 // unchanged if the property already exists.
1075 InsertSloppyBlockFunctionVarBindings(scope, &ok); 1075 InsertSloppyBlockFunctionVarBindings(scope, &ok);
1076 } 1076 }
1077 if (ok && (is_strict(language_mode()) || allow_harmony_sloppy() || 1077 if (ok && (is_strict(language_mode()) || allow_harmony_sloppy() ||
1078 allow_harmony_destructuring())) { 1078 allow_harmony_destructuring_bind())) {
1079 CheckConflictingVarDeclarations(scope_, &ok); 1079 CheckConflictingVarDeclarations(scope_, &ok);
1080 } 1080 }
1081 1081
1082 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) { 1082 if (ok && info->parse_restriction() == ONLY_SINGLE_FUNCTION_LITERAL) {
1083 if (body->length() != 1 || 1083 if (body->length() != 1 ||
1084 !body->at(0)->IsExpressionStatement() || 1084 !body->at(0)->IsExpressionStatement() ||
1085 !body->at(0)->AsExpressionStatement()-> 1085 !body->at(0)->AsExpressionStatement()->
1086 expression()->IsFunctionLiteral()) { 1086 expression()->IsFunctionLiteral()) {
1087 ReportMessage(MessageTemplate::kSingleFunctionLiteral); 1087 ReportMessage(MessageTemplate::kSingleFunctionLiteral);
1088 ok = false; 1088 ok = false;
(...skipping 1419 matching lines...) Expand 10 before | Expand all | Expand 10 after
2508 ExpressionClassifier pattern_classifier; 2508 ExpressionClassifier pattern_classifier;
2509 Token::Value next = peek(); 2509 Token::Value next = peek();
2510 pattern = ParsePrimaryExpression(&pattern_classifier, ok); 2510 pattern = ParsePrimaryExpression(&pattern_classifier, ok);
2511 if (!*ok) return; 2511 if (!*ok) return;
2512 ValidateBindingPattern(&pattern_classifier, ok); 2512 ValidateBindingPattern(&pattern_classifier, ok);
2513 if (!*ok) return; 2513 if (!*ok) return;
2514 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) { 2514 if (IsLexicalVariableMode(parsing_result->descriptor.mode)) {
2515 ValidateLetPattern(&pattern_classifier, ok); 2515 ValidateLetPattern(&pattern_classifier, ok);
2516 if (!*ok) return; 2516 if (!*ok) return;
2517 } 2517 }
2518 if (!allow_harmony_destructuring() && !pattern->IsVariableProxy()) { 2518 if (!allow_harmony_destructuring_bind() && !pattern->IsVariableProxy()) {
2519 ReportUnexpectedToken(next); 2519 ReportUnexpectedToken(next);
2520 *ok = false; 2520 *ok = false;
2521 return; 2521 return;
2522 } 2522 }
2523 } 2523 }
2524 2524
2525 bool is_pattern = pattern->IsObjectLiteral() || pattern->IsArrayLiteral(); 2525 bool is_pattern = pattern->IsObjectLiteral() || pattern->IsArrayLiteral();
2526 2526
2527 Scanner::Location variable_loc = scanner()->location(); 2527 Scanner::Location variable_loc = scanner()->location();
2528 const AstRawString* single_name = 2528 const AstRawString* single_name =
(...skipping 1865 matching lines...) Expand 10 before | Expand all | Expand 10 after
4394 allow_duplicate_parameters, CHECK_OK); 4394 allow_duplicate_parameters, CHECK_OK);
4395 4395
4396 if (is_strict(language_mode)) { 4396 if (is_strict(language_mode)) {
4397 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(), 4397 CheckStrictOctalLiteral(scope->start_position(), scope->end_position(),
4398 CHECK_OK); 4398 CHECK_OK);
4399 } 4399 }
4400 if (is_sloppy(language_mode) && allow_harmony_sloppy_function()) { 4400 if (is_sloppy(language_mode) && allow_harmony_sloppy_function()) {
4401 InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK); 4401 InsertSloppyBlockFunctionVarBindings(scope, CHECK_OK);
4402 } 4402 }
4403 if (is_strict(language_mode) || allow_harmony_sloppy() || 4403 if (is_strict(language_mode) || allow_harmony_sloppy() ||
4404 allow_harmony_destructuring()) { 4404 allow_harmony_destructuring_bind()) {
4405 CheckConflictingVarDeclarations(scope, CHECK_OK); 4405 CheckConflictingVarDeclarations(scope, CHECK_OK);
4406 } 4406 }
4407 } 4407 }
4408 4408
4409 bool has_duplicate_parameters = 4409 bool has_duplicate_parameters =
4410 !formals_classifier.is_valid_formal_parameter_list_without_duplicates(); 4410 !formals_classifier.is_valid_formal_parameter_list_without_duplicates();
4411 FunctionLiteral::ParameterFlag duplicate_parameters = 4411 FunctionLiteral::ParameterFlag duplicate_parameters =
4412 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters 4412 has_duplicate_parameters ? FunctionLiteral::kHasDuplicateParameters
4413 : FunctionLiteral::kNoDuplicateParameters; 4413 : FunctionLiteral::kNoDuplicateParameters;
4414 4414
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after
4814 if (reusable_preparser_ == NULL) { 4814 if (reusable_preparser_ == NULL) {
4815 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), 4815 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
4816 NULL, stack_limit_); 4816 NULL, stack_limit_);
4817 reusable_preparser_->set_allow_lazy(true); 4817 reusable_preparser_->set_allow_lazy(true);
4818 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); 4818 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
4819 SET_ALLOW(natives); 4819 SET_ALLOW(natives);
4820 SET_ALLOW(harmony_sloppy); 4820 SET_ALLOW(harmony_sloppy);
4821 SET_ALLOW(harmony_sloppy_let); 4821 SET_ALLOW(harmony_sloppy_let);
4822 SET_ALLOW(harmony_rest_parameters); 4822 SET_ALLOW(harmony_rest_parameters);
4823 SET_ALLOW(harmony_default_parameters); 4823 SET_ALLOW(harmony_default_parameters);
4824 SET_ALLOW(harmony_destructuring); 4824 SET_ALLOW(harmony_destructuring_bind);
4825 SET_ALLOW(strong_mode); 4825 SET_ALLOW(strong_mode);
4826 SET_ALLOW(harmony_do_expressions); 4826 SET_ALLOW(harmony_do_expressions);
4827 #undef SET_ALLOW 4827 #undef SET_ALLOW
4828 } 4828 }
4829 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( 4829 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
4830 language_mode(), function_state_->kind(), scope_->has_simple_parameters(), 4830 language_mode(), function_state_->kind(), scope_->has_simple_parameters(),
4831 logger, bookmark); 4831 logger, bookmark);
4832 if (pre_parse_timer_ != NULL) { 4832 if (pre_parse_timer_ != NULL) {
4833 pre_parse_timer_->Stop(); 4833 pre_parse_timer_->Stop();
4834 } 4834 }
(...skipping 1579 matching lines...) Expand 10 before | Expand all | Expand 10 after
6414 } 6414 }
6415 6415
6416 6416
6417 void Parser::RaiseLanguageMode(LanguageMode mode) { 6417 void Parser::RaiseLanguageMode(LanguageMode mode) {
6418 SetLanguageMode(scope_, 6418 SetLanguageMode(scope_,
6419 static_cast<LanguageMode>(scope_->language_mode() | mode)); 6419 static_cast<LanguageMode>(scope_->language_mode() | mode));
6420 } 6420 }
6421 6421
6422 } // namespace internal 6422 } // namespace internal
6423 } // namespace v8 6423 } // namespace v8
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/preparser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698