| 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, Expression* root) | 35 AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, |
| 36 FunctionLiteral* root) |
| 36 : root_(root), depth_(0) { | 37 : root_(root), depth_(0) { |
| 37 InitializeAstVisitor(isolate); | 38 InitializeAstVisitor(isolate); |
| 38 } | 39 } |
| 39 | 40 |
| 40 | 41 |
| 41 AstExpressionVisitor::AstExpressionVisitor(uintptr_t stack_limit, | 42 void AstExpressionVisitor::Run() { RECURSE(VisitFunctionLiteral(root_)); } |
| 42 Expression* root) | |
| 43 : root_(root), depth_(0) { | |
| 44 InitializeAstVisitor(stack_limit); | |
| 45 } | |
| 46 | |
| 47 | |
| 48 void AstExpressionVisitor::Run() { RECURSE(Visit(root_)); } | |
| 49 | 43 |
| 50 | 44 |
| 51 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) { | 45 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) { |
| 52 } | 46 } |
| 53 | 47 |
| 54 | 48 |
| 55 void AstExpressionVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) { | 49 void AstExpressionVisitor::VisitFunctionDeclaration(FunctionDeclaration* decl) { |
| 56 RECURSE(Visit(decl->fun())); | 50 RECURSE(Visit(decl->fun())); |
| 57 } | 51 } |
| 58 | 52 |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) { | 216 void AstExpressionVisitor::VisitRegExpLiteral(RegExpLiteral* expr) { |
| 223 VisitExpression(expr); | 217 VisitExpression(expr); |
| 224 } | 218 } |
| 225 | 219 |
| 226 | 220 |
| 227 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) { | 221 void AstExpressionVisitor::VisitObjectLiteral(ObjectLiteral* expr) { |
| 228 VisitExpression(expr); | 222 VisitExpression(expr); |
| 229 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); | 223 ZoneList<ObjectLiteralProperty*>* props = expr->properties(); |
| 230 for (int i = 0; i < props->length(); ++i) { | 224 for (int i = 0; i < props->length(); ++i) { |
| 231 ObjectLiteralProperty* prop = props->at(i); | 225 ObjectLiteralProperty* prop = props->at(i); |
| 232 if (!prop->key()->IsLiteral()) { | |
| 233 RECURSE_EXPRESSION(Visit(prop->key())); | |
| 234 } | |
| 235 RECURSE_EXPRESSION(Visit(prop->value())); | 226 RECURSE_EXPRESSION(Visit(prop->value())); |
| 236 } | 227 } |
| 237 } | 228 } |
| 238 | 229 |
| 239 | 230 |
| 240 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) { | 231 void AstExpressionVisitor::VisitArrayLiteral(ArrayLiteral* expr) { |
| 241 VisitExpression(expr); | 232 VisitExpression(expr); |
| 242 ZoneList<Expression*>* values = expr->values(); | 233 ZoneList<Expression*>* values = expr->values(); |
| 243 for (int i = 0; i < values->length(); ++i) { | 234 for (int i = 0; i < values->length(); ++i) { |
| 244 Expression* value = values->at(i); | 235 Expression* value = values->at(i); |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 329 |
| 339 | 330 |
| 340 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) { | 331 void AstExpressionVisitor::VisitDeclarations(ZoneList<Declaration*>* decls) { |
| 341 for (int i = 0; i < decls->length(); ++i) { | 332 for (int i = 0; i < decls->length(); ++i) { |
| 342 Declaration* decl = decls->at(i); | 333 Declaration* decl = decls->at(i); |
| 343 RECURSE(Visit(decl)); | 334 RECURSE(Visit(decl)); |
| 344 } | 335 } |
| 345 } | 336 } |
| 346 | 337 |
| 347 | 338 |
| 348 void AstExpressionVisitor::VisitClassLiteral(ClassLiteral* expr) { | 339 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 } | |
| 363 | 340 |
| 364 | 341 |
| 365 void AstExpressionVisitor::VisitSpread(Spread* expr) { | 342 void AstExpressionVisitor::VisitSpread(Spread* expr) {} |
| 366 VisitExpression(expr); | |
| 367 RECURSE_EXPRESSION(Visit(expr->expression())); | |
| 368 } | |
| 369 | 343 |
| 370 | 344 |
| 371 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} | 345 void AstExpressionVisitor::VisitEmptyParentheses(EmptyParentheses* expr) {} |
| 372 | 346 |
| 373 | 347 |
| 374 void AstExpressionVisitor::VisitSuperPropertyReference( | 348 void AstExpressionVisitor::VisitSuperPropertyReference( |
| 375 SuperPropertyReference* expr) {} | 349 SuperPropertyReference* expr) {} |
| 376 | 350 |
| 377 | 351 |
| 378 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} | 352 void AstExpressionVisitor::VisitSuperCallReference(SuperCallReference* expr) {} |
| 379 | 353 |
| 380 | 354 |
| 381 } // namespace internal | 355 } // namespace internal |
| 382 } // namespace v8 | 356 } // namespace v8 |
| OLD | NEW |