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

Side by Side Diff: src/ast-expression-visitor.cc

Issue 1405313002: [es6] Fix scoping for default parameters in arrow functions (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix class literal handling Created 5 years, 2 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
« no previous file with comments | « src/ast-expression-visitor.h ('k') | src/parameter-initializer-rewriter.h » ('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 2015 the V8 project authors. All rights reserved. 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 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/ast-expression-visitor.h" 7 #include "src/ast-expression-visitor.h"
8 8
9 #include "src/ast.h" 9 #include "src/ast.h"
10 #include "src/codegen.h" 10 #include "src/codegen.h"
(...skipping 14 matching lines...) Expand all
25 #define RECURSE_EXPRESSION(call) \ 25 #define RECURSE_EXPRESSION(call) \
26 do { \ 26 do { \
27 DCHECK(!HasStackOverflow()); \ 27 DCHECK(!HasStackOverflow()); \
28 ++depth_; \ 28 ++depth_; \
29 call; \ 29 call; \
30 --depth_; \ 30 --depth_; \
31 if (HasStackOverflow()) return; \ 31 if (HasStackOverflow()) return; \
32 } while (false) 32 } while (false)
33 33
34 34
35 AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, 35 AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, Expression* root)
36 FunctionLiteral* root)
37 : root_(root), depth_(0) { 36 : root_(root), depth_(0) {
38 InitializeAstVisitor(isolate); 37 InitializeAstVisitor(isolate);
39 } 38 }
40 39
41 40
42 void AstExpressionVisitor::Run() { RECURSE(VisitFunctionLiteral(root_)); } 41 AstExpressionVisitor::AstExpressionVisitor(uintptr_t stack_limit,
42 Expression* root)
43 : root_(root), depth_(0) {
44 InitializeAstVisitor(stack_limit);
45 }
46
47
48 void AstExpressionVisitor::Run() { RECURSE(Visit(root_)); }
43 49
44 50
45 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) { 51 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) {
46 } 52 }
47 53
48 54
49 void AstExpressionVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) { 55 void AstExpressionVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) {
50 RECURSE(Visit(decl->fun())); 56 RECURSE(Visit(decl->fun()));
51 } 57 }
52 58
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) { 222 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) {
217 VisitExpression(expr); 223 VisitExpression(expr);
218 } 224 }
219 225
220 226
221 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) { 227 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) {
222 VisitExpression(expr); 228 VisitExpression(expr);
223 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); 229 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
224 for (int i = 0; i < props->length(); ++i) { 230 for (int i = 0; i < props->length(); ++i) {
225 ObjectLiteralProperty* prop = props->at(i); 231 ObjectLiteralProperty* prop = props->at(i);
232 if (!prop->key()->IsLiteral()) {
233 RECURSE_EXPRESSION(Visit(prop->key()));
234 }
226 RECURSE_EXPRESSION(Visit(prop->value())); 235 RECURSE_EXPRESSION(Visit(prop->value()));
227 } 236 }
228 } 237 }
229 238
230 239
231 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) { 240 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) {
232 VisitExpression(expr); 241 VisitExpression(expr);
233 ZoneList<Expression*>* values = expr->values(); 242 ZoneList<Expression*>* values = expr->values();
234 for (int i = 0; i < values->length(); ++i) { 243 for (int i = 0; i < values->length(); ++i) {
235 Expression* value = values->at(i); 244 Expression* value = values->at(i);
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
329 338
330 339
331 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) { 340 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) {
332 for (int i = 0; i < decls->length(); ++i) { 341 for (int i = 0; i < decls->length(); ++i) {
333 Declaration* decl = decls->at(i); 342 Declaration* decl = decls->at(i);
334 RECURSE(Visit(decl)); 343 RECURSE(Visit(decl));
335 } 344 }
336 } 345 }
337 346
338 347
339 void AstExpressionVisitor::VisitClassLiteral(ClassLiteral* expr) {} 348 void AstExpressionVisitor::VisitClassLiteral(ClassLiteral* expr) {
349 VisitExpression(expr);
350 if (expr->extends() != nullptr) {
351 RECURSE_EXPRESSION(Visit(expr->extends()));
352 }
353 RECURSE_EXPRESSION(Visit(expr->constructor()));
354 ZoneList<ObjectLiteralProperty*>* props = expr->properties();
355 for (int i = 0; i < props->length(); ++i) {
356 ObjectLiteralProperty* prop = props->at(i);
357 if (!prop->key()->IsLiteral()) {
358 RECURSE_EXPRESSION(Visit(prop->key()));
359 }
360 RECURSE_EXPRESSION(Visit(prop->value()));
361 }
362 }
340 363
341 364
342 void AstExpressionVisitor::VisitSpread(Spread* expr) {} 365 void AstExpressionVisitor::VisitSpread(Spread* expr) {
366 VisitExpression(expr);
367 RECURSE_EXPRESSION(Visit(expr->expression()));
368 }
343 369
344 370
345 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} 371 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {}
346 372
347 373
348 void AstExpressionVisitor::VisitSuperPropertyReference( 374 void AstExpressionVisitor::VisitSuperPropertyReference(
349 SuperPropertyReference* expr) {} 375 SuperPropertyReference* expr) {}
350 376
351 377
352 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} 378 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {}
353 379
354 380
355 } // namespace internal 381 } // namespace internal
356 } // namespace v8 382 } // namespace v8
OLDNEW
« no previous file with comments | « src/ast-expression-visitor.h ('k') | src/parameter-initializer-rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698