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

Side by Side Diff: src/parser.cc

Issue 1161243005: Revert of [es6] Super call in arrows and eval (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: 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/pattern-rewriter.cc » ('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 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 ZoneList<Statement*>* body = NULL; 352 ZoneList<Statement*>* body = NULL;
353 353
354 { 354 {
355 AstNodeFactory function_factory(ast_value_factory()); 355 AstNodeFactory function_factory(ast_value_factory());
356 FunctionState function_state(&function_state_, &scope_, function_scope, 356 FunctionState function_state(&function_state_, &scope_, function_scope,
357 kind, &function_factory); 357 kind, &function_factory);
358 358
359 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); 359 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone());
360 AddAssertIsConstruct(body, pos); 360 AddAssertIsConstruct(body, pos);
361 if (call_super) { 361 if (call_super) {
362 // %_DefaultConstructorCallSuper(new.target, .this_function)
363 ZoneList<Expression*>* args = 362 ZoneList<Expression*>* args =
364 new (zone()) ZoneList<Expression*>(2, zone()); 363 new (zone()) ZoneList<Expression*>(0, zone());
365 VariableProxy* new_target_proxy = scope_->NewUnresolved(
366 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL,
367 pos);
368 args->Add(new_target_proxy, zone());
369 VariableProxy* this_function_proxy = scope_->NewUnresolved(
370 factory(), ast_value_factory()->this_function_string(),
371 Variable::NORMAL, pos);
372 args->Add(this_function_proxy, zone());
373 CallRuntime* call = factory()->NewCallRuntime( 364 CallRuntime* call = factory()->NewCallRuntime(
374 ast_value_factory()->empty_string(), 365 ast_value_factory()->empty_string(),
375 Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper), 366 Runtime::FunctionForId(Runtime::kInlineDefaultConstructorCallSuper),
376 args, pos); 367 args, pos);
377 body->Add(factory()->NewReturnStatement(call, pos), zone()); 368 body->Add(factory()->NewReturnStatement(call, pos), zone());
378 } 369 }
379 370
380 materialized_literal_count = function_state.materialized_literal_count(); 371 materialized_literal_count = function_state.materialized_literal_count();
381 expected_property_count = function_state.expected_property_count(); 372 expected_property_count = function_state.expected_property_count();
382 handler_count = function_state.handler_count(); 373 handler_count = function_state.handler_count();
(...skipping 366 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 } 740 }
750 741
751 742
752 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, 743 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
753 int pos) { 744 int pos) {
754 return scope->NewUnresolved(factory, 745 return scope->NewUnresolved(factory,
755 parser_->ast_value_factory()->this_string(), 746 parser_->ast_value_factory()->this_string(),
756 Variable::THIS, pos, pos + 4); 747 Variable::THIS, pos, pos + 4);
757 } 748 }
758 749
759 Expression* ParserTraits::SuperPropertyReference(Scope* scope, 750 Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory,
760 AstNodeFactory* factory, 751 int pos) {
761 int pos) { 752 // TODO(arv): Split into SuperProperty and SuperCall?
762 VariableProxy* home_object_proxy = scope->NewUnresolved( 753 VariableProxy* home_object_proxy = scope->NewUnresolved(
763 factory, parser_->ast_value_factory()->home_object_string(), 754 factory, parser_->ast_value_factory()->home_object_string(),
764 Variable::NORMAL, pos); 755 Variable::NORMAL, pos);
765 return factory->NewSuperPropertyReference( 756
757 return factory->NewSuperReference(
766 ThisExpression(scope, factory, pos)->AsVariableProxy(), home_object_proxy, 758 ThisExpression(scope, factory, pos)->AsVariableProxy(), home_object_proxy,
767 pos); 759 pos);
768 } 760 }
769 761
770 762
771 Expression* ParserTraits::SuperCallReference(Scope* scope,
772 AstNodeFactory* factory, int pos) {
773 VariableProxy* new_target_proxy = scope->NewUnresolved(
774 factory, parser_->ast_value_factory()->new_target_string(),
775 Variable::NORMAL, pos);
776 VariableProxy* this_function_proxy = scope->NewUnresolved(
777 factory, parser_->ast_value_factory()->this_function_string(),
778 Variable::NORMAL, pos);
779 return factory->NewSuperCallReference(
780 ThisExpression(scope, factory, pos)->AsVariableProxy(), new_target_proxy,
781 this_function_proxy, pos);
782 }
783
784
785 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope, 763 Expression* ParserTraits::DefaultConstructor(bool call_super, Scope* scope,
786 int pos, int end_pos) { 764 int pos, int end_pos) {
787 return parser_->DefaultConstructor(call_super, scope, pos, end_pos); 765 return parser_->DefaultConstructor(call_super, scope, pos, end_pos);
788 } 766 }
789 767
790 768
791 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos, 769 Literal* ParserTraits::ExpressionFromLiteral(Token::Value token, int pos,
792 Scanner* scanner, 770 Scanner* scanner,
793 AstNodeFactory* factory) { 771 AstNodeFactory* factory) {
794 switch (token) { 772 switch (token) {
(...skipping 4964 matching lines...) Expand 10 before | Expand all | Expand 10 after
5759 zone()); 5737 zone());
5760 return list; 5738 return list;
5761 } 5739 }
5762 UNREACHABLE(); 5740 UNREACHABLE();
5763 } 5741 }
5764 5742
5765 5743
5766 Expression* Parser::SpreadCall(Expression* function, 5744 Expression* Parser::SpreadCall(Expression* function,
5767 ZoneList<v8::internal::Expression*>* args, 5745 ZoneList<v8::internal::Expression*>* args,
5768 int pos) { 5746 int pos) {
5769 if (function->IsSuperCallReference()) { 5747 if (function->IsSuperReference()) {
5770 // Super calls 5748 // Super calls
5771 // %_CallSuperWithSpread(%ReflectConstruct(<super>, args, new.target))
5772 args->InsertAt(0, function, zone()); 5749 args->InsertAt(0, function, zone());
5773 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); 5750 args->Add(factory()->NewVariableProxy(scope_->new_target_var()), zone());
5774 Expression* result = factory()->NewCallRuntime( 5751 Expression* result = factory()->NewCallRuntime(
5775 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5752 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5776 args = new (zone()) ZoneList<Expression*>(1, zone()); 5753 args = new (zone()) ZoneList<Expression*>(0, zone());
5777 args->Add(result, zone()); 5754 args->Add(result, zone());
5778 return factory()->NewCallRuntime( 5755 return factory()->NewCallRuntime(
5779 ast_value_factory()->empty_string(), 5756 ast_value_factory()->empty_string(),
5780 Runtime::FunctionForId(Runtime::kInlineCallSuperWithSpread), args, pos); 5757 Runtime::FunctionForId(Runtime::kInlineCallSuperWithSpread), args, pos);
5781 } else { 5758 } else {
5782 if (function->IsProperty()) { 5759 if (function->IsProperty()) {
5783 // Method calls 5760 // Method calls
5784 if (function->AsProperty()->IsSuperAccess()) { 5761 if (function->AsProperty()->IsSuperAccess()) {
5785 Expression* home = 5762 Expression* home =
5786 ThisExpression(scope_, factory(), RelocInfo::kNoPosition); 5763 ThisExpression(scope_, factory(), RelocInfo::kNoPosition);
(...skipping 26 matching lines...) Expand all
5813 5790
5814 Expression* Parser::SpreadCallNew(Expression* function, 5791 Expression* Parser::SpreadCallNew(Expression* function,
5815 ZoneList<v8::internal::Expression*>* args, 5792 ZoneList<v8::internal::Expression*>* args,
5816 int pos) { 5793 int pos) {
5817 args->InsertAt(0, function, zone()); 5794 args->InsertAt(0, function, zone());
5818 5795
5819 return factory()->NewCallRuntime( 5796 return factory()->NewCallRuntime(
5820 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5797 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5821 } 5798 }
5822 } } // namespace v8::internal 5799 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/parser.h ('k') | src/pattern-rewriter.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698