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

Side by Side Diff: src/parser.cc

Issue 798243004: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Disable test on windows Created 5 years, 11 months 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 && 410 return property != NULL && property->obj()->IsVariableProxy() &&
411 property->obj()->AsVariableProxy() != NULL && 411 property->obj()->AsVariableProxy()->is_this();
412 property->obj()->AsVariableProxy()->is_this();
413 } 412 }
414 413
415 414
416 bool ParserTraits::IsIdentifier(Expression* expression) { 415 bool ParserTraits::IsIdentifier(Expression* expression) {
417 VariableProxy* operand = expression->AsVariableProxy(); 416 VariableProxy* operand = expression->AsVariableProxy();
418 return operand != NULL && !operand->is_this(); 417 return operand != NULL && !operand->is_this();
419 } 418 }
420 419
421 420
422 void ParserTraits::PushPropertyName(FuncNameInferrer* fni, 421 void ParserTraits::PushPropertyName(FuncNameInferrer* fni,
423 Expression* expression) { 422 Expression* expression) {
424 if (expression->IsPropertyName()) { 423 if (expression->IsPropertyName()) {
425 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); 424 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName());
426 } else { 425 } else {
427 fni->PushLiteralName( 426 fni->PushLiteralName(
428 parser_->ast_value_factory()->anonymous_function_string()); 427 parser_->ast_value_factory()->anonymous_function_string());
429 } 428 }
430 } 429 }
431 430
432 431
433 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left, 432 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left,
434 Expression* right) { 433 Expression* right) {
435 DCHECK(left != NULL); 434 DCHECK(left != NULL);
436 if (left->AsProperty() != NULL && 435 if (left->IsProperty() && right->IsFunctionLiteral()) {
437 right->AsFunctionLiteral() != NULL) {
438 right->AsFunctionLiteral()->set_pretenure(); 436 right->AsFunctionLiteral()->set_pretenure();
439 } 437 }
440 } 438 }
441 439
442 440
443 void ParserTraits::CheckPossibleEvalCall(Expression* expression, 441 void ParserTraits::CheckPossibleEvalCall(Expression* expression,
444 Scope* scope) { 442 Scope* scope) {
445 VariableProxy* callee = expression->AsVariableProxy(); 443 VariableProxy* callee = expression->AsVariableProxy();
446 if (callee != NULL && 444 if (callee != NULL &&
447 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { 445 callee->raw_name() == parser_->ast_value_factory()->eval_string()) {
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
799 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); 797 set_allow_natives(FLAG_allow_natives_syntax || info->is_native());
800 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); 798 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping);
801 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); 799 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules);
802 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); 800 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions);
803 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); 801 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals);
804 set_allow_harmony_classes(FLAG_harmony_classes); 802 set_allow_harmony_classes(FLAG_harmony_classes);
805 set_allow_harmony_object_literals(FLAG_harmony_object_literals); 803 set_allow_harmony_object_literals(FLAG_harmony_object_literals);
806 set_allow_harmony_templates(FLAG_harmony_templates); 804 set_allow_harmony_templates(FLAG_harmony_templates);
807 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 805 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
808 set_allow_harmony_unicode(FLAG_harmony_unicode); 806 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 3149 matching lines...) Expand 10 before | Expand all | Expand 10 after
3968 reusable_preparser_->set_allow_harmony_arrow_functions( 3968 reusable_preparser_->set_allow_harmony_arrow_functions(
3969 allow_harmony_arrow_functions()); 3969 allow_harmony_arrow_functions());
3970 reusable_preparser_->set_allow_harmony_numeric_literals( 3970 reusable_preparser_->set_allow_harmony_numeric_literals(
3971 allow_harmony_numeric_literals()); 3971 allow_harmony_numeric_literals());
3972 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 3972 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes());
3973 reusable_preparser_->set_allow_harmony_object_literals( 3973 reusable_preparser_->set_allow_harmony_object_literals(
3974 allow_harmony_object_literals()); 3974 allow_harmony_object_literals());
3975 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); 3975 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates());
3976 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); 3976 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy());
3977 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); 3977 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode());
3978 reusable_preparser_->set_allow_harmony_computed_property_names(
3979 allow_harmony_computed_property_names());
3978 } 3980 }
3979 PreParser::PreParseResult result = 3981 PreParser::PreParseResult result =
3980 reusable_preparser_->PreParseLazyFunction(strict_mode(), 3982 reusable_preparser_->PreParseLazyFunction(strict_mode(),
3981 is_generator(), 3983 is_generator(),
3982 logger); 3984 logger);
3983 if (pre_parse_timer_ != NULL) { 3985 if (pre_parse_timer_ != NULL) {
3984 pre_parse_timer_->Stop(); 3986 pre_parse_timer_->Stop();
3985 } 3987 }
3986 return result; 3988 return result;
3987 } 3989 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4027 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); 4029 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone());
4028 Expression* constructor = NULL; 4030 Expression* constructor = NULL;
4029 bool has_seen_constructor = false; 4031 bool has_seen_constructor = false;
4030 4032
4031 Expect(Token::LBRACE, CHECK_OK); 4033 Expect(Token::LBRACE, CHECK_OK);
4032 while (peek() != Token::RBRACE) { 4034 while (peek() != Token::RBRACE) {
4033 if (Check(Token::SEMICOLON)) continue; 4035 if (Check(Token::SEMICOLON)) continue;
4034 if (fni_ != NULL) fni_->Enter(); 4036 if (fni_ != NULL) fni_->Enter();
4035 const bool in_class = true; 4037 const bool in_class = true;
4036 const bool is_static = false; 4038 const bool is_static = false;
4037 ObjectLiteral::Property* property = ParsePropertyDefinition( 4039 bool is_computed_name = false; // Classes do not care about computed
4038 NULL, in_class, is_static, &has_seen_constructor, CHECK_OK); 4040 // property names here.
4041 ObjectLiteral::Property* property =
4042 ParsePropertyDefinition(NULL, in_class, is_static, &is_computed_name,
4043 &has_seen_constructor, CHECK_OK);
4039 4044
4040 if (has_seen_constructor && constructor == NULL) { 4045 if (has_seen_constructor && constructor == NULL) {
4041 constructor = GetPropertyValue(property); 4046 constructor = GetPropertyValue(property);
4042 } else { 4047 } else {
4043 properties->Add(property, zone()); 4048 properties->Add(property, zone());
4044 } 4049 }
4045 4050
4046 if (fni_ != NULL) { 4051 if (fni_ != NULL) {
4047 fni_->Infer(); 4052 fni_->Infer();
4048 fni_->Leave(); 4053 fni_->Leave();
(...skipping 1321 matching lines...) Expand 10 before | Expand all | Expand 10 after
5370 } else { 5375 } else {
5371 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5376 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5372 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5377 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5373 raw_string->length()); 5378 raw_string->length());
5374 } 5379 }
5375 } 5380 }
5376 5381
5377 return running_hash; 5382 return running_hash;
5378 } 5383 }
5379 } } // namespace v8::internal 5384 } } // 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