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/ast-expression-visitor.h" | 7 #include "src/ast/ast-expression-visitor.h" |
8 | 8 |
9 #include "src/ast/ast.h" | 9 #include "src/ast/ast.h" |
10 #include "src/ast/scopes.h" | 10 #include "src/ast/scopes.h" |
(...skipping 13 matching lines...) Expand all Loading... |
24 | 24 |
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 AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, Expression* root, |
35 AstExpressionVisitor::AstExpressionVisitor(Isolate* isolate, Expression* root) | 35 Mode mode) |
36 : root_(root), depth_(0) { | 36 : root_(root), depth_(0), mode_(mode) { |
37 InitializeAstVisitor(isolate); | 37 InitializeAstVisitor(isolate); |
38 } | 38 } |
39 | 39 |
40 | |
41 AstExpressionVisitor::AstExpressionVisitor(uintptr_t stack_limit, | 40 AstExpressionVisitor::AstExpressionVisitor(uintptr_t stack_limit, |
42 Expression* root) | 41 Expression* root, Mode mode) |
43 : root_(root), depth_(0) { | 42 : root_(root), depth_(0), mode_(mode) { |
44 InitializeAstVisitor(stack_limit); | 43 InitializeAstVisitor(stack_limit); |
45 } | 44 } |
46 | 45 |
47 | 46 |
48 void AstExpressionVisitor::Run() { RECURSE(Visit(root_)); } | 47 void AstExpressionVisitor::Run() { RECURSE(Visit(root_)); } |
49 | 48 |
50 | 49 |
51 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) { | 50 void AstExpressionVisitor::VisitVariableDeclaration(VariableDeclaration* decl) { |
52 } | 51 } |
53 | 52 |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 RECURSE(Visit(stmt->finally_block())); | 190 RECURSE(Visit(stmt->finally_block())); |
192 } | 191 } |
193 | 192 |
194 | 193 |
195 void AstExpressionVisitor::VisitDebuggerStatement(DebuggerStatement* stmt) {} | 194 void AstExpressionVisitor::VisitDebuggerStatement(DebuggerStatement* stmt) {} |
196 | 195 |
197 | 196 |
198 void AstExpressionVisitor::VisitFunctionLiteral(FunctionLiteral* expr) { | 197 void AstExpressionVisitor::VisitFunctionLiteral(FunctionLiteral* expr) { |
199 Scope* scope = expr->scope(); | 198 Scope* scope = expr->scope(); |
200 VisitExpression(expr); | 199 VisitExpression(expr); |
| 200 if (is_shallow()) return; |
201 RECURSE_EXPRESSION(VisitDeclarations(scope->declarations())); | 201 RECURSE_EXPRESSION(VisitDeclarations(scope->declarations())); |
202 RECURSE_EXPRESSION(VisitStatements(expr->body())); | 202 RECURSE_EXPRESSION(VisitStatements(expr->body())); |
203 } | 203 } |
204 | 204 |
205 | 205 |
206 void AstExpressionVisitor::VisitNativeFunctionLiteral( | 206 void AstExpressionVisitor::VisitNativeFunctionLiteral( |
207 NativeFunctionLiteral* expr) {} | 207 NativeFunctionLiteral* expr) {} |
208 | 208 |
209 | 209 |
210 void AstExpressionVisitor::VisitDoExpression(DoExpression* expr) { | 210 void AstExpressionVisitor::VisitDoExpression(DoExpression* expr) { |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
402 | 402 |
403 void AstExpressionVisitor::VisitRewritableExpression( | 403 void AstExpressionVisitor::VisitRewritableExpression( |
404 RewritableExpression* expr) { | 404 RewritableExpression* expr) { |
405 VisitExpression(expr); | 405 VisitExpression(expr); |
406 RECURSE(Visit(expr->expression())); | 406 RECURSE(Visit(expr->expression())); |
407 } | 407 } |
408 | 408 |
409 | 409 |
410 } // namespace internal | 410 } // namespace internal |
411 } // namespace v8 | 411 } // namespace v8 |
OLD | NEW |