OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 317 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
328 Label* break_target() { return &break_target_; } | 328 Label* break_target() { return &break_target_; } |
329 | 329 |
330 // Testers. | 330 // Testers. |
331 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } | 331 bool is_target_for_anonymous() const { return type_ == TARGET_FOR_ANONYMOUS; } |
332 | 332 |
333 // Bailout support. | 333 // Bailout support. |
334 int EntryId() const { return entry_id_; } | 334 int EntryId() const { return entry_id_; } |
335 int ExitId() const { return exit_id_; } | 335 int ExitId() const { return exit_id_; } |
336 | 336 |
337 protected: | 337 protected: |
338 BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type); | 338 BreakableStatement(Isolate* isolate, ZoneStringList* labels, Type type) |
| 339 : labels_(labels), |
| 340 type_(type), |
| 341 entry_id_(GetNextId(isolate)), |
| 342 exit_id_(GetNextId(isolate)) { |
| 343 ASSERT(labels == NULL || labels->length() > 0); |
| 344 } |
| 345 |
339 | 346 |
340 private: | 347 private: |
341 ZoneStringList* labels_; | 348 ZoneStringList* labels_; |
342 Type type_; | 349 Type type_; |
343 Label break_target_; | 350 Label break_target_; |
344 int entry_id_; | 351 int entry_id_; |
345 int exit_id_; | 352 int exit_id_; |
346 }; | 353 }; |
347 | 354 |
348 | 355 |
349 class Block: public BreakableStatement { | 356 class Block: public BreakableStatement { |
350 public: | 357 public: |
351 inline Block(Isolate* isolate, | 358 Block(Isolate* isolate, |
352 ZoneStringList* labels, | 359 ZoneStringList* labels, |
353 int capacity, | 360 int capacity, |
354 bool is_initializer_block); | 361 bool is_initializer_block) |
| 362 : BreakableStatement(isolate, labels, TARGET_FOR_NAMED_ONLY), |
| 363 statements_(capacity), |
| 364 is_initializer_block_(is_initializer_block), |
| 365 block_scope_(NULL) { |
| 366 } |
| 367 |
355 | 368 |
356 DECLARE_NODE_TYPE(Block) | 369 DECLARE_NODE_TYPE(Block) |
357 | 370 |
358 virtual bool IsInlineable() const; | 371 virtual bool IsInlineable() const; |
359 | 372 |
360 void AddStatement(Statement* statement) { statements_.Add(statement); } | 373 void AddStatement(Statement* statement) { statements_.Add(statement); } |
361 | 374 |
362 ZoneList<Statement*>* statements() { return &statements_; } | 375 ZoneList<Statement*>* statements() { return &statements_; } |
363 bool is_initializer_block() const { return is_initializer_block_; } | 376 bool is_initializer_block() const { return is_initializer_block_; } |
364 | 377 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 430 |
418 // Bailout support. | 431 // Bailout support. |
419 int OsrEntryId() const { return osr_entry_id_; } | 432 int OsrEntryId() const { return osr_entry_id_; } |
420 virtual int ContinueId() const = 0; | 433 virtual int ContinueId() const = 0; |
421 virtual int StackCheckId() const = 0; | 434 virtual int StackCheckId() const = 0; |
422 | 435 |
423 // Code generation | 436 // Code generation |
424 Label* continue_target() { return &continue_target_; } | 437 Label* continue_target() { return &continue_target_; } |
425 | 438 |
426 protected: | 439 protected: |
427 inline IterationStatement(Isolate* isolate, ZoneStringList* labels); | 440 IterationStatement(Isolate* isolate, ZoneStringList* labels) |
| 441 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), |
| 442 body_(NULL), |
| 443 continue_target_(), |
| 444 osr_entry_id_(GetNextId(isolate)) { |
| 445 } |
428 | 446 |
429 void Initialize(Statement* body) { | 447 void Initialize(Statement* body) { |
430 body_ = body; | 448 body_ = body; |
431 } | 449 } |
432 | 450 |
433 private: | 451 private: |
434 Statement* body_; | 452 Statement* body_; |
435 Label continue_target_; | 453 Label continue_target_; |
436 int osr_entry_id_; | 454 int osr_entry_id_; |
437 }; | 455 }; |
438 | 456 |
439 | 457 |
440 class DoWhileStatement: public IterationStatement { | 458 class DoWhileStatement: public IterationStatement { |
441 public: | 459 public: |
442 inline DoWhileStatement(Isolate* isolate, ZoneStringList* labels); | 460 DoWhileStatement(Isolate* isolate, ZoneStringList* labels) |
| 461 : IterationStatement(isolate, labels), |
| 462 cond_(NULL), |
| 463 condition_position_(-1), |
| 464 continue_id_(GetNextId(isolate)), |
| 465 back_edge_id_(GetNextId(isolate)) { |
| 466 } |
443 | 467 |
444 DECLARE_NODE_TYPE(DoWhileStatement) | 468 DECLARE_NODE_TYPE(DoWhileStatement) |
445 | 469 |
446 void Initialize(Expression* cond, Statement* body) { | 470 void Initialize(Expression* cond, Statement* body) { |
447 IterationStatement::Initialize(body); | 471 IterationStatement::Initialize(body); |
448 cond_ = cond; | 472 cond_ = cond; |
449 } | 473 } |
450 | 474 |
451 Expression* cond() const { return cond_; } | 475 Expression* cond() const { return cond_; } |
452 | 476 |
(...skipping 12 matching lines...) Expand all Loading... |
465 private: | 489 private: |
466 Expression* cond_; | 490 Expression* cond_; |
467 int condition_position_; | 491 int condition_position_; |
468 int continue_id_; | 492 int continue_id_; |
469 int back_edge_id_; | 493 int back_edge_id_; |
470 }; | 494 }; |
471 | 495 |
472 | 496 |
473 class WhileStatement: public IterationStatement { | 497 class WhileStatement: public IterationStatement { |
474 public: | 498 public: |
475 inline WhileStatement(Isolate* isolate, ZoneStringList* labels); | 499 WhileStatement(Isolate* isolate, ZoneStringList* labels) |
| 500 : IterationStatement(isolate, labels), |
| 501 cond_(NULL), |
| 502 may_have_function_literal_(true), |
| 503 body_id_(GetNextId(isolate)) { |
| 504 } |
476 | 505 |
477 DECLARE_NODE_TYPE(WhileStatement) | 506 DECLARE_NODE_TYPE(WhileStatement) |
478 | 507 |
479 void Initialize(Expression* cond, Statement* body) { | 508 void Initialize(Expression* cond, Statement* body) { |
480 IterationStatement::Initialize(body); | 509 IterationStatement::Initialize(body); |
481 cond_ = cond; | 510 cond_ = cond; |
482 } | 511 } |
483 | 512 |
484 Expression* cond() const { return cond_; } | 513 Expression* cond() const { return cond_; } |
485 bool may_have_function_literal() const { | 514 bool may_have_function_literal() const { |
(...skipping 12 matching lines...) Expand all Loading... |
498 private: | 527 private: |
499 Expression* cond_; | 528 Expression* cond_; |
500 // True if there is a function literal subexpression in the condition. | 529 // True if there is a function literal subexpression in the condition. |
501 bool may_have_function_literal_; | 530 bool may_have_function_literal_; |
502 int body_id_; | 531 int body_id_; |
503 }; | 532 }; |
504 | 533 |
505 | 534 |
506 class ForStatement: public IterationStatement { | 535 class ForStatement: public IterationStatement { |
507 public: | 536 public: |
508 inline ForStatement(Isolate* isolate, ZoneStringList* labels); | 537 ForStatement(Isolate* isolate, ZoneStringList* labels) |
| 538 : IterationStatement(isolate, labels), |
| 539 init_(NULL), |
| 540 cond_(NULL), |
| 541 next_(NULL), |
| 542 may_have_function_literal_(true), |
| 543 loop_variable_(NULL), |
| 544 continue_id_(GetNextId(isolate)), |
| 545 body_id_(GetNextId(isolate)) { |
| 546 } |
509 | 547 |
510 DECLARE_NODE_TYPE(ForStatement) | 548 DECLARE_NODE_TYPE(ForStatement) |
511 | 549 |
512 void Initialize(Statement* init, | 550 void Initialize(Statement* init, |
513 Expression* cond, | 551 Expression* cond, |
514 Statement* next, | 552 Statement* next, |
515 Statement* body) { | 553 Statement* body) { |
516 IterationStatement::Initialize(body); | 554 IterationStatement::Initialize(body); |
517 init_ = init; | 555 init_ = init; |
518 cond_ = cond; | 556 cond_ = cond; |
(...skipping 28 matching lines...) Expand all Loading... |
547 // True if there is a function literal subexpression in the condition. | 585 // True if there is a function literal subexpression in the condition. |
548 bool may_have_function_literal_; | 586 bool may_have_function_literal_; |
549 Variable* loop_variable_; | 587 Variable* loop_variable_; |
550 int continue_id_; | 588 int continue_id_; |
551 int body_id_; | 589 int body_id_; |
552 }; | 590 }; |
553 | 591 |
554 | 592 |
555 class ForInStatement: public IterationStatement { | 593 class ForInStatement: public IterationStatement { |
556 public: | 594 public: |
557 inline ForInStatement(Isolate* isolate, ZoneStringList* labels); | 595 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
| 596 : IterationStatement(isolate, labels), |
| 597 each_(NULL), |
| 598 enumerable_(NULL), |
| 599 assignment_id_(GetNextId(isolate)) { |
| 600 } |
558 | 601 |
559 DECLARE_NODE_TYPE(ForInStatement) | 602 DECLARE_NODE_TYPE(ForInStatement) |
560 | 603 |
561 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 604 void Initialize(Expression* each, Expression* enumerable, Statement* body) { |
562 IterationStatement::Initialize(body); | 605 IterationStatement::Initialize(body); |
563 each_ = each; | 606 each_ = each; |
564 enumerable_ = enumerable; | 607 enumerable_ = enumerable; |
565 } | 608 } |
566 | 609 |
567 Expression* each() const { return each_; } | 610 Expression* each() const { return each_; } |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
693 int position_; | 736 int position_; |
694 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; | 737 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; |
695 CompareTypeFeedback compare_type_; | 738 CompareTypeFeedback compare_type_; |
696 int compare_id_; | 739 int compare_id_; |
697 int entry_id_; | 740 int entry_id_; |
698 }; | 741 }; |
699 | 742 |
700 | 743 |
701 class SwitchStatement: public BreakableStatement { | 744 class SwitchStatement: public BreakableStatement { |
702 public: | 745 public: |
703 inline SwitchStatement(Isolate* isolate, ZoneStringList* labels); | 746 SwitchStatement(Isolate* isolate, ZoneStringList* labels) |
| 747 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), |
| 748 tag_(NULL), |
| 749 cases_(NULL) { |
| 750 } |
| 751 |
704 | 752 |
705 DECLARE_NODE_TYPE(SwitchStatement) | 753 DECLARE_NODE_TYPE(SwitchStatement) |
706 | 754 |
707 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 755 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
708 tag_ = tag; | 756 tag_ = tag; |
709 cases_ = cases; | 757 cases_ = cases; |
710 } | 758 } |
711 | 759 |
712 Expression* tag() const { return tag_; } | 760 Expression* tag() const { return tag_; } |
713 ZoneList<CaseClause*>* cases() const { return cases_; } | 761 ZoneList<CaseClause*>* cases() const { return cases_; } |
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 | 2152 |
2105 private: | 2153 private: |
2106 Isolate* isolate_; | 2154 Isolate* isolate_; |
2107 bool stack_overflow_; | 2155 bool stack_overflow_; |
2108 }; | 2156 }; |
2109 | 2157 |
2110 | 2158 |
2111 } } // namespace v8::internal | 2159 } } // namespace v8::internal |
2112 | 2160 |
2113 #endif // V8_AST_H_ | 2161 #endif // V8_AST_H_ |
OLD | NEW |