OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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-numbering.h" | 5 #include "src/ast/ast-numbering.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 19 matching lines...) Expand all Loading... |
30 // AST node visitor interface. | 30 // AST node visitor interface. |
31 #define DEFINE_VISIT(type) void Visit##type(type* node); | 31 #define DEFINE_VISIT(type) void Visit##type(type* node); |
32 AST_NODE_LIST(DEFINE_VISIT) | 32 AST_NODE_LIST(DEFINE_VISIT) |
33 #undef DEFINE_VISIT | 33 #undef DEFINE_VISIT |
34 | 34 |
35 void VisitVariableProxyReference(VariableProxy* node); | 35 void VisitVariableProxyReference(VariableProxy* node); |
36 void VisitPropertyReference(Property* node); | 36 void VisitPropertyReference(Property* node); |
37 void VisitReference(Expression* expr); | 37 void VisitReference(Expression* expr); |
38 | 38 |
39 void VisitStatements(ZoneList<Statement*>* statements); | 39 void VisitStatements(ZoneList<Statement*>* statements); |
40 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 40 void VisitDeclarations(Declaration::List* declarations); |
41 void VisitArguments(ZoneList<Expression*>* arguments); | 41 void VisitArguments(ZoneList<Expression*>* arguments); |
42 void VisitLiteralProperty(LiteralProperty* property); | 42 void VisitLiteralProperty(LiteralProperty* property); |
43 | 43 |
44 int ReserveIdRange(int n) { | 44 int ReserveIdRange(int n) { |
45 int tmp = next_id_; | 45 int tmp = next_id_; |
46 next_id_ += n; | 46 next_id_ += n; |
47 return tmp; | 47 return tmp; |
48 } | 48 } |
49 | 49 |
50 void IncrementNodeCount() { properties_.add_node_count(1); } | 50 void IncrementNodeCount() { properties_.add_node_count(1); } |
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 540 } |
541 | 541 |
542 | 542 |
543 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { | 543 void AstNumberingVisitor::VisitStatements(ZoneList<Statement*>* statements) { |
544 if (statements == NULL) return; | 544 if (statements == NULL) return; |
545 for (int i = 0; i < statements->length(); i++) { | 545 for (int i = 0; i < statements->length(); i++) { |
546 Visit(statements->at(i)); | 546 Visit(statements->at(i)); |
547 } | 547 } |
548 } | 548 } |
549 | 549 |
550 | 550 void AstNumberingVisitor::VisitDeclarations(Declaration::List* decls) { |
551 void AstNumberingVisitor::VisitDeclarations( | 551 for (Declaration* decl : *decls) Visit(decl); |
552 ZoneList<Declaration*>* declarations) { | |
553 for (int i = 0; i < declarations->length(); i++) { | |
554 Visit(declarations->at(i)); | |
555 } | |
556 } | 552 } |
557 | 553 |
558 | 554 |
559 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { | 555 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { |
560 for (int i = 0; i < arguments->length(); i++) { | 556 for (int i = 0; i < arguments->length(); i++) { |
561 Visit(arguments->at(i)); | 557 Visit(arguments->at(i)); |
562 } | 558 } |
563 } | 559 } |
564 | 560 |
565 | 561 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
609 } | 605 } |
610 | 606 |
611 | 607 |
612 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 608 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
613 FunctionLiteral* function) { | 609 FunctionLiteral* function) { |
614 AstNumberingVisitor visitor(isolate, zone); | 610 AstNumberingVisitor visitor(isolate, zone); |
615 return visitor.Renumber(function); | 611 return visitor.Renumber(function); |
616 } | 612 } |
617 } // namespace internal | 613 } // namespace internal |
618 } // namespace v8 | 614 } // namespace v8 |
OLD | NEW |