| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/ast-numbering.h" | 8 #include "src/ast-numbering.h" |
| 9 #include "src/compiler.h" | 9 #include "src/compiler.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 | 15 |
| 16 class AstNumberingVisitor FINAL : public AstVisitor { | 16 class AstNumberingVisitor FINAL : public AstVisitor { |
| 17 public: | 17 public: |
| 18 explicit AstNumberingVisitor(Zone* zone) | 18 explicit AstNumberingVisitor(Zone* zone) |
| 19 : AstVisitor(), next_id_(BailoutId::FirstUsable().ToInt()) { | 19 : AstVisitor(), next_id_(BailoutId::FirstUsable().ToInt()) { |
| 20 InitializeAstVisitor(zone); | 20 InitializeAstVisitor(zone); |
| 21 } | 21 } |
| 22 | 22 |
| 23 void Renumber(FunctionLiteral* node); | 23 void Renumber(FunctionLiteral* node); |
| 24 | 24 |
| 25 private: | 25 private: |
| 26 // AST node visitor interface. | 26 // AST node visitor interface. |
| 27 #define DEFINE_VISIT(type) virtual void Visit##type(type* node); | 27 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) OVERRIDE; |
| 28 AST_NODE_LIST(DEFINE_VISIT) | 28 AST_NODE_LIST(DEFINE_VISIT) |
| 29 #undef DEFINE_VISIT | 29 #undef DEFINE_VISIT |
| 30 | 30 |
| 31 void VisitStatements(ZoneList<Statement*>* statements); | 31 void VisitStatements(ZoneList<Statement*>* statements) OVERRIDE; |
| 32 void VisitDeclarations(ZoneList<Declaration*>* declarations); | 32 void VisitDeclarations(ZoneList<Declaration*>* declarations) OVERRIDE; |
| 33 void VisitArguments(ZoneList<Expression*>* arguments); | 33 void VisitArguments(ZoneList<Expression*>* arguments); |
| 34 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 34 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
| 35 | 35 |
| 36 int ReserveIdRange(int n) { | 36 int ReserveIdRange(int n) { |
| 37 int tmp = next_id_; | 37 int tmp = next_id_; |
| 38 next_id_ += n; | 38 next_id_ += n; |
| 39 return tmp; | 39 return tmp; |
| 40 } | 40 } |
| 41 | 41 |
| 42 void IncrementNodeCount() { properties_.add_node_count(1); } | 42 void IncrementNodeCount() { properties_.add_node_count(1); } |
| (...skipping 427 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 470 } | 470 } |
| 471 | 471 |
| 472 | 472 |
| 473 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { | 473 bool AstNumbering::Renumber(FunctionLiteral* function, Zone* zone) { |
| 474 AstNumberingVisitor visitor(zone); | 474 AstNumberingVisitor visitor(zone); |
| 475 visitor.Renumber(function); | 475 visitor.Renumber(function); |
| 476 return !visitor.HasStackOverflow(); | 476 return !visitor.HasStackOverflow(); |
| 477 } | 477 } |
| 478 } | 478 } |
| 479 } // namespace v8::internal | 479 } // namespace v8::internal |
| OLD | NEW |