| 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 #ifndef V8_AST_LITERAL_REINDEXER | 5 #ifndef V8_AST_LITERAL_REINDEXER |
| 6 #define V8_AST_LITERAL_REINDEXER | 6 #define V8_AST_LITERAL_REINDEXER |
| 7 | 7 |
| 8 #include "src/ast.h" | 8 #include "src/ast.h" |
| 9 #include "src/scopes.h" | 9 #include "src/scopes.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 class AstLiteralReindexer final : public AstVisitor { | 14 class AstLiteralReindexer final : public AstVisitor { |
| 15 public: | 15 public: |
| 16 AstLiteralReindexer() : AstVisitor(), next_index_(0) {} | 16 AstLiteralReindexer() : AstVisitor(), next_index_(0) {} |
| 17 | 17 |
| 18 int count() const { return next_index_; } | 18 int count() const { return next_index_; } |
| 19 void Reindex(Expression* pattern); | 19 void Reindex(Expression* pattern); |
| 20 int NextIndex() { return next_index_++; } | 20 int NextIndex() { return next_index_++; } |
| 21 | 21 |
| 22 private: | 22 private: |
| 23 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) override; | 23 #define DEFINE_VISIT(type) void Visit##type(type* node) override; |
| 24 AST_NODE_LIST(DEFINE_VISIT) | 24 AST_NODE_LIST(DEFINE_VISIT) |
| 25 #undef DEFINE_VISIT | 25 #undef DEFINE_VISIT |
| 26 | 26 |
| 27 void VisitStatements(ZoneList<Statement*>* statements) override; | 27 void VisitStatements(ZoneList<Statement*>* statements) override; |
| 28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; | 28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| 29 void VisitArguments(ZoneList<Expression*>* arguments); | 29 void VisitArguments(ZoneList<Expression*>* arguments); |
| 30 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); | 30 void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
| 31 | 31 |
| 32 void UpdateIndex(MaterializedLiteral* literal) { | 32 void UpdateIndex(MaterializedLiteral* literal) { |
| 33 literal->literal_index_ = next_index_++; | 33 literal->literal_index_ = next_index_++; |
| 34 } | 34 } |
| 35 | 35 |
| 36 void Visit(AstNode* node) override { node->Accept(this); } | 36 void Visit(AstNode* node) override { node->Accept(this); } |
| 37 | 37 |
| 38 int next_index_; | 38 int next_index_; |
| 39 | 39 |
| 40 DISALLOW_COPY_AND_ASSIGN(AstLiteralReindexer); | 40 DISALLOW_COPY_AND_ASSIGN(AstLiteralReindexer); |
| 41 }; | 41 }; |
| 42 } // namespace internal | 42 } // namespace internal |
| 43 } // namespace v8 | 43 } // namespace v8 |
| 44 | 44 |
| 45 #endif // V8_AST_LITERAL_REINDEXER | 45 #endif // V8_AST_LITERAL_REINDEXER |
| OLD | NEW |