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

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

Issue 766663003: harmony-classes: Implement 'super(...)' call syntactic restriction. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Patch for landing 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
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/ast-this-access-visitor.h"
6 #include "src/parser.h"
7
8 namespace v8 {
9 namespace internal {
10
11 typedef class AstThisAccessVisitor ATAV; // for code shortitude.
12
13 ATAV::AstThisAccessVisitor(Zone* zone) : uses_this_(false) {
14 InitializeAstVisitor(zone);
15 }
16
17
18 void ATAV::VisitVariableProxy(VariableProxy* proxy) {
19 if (proxy->is_this()) {
20 uses_this_ = true;
21 }
22 }
23
24
25 // ---------------------------------------------------------------------------
26 // -- Leaf nodes -------------------------------------------------------------
27 // ---------------------------------------------------------------------------
28
29 void ATAV::VisitVariableDeclaration(VariableDeclaration* leaf) {}
30 void ATAV::VisitFunctionDeclaration(FunctionDeclaration* leaf) {}
31 void ATAV::VisitModuleDeclaration(ModuleDeclaration* leaf) {}
32 void ATAV::VisitImportDeclaration(ImportDeclaration* leaf) {}
33 void ATAV::VisitExportDeclaration(ExportDeclaration* leaf) {}
34 void ATAV::VisitModuleVariable(ModuleVariable* leaf) {}
35 void ATAV::VisitModulePath(ModulePath* leaf) {}
36 void ATAV::VisitModuleUrl(ModuleUrl* leaf) {}
37 void ATAV::VisitEmptyStatement(EmptyStatement* leaf) {}
38 void ATAV::VisitContinueStatement(ContinueStatement* leaf) {}
39 void ATAV::VisitBreakStatement(BreakStatement* leaf) {}
40 void ATAV::VisitDebuggerStatement(DebuggerStatement* leaf) {}
41 void ATAV::VisitFunctionLiteral(FunctionLiteral* leaf) {}
42 void ATAV::VisitNativeFunctionLiteral(NativeFunctionLiteral* leaf) {}
43 void ATAV::VisitLiteral(Literal* leaf) {}
44 void ATAV::VisitRegExpLiteral(RegExpLiteral* leaf) {}
45 void ATAV::VisitThisFunction(ThisFunction* leaf) {}
46 void ATAV::VisitSuperReference(SuperReference* leaf) {}
47
48
49 // ---------------------------------------------------------------------------
50 // -- Pass-through nodes------------------------------------------------------
51 // ---------------------------------------------------------------------------
52 void ATAV::VisitModuleLiteral(ModuleLiteral* e) { Visit(e->body()); }
53
54
55 void ATAV::VisitBlock(Block* stmt) { VisitStatements(stmt->statements()); }
arv (Not doing code reviews) 2014/12/01 15:14:07 I'm surprised that we don't have a base class that
56
57
58 void ATAV::VisitExpressionStatement(ExpressionStatement* stmt) {
59 Visit(stmt->expression());
60 }
61
62
63 void ATAV::VisitIfStatement(IfStatement* stmt) {
64 Visit(stmt->condition());
65 Visit(stmt->then_statement());
66 Visit(stmt->else_statement());
67 }
68
69
70 void ATAV::VisitReturnStatement(ReturnStatement* stmt) {
71 Visit(stmt->expression());
72 }
73
74
75 void ATAV::VisitWithStatement(WithStatement* stmt) {
76 Visit(stmt->expression());
77 Visit(stmt->statement());
78 }
79
80
81 void ATAV::VisitSwitchStatement(SwitchStatement* stmt) {
82 Visit(stmt->tag());
83 ZoneList<CaseClause*>* clauses = stmt->cases();
84 for (int i = 0; i < clauses->length(); i++) {
85 Visit(clauses->at(i));
86 }
87 }
88
89
90 void ATAV::VisitTryFinallyStatement(TryFinallyStatement* stmt) {
91 Visit(stmt->try_block());
92 Visit(stmt->finally_block());
93 }
94
95
96 void ATAV::VisitClassLiteral(ClassLiteral* e) {
97 VisitIfNotNull(e->extends());
98 VisitIfNotNull(e->constructor());
arv (Not doing code reviews) 2014/12/01 15:14:07 constructor cannot be null. If there isn't a user
99 ZoneList<ObjectLiteralProperty*>* properties = e->properties();
100 for (int i = 0; i < properties->length(); i++) {
101 Visit(properties->at(i)->value());
102 }
103 }
104
105
106 void ATAV::VisitConditional(Conditional* e) {
107 Visit(e->condition());
108 Visit(e->then_expression());
109 Visit(e->else_expression());
110 }
111
112
113 void ATAV::VisitObjectLiteral(ObjectLiteral* e) {
114 ZoneList<ObjectLiteralProperty*>* properties = e->properties();
115 for (int i = 0; i < properties->length(); i++) {
116 Visit(properties->at(i)->value());
117 }
118 }
119
120
121 void ATAV::VisitArrayLiteral(ArrayLiteral* e) { VisitExpressions(e->values()); }
122
123
124 void ATAV::VisitYield(Yield* stmt) {
125 Visit(stmt->generator_object());
126 Visit(stmt->expression());
127 }
128
129
130 void ATAV::VisitThrow(Throw* stmt) { Visit(stmt->exception()); }
131
132
133 void ATAV::VisitProperty(Property* e) {
134 Visit(e->obj());
135 Visit(e->key());
136 }
137
138
139 void ATAV::VisitCall(Call* e) {
140 Visit(e->expression());
141 VisitExpressions(e->arguments());
142 }
143
144
145 void ATAV::VisitCallNew(CallNew* e) {
146 Visit(e->expression());
147 VisitExpressions(e->arguments());
148 }
149
150
151 void ATAV::VisitCallRuntime(CallRuntime* e) {
152 VisitExpressions(e->arguments());
153 }
154
155
156 void ATAV::VisitUnaryOperation(UnaryOperation* e) { Visit(e->expression()); }
157
158
159 void ATAV::VisitBinaryOperation(BinaryOperation* e) {
160 Visit(e->left());
161 Visit(e->right());
162 }
163
164
165 void ATAV::VisitCompareOperation(CompareOperation* e) {
166 Visit(e->left());
167 Visit(e->right());
168 }
169
170
171 void ATAV::VisitCaseClause(CaseClause* cc) {
172 if (!cc->is_default()) Visit(cc->label());
173 VisitStatements(cc->statements());
174 }
175
176
177 void ATAV::VisitModuleStatement(ModuleStatement* stmt) { Visit(stmt->body()); }
178
179
180 void ATAV::VisitTryCatchStatement(TryCatchStatement* stmt) {
181 Visit(stmt->try_block());
182 Visit(stmt->catch_block());
183 }
184
185
186 void ATAV::VisitDoWhileStatement(DoWhileStatement* loop) {
187 Visit(loop->body());
188 Visit(loop->cond());
189 }
190
191
192 void ATAV::VisitWhileStatement(WhileStatement* loop) {
193 Visit(loop->cond());
194 Visit(loop->body());
195 }
196
197
198 void ATAV::VisitForStatement(ForStatement* loop) {
199 VisitIfNotNull(loop->init());
200 VisitIfNotNull(loop->cond());
201 Visit(loop->body());
202 VisitIfNotNull(loop->next());
203 }
204
205
206 void ATAV::VisitForInStatement(ForInStatement* loop) {
207 Visit(loop->each());
208 Visit(loop->subject());
209 Visit(loop->body());
210 }
211
212
213 void ATAV::VisitForOfStatement(ForOfStatement* loop) {
214 Visit(loop->each());
215 Visit(loop->subject());
216 Visit(loop->body());
217 }
218
219
220 void ATAV::VisitAssignment(Assignment* stmt) {
221 Expression* l = stmt->target();
222 Visit(l);
223 Visit(stmt->value());
224 }
225
226
227 void ATAV::VisitCountOperation(CountOperation* e) {
228 Expression* l = e->expression();
229 Visit(l);
230 }
231 }
232 } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698