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
3 // found in the LICENSE file.
5 #ifndef V8_AST_LITERAL_REINDEXER
6 #define V8_AST_LITERAL_REINDEXER
9 #include "src/scopes.h"
14 class AstLiteralReindexer final : public AstVisitor {
16 AstLiteralReindexer() : AstVisitor(), next_index_(0) {}
18 int count() const { return next_index_; }
19 void Reindex(Expression* pattern);
20 int NextIndex() { return next_index_++; }
23 #define DEFINE_VISIT(type) virtual void Visit##type(type* node) override;
24 AST_NODE_LIST(DEFINE_VISIT)
27 void VisitStatements(ZoneList<Statement*>* statements) override;
28 void VisitDeclarations(ZoneList<Declaration*>* declarations) override;
29 void VisitArguments(ZoneList<Expression*>* arguments);
30 void VisitObjectLiteralProperty(ObjectLiteralProperty* property);
32 void UpdateIndex(MaterializedLiteral* literal) {
33 literal->literal_index_ = next_index_++;
36 void Visit(AstNode* node) override { node->Accept(this); }
40 DISALLOW_COPY_AND_ASSIGN(AstLiteralReindexer);
43 } // namespace v8::internal
45 #endif // V8_AST_LITERAL_REINDEXER