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 InitializeAstVisitor(isolate); | 23 InitializeAstVisitor(isolate); |
25 } | 24 } |
26 | 25 |
27 bool Renumber(FunctionLiteral* node); | 26 bool Renumber(FunctionLiteral* node); |
28 | 27 |
29 private: | 28 private: |
30 // AST node visitor interface. | 29 // AST node visitor interface. |
31 #define DEFINE_VISIT(type) void Visit##type(type* node) override; | 30 #define DEFINE_VISIT(type) void Visit##type(type* node); |
32 AST_NODE_LIST(DEFINE_VISIT) | 31 AST_NODE_LIST(DEFINE_VISIT) |
33 #undef DEFINE_VISIT | 32 #undef DEFINE_VISIT |
34 | 33 |
35 void VisitVariableProxyReference(VariableProxy* node); | 34 void VisitVariableProxyReference(VariableProxy* node); |
36 void VisitPropertyReference(Property* node); | 35 void VisitPropertyReference(Property* node); |
37 void VisitReference(Expression* expr); | 36 void VisitReference(Expression* expr); |
38 | 37 |
39 void VisitStatements(ZoneList<Statement*>* statements) override; | 38 void VisitStatements(ZoneList<Statement*>* statements); |
40 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 39 void VisitDeclarations(ZoneList<Declaration*>* declarations); |
41 void VisitArguments(ZoneList<Expression*>* arguments); | 40 void VisitArguments(ZoneList<Expression*>* arguments); |
42 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 41 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
43 | 42 |
44 int ReserveIdRange(int n) { | 43 int ReserveIdRange(int n) { |
45 int tmp = next_id_; | 44 int tmp = next_id_; |
46 next_id_ += n; | 45 next_id_ += n; |
47 return tmp; | 46 return tmp; |
48 } | 47 } |
49 | 48 |
50 void IncrementNodeCount() { properties_.add_node_count(1); } | 49 void IncrementNodeCount() { properties_.add_node_count(1); } |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
585 } | 584 } |
586 | 585 |
587 | 586 |
588 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, | 587 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, |
589 FunctionLiteral* function) { | 588 FunctionLiteral* function) { |
590 AstNumberingVisitor visitor(isolate, zone); | 589 AstNumberingVisitor visitor(isolate, zone); |
591 return visitor.Renumber(function); | 590 return visitor.Renumber(function); |
592 } | 591 } |
593 } // namespace internal | 592 } // namespace internal |
594 } // namespace v8 | 593 } // namespace v8 |
OLD | NEW |