| OLD | NEW |
| 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 Loading... |
| 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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) { | 228 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 223 VisitExpression(expr); | 229 VisitExpression(expr); |
| 224 } | 230 } |
| 225 | 231 |
| 226 | 232 |
| 227 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) { | 233 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) { |
| 228 VisitExpression(expr); | 234 VisitExpression(expr); |
| 229 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); | 235 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); |
| 230 for (int i = 0; i < props->length(); ++i) { | 236 for (int i = 0; i < props->length(); ++i) { |
| 231 ObjectLiteralProperty* prop = props->at(i); | 237 ObjectLiteralProperty* prop = props->at(i); |
| 238 if (!prop->key()->IsLiteral()) { |
| 239 RECURSE_EXPRESSION(Visit(prop->key())); |
| 240 } |
| 232 RECURSE_EXPRESSION(Visit(prop->value())); | 241 RECURSE_EXPRESSION(Visit(prop->value())); |
| 233 } | 242 } |
| 234 } | 243 } |
| 235 | 244 |
| 236 | 245 |
| 237 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) { | 246 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) { |
| 238 VisitExpression(expr); | 247 VisitExpression(expr); |
| 239 ZoneList<Expression*>* values = expr->values(); | 248 ZoneList<Expression*>* values = expr->values(); |
| 240 for (int i = 0; i < values->length(); ++i) { | 249 for (int i = 0; i < values->length(); ++i) { |
| 241 Expression* value = values->at(i); | 250 Expression* value = values->at(i); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 | 344 |
| 336 | 345 |
| 337 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) { | 346 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) { |
| 338 for (int i = 0; i < decls->length(); ++i) { | 347 for (int i = 0; i < decls->length(); ++i) { |
| 339 Declaration* decl = decls->at(i); | 348 Declaration* decl = decls->at(i); |
| 340 RECURSE(Visit(decl)); | 349 RECURSE(Visit(decl)); |
| 341 } | 350 } |
| 342 } | 351 } |
| 343 | 352 |
| 344 | 353 |
| 345 void AstExpressionVisitor::VisitClassLiteral(ClassLiteral* expr) {} | 354 void AstExpressionVisitor::VisitClassLiteral(ClassLiteral* expr) { |
| 355 VisitExpression(expr); |
| 356 if (expr->extends() != nullptr) { |
| 357 RECURSE_EXPRESSION(Visit(expr->extends())); |
| 358 } |
| 359 RECURSE_EXPRESSION(Visit(expr->constructor())); |
| 360 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); |
| 361 for (int i = 0; i < props->length(); ++i) { |
| 362 ObjectLiteralProperty* prop = props->at(i); |
| 363 if (!prop->key()->IsLiteral()) { |
| 364 RECURSE_EXPRESSION(Visit(prop->key())); |
| 365 } |
| 366 RECURSE_EXPRESSION(Visit(prop->value())); |
| 367 } |
| 368 } |
| 346 | 369 |
| 347 | 370 |
| 348 void AstExpressionVisitor::VisitSpread(Spread* expr) {} | 371 void AstExpressionVisitor::VisitSpread(Spread* expr) { |
| 372 VisitExpression(expr); |
| 373 RECURSE_EXPRESSION(Visit(expr->expression())); |
| 374 } |
| 349 | 375 |
| 350 | 376 |
| 351 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} | 377 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} |
| 352 | 378 |
| 353 | 379 |
| 354 void AstExpressionVisitor::VisitSuperPropertyReference( | 380 void AstExpressionVisitor::VisitSuperPropertyReference( |
| 355 SuperPropertyReference* expr) {} | 381 SuperPropertyReference* expr) {} |
| 356 | 382 |
| 357 | 383 |
| 358 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} | 384 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} |
| 359 | 385 |
| 360 | 386 |
| 361 } // namespace internal | 387 } // namespace internal |
| 362 } // namespace v8 | 388 } // namespace v8 |
| OLD | NEW |