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

Side by Side Diff: src/parser.cc

Issue 1169853002: [es6] Parsing of new.target (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Add constant Created 5 years, 6 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 738 matching lines...) Expand 10 before | Expand all | Expand 10 after
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
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 static const int kNewTargetStringLength = 10;
794 return scope->NewUnresolved(
795 factory, parser_->ast_value_factory()->new_target_string(),
796 Variable::NORMAL, pos, pos + kNewTargetStringLength);
797 }
798
799
789 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, 800 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope,
790 int pos, int end_pos) { 801 int pos, int end_pos) {
791 return parser_->DefaultConstructor(call_super, scope, pos, end_pos); 802 return parser_->DefaultConstructor(call_super, scope, pos, end_pos);
792 } 803 }
793 804
794 805
795 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos, 806 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos,
796 Scanner* scanner, 807 Scanner* scanner,
797 AstNodeFactory* factory) { 808 AstNodeFactory* factory) {
798 switch (token) { 809 switch (token) {
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 set_allow_harmony_classes(FLAG_harmony_classes); 914 set_allow_harmony_classes(FLAG_harmony_classes);
904 set_allow_harmony_object_literals(FLAG_harmony_object_literals); 915 set_allow_harmony_object_literals(FLAG_harmony_object_literals);
905 set_allow_harmony_sloppy(FLAG_harmony_sloppy); 916 set_allow_harmony_sloppy(FLAG_harmony_sloppy);
906 set_allow_harmony_unicode(FLAG_harmony_unicode); 917 set_allow_harmony_unicode(FLAG_harmony_unicode);
907 set_allow_harmony_computed_property_names( 918 set_allow_harmony_computed_property_names(
908 FLAG_harmony_computed_property_names); 919 FLAG_harmony_computed_property_names);
909 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters); 920 set_allow_harmony_rest_params(FLAG_harmony_rest_parameters);
910 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls); 921 set_allow_harmony_spreadcalls(FLAG_harmony_spreadcalls);
911 set_allow_harmony_destructuring(FLAG_harmony_destructuring); 922 set_allow_harmony_destructuring(FLAG_harmony_destructuring);
912 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays); 923 set_allow_harmony_spread_arrays(FLAG_harmony_spread_arrays);
924 set_allow_harmony_new_target(FLAG_harmony_new_target);
913 set_allow_strong_mode(FLAG_strong_mode); 925 set_allow_strong_mode(FLAG_strong_mode);
914 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount; 926 for (int feature = 0; feature < v8::Isolate::kUseCounterFeatureCount;
915 ++feature) { 927 ++feature) {
916 use_counts_[feature] = 0; 928 use_counts_[feature] = 0;
917 } 929 }
918 if (info->ast_value_factory() == NULL) { 930 if (info->ast_value_factory() == NULL) {
919 // info takes ownership of AstValueFactory. 931 // info takes ownership of AstValueFactory.
920 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed())); 932 info->set_ast_value_factory(new AstValueFactory(zone(), info->hash_seed()));
921 info->set_ast_value_factory_owned(); 933 info->set_ast_value_factory_owned();
922 ast_value_factory_ = info->ast_value_factory(); 934 ast_value_factory_ = info->ast_value_factory();
(...skipping 3356 matching lines...) Expand 10 before | Expand all | Expand 10 after
4279 // main thread preparse times. 4291 // main thread preparse times.
4280 if (pre_parse_timer_ != NULL) { 4292 if (pre_parse_timer_ != NULL) {
4281 pre_parse_timer_->Start(); 4293 pre_parse_timer_->Start();
4282 } 4294 }
4283 DCHECK_EQ(Token::LBRACE, scanner()->current_token()); 4295 DCHECK_EQ(Token::LBRACE, scanner()->current_token());
4284 4296
4285 if (reusable_preparser_ == NULL) { 4297 if (reusable_preparser_ == NULL) {
4286 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(), 4298 reusable_preparser_ = new PreParser(zone(), &scanner_, ast_value_factory(),
4287 NULL, stack_limit_); 4299 NULL, stack_limit_);
4288 reusable_preparser_->set_allow_lazy(true); 4300 reusable_preparser_->set_allow_lazy(true);
4289 reusable_preparser_->set_allow_natives(allow_natives()); 4301 #define SET_ALLOW(name) reusable_preparser_->set_allow_##name(allow_##name());
4290 reusable_preparser_->set_allow_harmony_modules(allow_harmony_modules()); 4302 SET_ALLOW(natives);
4291 reusable_preparser_->set_allow_harmony_arrow_functions( 4303 SET_ALLOW(harmony_modules);
4292 allow_harmony_arrow_functions()); 4304 SET_ALLOW(harmony_arrow_functions);
4293 reusable_preparser_->set_allow_harmony_classes(allow_harmony_classes()); 4305 SET_ALLOW(harmony_classes);
4294 reusable_preparser_->set_allow_harmony_object_literals( 4306 SET_ALLOW(harmony_object_literals);
4295 allow_harmony_object_literals()); 4307 SET_ALLOW(harmony_sloppy);
4296 reusable_preparser_->set_allow_harmony_sloppy(allow_harmony_sloppy()); 4308 SET_ALLOW(harmony_unicode);
4297 reusable_preparser_->set_allow_harmony_unicode(allow_harmony_unicode()); 4309 SET_ALLOW(harmony_computed_property_names);
4298 reusable_preparser_->set_allow_harmony_computed_property_names( 4310 SET_ALLOW(harmony_rest_params);
4299 allow_harmony_computed_property_names()); 4311 SET_ALLOW(harmony_spreadcalls);
4300 reusable_preparser_->set_allow_harmony_rest_params( 4312 SET_ALLOW(harmony_destructuring);
4301 allow_harmony_rest_params()); 4313 SET_ALLOW(harmony_spread_arrays);
4302 reusable_preparser_->set_allow_harmony_spreadcalls( 4314 SET_ALLOW(harmony_new_target);
4303 allow_harmony_spreadcalls()); 4315 SET_ALLOW(strong_mode);
4304 reusable_preparser_->set_allow_harmony_destructuring( 4316 #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 } 4317 }
4310 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction( 4318 PreParser::PreParseResult result = reusable_preparser_->PreParseLazyFunction(
4311 language_mode(), function_state_->kind(), logger, bookmark); 4319 language_mode(), function_state_->kind(), logger, bookmark);
4312 if (pre_parse_timer_ != NULL) { 4320 if (pre_parse_timer_ != NULL) {
4313 pre_parse_timer_->Stop(); 4321 pre_parse_timer_->Stop();
4314 } 4322 }
4315 return result; 4323 return result;
4316 } 4324 }
4317 4325
4318 4326
(...skipping 1503 matching lines...) Expand 10 before | Expand all | Expand 10 after
5822 Expression* Parser::SpreadCallNew(Expression* function, 5830 Expression* Parser::SpreadCallNew(Expression* function,
5823 ZoneList<v8::internal::Expression*>* args, 5831 ZoneList<v8::internal::Expression*>* args,
5824 int pos) { 5832 int pos) {
5825 args->InsertAt(0, function, zone()); 5833 args->InsertAt(0, function, zone());
5826 5834
5827 return factory()->NewCallRuntime( 5835 return factory()->NewCallRuntime(
5828 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5836 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5829 } 5837 }
5830 } // namespace internal 5838 } // namespace internal
5831 } // namespace v8 5839 } // namespace v8
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