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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
749 } | 749 } |
750 | 750 |
751 | 751 |
752 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, | 752 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, |
753 int pos) { | 753 int pos) { |
754 return scope->NewUnresolved(factory, | 754 return scope->NewUnresolved(factory, |
755 parser_->ast_value_factory()->this_string(), | 755 parser_->ast_value_factory()->this_string(), |
756 Variable::THIS, pos, pos + 4); | 756 Variable::THIS, pos, pos + 4); |
757 } | 757 } |
758 | 758 |
759 | |
759 Expression* ParserTraits::SuperPropertyReference(Scope* scope, | 760 Expression* ParserTraits::SuperPropertyReference(Scope* scope, |
760 AstNodeFactory* factory, | 761 AstNodeFactory* factory, |
761 int pos) { | 762 int pos) { |
762 // this_function[home_object_symbol] | 763 // this_function[home_object_symbol] |
763 VariableProxy* this_function_proxy = scope->NewUnresolved( | 764 VariableProxy* this_function_proxy = scope->NewUnresolved( |
764 factory, parser_->ast_value_factory()->this_function_string(), | 765 factory, parser_->ast_value_factory()->this_function_string(), |
765 Variable::NORMAL, pos); | 766 Variable::NORMAL, pos); |
766 Expression* home_object_symbol_literal = | 767 Expression* home_object_symbol_literal = |
767 factory->NewSymbolLiteral("home_object_symbol", RelocInfo::kNoPosition); | 768 factory->NewSymbolLiteral("home_object_symbol", RelocInfo::kNoPosition); |
768 Expression* home_object = factory->NewProperty( | 769 Expression* home_object = factory->NewProperty( |
(...skipping 10 matching lines...) Expand all Loading... | |
779 Variable::NORMAL, pos); | 780 Variable::NORMAL, pos); |
780 VariableProxy* this_function_proxy = scope->NewUnresolved( | 781 VariableProxy* this_function_proxy = scope->NewUnresolved( |
781 factory, parser_->ast_value_factory()->this_function_string(), | 782 factory, parser_->ast_value_factory()->this_function_string(), |
782 Variable::NORMAL, pos); | 783 Variable::NORMAL, pos); |
783 return factory->NewSuperCallReference( | 784 return factory->NewSuperCallReference( |
784 ThisExpression(scope, factory, pos)->AsVariableProxy(), new_target_proxy, | 785 ThisExpression(scope, factory, pos)->AsVariableProxy(), new_target_proxy, |
785 this_function_proxy, pos); | 786 this_function_proxy, pos); |
786 } | 787 } |
787 | 788 |
788 | 789 |
790 Expression* ParserTraits::NewTargetExpression(Scope* scope, | |
791 AstNodeFactory* factory, | |
792 int pos) { | |
793 return scope->NewUnresolved(factory, | |
794 parser_->ast_value_factory()->new_target_string(), | |
795 Variable::NORMAL, pos, pos + 10); | |
arv (Not doing code reviews)
2015/06/08 19:56:44
Is there a way to get the length of "new.target" a
Dmitry Lomov (no reviews)
2015/06/09 09:57:23
Maybe add a constant?
| |
796 } | |
797 | |
798 | |
789 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, | 799 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, |
790 int pos, int end_pos) { | 800 int pos, int end_pos) { |
791 return parser_->DefaultConstructor(call_super, scope, pos, end_pos); | 801 return parser_->DefaultConstructor(call_super, scope, pos, end_pos); |
792 } | 802 } |
793 | 803 |
794 | 804 |
795 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos, | 805 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos, |
796 Scanner* scanner, | 806 Scanner* scanner, |
797 AstNodeFactory* factory) { | 807 AstNodeFactory* factory) { |
798 switch (token) { | 808 switch (token) { |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
903 set_allow_harmony_classes(FLAG_harmony_classes); | 913 set_allow_harmony_classes(FLAG_harmony_classes); |
904 set_allow_harmony_object_literals(FLAG_harmony_object_literals); | 914 set_allow_harmony_object_literals(FLAG_harmony_object_literals); |
905 set_allow_harmony_sloppy(FLAG_harmony_sloppy); | 915 set_allow_harmony_sloppy(FLAG_harmony_sloppy); |
906 set_allow_harmony_unicode(FLAG_harmony_unicode); | 916 set_allow_harmony_unicode(FLAG_harmony_unicode); |
907 set_allow_harmony_computed_property_names( | 917 set_allow_harmony_computed_property_names( |
908 FLAG_harmony_computed_property_names); | 918 FLAG_harmony_computed_property_names); |
909 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); | 919 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); |
910 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); | 920 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); |
911 set_allow_harmony_destructuring(FLAG_harmony_destructuring); | 921 set_allow_harmony_destructuring(FLAG_harmony_destructuring); |
912 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); | 922 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); |
923 set_allow_harmony_new_target(FLAG_harmony_new_target); | |
913 set_allow_strong_mode(FLAG_strong_mode); | 924 set_allow_strong_mode(FLAG_strong_mode); |
914 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; | 925 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; |
915 ++feature) { | 926 ++feature) { |
916 use_counts_[feature] = 0; | 927 use_counts_[feature] = 0; |
917 } | 928 } |
918 if (info->ast_value_factory() == NULL) { | 929 if (info->ast_value_factory() == NULL) { |
919 // info takes ownership of AstValueFactory. | 930 // info takes ownership of AstValueFactory. |
920 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); | 931 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); |
921 info->set_ast_value_factory_owned(); | 932 info->set_ast_value_factory_owned(); |
922 ast_value_factory_ = info->ast_value_factory(); | 933 ast_value_factory_ = info->ast_value_factory(); |
(...skipping 3356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4279 // main thread preparse times. | 4290 // main thread preparse times. |
4280 if (pre_parse_timer_ != NULL) { | 4291 if (pre_parse_timer_ != NULL) { |
4281 pre_parse_timer_->Start(); | 4292 pre_parse_timer_->Start(); |
4282 } | 4293 } |
4283 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); | 4294 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); |
4284 | 4295 |
4285 if (reusable_preparser_ == NULL) { | 4296 if (reusable_preparser_ == NULL) { |
4286 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), | 4297 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), |
4287 NULL, stack_limit_); | 4298 NULL, stack_limit_); |
4288 reusable_preparser_->set_allow_lazy(true); | 4299 reusable_preparser_->set_allow_lazy(true); |
4289 reusable_preparser_->set_allow_natives(allow_natives()); | 4300 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name()); |
4290 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules()); | 4301 SET_ALLOW(natives); |
4291 reusable_preparser_->set_allow_harmony_arrow_functions( | 4302 SET_ALLOW(harmony_modules); |
4292 allow_harmony_arrow_functions()); | 4303 SET_ALLOW(harmony_arrow_functions); |
4293 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); | 4304 SET_ALLOW(harmony_classes); |
4294 reusable_preparser_->set_allow_harmony_object_literals( | 4305 SET_ALLOW(harmony_object_literals); |
4295 allow_harmony_object_literals()); | 4306 SET_ALLOW(harmony_sloppy); |
4296 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); | 4307 SET_ALLOW(harmony_unicode); |
4297 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); | 4308 SET_ALLOW(harmony_computed_property_names); |
4298 reusable_preparser_->set_allow_harmony_computed_property_names( | 4309 SET_ALLOW(harmony_rest_params); |
4299 allow_harmony_computed_property_names()); | 4310 SET_ALLOW(harmony_spreadcalls); |
4300 reusable_preparser_->set_allow_harmony_rest_params( | 4311 SET_ALLOW(harmony_destructuring); |
4301 allow_harmony_rest_params()); | 4312 SET_ALLOW(harmony_spread_arrays); |
4302 reusable_preparser_->set_allow_harmony_spreadcalls( | 4313 SET_ALLOW(harmony_new_target); |
4303 allow_harmony_spreadcalls()); | 4314 SET_ALLOW(strong_mode); |
4304 reusable_preparser_->set_allow_harmony_destructuring( | 4315 #undef SET_ALLOW |
4305 allow_harmony_destructuring()); | |
4306 reusable_preparser_->set_allow_harmony_spread_arrays( | |
4307 allow_harmony_spread_arrays()); | |
4308 reusable_preparser_->set_allow_strong_mode(allow_strong_mode()); | |
4309 } | 4316 } |
4310 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( | 4317 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( |
4311 language_mode(), function_state_->kind(), logger, bookmark); | 4318 language_mode(), function_state_->kind(), logger, bookmark); |
4312 if (pre_parse_timer_ != NULL) { | 4319 if (pre_parse_timer_ != NULL) { |
4313 pre_parse_timer_->Stop(); | 4320 pre_parse_timer_->Stop(); |
4314 } | 4321 } |
4315 return result; | 4322 return result; |
4316 } | 4323 } |
4317 | 4324 |
4318 | 4325 |
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5822 Expression* Parser::SpreadCallNew(Expression* function, | 5829 Expression* Parser::SpreadCallNew(Expression* function, |
5823 ZoneList<v8::internal::Expression*>* args, | 5830 ZoneList<v8::internal::Expression*>* args, |
5824 int pos) { | 5831 int pos) { |
5825 args->InsertAt(0, function, zone()); | 5832 args->InsertAt(0, function, zone()); |
5826 | 5833 |
5827 return factory()->NewCallRuntime( | 5834 return factory()->NewCallRuntime( |
5828 ast_value_factory()->reflect_construct_string(), NULL, args, pos); | 5835 ast_value_factory()->reflect_construct_string(), NULL, args, pos); |
5829 } | 5836 } |
5830 } // namespace internal | 5837 } // namespace internal |
5831 } // namespace v8 | 5838 } // namespace v8 |
OLD | NEW |