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/ast/ast.h" | 5 #include "src/ast/ast.h" |
6 #include "src/ast/ast-expression-rewriter.h" | 6 #include "src/ast/ast-expression-rewriter.h" |
7 | 7 |
8 namespace v8 { | 8 namespace v8 { |
9 namespace internal { | 9 namespace internal { |
10 | 10 |
11 // ---------------------------------------------------------------------------- | 11 // ---------------------------------------------------------------------------- |
12 // Implementation of AstExpressionRewriter | 12 // Implementation of AstExpressionRewriter |
13 // The AST is traversed but no actual rewriting takes place, unless the | 13 // The AST is traversed but no actual rewriting takes place, unless the |
14 // Visit methods are overriden in subclasses. | 14 // Visit methods are overriden in subclasses. |
15 | 15 |
16 #define REWRITE_THIS(node) \ | 16 #define REWRITE_THIS(node) \ |
17 do { \ | 17 do { \ |
18 if (!RewriteExpression(node)) return; \ | 18 if (!RewriteExpression(node)) return; \ |
19 } while (false) | 19 } while (false) |
20 #define NOTHING() DCHECK_NULL(replacement_) | 20 #define NOTHING() DCHECK_NULL(replacement_) |
21 | 21 |
22 | 22 void AstExpressionRewriter::VisitDeclarations(Declaration::List* declarations) { |
23 void AstExpressionRewriter::VisitDeclarations( | 23 for (Declaration::List::Iterator it = declarations->begin(); |
24 ZoneList<Declaration*>* declarations) { | 24 it != declarations->end(); ++it) { |
25 for (int i = 0; i < declarations->length(); i++) { | 25 AST_REWRITE(Declaration, *it, it = replacement); |
26 AST_REWRITE_LIST_ELEMENT(Declaration, declarations, i); | |
27 } | 26 } |
28 } | 27 } |
29 | 28 |
30 | 29 |
31 void AstExpressionRewriter::VisitStatements(ZoneList<Statement*>* statements) { | 30 void AstExpressionRewriter::VisitStatements(ZoneList<Statement*>* statements) { |
32 for (int i = 0; i < statements->length(); i++) { | 31 for (int i = 0; i < statements->length(); i++) { |
33 AST_REWRITE_LIST_ELEMENT(Statement, statements, i); | 32 AST_REWRITE_LIST_ELEMENT(Statement, statements, i); |
34 // Not stopping when a jump statement is found. | 33 // Not stopping when a jump statement is found. |
35 } | 34 } |
36 } | 35 } |
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 | 382 |
384 void AstExpressionRewriter::VisitRewritableExpression( | 383 void AstExpressionRewriter::VisitRewritableExpression( |
385 RewritableExpression* node) { | 384 RewritableExpression* node) { |
386 REWRITE_THIS(node); | 385 REWRITE_THIS(node); |
387 AST_REWRITE(Expression, node->expression(), node->Rewrite(replacement)); | 386 AST_REWRITE(Expression, node->expression(), node->Rewrite(replacement)); |
388 } | 387 } |
389 | 388 |
390 | 389 |
391 } // namespace internal | 390 } // namespace internal |
392 } // namespace v8 | 391 } // namespace v8 |
OLD | NEW |