Chromium Code Reviews| Index: src/ast-literal-reindexer.h |
| diff --git a/src/ast-literal-reindexer.h b/src/ast-literal-reindexer.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..901a8877e7551f22138c5f37e3f1450cc71e1e3a |
| --- /dev/null |
| +++ b/src/ast-literal-reindexer.h |
| @@ -0,0 +1,48 @@ |
| +// Copyright 2015 the V8 project authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef V8_AST_LITERAL_REINDEXER |
| +#define V8_AST_LITERAL_REINDEXER |
| + |
| +#include "src/v8.h" |
| + |
| +#include "src/ast.h" |
| +#include "src/scopes.h" |
| + |
| +#include "src/prettyprinter.h" |
|
adamk
2015/06/26 15:06:37
I don't think you need this include, maybe you wer
Dmitry Lomov (no reviews)
2015/06/26 21:13:13
Done.
|
| + |
| +namespace v8 { |
| +namespace internal { |
| + |
| +class AstLiteralReindexer final : public AstVisitor { |
| + public: |
| + AstLiteralReindexer() : AstVisitor(), next_index_(0) {} |
| + |
| + int count() const { return next_index_; } |
| + void Reindex(Expression* pattern); |
| + |
| + private: |
| + int next_index_; |
|
adamk
2015/06/26 15:06:37
Nit: member variables should come after methods.
Dmitry Lomov (no reviews)
2015/06/26 21:13:13
Done.
|
| + |
| +#define DEFINE_VISIT(type) virtual void Visit##type(type* node) override; |
| + AST_NODE_LIST(DEFINE_VISIT) |
| +#undef DEFINE_VISIT |
| + |
| + void VisitStatements(ZoneList<Statement*>* statements) override; |
| + void VisitDeclarations(ZoneList<Declaration*>* declarations) override; |
| + void VisitArguments(ZoneList<Expression*>* arguments); |
| + void VisitObjectLiteralProperty(ObjectLiteralProperty* property); |
| + |
| + void UpdateIndex(MaterializedLiteral* literal) { |
| + literal->literal_index_ = next_index_++; |
| + } |
| + |
| + void Visit(AstNode* node) override { node->Accept(this); } |
| + |
| + DISALLOW_COPY_AND_ASSIGN(AstLiteralReindexer); |
| +}; |
| +} |
| +} // namespace v8::internal |
| + |
| +#endif // V8_AST_LITERAL_REINDEXER |