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

Unified Diff: src/ast/ast.h

Issue 1309813007: [es6] implement destructuring assignment (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Remove facilities for rewriting the expression multiple ways Created 5 years 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
« no previous file with comments | « no previous file | src/ast/ast-expression-visitor.cc » ('j') | src/flag-definitions.h » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/ast/ast.h
diff --git a/src/ast/ast.h b/src/ast/ast.h
index 1c053ddf076ac166903b3e4d7ec2fa8dbef43ab2..d3652d04e5150421a811640326745e9f8042afb8 100644
--- a/src/ast/ast.h
+++ b/src/ast/ast.h
@@ -91,7 +91,8 @@ namespace internal {
V(SuperCallReference) \
V(CaseClause) \
V(EmptyParentheses) \
- V(DoExpression)
+ V(DoExpression) \
+ V(RewritableExpression)
#define AST_NODE_LIST(V) \
DECLARATION_NODE_LIST(V) \
@@ -402,6 +403,36 @@ class Expression : public AstNode {
};
+class RewritableExpression : public Expression {
adamk 2015/12/02 01:51:36 This got lost in the back-and-forth, but now that
+ public:
+ DECLARE_NODE_TYPE(RewritableExpression)
+
+ Expression* expression() { return expr_; }
+ bool is_rewritten() const { return is_rewritten_; }
+
+ void Rewrite(Expression* new_expression) {
+ DCHECK(!is_rewritten());
+ DCHECK_NOT_NULL(new_expression);
+ expr_ = new_expression;
+ is_rewritten_ = true;
+ }
+
+ static int num_ids() { return parent_num_ids(); }
+
+ protected:
+ RewritableExpression(Zone* zone, Expression* expression)
+ : Expression(zone, expression->position()),
+ is_rewritten_(false),
+ expr_(expression) {}
+
+ private:
+ int local_id(int n) const { return base_id() + parent_num_ids() + n; }
+
+ bool is_rewritten_;
+ Expression* expr_;
+};
+
+
class BreakableStatement : public Statement {
public:
enum BreakableType {
@@ -2333,6 +2364,7 @@ class Assignment final : public Expression {
Token::Value op() const { return TokenField::decode(bit_field_); }
Expression* target() const { return target_; }
Expression* value() const { return value_; }
+
BinaryOperation* binary_operation() const { return binary_operation_; }
// This check relies on the definition order of token in token.h.
@@ -2380,9 +2412,12 @@ class Assignment final : public Expression {
int local_id(int n) const { return base_id() + parent_num_ids() + n; }
class IsUninitializedField : public BitField16<bool, 0, 1> {};
- class KeyTypeField : public BitField16<IcCheckType, 1, 1> {};
- class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {};
- class TokenField : public BitField16<Token::Value, 5, 8> {};
+ class KeyTypeField
+ : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {};
+ class StoreModeField
+ : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {};
+ class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> {
+ };
// Starts with 16-bit field, which should get packed together with
// Expression's trailing 16-bit field.
@@ -3195,7 +3230,6 @@ class AstVisitor BASE_EMBEDDED {
#undef DEF_VISIT
};
-
#define DEFINE_AST_VISITOR_SUBCLASS_MEMBERS() \
public: \
void Visit(AstNode* node) final { \
@@ -3548,6 +3582,11 @@ class AstNodeFactory final BASE_EMBEDDED {
local_zone_, condition, then_expression, else_expression, position);
}
+ RewritableExpression* NewRewritableExpression(Expression* expression) {
adamk 2015/12/02 01:51:36 And this should take an Assignment*
caitp (gmail) 2015/12/02 02:25:26 complicates things a bit too much --- causes issue
+ DCHECK_NOT_NULL(expression);
+ return new (local_zone_) RewritableExpression(local_zone_, expression);
+ }
+
Assignment* NewAssignment(Token::Value op,
Expression* target,
Expression* value,
« no previous file with comments | « no previous file | src/ast/ast-expression-visitor.cc » ('j') | src/flag-definitions.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698