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

Side by Side Diff: src/parser.cc

Issue 1097283003: Resolve references to "this" the same way as normal variables (Closed) Base URL: https://chromium.googlesource.com/v8/v8@master
Patch Set: Add tests for "this" scoping in arrow functions Created 5 years, 8 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
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 721 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 } 732 }
733 733
734 734
735 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) { 735 const AstRawString* ParserTraits::GetNextSymbol(Scanner* scanner) {
736 return parser_->scanner()->NextSymbol(parser_->ast_value_factory()); 736 return parser_->scanner()->NextSymbol(parser_->ast_value_factory());
737 } 737 }
738 738
739 739
740 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory, 740 Expression* ParserTraits::ThisExpression(Scope* scope, AstNodeFactory* factory,
741 int pos) { 741 int pos) {
742 return factory->NewVariableProxy(scope->receiver(), pos); 742 return scope->NewUnresolved(factory,
743 parser_->ast_value_factory()->this_string(), pos,
744 pos + 4, Variable::THIS);
743 } 745 }
744 746
745 Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory, 747 Expression* ParserTraits::SuperReference(Scope* scope, AstNodeFactory* factory,
746 int pos) { 748 int pos) {
747 return factory->NewSuperReference( 749 return factory->NewSuperReference(
748 ThisExpression(scope, factory, pos)->AsVariableProxy(), 750 ThisExpression(scope, factory, pos)->AsVariableProxy(),
749 pos); 751 pos);
750 } 752 }
751 753
752 754
(...skipping 4988 matching lines...) Expand 10 before | Expand all | Expand 10 after
5741 5743
5742 Expression* Parser::SpreadCallNew(Expression* function, 5744 Expression* Parser::SpreadCallNew(Expression* function,
5743 ZoneList<v8::internal::Expression*>* args, 5745 ZoneList<v8::internal::Expression*>* args,
5744 int pos) { 5746 int pos) {
5745 args->InsertAt(0, function, zone()); 5747 args->InsertAt(0, function, zone());
5746 5748
5747 return factory()->NewCallRuntime( 5749 return factory()->NewCallRuntime(
5748 ast_value_factory()->reflect_construct_string(), NULL, args, pos); 5750 ast_value_factory()->reflect_construct_string(), NULL, args, pos);
5749 } 5751 }
5750 } } // namespace v8::internal 5752 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/heap/heap.h ('k') | src/runtime/runtime-debug.cc » ('j') | src/scopes.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698