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

Side by Side Diff: src/parser.cc

Issue 795573005: ES6 computed property names (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup tests a bit 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 && 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 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());
3979 } 3981 }
3980 PreParser::PreParseResult result = 3982 PreParser::PreParseResult result =
3981 reusable_preparser_->PreParseLazyFunction(strict_mode(), 3983 reusable_preparser_->PreParseLazyFunction(strict_mode(),
3982 is_generator(), 3984 is_generator(),
3983 logger); 3985 logger);
3984 if (pre_parse_timer_ != NULL) { 3986 if (pre_parse_timer_ != NULL) {
3985 pre_parse_timer_->Stop(); 3987 pre_parse_timer_->Stop();
3986 } 3988 }
3987 return result; 3989 return result;
3988 } 3990 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
4028 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); 4030 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone());
4029 Expression* constructor = NULL; 4031 Expression* constructor = NULL;
4030 bool has_seen_constructor = false; 4032 bool has_seen_constructor = false;
4031 4033
4032 Expect(Token::LBRACE, CHECK_OK); 4034 Expect(Token::LBRACE, CHECK_OK);
4033 while (peek() != Token::RBRACE) { 4035 while (peek() != Token::RBRACE) {
4034 if (Check(Token::SEMICOLON)) continue; 4036 if (Check(Token::SEMICOLON)) continue;
4035 if (fni_ != NULL) fni_->Enter(); 4037 if (fni_ != NULL) fni_->Enter();
4036 const bool in_class = true; 4038 const bool in_class = true;
4037 const bool is_static = false; 4039 const bool is_static = false;
4038 ObjectLiteral::Property* property = ParsePropertyDefinition( 4040 bool is_computed_name = false; // Classes do not care about computed
4039 NULL, in_class, is_static, &has_seen_constructor, CHECK_OK); 4041 // property names here.
4042 ObjectLiteral::Property* property =
4043 ParsePropertyDefinition(NULL, in_class, is_static, &is_computed_name,
4044 &has_seen_constructor, CHECK_OK);
4040 4045
4041 if (has_seen_constructor && constructor == NULL) { 4046 if (has_seen_constructor && constructor == NULL) {
4042 constructor = GetPropertyValue(property); 4047 constructor = GetPropertyValue(property);
4043 } else { 4048 } else {
4044 properties->Add(property, zone()); 4049 properties->Add(property, zone());
4045 } 4050 }
4046 4051
4047 if (fni_ != NULL) { 4052 if (fni_ != NULL) {
4048 fni_->Infer(); 4053 fni_->Infer();
4049 fni_->Leave(); 4054 fni_->Leave();
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after
5291 } else { 5296 } else {
5292 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); 5297 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data());
5293 running_hash = StringHasher::ComputeRunningHash(running_hash, data, 5298 running_hash = StringHasher::ComputeRunningHash(running_hash, data,
5294 raw_string->length()); 5299 raw_string->length());
5295 } 5300 }
5296 } 5301 }
5297 5302
5298 return running_hash; 5303 return running_hash;
5299 } 5304 }
5300 } } // namespace v8::internal 5305 } } // 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