| OLD | NEW |
| 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 V(Block) \ | 57 V(Block) \ |
| 58 V(ExpressionStatement) \ | 58 V(ExpressionStatement) \ |
| 59 V(EmptyStatement) \ | 59 V(EmptyStatement) \ |
| 60 V(IfStatement) \ | 60 V(IfStatement) \ |
| 61 V(ContinueStatement) \ | 61 V(ContinueStatement) \ |
| 62 V(BreakStatement) \ | 62 V(BreakStatement) \ |
| 63 V(ReturnStatement) \ | 63 V(ReturnStatement) \ |
| 64 V(WithEnterStatement) \ | 64 V(WithEnterStatement) \ |
| 65 V(WithExitStatement) \ | 65 V(WithExitStatement) \ |
| 66 V(SwitchStatement) \ | 66 V(SwitchStatement) \ |
| 67 V(LoopStatement) \ | 67 V(DoWhileStatement) \ |
| 68 V(WhileStatement) \ |
| 69 V(ForStatement) \ |
| 68 V(ForInStatement) \ | 70 V(ForInStatement) \ |
| 69 V(TryCatch) \ | 71 V(TryCatchStatement) \ |
| 70 V(TryFinally) \ | 72 V(TryFinallyStatement) \ |
| 71 V(DebuggerStatement) | 73 V(DebuggerStatement) |
| 72 | 74 |
| 73 #define EXPRESSION_NODE_LIST(V) \ | 75 #define EXPRESSION_NODE_LIST(V) \ |
| 74 V(FunctionLiteral) \ | 76 V(FunctionLiteral) \ |
| 75 V(FunctionBoilerplateLiteral) \ | 77 V(FunctionBoilerplateLiteral) \ |
| 76 V(Conditional) \ | 78 V(Conditional) \ |
| 77 V(Slot) \ | 79 V(Slot) \ |
| 78 V(VariableProxy) \ | 80 V(VariableProxy) \ |
| 79 V(Literal) \ | 81 V(Literal) \ |
| 80 V(RegExpLiteral) \ | 82 V(RegExpLiteral) \ |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 void Initialize(Statement* body) { | 289 void Initialize(Statement* body) { |
| 288 body_ = body; | 290 body_ = body; |
| 289 } | 291 } |
| 290 | 292 |
| 291 private: | 293 private: |
| 292 Statement* body_; | 294 Statement* body_; |
| 293 BreakTarget continue_target_; | 295 BreakTarget continue_target_; |
| 294 }; | 296 }; |
| 295 | 297 |
| 296 | 298 |
| 297 class LoopStatement: public IterationStatement { | 299 class DoWhileStatement: public IterationStatement { |
| 298 public: | 300 public: |
| 299 enum Type { DO_LOOP, FOR_LOOP, WHILE_LOOP }; | 301 explicit DoWhileStatement(ZoneStringList* labels) |
| 302 : IterationStatement(labels), cond_(NULL) { |
| 303 } |
| 300 | 304 |
| 301 LoopStatement(ZoneStringList* labels, Type type) | 305 void Initialize(Expression* cond, Statement* body) { |
| 306 IterationStatement::Initialize(body); |
| 307 cond_ = cond; |
| 308 } |
| 309 |
| 310 virtual void Accept(AstVisitor* v); |
| 311 |
| 312 Expression* cond() const { return cond_; } |
| 313 |
| 314 private: |
| 315 Expression* cond_; |
| 316 }; |
| 317 |
| 318 |
| 319 class WhileStatement: public IterationStatement { |
| 320 public: |
| 321 explicit WhileStatement(ZoneStringList* labels) |
| 302 : IterationStatement(labels), | 322 : IterationStatement(labels), |
| 303 type_(type), | 323 cond_(NULL), |
| 324 may_have_function_literal_(true) { |
| 325 } |
| 326 |
| 327 void Initialize(Expression* cond, Statement* body) { |
| 328 IterationStatement::Initialize(body); |
| 329 cond_ = cond; |
| 330 } |
| 331 |
| 332 virtual void Accept(AstVisitor* v); |
| 333 |
| 334 Expression* cond() const { return cond_; } |
| 335 bool may_have_function_literal() const { |
| 336 return may_have_function_literal_; |
| 337 } |
| 338 |
| 339 private: |
| 340 Expression* cond_; |
| 341 // True if there is a function literal subexpression in the condition. |
| 342 bool may_have_function_literal_; |
| 343 |
| 344 friend class AstOptimizer; |
| 345 }; |
| 346 |
| 347 |
| 348 class ForStatement: public IterationStatement { |
| 349 public: |
| 350 explicit ForStatement(ZoneStringList* labels) |
| 351 : IterationStatement(labels), |
| 304 init_(NULL), | 352 init_(NULL), |
| 305 cond_(NULL), | 353 cond_(NULL), |
| 306 next_(NULL), | 354 next_(NULL), |
| 307 may_have_function_literal_(true) { | 355 may_have_function_literal_(true) { |
| 308 } | 356 } |
| 309 | 357 |
| 310 void Initialize(Statement* init, | 358 void Initialize(Statement* init, |
| 311 Expression* cond, | 359 Expression* cond, |
| 312 Statement* next, | 360 Statement* next, |
| 313 Statement* body) { | 361 Statement* body) { |
| 314 ASSERT(init == NULL || type_ == FOR_LOOP); | |
| 315 ASSERT(next == NULL || type_ == FOR_LOOP); | |
| 316 IterationStatement::Initialize(body); | 362 IterationStatement::Initialize(body); |
| 317 init_ = init; | 363 init_ = init; |
| 318 cond_ = cond; | 364 cond_ = cond; |
| 319 next_ = next; | 365 next_ = next; |
| 320 } | 366 } |
| 321 | 367 |
| 322 virtual void Accept(AstVisitor* v); | 368 virtual void Accept(AstVisitor* v); |
| 323 | 369 |
| 324 Type type() const { return type_; } | |
| 325 Statement* init() const { return init_; } | 370 Statement* init() const { return init_; } |
| 326 Expression* cond() const { return cond_; } | 371 Expression* cond() const { return cond_; } |
| 327 Statement* next() const { return next_; } | 372 Statement* next() const { return next_; } |
| 328 bool may_have_function_literal() const { | 373 bool may_have_function_literal() const { |
| 329 return may_have_function_literal_; | 374 return may_have_function_literal_; |
| 330 } | 375 } |
| 331 | 376 |
| 332 #ifdef DEBUG | |
| 333 const char* OperatorString() const; | |
| 334 #endif | |
| 335 | |
| 336 private: | 377 private: |
| 337 Type type_; | |
| 338 Statement* init_; | 378 Statement* init_; |
| 339 Expression* cond_; | 379 Expression* cond_; |
| 340 Statement* next_; | 380 Statement* next_; |
| 341 // True if there is a function literal subexpression in the condition. | 381 // True if there is a function literal subexpression in the condition. |
| 342 bool may_have_function_literal_; | 382 bool may_have_function_literal_; |
| 343 | 383 |
| 344 friend class AstOptimizer; | 384 friend class AstOptimizer; |
| 345 }; | 385 }; |
| 346 | 386 |
| 347 | 387 |
| (...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 562 | 602 |
| 563 Block* try_block() const { return try_block_; } | 603 Block* try_block() const { return try_block_; } |
| 564 ZoneList<BreakTarget*>* escaping_targets() const { return escaping_targets_; } | 604 ZoneList<BreakTarget*>* escaping_targets() const { return escaping_targets_; } |
| 565 | 605 |
| 566 private: | 606 private: |
| 567 Block* try_block_; | 607 Block* try_block_; |
| 568 ZoneList<BreakTarget*>* escaping_targets_; | 608 ZoneList<BreakTarget*>* escaping_targets_; |
| 569 }; | 609 }; |
| 570 | 610 |
| 571 | 611 |
| 572 class TryCatch: public TryStatement { | 612 class TryCatchStatement: public TryStatement { |
| 573 public: | 613 public: |
| 574 TryCatch(Block* try_block, Expression* catch_var, Block* catch_block) | 614 TryCatchStatement(Block* try_block, |
| 615 Expression* catch_var, |
| 616 Block* catch_block) |
| 575 : TryStatement(try_block), | 617 : TryStatement(try_block), |
| 576 catch_var_(catch_var), | 618 catch_var_(catch_var), |
| 577 catch_block_(catch_block) { | 619 catch_block_(catch_block) { |
| 578 ASSERT(catch_var->AsVariableProxy() != NULL); | 620 ASSERT(catch_var->AsVariableProxy() != NULL); |
| 579 } | 621 } |
| 580 | 622 |
| 581 virtual void Accept(AstVisitor* v); | 623 virtual void Accept(AstVisitor* v); |
| 582 | 624 |
| 583 Expression* catch_var() const { return catch_var_; } | 625 Expression* catch_var() const { return catch_var_; } |
| 584 Block* catch_block() const { return catch_block_; } | 626 Block* catch_block() const { return catch_block_; } |
| 585 | 627 |
| 586 private: | 628 private: |
| 587 Expression* catch_var_; | 629 Expression* catch_var_; |
| 588 Block* catch_block_; | 630 Block* catch_block_; |
| 589 }; | 631 }; |
| 590 | 632 |
| 591 | 633 |
| 592 class TryFinally: public TryStatement { | 634 class TryFinallyStatement: public TryStatement { |
| 593 public: | 635 public: |
| 594 TryFinally(Block* try_block, Block* finally_block) | 636 TryFinallyStatement(Block* try_block, Block* finally_block) |
| 595 : TryStatement(try_block), | 637 : TryStatement(try_block), |
| 596 finally_block_(finally_block) { } | 638 finally_block_(finally_block) { } |
| 597 | 639 |
| 598 virtual void Accept(AstVisitor* v); | 640 virtual void Accept(AstVisitor* v); |
| 599 | 641 |
| 600 Block* finally_block() const { return finally_block_; } | 642 Block* finally_block() const { return finally_block_; } |
| 601 | 643 |
| 602 private: | 644 private: |
| 603 Block* finally_block_; | 645 Block* finally_block_; |
| 604 }; | 646 }; |
| (...skipping 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1715 #undef DEF_VISIT | 1757 #undef DEF_VISIT |
| 1716 | 1758 |
| 1717 private: | 1759 private: |
| 1718 bool stack_overflow_; | 1760 bool stack_overflow_; |
| 1719 }; | 1761 }; |
| 1720 | 1762 |
| 1721 | 1763 |
| 1722 } } // namespace v8::internal | 1764 } } // namespace v8::internal |
| 1723 | 1765 |
| 1724 #endif // V8_AST_H_ | 1766 #endif // V8_AST_H_ |
| OLD | NEW |