v8/src/ast-literal-reindexer.h
caitpotter88 510baeacba [es6] Re-implement rest parameters via desugaring.
Kills the kRestParameter bailout/disabled optimization, and fixes
lazily parsed arrow functions with rest parameters.

Supercedes https://crrev.com/1235153006/

BUG=chromium:508074, v8:2160, v8:2700
LOG=N
R=rossberg@chromium.org, adamk@chromium.org, wingo@igalia.com

Review URL: https://codereview.chromium.org/1272673003

Cr-Commit-Position: refs/heads/master@{#30550}
2015-09-02 21:11:05 +00:00

46 lines
1.2 KiB
C++

// 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/ast.h"
#include "src/scopes.h"
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);
int NextIndex() { return next_index_++; }
private:
#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); }
int next_index_;
DISALLOW_COPY_AND_ASSIGN(AstLiteralReindexer);
};
}
} // namespace v8::internal
#endif // V8_AST_LITERAL_REINDEXER