Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(61)

Unified Diff: src/ast.h

Issue 1272673003: [es6] Re-implement rest parameters via desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase + fix brokenness Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/ast.h
diff --git a/src/ast.h b/src/ast.h
index 7eb73d9023547f9587a95aec5d64d6153c8b2fdb..6eb4f16f3a6d0fd24492f3847311237805060eac 100644
--- a/src/ast.h
+++ b/src/ast.h
@@ -89,7 +89,8 @@ namespace internal {
V(SuperPropertyReference) \
V(SuperCallReference) \
V(CaseClause) \
- V(EmptyParentheses)
+ V(EmptyParentheses) \
+ V(RestParameter)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
@@ -1730,6 +1731,29 @@ class VariableProxy final : public Expression {
};
+class RestParameter final : public Expression {
+ public:
+ DECLARE_NODE_TYPE(RestParameter)
+
+ VariableProxy* parameter() const { return parameter_; }
+ int literal_index() const { return literal_index_; }
+
+ int end_position() const { return parameter_->end_position(); }
+
+ protected:
+ RestParameter(Zone* zone, VariableProxy* parameter, int literal_index,
+ int position)
+ : Expression(zone, position),
+ parameter_(parameter),
+ literal_index_(literal_index) {}
+
+ VariableProxy* parameter_;
+ int literal_index_;
+
+ friend class AstLiteralReindexer;
+};
+
+
// Left-hand side can only be a property, a global or a (parameter or local)
// slot.
enum LhsKind {
@@ -3499,6 +3523,15 @@ class AstNodeFactory final BASE_EMBEDDED {
VariableProxy(zone_, name, variable_kind, start_position, end_position);
}
+ RestParameter* NewRestParameter(VariableProxy* parameter, int literal_index,
+ int position) {
+ DCHECK_NOT_NULL(parameter);
+ DCHECK(literal_index >= 0);
+ DCHECK(position >= 0);
+
+ return new (zone_) RestParameter(zone_, parameter, literal_index, position);
+ }
+
Property* NewProperty(Expression* obj, Expression* key, int pos) {
return new (zone_) Property(zone_, obj, key, pos);
}

Powered by Google App Engine
This is Rietveld 408576698