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, |