OLD | NEW |
---|---|
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 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 && |
411 property->obj()->AsVariableProxy() != NULL && | 411 property->obj()->IsVariableProxy() && |
412 property->obj()->AsVariableProxy()->is_this(); | 412 property->obj()->AsVariableProxy()->is_this(); |
413 } | 413 } |
414 | 414 |
415 | 415 |
416 bool ParserTraits::IsIdentifier(Expression* expression) { | 416 bool ParserTraits::IsIdentifier(Expression* expression) { |
417 VariableProxy* operand = expression->AsVariableProxy(); | 417 VariableProxy* operand = expression->AsVariableProxy(); |
418 return operand != NULL && !operand->is_this(); | 418 return operand != NULL && !operand->is_this(); |
419 } | 419 } |
420 | 420 |
421 | 421 |
422 void ParserTraits::PushPropertyName(FuncNameInferrer* fni, | 422 void ParserTraits::PushPropertyName(FuncNameInferrer* fni, |
423 Expression* expression) { | 423 Expression* expression) { |
424 if (expression->IsPropertyName()) { | 424 if (expression->IsPropertyName()) { |
425 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); | 425 fni->PushLiteralName(expression->AsLiteral()->AsRawPropertyName()); |
426 } else { | 426 } else { |
427 fni->PushLiteralName( | 427 fni->PushLiteralName( |
428 parser_->ast_value_factory()->anonymous_function_string()); | 428 parser_->ast_value_factory()->anonymous_function_string()); |
429 } | 429 } |
430 } | 430 } |
431 | 431 |
432 | 432 |
433 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left, | 433 void ParserTraits::CheckAssigningFunctionLiteralToProperty(Expression* left, |
434 Expression* right) { | 434 Expression* right) { |
435 DCHECK(left != NULL); | 435 DCHECK(left != NULL); |
436 if (left->AsProperty() != NULL && | 436 if (left->IsProperty() && right->IsFunctionLiteral()) { |
437 right->AsFunctionLiteral() != NULL) { | |
438 right->AsFunctionLiteral()->set_pretenure(); | 437 right->AsFunctionLiteral()->set_pretenure(); |
439 } | 438 } |
440 } | 439 } |
441 | 440 |
442 | 441 |
443 void ParserTraits::CheckPossibleEvalCall(Expression* expression, | 442 void ParserTraits::CheckPossibleEvalCall(Expression* expression, |
444 Scope* scope) { | 443 Scope* scope) { |
445 VariableProxy* callee = expression->AsVariableProxy(); | 444 VariableProxy* callee = expression->AsVariableProxy(); |
446 if (callee != NULL && | 445 if (callee != NULL && |
447 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { | 446 callee->raw_name() == parser_->ast_value_factory()->eval_string()) { |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
710 default: | 709 default: |
711 DCHECK(false); | 710 DCHECK(false); |
712 } | 711 } |
713 return NULL; | 712 return NULL; |
714 } | 713 } |
715 | 714 |
716 | 715 |
717 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, | 716 Expression* ParserTraits::ExpressionFromIdentifier(const AstRawString* name, |
718 int pos, Scope* scope, | 717 int pos, Scope* scope, |
719 AstNodeFactory* factory) { | 718 AstNodeFactory* factory) { |
720 if (parser_->fni_ != NULL) parser_->fni_->PushVariableName(name); | |
arv (Not doing code reviews)
2014/12/10 23:38:13
I can problably revert this now. I don't call thes
arv (Not doing code reviews)
2014/12/11 23:10:33
Done.
| |
721 // The name may refer to a module instance object, so its type is unknown. | 719 // The name may refer to a module instance object, so its type is unknown. |
722 #ifdef DEBUG | 720 #ifdef DEBUG |
723 if (FLAG_print_interface_details) | 721 if (FLAG_print_interface_details) |
724 PrintF("# Variable %.*s ", name->length(), name->raw_data()); | 722 PrintF("# Variable %.*s ", name->length(), name->raw_data()); |
725 #endif | 723 #endif |
726 Interface* interface = Interface::NewUnknown(parser_->zone()); | 724 Interface* interface = Interface::NewUnknown(parser_->zone()); |
727 return scope->NewUnresolved(factory, name, interface, pos); | 725 return scope->NewUnresolved(factory, name, interface, pos); |
728 } | 726 } |
729 | 727 |
730 | 728 |
731 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, | 729 Expression* ParserTraits::ExpressionFromString(int pos, Scanner* scanner, |
732 AstNodeFactory* factory) { | 730 AstNodeFactory* factory) { |
733 const AstRawString* symbol = GetSymbol(scanner); | 731 const AstRawString* symbol = GetSymbol(scanner); |
734 if (parser_->fni_ != NULL) parser_->fni_->PushLiteralName(symbol); | |
735 return factory->NewStringLiteral(symbol, pos); | 732 return factory->NewStringLiteral(symbol, pos); |
736 } | 733 } |
737 | 734 |
738 | 735 |
739 Expression* ParserTraits::GetIterator(Expression* iterable, | 736 Expression* ParserTraits::GetIterator(Expression* iterable, |
740 AstNodeFactory* factory) { | 737 AstNodeFactory* factory) { |
741 Expression* iterator_symbol_literal = | 738 Expression* iterator_symbol_literal = |
742 factory->NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition); | 739 factory->NewSymbolLiteral("iterator_symbol", RelocInfo::kNoPosition); |
743 int pos = iterable->position(); | 740 int pos = iterable->position(); |
744 Expression* prop = | 741 Expression* prop = |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
799 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); | 796 set_allow_natives(FLAG_allow_natives_syntax || info->is_native()); |
800 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); | 797 set_allow_harmony_scoping(!info->is_native() && FLAG_harmony_scoping); |
801 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); | 798 set_allow_harmony_modules(!info->is_native() && FLAG_harmony_modules); |
802 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); | 799 set_allow_harmony_arrow_functions(FLAG_harmony_arrow_functions); |
803 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); | 800 set_allow_harmony_numeric_literals(FLAG_harmony_numeric_literals); |
804 set_allow_harmony_classes(FLAG_harmony_classes); | 801 set_allow_harmony_classes(FLAG_harmony_classes); |
805 set_allow_harmony_object_literals(FLAG_harmony_object_literals); | 802 set_allow_harmony_object_literals(FLAG_harmony_object_literals); |
806 set_allow_harmony_templates(FLAG_harmony_templates); | 803 set_allow_harmony_templates(FLAG_harmony_templates); |
807 set_allow_harmony_sloppy(FLAG_harmony_sloppy); | 804 set_allow_harmony_sloppy(FLAG_harmony_sloppy); |
808 set_allow_harmony_unicode(FLAG_harmony_unicode); | 805 set_allow_harmony_unicode(FLAG_harmony_unicode); |
806 set_allow_harmony_computed_property_names( | |
807 FLAG_harmony_computed_property_names); | |
809 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 808 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
810 ++feature) { | 809 ++feature) { |
811 use_counts_[feature] = 0; | 810 use_counts_[feature] = 0; |
812 } | 811 } |
813 if (info->ast_value_factory() == NULL) { | 812 if (info->ast_value_factory() == NULL) { |
814 // info takes ownership of AstValueFactory. | 813 // info takes ownership of AstValueFactory. |
815 info->SetAstValueFactory( | 814 info->SetAstValueFactory( |
816 new AstValueFactory(zone(), parse_info->hash_seed)); | 815 new AstValueFactory(zone(), parse_info->hash_seed)); |
817 } | 816 } |
818 } | 817 } |
(...skipping 3150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3969 reusable_preparser_->set_allow_harmony_arrow_functions( | 3968 reusable_preparser_->set_allow_harmony_arrow_functions( |
3970 allow_harmony_arrow_functions()); | 3969 allow_harmony_arrow_functions()); |
3971 reusable_preparser_->set_allow_harmony_numeric_literals( | 3970 reusable_preparser_->set_allow_harmony_numeric_literals( |
3972 allow_harmony_numeric_literals()); | 3971 allow_harmony_numeric_literals()); |
3973 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); | 3972 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); |
3974 reusable_preparser_->set_allow_harmony_object_literals( | 3973 reusable_preparser_->set_allow_harmony_object_literals( |
3975 allow_harmony_object_literals()); | 3974 allow_harmony_object_literals()); |
3976 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); | 3975 reusable_preparser_->set_allow_harmony_templates(allow_harmony_templates()); |
3977 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); | 3976 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); |
3978 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()); | |
3979 } | 3980 } |
3980 PreParser::PreParseResult result = | 3981 PreParser::PreParseResult result = |
3981 reusable_preparser_->PreParseLazyFunction(strict_mode(), | 3982 reusable_preparser_->PreParseLazyFunction(strict_mode(), |
3982 is_generator(), | 3983 is_generator(), |
3983 logger); | 3984 logger); |
3984 if (pre_parse_timer_ != NULL) { | 3985 if (pre_parse_timer_ != NULL) { |
3985 pre_parse_timer_->Stop(); | 3986 pre_parse_timer_->Stop(); |
3986 } | 3987 } |
3987 return result; | 3988 return result; |
3988 } | 3989 } |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4028 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); | 4029 ZoneList<ObjectLiteral::Property*>* properties = NewPropertyList(4, zone()); |
4029 Expression* constructor = NULL; | 4030 Expression* constructor = NULL; |
4030 bool has_seen_constructor = false; | 4031 bool has_seen_constructor = false; |
4031 | 4032 |
4032 Expect(Token::LBRACE, CHECK_OK); | 4033 Expect(Token::LBRACE, CHECK_OK); |
4033 while (peek() != Token::RBRACE) { | 4034 while (peek() != Token::RBRACE) { |
4034 if (Check(Token::SEMICOLON)) continue; | 4035 if (Check(Token::SEMICOLON)) continue; |
4035 if (fni_ != NULL) fni_->Enter(); | 4036 if (fni_ != NULL) fni_->Enter(); |
4036 const bool in_class = true; | 4037 const bool in_class = true; |
4037 const bool is_static = false; | 4038 const bool is_static = false; |
4039 bool is_computed_name = false; | |
Dmitry Lomov (no reviews)
2014/12/11 12:34:35
this should be has_seen_computed_name, right? Or w
arv (Not doing code reviews)
2014/12/11 23:10:33
Classes do not care about computed property name h
| |
4038 ObjectLiteral::Property* property = ParsePropertyDefinition( | 4040 ObjectLiteral::Property* property = ParsePropertyDefinition( |
4039 NULL, in_class, is_static, &has_seen_constructor, CHECK_OK); | 4041 NULL, in_class, is_static, &is_computed_name, &has_seen_constructor, |
4042 CHECK_OK); | |
4040 | 4043 |
4041 if (has_seen_constructor && constructor == NULL) { | 4044 if (has_seen_constructor && constructor == NULL) { |
4042 constructor = GetPropertyValue(property); | 4045 constructor = GetPropertyValue(property); |
4043 } else { | 4046 } else { |
4044 properties->Add(property, zone()); | 4047 properties->Add(property, zone()); |
4045 } | 4048 } |
4046 | 4049 |
4047 if (fni_ != NULL) { | 4050 if (fni_ != NULL) { |
4048 fni_->Infer(); | 4051 fni_->Infer(); |
4049 fni_->Leave(); | 4052 fni_->Leave(); |
(...skipping 1241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5291 } else { | 5294 } else { |
5292 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); | 5295 const uc16* data = reinterpret_cast<const uc16*>(raw_string->raw_data()); |
5293 running_hash = StringHasher::ComputeRunningHash(running_hash, data, | 5296 running_hash = StringHasher::ComputeRunningHash(running_hash, data, |
5294 raw_string->length()); | 5297 raw_string->length()); |
5295 } | 5298 } |
5296 } | 5299 } |
5297 | 5300 |
5298 return running_hash; | 5301 return running_hash; |
5299 } | 5302 } |
5300 } } // namespace v8::internal | 5303 } } // namespace v8::internal |
OLD | NEW |