| Index: src/ast.h
|
| ===================================================================
|
| --- src/ast.h (revision 4136)
|
| +++ src/ast.h (working copy)
|
| @@ -120,11 +120,15 @@
|
| static const int kNoNumber = -1;
|
|
|
| AstNode() : num_(kNoNumber) {}
|
| +
|
| + explicit AstNode(AstNode* other);
|
| +
|
| virtual ~AstNode() { }
|
| virtual void Accept(AstVisitor* v) = 0;
|
|
|
| // Type testing & conversion.
|
| virtual Statement* AsStatement() { return NULL; }
|
| + virtual Block* AsBlock() { return NULL; }
|
| virtual ExpressionStatement* AsExpressionStatement() { return NULL; }
|
| virtual EmptyStatement* AsEmptyStatement() { return NULL; }
|
| virtual Expression* AsExpression() { return NULL; }
|
| @@ -136,6 +140,7 @@
|
| virtual TargetCollector* AsTargetCollector() { return NULL; }
|
| virtual BreakableStatement* AsBreakableStatement() { return NULL; }
|
| virtual IterationStatement* AsIterationStatement() { return NULL; }
|
| + virtual ForStatement* AsForStatement() { return NULL; }
|
| virtual UnaryOperation* AsUnaryOperation() { return NULL; }
|
| virtual CountOperation* AsCountOperation() { return NULL; }
|
| virtual BinaryOperation* AsBinaryOperation() { return NULL; }
|
| @@ -159,6 +164,8 @@
|
| public:
|
| Statement() : statement_pos_(RelocInfo::kNoPosition) {}
|
|
|
| + explicit Statement(Statement* other);
|
| +
|
| virtual Statement* AsStatement() { return this; }
|
| virtual ReturnStatement* AsReturnStatement() { return NULL; }
|
|
|
| @@ -200,6 +207,8 @@
|
| def_(NULL),
|
| defined_vars_(NULL) {}
|
|
|
| + explicit Expression(Expression* other);
|
| +
|
| virtual Expression* AsExpression() { return this; }
|
|
|
| virtual bool IsValidLeftHandSide() { return false; }
|
| @@ -268,7 +277,6 @@
|
| bitfields_ |= ToInt32Field::encode(to_int32);
|
| }
|
|
|
| -
|
| private:
|
| uint32_t bitfields_;
|
| StaticType type_;
|
| @@ -330,6 +338,8 @@
|
| ASSERT(labels == NULL || labels->length() > 0);
|
| }
|
|
|
| + explicit BreakableStatement(BreakableStatement* other);
|
| +
|
| private:
|
| ZoneStringList* labels_;
|
| Type type_;
|
| @@ -344,8 +354,14 @@
|
| statements_(capacity),
|
| is_initializer_block_(is_initializer_block) { }
|
|
|
| + // Construct a clone initialized from the original block and
|
| + // a deep copy of all statements of the original block.
|
| + Block(Block* other, ZoneList<Statement*>* statements);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| + virtual Block* AsBlock() { return this; }
|
| +
|
| virtual Assignment* StatementAsSimpleAssignment() {
|
| if (statements_.length() != 1) return NULL;
|
| return statements_[0]->StatementAsSimpleAssignment();
|
| @@ -397,6 +413,7 @@
|
| virtual IterationStatement* AsIterationStatement() { return this; }
|
|
|
| Statement* body() const { return body_; }
|
| + void set_body(Statement* stmt) { body_ = stmt; }
|
|
|
| // Code generation
|
| BreakTarget* continue_target() { return &continue_target_; }
|
| @@ -405,6 +422,10 @@
|
| explicit IterationStatement(ZoneStringList* labels)
|
| : BreakableStatement(labels, TARGET_FOR_ANONYMOUS), body_(NULL) { }
|
|
|
| + // Construct a clone initialized from original and
|
| + // a deep copy of the original body.
|
| + IterationStatement(IterationStatement* other, Statement* body);
|
| +
|
| void Initialize(Statement* body) {
|
| body_ = body;
|
| }
|
| @@ -478,8 +499,19 @@
|
| cond_(NULL),
|
| next_(NULL),
|
| may_have_function_literal_(true),
|
| - loop_variable_(NULL) {}
|
| + loop_variable_(NULL),
|
| + peel_this_loop_(false) {}
|
|
|
| + // Construct a for-statement initialized from another for-statement
|
| + // and deep copies of all parts of the original statement.
|
| + ForStatement(ForStatement* other,
|
| + Statement* init,
|
| + Expression* cond,
|
| + Statement* next,
|
| + Statement* body);
|
| +
|
| + virtual ForStatement* AsForStatement() { return this; }
|
| +
|
| void Initialize(Statement* init,
|
| Expression* cond,
|
| Statement* next,
|
| @@ -493,8 +525,11 @@
|
| virtual void Accept(AstVisitor* v);
|
|
|
| Statement* init() const { return init_; }
|
| + void set_init(Statement* stmt) { init_ = stmt; }
|
| Expression* cond() const { return cond_; }
|
| + void set_cond(Expression* expr) { cond_ = expr; }
|
| Statement* next() const { return next_; }
|
| + void set_next(Statement* stmt) { next_ = stmt; }
|
| bool may_have_function_literal() const {
|
| return may_have_function_literal_;
|
| }
|
| @@ -503,6 +538,9 @@
|
| Variable* loop_variable() { return loop_variable_; }
|
| void set_loop_variable(Variable* var) { loop_variable_ = var; }
|
|
|
| + bool peel_this_loop() { return peel_this_loop_; }
|
| + void set_peel_this_loop(bool b) { peel_this_loop_ = b; }
|
| +
|
| private:
|
| Statement* init_;
|
| Expression* cond_;
|
| @@ -510,6 +548,7 @@
|
| // True if there is a function literal subexpression in the condition.
|
| bool may_have_function_literal_;
|
| Variable* loop_variable_;
|
| + bool peel_this_loop_;
|
|
|
| friend class AstOptimizer;
|
| };
|
| @@ -542,6 +581,10 @@
|
| explicit ExpressionStatement(Expression* expression)
|
| : expression_(expression) { }
|
|
|
| + // Construct an expression statement initialized from another
|
| + // expression statement and a deep copy of the original expression.
|
| + ExpressionStatement(ExpressionStatement* other, Expression* expression);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing & conversion.
|
| @@ -684,6 +727,13 @@
|
| then_statement_(then_statement),
|
| else_statement_(else_statement) { }
|
|
|
| + // Construct an if-statement initialized from another if-statement
|
| + // and deep copies of all parts of the original.
|
| + IfStatement(IfStatement* other,
|
| + Expression* condition,
|
| + Statement* then_statement,
|
| + Statement* else_statement);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
|
| @@ -691,7 +741,9 @@
|
|
|
| Expression* condition() const { return condition_; }
|
| Statement* then_statement() const { return then_statement_; }
|
| + void set_then_statement(Statement* stmt) { then_statement_ = stmt; }
|
| Statement* else_statement() const { return else_statement_; }
|
| + void set_else_statement(Statement* stmt) { else_statement_ = stmt; }
|
|
|
| private:
|
| Expression* condition_;
|
| @@ -786,6 +838,10 @@
|
|
|
| class EmptyStatement: public Statement {
|
| public:
|
| + EmptyStatement() {}
|
| +
|
| + explicit EmptyStatement(EmptyStatement* other);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing & conversion.
|
| @@ -1144,6 +1200,8 @@
|
| Property(Expression* obj, Expression* key, int pos, Type type = NORMAL)
|
| : obj_(obj), key_(key), pos_(pos), type_(type) { }
|
|
|
| + Property(Property* other, Expression* obj, Expression* key);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing & conversion
|
| @@ -1178,6 +1236,8 @@
|
| Call(Expression* expression, ZoneList<Expression*>* arguments, int pos)
|
| : expression_(expression), arguments_(arguments), pos_(pos) { }
|
|
|
| + Call(Call* other, Expression* expression, ZoneList<Expression*>* arguments);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing and conversion.
|
| @@ -1254,6 +1314,8 @@
|
| ASSERT(Token::IsUnaryOp(op));
|
| }
|
|
|
| + UnaryOperation(UnaryOperation* other, Expression* expression);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing & conversion
|
| @@ -1277,6 +1339,8 @@
|
| ASSERT(Token::IsBinaryOp(op));
|
| }
|
|
|
| + BinaryOperation(BinaryOperation* other, Expression* left, Expression* right);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| // Type testing & conversion
|
| @@ -1328,6 +1392,8 @@
|
| ASSERT(Token::IsCountOp(op));
|
| }
|
|
|
| + CountOperation(CountOperation* other, Expression* expression);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| virtual CountOperation* AsCountOperation() { return this; }
|
| @@ -1362,6 +1428,10 @@
|
| ASSERT(Token::IsCompareOp(op));
|
| }
|
|
|
| + CompareOperation(CompareOperation* other,
|
| + Expression* left,
|
| + Expression* right);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
|
|
| virtual bool IsPrimitive();
|
| @@ -1417,6 +1487,8 @@
|
| ASSERT(Token::IsAssignmentOp(op));
|
| }
|
|
|
| + Assignment(Assignment* other, Expression* target, Expression* value);
|
| +
|
| virtual void Accept(AstVisitor* v);
|
| virtual Assignment* AsAssignment() { return this; }
|
|
|
| @@ -1992,6 +2064,28 @@
|
| };
|
|
|
|
|
| +class CopyAstVisitor : public AstVisitor {
|
| + public:
|
| + Expression* DeepCopyExpr(Expression* expr);
|
| +
|
| + Statement* DeepCopyStmt(Statement* stmt);
|
| +
|
| + private:
|
| + ZoneList<Expression*>* DeepCopyExprList(ZoneList<Expression*>* expressions);
|
| +
|
| + ZoneList<Statement*>* DeepCopyStmtList(ZoneList<Statement*>* statements);
|
| +
|
| + // AST node visit functions.
|
| +#define DECLARE_VISIT(type) virtual void Visit##type(type* node);
|
| + AST_NODE_LIST(DECLARE_VISIT)
|
| +#undef DECLARE_VISIT
|
| +
|
| + // Holds the result of copying an expression.
|
| + Expression* expr_;
|
| + // Holds the result of copying a statement.
|
| + Statement* stmt_;
|
| +};
|
| +
|
| } } // namespace v8::internal
|
|
|
| #endif // V8_AST_H_
|
|
|