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/ast-literal-reindexer.h" | |
6 | |
7 #include "src/ast/ast.h" | |
8 #include "src/ast/scopes.h" | |
9 #include "src/objects-inl.h" | |
10 | |
11 namespace v8 { | |
12 namespace internal { | |
13 | |
14 | |
15 void AstLiteralReindexer::VisitVariableDeclaration(VariableDeclaration* node) { | |
16 VisitVariableProxy(node->proxy()); | |
17 } | |
18 | |
19 | |
20 void AstLiteralReindexer::VisitEmptyStatement(EmptyStatement* node) {} | |
21 | |
22 | |
23 void AstLiteralReindexer::VisitSloppyBlockFunctionStatement( | |
24 SloppyBlockFunctionStatement* node) { | |
25 Visit(node->statement()); | |
26 } | |
27 | |
28 | |
29 void AstLiteralReindexer::VisitContinueStatement(ContinueStatement* node) {} | |
30 | |
31 | |
32 void AstLiteralReindexer::VisitBreakStatement(BreakStatement* node) {} | |
33 | |
34 | |
35 void AstLiteralReindexer::VisitDebuggerStatement(DebuggerStatement* node) {} | |
36 | |
37 | |
38 void AstLiteralReindexer::VisitNativeFunctionLiteral( | |
39 NativeFunctionLiteral* node) {} | |
40 | |
41 | |
42 void AstLiteralReindexer::VisitDoExpression(DoExpression* node) { | |
43 Visit(node->block()); | |
44 Visit(node->result()); | |
45 } | |
46 | |
47 | |
48 void AstLiteralReindexer::VisitLiteral(Literal* node) {} | |
49 | |
50 | |
51 void AstLiteralReindexer::VisitRegExpLiteral(RegExpLiteral* node) { | |
52 UpdateIndex(node); | |
53 } | |
54 | |
55 | |
56 void AstLiteralReindexer::VisitVariableProxy(VariableProxy* node) {} | |
57 | |
58 | |
59 void AstLiteralReindexer::VisitThisFunction(ThisFunction* node) {} | |
60 | |
61 | |
62 void AstLiteralReindexer::VisitSuperPropertyReference( | |
63 SuperPropertyReference* node) { | |
64 Visit(node->this_var()); | |
65 Visit(node->home_object()); | |
66 } | |
67 | |
68 | |
69 void AstLiteralReindexer::VisitSuperCallReference(SuperCallReference* node) { | |
70 Visit(node->this_var()); | |
71 Visit(node->new_target_var()); | |
72 Visit(node->this_function_var()); | |
73 } | |
74 | |
75 | |
76 void AstLiteralReindexer::VisitRewritableExpression( | |
77 RewritableExpression* node) { | |
78 Visit(node->expression()); | |
79 } | |
80 | |
81 | |
82 void AstLiteralReindexer::VisitExpressionStatement(ExpressionStatement* node) { | |
83 Visit(node->expression()); | |
84 } | |
85 | |
86 | |
87 void AstLiteralReindexer::VisitReturnStatement(ReturnStatement* node) { | |
88 Visit(node->expression()); | |
89 } | |
90 | |
91 | |
92 void AstLiteralReindexer::VisitYield(Yield* node) { | |
93 Visit(node->generator_object()); | |
94 Visit(node->expression()); | |
95 } | |
96 | |
97 | |
98 void AstLiteralReindexer::VisitThrow(Throw* node) { Visit(node->exception()); } | |
99 | |
100 | |
101 void AstLiteralReindexer::VisitUnaryOperation(UnaryOperation* node) { | |
102 Visit(node->expression()); | |
103 } | |
104 | |
105 | |
106 void AstLiteralReindexer::VisitCountOperation(CountOperation* node) { | |
107 Visit(node->expression()); | |
108 } | |
109 | |
110 | |
111 void AstLiteralReindexer::VisitBlock(Block* node) { | |
112 VisitStatements(node->statements()); | |
113 } | |
114 | |
115 | |
116 void AstLiteralReindexer::VisitFunctionDeclaration(FunctionDeclaration* node) { | |
117 VisitVariableProxy(node->proxy()); | |
118 VisitFunctionLiteral(node->fun()); | |
119 } | |
120 | |
121 | |
122 void AstLiteralReindexer::VisitCallRuntime(CallRuntime* node) { | |
123 VisitArguments(node->arguments()); | |
124 } | |
125 | |
126 | |
127 void AstLiteralReindexer::VisitWithStatement(WithStatement* node) { | |
128 Visit(node->expression()); | |
129 Visit(node->statement()); | |
130 } | |
131 | |
132 | |
133 void AstLiteralReindexer::VisitDoWhileStatement(DoWhileStatement* node) { | |
134 Visit(node->body()); | |
135 Visit(node->cond()); | |
136 } | |
137 | |
138 | |
139 void AstLiteralReindexer::VisitWhileStatement(WhileStatement* node) { | |
140 Visit(node->cond()); | |
141 Visit(node->body()); | |
142 } | |
143 | |
144 | |
145 void AstLiteralReindexer::VisitTryCatchStatement(TryCatchStatement* node) { | |
146 Visit(node->try_block()); | |
147 Visit(node->catch_block()); | |
148 } | |
149 | |
150 | |
151 void AstLiteralReindexer::VisitTryFinallyStatement(TryFinallyStatement* node) { | |
152 Visit(node->try_block()); | |
153 Visit(node->finally_block()); | |
154 } | |
155 | |
156 | |
157 void AstLiteralReindexer::VisitProperty(Property* node) { | |
158 Visit(node->key()); | |
159 Visit(node->obj()); | |
160 } | |
161 | |
162 | |
163 void AstLiteralReindexer::VisitAssignment(Assignment* node) { | |
164 Visit(node->target()); | |
165 Visit(node->value()); | |
166 } | |
167 | |
168 | |
169 void AstLiteralReindexer::VisitBinaryOperation(BinaryOperation* node) { | |
170 Visit(node->left()); | |
171 Visit(node->right()); | |
172 } | |
173 | |
174 | |
175 void AstLiteralReindexer::VisitCompareOperation(CompareOperation* node) { | |
176 Visit(node->left()); | |
177 Visit(node->right()); | |
178 } | |
179 | |
180 | |
181 void AstLiteralReindexer::VisitSpread(Spread* node) { | |
182 // This is reachable because ParserBase::ParseArrowFunctionLiteral calls | |
183 // ReindexLiterals before calling RewriteDestructuringAssignments. | |
184 Visit(node->expression()); | |
185 } | |
186 | |
187 | |
188 void AstLiteralReindexer::VisitEmptyParentheses(EmptyParentheses* node) {} | |
189 | |
190 void AstLiteralReindexer::VisitGetIterator(GetIterator* node) { | |
191 Visit(node->iterable()); | |
192 } | |
193 | |
194 void AstLiteralReindexer::VisitForInStatement(ForInStatement* node) { | |
195 Visit(node->each()); | |
196 Visit(node->enumerable()); | |
197 Visit(node->body()); | |
198 } | |
199 | |
200 | |
201 void AstLiteralReindexer::VisitForOfStatement(ForOfStatement* node) { | |
202 Visit(node->assign_iterator()); | |
203 Visit(node->next_result()); | |
204 Visit(node->result_done()); | |
205 Visit(node->assign_each()); | |
206 Visit(node->body()); | |
207 } | |
208 | |
209 | |
210 void AstLiteralReindexer::VisitConditional(Conditional* node) { | |
211 Visit(node->condition()); | |
212 Visit(node->then_expression()); | |
213 Visit(node->else_expression()); | |
214 } | |
215 | |
216 | |
217 void AstLiteralReindexer::VisitIfStatement(IfStatement* node) { | |
218 Visit(node->condition()); | |
219 Visit(node->then_statement()); | |
220 if (node->HasElseStatement()) { | |
221 Visit(node->else_statement()); | |
222 } | |
223 } | |
224 | |
225 | |
226 void AstLiteralReindexer::VisitSwitchStatement(SwitchStatement* node) { | |
227 Visit(node->tag()); | |
228 ZoneList<CaseClause*>* cases = node->cases(); | |
229 for (int i = 0; i < cases->length(); i++) { | |
230 VisitCaseClause(cases->at(i)); | |
231 } | |
232 } | |
233 | |
234 | |
235 void AstLiteralReindexer::VisitCaseClause(CaseClause* node) { | |
236 if (!node->is_default()) Visit(node->label()); | |
237 VisitStatements(node->statements()); | |
238 } | |
239 | |
240 | |
241 void AstLiteralReindexer::VisitForStatement(ForStatement* node) { | |
242 if (node->init() != NULL) Visit(node->init()); | |
243 if (node->cond() != NULL) Visit(node->cond()); | |
244 if (node->next() != NULL) Visit(node->next()); | |
245 Visit(node->body()); | |
246 } | |
247 | |
248 | |
249 void AstLiteralReindexer::VisitClassLiteral(ClassLiteral* node) { | |
250 if (node->extends()) Visit(node->extends()); | |
251 if (node->constructor()) Visit(node->constructor()); | |
252 if (node->class_variable_proxy()) { | |
253 VisitVariableProxy(node->class_variable_proxy()); | |
254 } | |
255 for (int i = 0; i < node->properties()->length(); i++) { | |
256 VisitLiteralProperty(node->properties()->at(i)); | |
257 } | |
258 } | |
259 | |
260 void AstLiteralReindexer::VisitObjectLiteral(ObjectLiteral* node) { | |
261 UpdateIndex(node); | |
262 for (int i = 0; i < node->properties()->length(); i++) { | |
263 VisitLiteralProperty(node->properties()->at(i)); | |
264 } | |
265 } | |
266 | |
267 void AstLiteralReindexer::VisitLiteralProperty(LiteralProperty* 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 void AstLiteralReindexer::Reindex(Expression* pattern) { Visit(pattern); } | |
321 } // namespace internal | |
322 } // namespace v8 | |
OLD | NEW |