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

Side by Side Diff: src/parser.cc

Issue 807033003: Revert of ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 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/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/v8.h" 5 #include "src/v8.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/bailout-reason.h" 9 #include "src/bailout-reason.h"
10 #include "src/base/platform/platform.h" 10 #include "src/base/platform/platform.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 400
401 401
402 bool ParserTraits::IsConstructor(const AstRawString* identifier) const { 402 bool ParserTraits::IsConstructor(const AstRawString* identifier) const {
403 return identifier == parser_->ast_value_factory()->constructor_string(); 403 return identifier == parser_->ast_value_factory()->constructor_string();
404 } 404 }
405 405
406 406
407 bool ParserTraits::IsThisProperty(Expression* expression) { 407 bool ParserTraits::IsThisProperty(Expression* expression) {
408 DCHECK(expression != NULL); 408 DCHECK(expression != NULL);
409 Property* property = expression->AsProperty(); 409 Property* property = expression->AsProperty();
410 return property != NULL && property->obj()->IsVariableProxy() && 410 return property != NULL &&
411 property->obj()->AsVariableProxy()->is_this(); 411 property->obj()->AsVariableProxy() != NULL &&
412 property->obj()->AsVariableProxy()->is_this();
412 } 413 }
413 414
414 415
415 bool ParserTraits::IsIdentifier(Expression* expression) { 416 bool ParserTraits::IsIdentifier(Expression* expression) {
416 VariableProxy* operand = expression->AsVariableProxy(); 417 VariableProxy* operand = expression->AsVariableProxy();
417 return operand != NULL && !operand->is_this(); 418 return operand != NULL && !operand->is_this();
418 } 419 }
419 420
420 421
421 void ParserTraits::PushPropertyName(FuncNameInferrer* fni, 422 void ParserTraits::PushPropertyName(FuncNameInferrer* fni,
422 Expression* expression) { 423 Expression* expression) {
423 if (expression->IsPropertyName()) { 424 if (expression->IsPropertyName()) {
424 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); 425 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
425 } else { 426 } else {
426 fni->PushLiteralName( 427 fni->PushLiteralName(
427 parser_->ast_value_factory()->anonymous_function_string()); 428 parser_->ast_value_factory()->anonymous_function_string());
428 } 429 }
429 } 430 }
430 431
431 432
432 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left, 433 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left,
433 Expression* right) { 434 Expression* right) {
434 DCHECK(left != NULL); 435 DCHECK(left != NULL);
435 if (left->IsProperty() && right->IsFunctionLiteral()) { 436 if (left->AsProperty() != NULL &&
437 right->AsFunctionLiteral() != NULL) {
436 right->AsFunctionLiteral()->set_pretenure(); 438 right->AsFunctionLiteral()->set_pretenure();
437 } 439 }
438 } 440 }
439 441
440 442
441 void ParserTraits::CheckPossibleEvalCall(Expression* expression, 443 void ParserTraits::CheckPossibleEvalCall(Expression* expression,
442 Scope* scope) { 444 Scope* scope) {
443 VariableProxy* callee = expression->AsVariableProxy(); 445 VariableProxy* callee = expression->AsVariableProxy();
444 if (callee != NULL && 446 if (callee != NULL &&
445 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { 447 callee->raw_name() == parser_->ast_value_factory()->eval_string()) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); 799 set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
798 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); 800 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
799 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); 801 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules);
800 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); 802 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions);
801 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 803 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
802 set_allow_harmony_classes(FLAG_harmony_classes); 804 set_allow_harmony_classes(FLAG_harmony_classes);
803 set_allow_harmony_object_literals(FLAG_harmony_object_literals); 805 set_allow_harmony_object_literals(FLAG_harmony_object_literals);
804 set_allow_harmony_templates(FLAG_harmony_templates); 806 set_allow_harmony_templates(FLAG_harmony_templates);
805 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 807 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
806 set_allow_harmony_unicode(FLAG_harmony_unicode); 808 set_allow_harmony_unicode(FLAG_harmony_unicode);
807 set_allow_harmony_computed_property_names(
808 FLAG_harmony_computed_property_names);
809 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 809 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
810 ++feature) { 810 ++feature) {
811 use_counts_[feature] = 0; 811 use_counts_[feature] = 0;
812 } 812 }
813 if (info->ast_value_factory() == NULL) { 813 if (info->ast_value_factory() == NULL) {
814 // info takes ownership of AstValueFactory. 814 // info takes ownership of AstValueFactory.
815 info->SetAstValueFactory( 815 info->SetAstValueFactory(
816 new AstValueFactory(zone(), parse_info->hash_seed)); 816 new AstValueFactory(zone(), parse_info->hash_seed));
817 } 817 }
818 } 818 }
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after
3969 reusable_preparser_->set_allow_harmony_arrow_functions( 3969 reusable_preparser_->set_allow_harmony_arrow_functions(
3970 allow_harmony_arrow_functions()); 3970 allow_harmony_arrow_functions());
3971 reusable_preparser_->set_allow_harmony_numeric_literals( 3971 reusable_preparser_->set_allow_harmony_numeric_literals(
3972 allow_harmony_numeric_literals()); 3972 allow_harmony_numeric_literals());
3973 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 3973 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes());
3974 reusable_preparser_->set_allow_harmony_object_literals( 3974 reusable_preparser_->set_allow_harmony_object_literals(
3975 allow_harmony_object_literals()); 3975 allow_harmony_object_literals());
3976 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); 3976 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates());
3977 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); 3977 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy());
3978 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); 3978 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode());
3979 reusable_preparser_->set_allow_harmony_computed_property_names(
3980 allow_harmony_computed_property_names());
3981 } 3979 }
3982 PreParser::PreParseResult result = 3980 PreParser::PreParseResult result =
3983 reusable_preparser_->PreParseLazyFunction(strict_mode(), 3981 reusable_preparser_->PreParseLazyFunction(strict_mode(),
3984 is_generator(), 3982 is_generator(),
3985 logger); 3983 logger);
3986 if (pre_parse_timer_ != NULL) { 3984 if (pre_parse_timer_ != NULL) {
3987 pre_parse_timer_->Stop(); 3985 pre_parse_timer_->Stop();
3988 } 3986 }
3989 return result; 3987 return result;
3990 } 3988 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4030 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); 4028 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone());
4031 Expression* constructor = NULL; 4029 Expression* constructor = NULL;
4032 bool has_seen_constructor = false; 4030 bool has_seen_constructor = false;
4033 4031
4034 Expect(Token::LBRACE, CHECK_OK); 4032 Expect(Token::LBRACE, CHECK_OK);
4035 while (peek() != Token::RBRACE) { 4033 while (peek() != Token::RBRACE) {
4036 if (Check(Token::SEMICOLON)) continue; 4034 if (Check(Token::SEMICOLON)) continue;
4037 if (fni_ != NULL) fni_->Enter(); 4035 if (fni_ != NULL) fni_->Enter();
4038 const bool in_class = true; 4036 const bool in_class = true;
4039 const bool is_static = false; 4037 const bool is_static = false;
4040 bool is_computed_name = false; // Classes do not care about computed 4038 ObjectLiteral::Property* property = ParsePropertyDefinition(
4041 // property names here. 4039 NULL, in_class, is_static, &has_seen_constructor, CHECK_OK);
4042 ObjectLiteral::Property* property =
4043 ParsePropertyDefinition(NULL, in_class, is_static, &is_computed_name,
4044 &has_seen_constructor, CHECK_OK);
4045 4040
4046 if (has_seen_constructor && constructor == NULL) { 4041 if (has_seen_constructor && constructor == NULL) {
4047 constructor = GetPropertyValue(property); 4042 constructor = GetPropertyValue(property);
4048 } else { 4043 } else {
4049 properties->Add(property, zone()); 4044 properties->Add(property, zone());
4050 } 4045 }
4051 4046
4052 if (fni_ != NULL) { 4047 if (fni_ != NULL) {
4053 fni_->Infer(); 4048 fni_->Infer();
4054 fni_->Leave(); 4049 fni_->Leave();
(...skipping 1244 matching lines...) Expand 10 before | Expand all | Expand 10 after
5299 } else { 5294 } else {
5300 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5295 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5301 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5296 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5302 raw_string->length()); 5297 raw_string->length());
5303 } 5298 }
5304 } 5299 }
5305 5300
5306 return running_hash; 5301 return running_hash;
5307 } 5302 }
5308 } } // namespace v8::internal 5303 } } // namespace v8::internal
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