OLD | NEW |
| (Empty) |
1 // Copyright 2015 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-literal-reindexer.h" | |
6 | |
7 #include "src/ast.h" | |
8 #include "src/scopes.h" | |
9 | |
10 namespace v8 { | |
11 namespace internal { | |
12 | |
13 | |
14 void AstLiteralReindexer::VisitVariableDeclaration(VariableDeclaration* node) { | |
15 VisitVariableProxy(node->proxy()); | |
16 } | |
17 | |
18 | |
19 void AstLiteralReindexer::VisitExportDeclaration(ExportDeclaration* node) { | |
20 VisitVariableProxy(node->proxy()); | |
21 } | |
22 | |
23 | |
24 void AstLiteralReindexer::VisitEmptyStatement(EmptyStatement* node) {} | |
25 | |
26 | |
27 void AstLiteralReindexer::VisitSloppyBlockFunctionStatement( | |
28 SloppyBlockFunctionStatement* node) { | |
29 Visit(node->statement()); | |
30 } | |
31 | |
32 | |
33 void AstLiteralReindexer::VisitContinueStatement(ContinueStatement* node) {} | |
34 | |
35 | |
36 void AstLiteralReindexer::VisitBreakStatement(BreakStatement* node) {} | |
37 | |
38 | |
39 void AstLiteralReindexer::VisitDebuggerStatement(DebuggerStatement* node) {} | |
40 | |
41 | |
42 void AstLiteralReindexer::VisitNativeFunctionLiteral( | |
43 NativeFunctionLiteral* node) {} | |
44 | |
45 | |
46 void AstLiteralReindexer::VisitDoExpression(DoExpression* node) { | |
47 // TODO(caitp): literals in do expressions need re-indexing too. | |
48 } | |
49 | |
50 | |
51 void AstLiteralReindexer::VisitLiteral(Literal* node) {} | |
52 | |
53 | |
54 void AstLiteralReindexer::VisitRegExpLiteral(RegExpLiteral* node) { | |
55 UpdateIndex(node); | |
56 } | |
57 | |
58 | |
59 void AstLiteralReindexer::VisitVariableProxy(VariableProxy* node) {} | |
60 | |
61 | |
62 void AstLiteralReindexer::VisitThisFunction(ThisFunction* node) {} | |
63 | |
64 | |
65 void AstLiteralReindexer::VisitSuperPropertyReference( | |
66 SuperPropertyReference* node) { | |
67 Visit(node->this_var()); | |
68 Visit(node->home_object()); | |
69 } | |
70 | |
71 | |
72 void AstLiteralReindexer::VisitSuperCallReference(SuperCallReference* node) { | |
73 Visit(node->this_var()); | |
74 Visit(node->new_target_var()); | |
75 Visit(node->this_function_var()); | |
76 } | |
77 | |
78 | |
79 void AstLiteralReindexer::VisitImportDeclaration(ImportDeclaration* node) { | |
80 VisitVariableProxy(node->proxy()); | |
81 } | |
82 | |
83 | |
84 void AstLiteralReindexer::VisitExpressionStatement(ExpressionStatement* node) { | |
85 Visit(node->expression()); | |
86 } | |
87 | |
88 | |
89 void AstLiteralReindexer::VisitReturnStatement(ReturnStatement* node) { | |
90 Visit(node->expression()); | |
91 } | |
92 | |
93 | |
94 void AstLiteralReindexer::VisitYield(Yield* node) { | |
95 Visit(node->generator_object()); | |
96 Visit(node->expression()); | |
97 } | |
98 | |
99 | |
100 void AstLiteralReindexer::VisitThrow(Throw* node) { Visit(node->exception()); } | |
101 | |
102 | |
103 void AstLiteralReindexer::VisitUnaryOperation(UnaryOperation* node) { | |
104 Visit(node->expression()); | |
105 } | |
106 | |
107 | |
108 void AstLiteralReindexer::VisitCountOperation(CountOperation* node) { | |
109 Visit(node->expression()); | |
110 } | |
111 | |
112 | |
113 void AstLiteralReindexer::VisitBlock(Block* node) { | |
114 VisitStatements(node->statements()); | |
115 } | |
116 | |
117 | |
118 void AstLiteralReindexer::VisitFunctionDeclaration(FunctionDeclaration* node) { | |
119 VisitVariableProxy(node->proxy()); | |
120 VisitFunctionLiteral(node->fun()); | |
121 } | |
122 | |
123 | |
124 void AstLiteralReindexer::VisitCallRuntime(CallRuntime* node) { | |
125 VisitArguments(node->arguments()); | |
126 } | |
127 | |
128 | |
129 void AstLiteralReindexer::VisitWithStatement(WithStatement* node) { | |
130 Visit(node->expression()); | |
131 Visit(node->statement()); | |
132 } | |
133 | |
134 | |
135 void AstLiteralReindexer::VisitDoWhileStatement(DoWhileStatement* node) { | |
136 Visit(node->body()); | |
137 Visit(node->cond()); | |
138 } | |
139 | |
140 | |
141 void AstLiteralReindexer::VisitWhileStatement(WhileStatement* node) { | |
142 Visit(node->cond()); | |
143 Visit(node->body()); | |
144 } | |
145 | |
146 | |
147 void AstLiteralReindexer::VisitTryCatchStatement(TryCatchStatement* node) { | |
148 Visit(node->try_block()); | |
149 Visit(node->catch_block()); | |
150 } | |
151 | |
152 | |
153 void AstLiteralReindexer::VisitTryFinallyStatement(TryFinallyStatement* node) { | |
154 Visit(node->try_block()); | |
155 Visit(node->finally_block()); | |
156 } | |
157 | |
158 | |
159 void AstLiteralReindexer::VisitProperty(Property* node) { | |
160 Visit(node->key()); | |
161 Visit(node->obj()); | |
162 } | |
163 | |
164 | |
165 void AstLiteralReindexer::VisitAssignment(Assignment* node) { | |
166 Visit(node->target()); | |
167 Visit(node->value()); | |
168 } | |
169 | |
170 | |
171 void AstLiteralReindexer::VisitBinaryOperation(BinaryOperation* node) { | |
172 Visit(node->left()); | |
173 Visit(node->right()); | |
174 } | |
175 | |
176 | |
177 void AstLiteralReindexer::VisitCompareOperation(CompareOperation* node) { | |
178 Visit(node->left()); | |
179 Visit(node->right()); | |
180 } | |
181 | |
182 | |
183 void AstLiteralReindexer::VisitSpread(Spread* node) { | |
184 Visit(node->expression()); | |
185 } | |
186 | |
187 | |
188 void AstLiteralReindexer::VisitEmptyParentheses(EmptyParentheses* node) {} | |
189 | |
190 | |
191 void AstLiteralReindexer::VisitForInStatement(ForInStatement* node) { | |
192 Visit(node->each()); | |
193 Visit(node->enumerable()); | |
194 Visit(node->body()); | |
195 } | |
196 | |
197 | |
198 void AstLiteralReindexer::VisitForOfStatement(ForOfStatement* node) { | |
199 Visit(node->assign_iterator()); | |
200 Visit(node->next_result()); | |
201 Visit(node->result_done()); | |
202 Visit(node->assign_each()); | |
203 Visit(node->body()); | |
204 } | |
205 | |
206 | |
207 void AstLiteralReindexer::VisitConditional(Conditional* node) { | |
208 Visit(node->condition()); | |
209 Visit(node->then_expression()); | |
210 Visit(node->else_expression()); | |
211 } | |
212 | |
213 | |
214 void AstLiteralReindexer::VisitIfStatement(IfStatement* node) { | |
215 Visit(node->condition()); | |
216 Visit(node->then_statement()); | |
217 if (node->HasElseStatement()) { | |
218 Visit(node->else_statement()); | |
219 } | |
220 } | |
221 | |
222 | |
223 void AstLiteralReindexer::VisitSwitchStatement(SwitchStatement* node) { | |
224 Visit(node->tag()); | |
225 ZoneList<CaseClause*>* cases = node->cases(); | |
226 for (int i = 0; i < cases->length(); i++) { | |
227 VisitCaseClause(cases->at(i)); | |
228 } | |
229 } | |
230 | |
231 | |
232 void AstLiteralReindexer::VisitCaseClause(CaseClause* node) { | |
233 if (!node->is_default()) Visit(node->label()); | |
234 VisitStatements(node->statements()); | |
235 } | |
236 | |
237 | |
238 void AstLiteralReindexer::VisitForStatement(ForStatement* node) { | |
239 if (node->init() != NULL) Visit(node->init()); | |
240 if (node->cond() != NULL) Visit(node->cond()); | |
241 if (node->next() != NULL) Visit(node->next()); | |
242 Visit(node->body()); | |
243 } | |
244 | |
245 | |
246 void AstLiteralReindexer::VisitClassLiteral(ClassLiteral* node) { | |
247 if (node->extends()) Visit(node->extends()); | |
248 if (node->constructor()) Visit(node->constructor()); | |
249 if (node->class_variable_proxy()) { | |
250 VisitVariableProxy(node->class_variable_proxy()); | |
251 } | |
252 for (int i = 0; i < node->properties()->length(); i++) { | |
253 VisitObjectLiteralProperty(node->properties()->at(i)); | |
254 } | |
255 } | |
256 | |
257 | |
258 void AstLiteralReindexer::VisitObjectLiteral(ObjectLiteral* node) { | |
259 UpdateIndex(node); | |
260 for (int i = 0; i < node->properties()->length(); i++) { | |
261 VisitObjectLiteralProperty(node->properties()->at(i)); | |
262 } | |
263 } | |
264 | |
265 | |
266 void AstLiteralReindexer::VisitObjectLiteralProperty( | |
267 ObjectLiteralProperty* node) { | |
268 Visit(node->key()); | |
269 Visit(node->value()); | |
270 } | |
271 | |
272 | |
273 void AstLiteralReindexer::VisitArrayLiteral(ArrayLiteral* node) { | |
274 UpdateIndex(node); | |
275 for (int i = 0; i < node->values()->length(); i++) { | |
276 Visit(node->values()->at(i)); | |
277 } | |
278 } | |
279 | |
280 | |
281 void AstLiteralReindexer::VisitCall(Call* node) { | |
282 Visit(node->expression()); | |
283 VisitArguments(node->arguments()); | |
284 } | |
285 | |
286 | |
287 void AstLiteralReindexer::VisitCallNew(CallNew* node) { | |
288 Visit(node->expression()); | |
289 VisitArguments(node->arguments()); | |
290 } | |
291 | |
292 | |
293 void AstLiteralReindexer::VisitStatements(ZoneList<Statement*>* statements) { | |
294 if (statements == NULL) return; | |
295 for (int i = 0; i < statements->length(); i++) { | |
296 Visit(statements->at(i)); | |
297 } | |
298 } | |
299 | |
300 | |
301 void AstLiteralReindexer::VisitDeclarations( | |
302 ZoneList<Declaration*>* declarations) { | |
303 for (int i = 0; i < declarations->length(); i++) { | |
304 Visit(declarations->at(i)); | |
305 } | |
306 } | |
307 | |
308 | |
309 void AstLiteralReindexer::VisitArguments(ZoneList<Expression*>* arguments) { | |
310 for (int i = 0; i < arguments->length(); i++) { | |
311 Visit(arguments->at(i)); | |
312 } | |
313 } | |
314 | |
315 | |
316 void AstLiteralReindexer::VisitFunctionLiteral(FunctionLiteral* node) { | |
317 // We don't recurse into the declarations or body of the function literal: | |
318 } | |
319 | |
320 | |
321 void AstLiteralReindexer::Reindex(Expression* pattern) { | |
322 pattern->Accept(this); | |
323 } | |
324 } // namespace internal | |
325 } // namespace v8 | |
OLD | NEW |