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

Side by Side Diff: src/ast-this-access-visitor.cc

Issue 770843002: harmony-classes: Fix some issues with syntactic restriction on super(...). (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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/ast-this-access-visitor.h ('k') | src/scopes.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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/ast-this-access-visitor.h" 5 #include "src/ast-this-access-visitor.h"
6 #include "src/parser.h" 6 #include "src/parser.h"
7 7
8 namespace v8 { 8 namespace v8 {
9 namespace internal { 9 namespace internal {
10 10
11 typedef class AstThisAccessVisitor ATAV; // for code shortitude. 11 typedef class AstThisAccessVisitor ATAV; // for code shortitude.
12 12
13 ATAV::AstThisAccessVisitor(Zone* zone) : uses_this_(false) { 13 ATAV::AstThisAccessVisitor(Zone* zone) : uses_this_(false) {
14 InitializeAstVisitor(zone); 14 InitializeAstVisitor(zone);
15 } 15 }
16 16
17 17
18 void ATAV::VisitVariableProxy(VariableProxy* proxy) { 18 void ATAV::VisitVariableProxy(VariableProxy* proxy) {
19 if (proxy->is_this()) { 19 if (proxy->is_this()) {
20 uses_this_ = true; 20 uses_this_ = true;
21 } 21 }
22 } 22 }
23 23
24 24
25 void ATAV::VisitSuperReference(SuperReference* leaf) {
26 // disallow super.method() and super(...).
27 uses_this_ = true;
28 }
29
30
31 void ATAV::VisitCallNew(CallNew* e) {
32 // new super(..) does not use 'this'.
33 if (!e->expression()->IsSuperReference()) {
34 Visit(e->expression());
35 }
36 VisitExpressions(e->arguments());
37 }
38
39
25 // --------------------------------------------------------------------------- 40 // ---------------------------------------------------------------------------
26 // -- Leaf nodes ------------------------------------------------------------- 41 // -- Leaf nodes -------------------------------------------------------------
27 // --------------------------------------------------------------------------- 42 // ---------------------------------------------------------------------------
28 43
29 void ATAV::VisitVariableDeclaration(VariableDeclaration* leaf) {} 44 void ATAV::VisitVariableDeclaration(VariableDeclaration* leaf) {}
30 void ATAV::VisitFunctionDeclaration(FunctionDeclaration* leaf) {} 45 void ATAV::VisitFunctionDeclaration(FunctionDeclaration* leaf) {}
31 void ATAV::VisitModuleDeclaration(ModuleDeclaration* leaf) {} 46 void ATAV::VisitModuleDeclaration(ModuleDeclaration* leaf) {}
32 void ATAV::VisitImportDeclaration(ImportDeclaration* leaf) {} 47 void ATAV::VisitImportDeclaration(ImportDeclaration* leaf) {}
33 void ATAV::VisitExportDeclaration(ExportDeclaration* leaf) {} 48 void ATAV::VisitExportDeclaration(ExportDeclaration* leaf) {}
34 void ATAV::VisitModuleVariable(ModuleVariable* leaf) {} 49 void ATAV::VisitModuleVariable(ModuleVariable* leaf) {}
35 void ATAV::VisitModulePath(ModulePath* leaf) {} 50 void ATAV::VisitModulePath(ModulePath* leaf) {}
36 void ATAV::VisitModuleUrl(ModuleUrl* leaf) {} 51 void ATAV::VisitModuleUrl(ModuleUrl* leaf) {}
37 void ATAV::VisitEmptyStatement(EmptyStatement* leaf) {} 52 void ATAV::VisitEmptyStatement(EmptyStatement* leaf) {}
38 void ATAV::VisitContinueStatement(ContinueStatement* leaf) {} 53 void ATAV::VisitContinueStatement(ContinueStatement* leaf) {}
39 void ATAV::VisitBreakStatement(BreakStatement* leaf) {} 54 void ATAV::VisitBreakStatement(BreakStatement* leaf) {}
40 void ATAV::VisitDebuggerStatement(DebuggerStatement* leaf) {} 55 void ATAV::VisitDebuggerStatement(DebuggerStatement* leaf) {}
41 void ATAV::VisitFunctionLiteral(FunctionLiteral* leaf) {} 56 void ATAV::VisitFunctionLiteral(FunctionLiteral* leaf) {}
42 void ATAV::VisitNativeFunctionLiteral(NativeFunctionLiteral* leaf) {} 57 void ATAV::VisitNativeFunctionLiteral(NativeFunctionLiteral* leaf) {}
43 void ATAV::VisitLiteral(Literal* leaf) {} 58 void ATAV::VisitLiteral(Literal* leaf) {}
44 void ATAV::VisitRegExpLiteral(RegExpLiteral* leaf) {} 59 void ATAV::VisitRegExpLiteral(RegExpLiteral* leaf) {}
45 void ATAV::VisitThisFunction(ThisFunction* leaf) {} 60 void ATAV::VisitThisFunction(ThisFunction* leaf) {}
46 void ATAV::VisitSuperReference(SuperReference* leaf) {}
47
48 61
49 // --------------------------------------------------------------------------- 62 // ---------------------------------------------------------------------------
50 // -- Pass-through nodes------------------------------------------------------ 63 // -- Pass-through nodes------------------------------------------------------
51 // --------------------------------------------------------------------------- 64 // ---------------------------------------------------------------------------
52 void ATAV::VisitModuleLiteral(ModuleLiteral* e) { Visit(e->body()); } 65 void ATAV::VisitModuleLiteral(ModuleLiteral* e) { Visit(e->body()); }
53 66
54 67
55 void ATAV::VisitBlock(Block* stmt) { VisitStatements(stmt->statements()); } 68 void ATAV::VisitBlock(Block* stmt) { VisitStatements(stmt->statements()); }
56 69
57 70
(...skipping 30 matching lines...) Expand all
88 101
89 102
90 void ATAV::VisitTryFinallyStatement(TryFinallyStatement* stmt) { 103 void ATAV::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
91 Visit(stmt->try_block()); 104 Visit(stmt->try_block());
92 Visit(stmt->finally_block()); 105 Visit(stmt->finally_block());
93 } 106 }
94 107
95 108
96 void ATAV::VisitClassLiteral(ClassLiteral* e) { 109 void ATAV::VisitClassLiteral(ClassLiteral* e) {
97 VisitIfNotNull(e->extends()); 110 VisitIfNotNull(e->extends());
98 VisitIfNotNull(e->constructor()); 111 Visit(e->constructor());
99 ZoneList<ObjectLiteralProperty*>* properties = e->properties(); 112 ZoneList<ObjectLiteralProperty*>* properties = e->properties();
100 for (int i = 0; i < properties->length(); i++) { 113 for (int i = 0; i < properties->length(); i++) {
101 Visit(properties->at(i)->value()); 114 Visit(properties->at(i)->value());
102 } 115 }
103 } 116 }
104 117
105 118
106 void ATAV::VisitConditional(Conditional* e) { 119 void ATAV::VisitConditional(Conditional* e) {
107 Visit(e->condition()); 120 Visit(e->condition());
108 Visit(e->then_expression()); 121 Visit(e->then_expression());
(...skipping 26 matching lines...) Expand all
135 Visit(e->key()); 148 Visit(e->key());
136 } 149 }
137 150
138 151
139 void ATAV::VisitCall(Call* e) { 152 void ATAV::VisitCall(Call* e) {
140 Visit(e->expression()); 153 Visit(e->expression());
141 VisitExpressions(e->arguments()); 154 VisitExpressions(e->arguments());
142 } 155 }
143 156
144 157
145 void ATAV::VisitCallNew(CallNew* e) {
146 Visit(e->expression());
147 VisitExpressions(e->arguments());
148 }
149
150
151 void ATAV::VisitCallRuntime(CallRuntime* e) { 158 void ATAV::VisitCallRuntime(CallRuntime* e) {
152 VisitExpressions(e->arguments()); 159 VisitExpressions(e->arguments());
153 } 160 }
154 161
155 162
156 void ATAV::VisitUnaryOperation(UnaryOperation* e) { Visit(e->expression()); } 163 void ATAV::VisitUnaryOperation(UnaryOperation* e) { Visit(e->expression()); }
157 164
158 165
159 void ATAV::VisitBinaryOperation(BinaryOperation* e) { 166 void ATAV::VisitBinaryOperation(BinaryOperation* e) {
160 Visit(e->left()); 167 Visit(e->left());
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 Visit(stmt->value()); 230 Visit(stmt->value());
224 } 231 }
225 232
226 233
227 void ATAV::VisitCountOperation(CountOperation* e) { 234 void ATAV::VisitCountOperation(CountOperation* e) {
228 Expression* l = e->expression(); 235 Expression* l = e->expression();
229 Visit(l); 236 Visit(l);
230 } 237 }
231 } 238 }
232 } // namespace v8::internal 239 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast-this-access-visitor.h ('k') | src/scopes.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698