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 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class AstNumberingVisitor final : public AstVisitor { | 13 class AstNumberingVisitor final : public AstVisitor<AstNumberingVisitor> { |
14 public: | 14 public: |
15 AstNumberingVisitor(Isolate* isolate, Zone* zone) | 15 AstNumberingVisitor(Isolate* isolate, Zone* zone) |
16 : AstVisitor(), | 16 : isolate_(isolate), |
17 isolate_(isolate), | |
18 zone_(zone), | 17 zone_(zone), |
19 next_id_(BailoutId::FirstUsable().ToInt()), | 18 next_id_(BailoutId::FirstUsable().ToInt()), |
20 yield_count_(0), | 19 yield_count_(0), |
21 properties_(zone), | 20 properties_(zone), |
22 slot_cache_(zone), | 21 slot_cache_(zone), |
23 dont_optimize_reason_(kNoReason), | 22 dont_optimize_reason_(kNoReason), |
24 catch_predicted_(false) { | 23 catch_predicted_(false) { |
25 InitializeAstVisitor(isolate); | 24 InitializeAstVisitor(isolate); |
26 } | 25 } |
27 | 26 |
28 bool Renumber(FunctionLiteral* node); | 27 bool Renumber(FunctionLiteral* node); |
29 | 28 |
30 private: | 29 private: |
31 // AST node visitor interface. | 30 // AST node visitor interface. |
32 #define DEFINE_VISIT(type) void Visit##type(type* node) override; | 31 #define DEFINE_VISIT(type) void Visit##type(type* node); |
33 AST_NODE_LIST(DEFINE_VISIT) | 32 AST_NODE_LIST(DEFINE_VISIT) |
34 #undef DEFINE_VISIT | 33 #undef DEFINE_VISIT |
35 | 34 |
36 void VisitVariableProxyReference(VariableProxy* node); | 35 void VisitVariableProxyReference(VariableProxy* node); |
37 void VisitPropertyReference(Property* node); | 36 void VisitPropertyReference(Property* node); |
38 void VisitReference(Expression* expr); | 37 void VisitReference(Expression* expr); |
39 | 38 |
40 void VisitStatements(ZoneList<Statement*>* statements) override; | 39 void VisitStatements(ZoneList<Statement*>* statements); |
41 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 40 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
42 void VisitArguments(ZoneList<Expression*>* arguments); | 41 void VisitArguments(ZoneList<Expression*>* arguments); |
43 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 42 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
44 | 43 |
45 int ReserveIdRange(int n) { | 44 int ReserveIdRange(int n) { |
46 int tmp = next_id_; | 45 int tmp = next_id_; |
47 next_id_ += n; | 46 next_id_ += n; |
48 return tmp; | 47 return tmp; |
49 } | 48 } |
50 | 49 |
51 void IncrementNodeCount() { properties_.add_node_count(1); } | 50 void IncrementNodeCount() { properties_.add_node_count(1); } |
(...skipping 548 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
600 } | 599 } |
601 | 600 |
602 | 601 |
603 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 602 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
604 FunctionLiteral* function) { | 603 FunctionLiteral* function) { |
605 AstNumberingVisitor visitor(isolate, zone); | 604 AstNumberingVisitor visitor(isolate, zone); |
606 return visitor.Renumber(function); | 605 return visitor.Renumber(function); |
607 } | 606 } |
608 } // namespace internal | 607 } // namespace internal |
609 } // namespace v8 | 608 } // namespace v8 |
OLD | NEW |