OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/ast/ast-types.h" | 8 #include "src/ast/ast-types.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value); | 461 bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value); |
462 } | 462 } |
463 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 463 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
464 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 464 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
465 | 465 |
466 ZoneList<Statement*> statements_; | 466 ZoneList<Statement*> statements_; |
467 Scope* scope_; | 467 Scope* scope_; |
468 | 468 |
469 class IgnoreCompletionField | 469 class IgnoreCompletionField |
470 : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {}; | 470 : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {}; |
471 | |
472 protected: | |
473 static const uint8_t kNextBitFieldIndex = IgnoreCompletionField::kNext; | |
474 }; | 471 }; |
475 | 472 |
476 | 473 |
477 class DoExpression final : public Expression { | 474 class DoExpression final : public Expression { |
478 public: | 475 public: |
479 Block* block() { return block_; } | 476 Block* block() { return block_; } |
480 void set_block(Block* b) { block_ = b; } | 477 void set_block(Block* b) { block_ = b; } |
481 VariableProxy* result() { return result_; } | 478 VariableProxy* result() { return result_; } |
482 void set_result(VariableProxy* v) { result_ = v; } | 479 void set_result(VariableProxy* v) { result_ = v; } |
483 FunctionLiteral* represented_function() { return represented_function_; } | 480 FunctionLiteral* represented_function() { return represented_function_; } |
484 void set_represented_function(FunctionLiteral* f) { | 481 void set_represented_function(FunctionLiteral* f) { |
485 represented_function_ = f; | 482 represented_function_ = f; |
486 } | 483 } |
487 bool IsAnonymousFunctionDefinition() const; | 484 bool IsAnonymousFunctionDefinition() const; |
488 | 485 |
489 protected: | |
490 static const uint8_t kNextBitFieldIndex = Expression::kNextBitFieldIndex; | |
491 | |
492 private: | 486 private: |
493 friend class AstNodeFactory; | 487 friend class AstNodeFactory; |
494 | 488 |
495 DoExpression(Block* block, VariableProxy* result, int pos) | 489 DoExpression(Block* block, VariableProxy* result, int pos) |
496 : Expression(pos, kDoExpression), | 490 : Expression(pos, kDoExpression), |
497 block_(block), | 491 block_(block), |
498 result_(result), | 492 result_(result), |
499 represented_function_(nullptr) { | 493 represented_function_(nullptr) { |
500 DCHECK_NOT_NULL(block_); | 494 DCHECK_NOT_NULL(block_); |
501 DCHECK_NOT_NULL(result_); | 495 DCHECK_NOT_NULL(result_); |
(...skipping 11 matching lines...) Expand all Loading... |
513 public: | 507 public: |
514 typedef ThreadedList<Declaration> List; | 508 typedef ThreadedList<Declaration> List; |
515 | 509 |
516 VariableProxy* proxy() const { return proxy_; } | 510 VariableProxy* proxy() const { return proxy_; } |
517 Scope* scope() const { return scope_; } | 511 Scope* scope() const { return scope_; } |
518 | 512 |
519 protected: | 513 protected: |
520 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) | 514 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) |
521 : AstNode(pos, type), proxy_(proxy), scope_(scope), next_(nullptr) {} | 515 : AstNode(pos, type), proxy_(proxy), scope_(scope), next_(nullptr) {} |
522 | 516 |
523 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex; | |
524 | |
525 private: | 517 private: |
526 VariableProxy* proxy_; | 518 VariableProxy* proxy_; |
527 // Nested scope from which the declaration originated. | 519 // Nested scope from which the declaration originated. |
528 Scope* scope_; | 520 Scope* scope_; |
529 // Declarations list threaded through the declarations. | 521 // Declarations list threaded through the declarations. |
530 Declaration** next() { return &next_; } | 522 Declaration** next() { return &next_; } |
531 Declaration* next_; | 523 Declaration* next_; |
532 friend List; | 524 friend List; |
533 }; | 525 }; |
534 | 526 |
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 static int parent_num_ids() { return ForEachStatement::num_ids(); } | 765 static int parent_num_ids() { return ForEachStatement::num_ids(); } |
774 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 766 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
775 | 767 |
776 Expression* each_; | 768 Expression* each_; |
777 Expression* subject_; | 769 Expression* subject_; |
778 FeedbackVectorSlot each_slot_; | 770 FeedbackVectorSlot each_slot_; |
779 FeedbackVectorSlot for_in_feedback_slot_; | 771 FeedbackVectorSlot for_in_feedback_slot_; |
780 | 772 |
781 class ForInTypeField | 773 class ForInTypeField |
782 : public BitField<ForInType, ForEachStatement::kNextBitFieldIndex, 1> {}; | 774 : public BitField<ForInType, ForEachStatement::kNextBitFieldIndex, 1> {}; |
783 | |
784 protected: | |
785 static const uint8_t kNextBitFieldIndex = ForInTypeField::kNext; | |
786 }; | 775 }; |
787 | 776 |
788 | 777 |
789 class ForOfStatement final : public ForEachStatement { | 778 class ForOfStatement final : public ForEachStatement { |
790 public: | 779 public: |
791 void Initialize(Statement* body, Variable* iterator, | 780 void Initialize(Statement* body, Variable* iterator, |
792 Expression* assign_iterator, Expression* next_result, | 781 Expression* assign_iterator, Expression* next_result, |
793 Expression* result_done, Expression* assign_each) { | 782 Expression* result_done, Expression* assign_each) { |
794 ForEachStatement::Initialize(body); | 783 ForEachStatement::Initialize(body); |
795 iterator_ = iterator; | 784 iterator_ = iterator; |
(...skipping 673 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1469 properties_(properties) { | 1458 properties_(properties) { |
1470 bit_field_ |= FastElementsField::encode(false) | | 1459 bit_field_ |= FastElementsField::encode(false) | |
1471 HasElementsField::encode(false) | | 1460 HasElementsField::encode(false) | |
1472 MayStoreDoublesField::encode(false); | 1461 MayStoreDoublesField::encode(false); |
1473 } | 1462 } |
1474 | 1463 |
1475 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1464 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1476 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1465 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1477 | 1466 |
1478 uint32_t boilerplate_properties_; | 1467 uint32_t boilerplate_properties_; |
1479 FeedbackVectorSlot slot_; | |
1480 Handle<FixedArray> constant_properties_; | 1468 Handle<FixedArray> constant_properties_; |
1481 ZoneList<Property*>* properties_; | 1469 ZoneList<Property*>* properties_; |
1482 | 1470 |
1483 class FastElementsField | 1471 class FastElementsField |
1484 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; | 1472 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; |
1485 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { | 1473 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { |
1486 }; | 1474 }; |
1487 class MayStoreDoublesField | 1475 class MayStoreDoublesField |
1488 : public BitField<bool, HasElementsField::kNext, 1> {}; | 1476 : public BitField<bool, HasElementsField::kNext, 1> {}; |
1489 | |
1490 protected: | |
1491 static const uint8_t kNextBitFieldIndex = MayStoreDoublesField::kNext; | |
1492 }; | 1477 }; |
1493 | 1478 |
1494 | 1479 |
1495 // A map from property names to getter/setter pairs allocated in the zone. | 1480 // A map from property names to getter/setter pairs allocated in the zone. |
1496 class AccessorTable | 1481 class AccessorTable |
1497 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1482 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
1498 bool (*)(void*, void*), | 1483 bool (*)(void*, void*), |
1499 ZoneAllocationPolicy> { | 1484 ZoneAllocationPolicy> { |
1500 public: | 1485 public: |
1501 explicit AccessorTable(Zone* zone) | 1486 explicit AccessorTable(Zone* zone) |
(...skipping 2101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3603 : NULL; \ | 3588 : NULL; \ |
3604 } | 3589 } |
3605 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3590 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3606 #undef DECLARE_NODE_FUNCTIONS | 3591 #undef DECLARE_NODE_FUNCTIONS |
3607 | 3592 |
3608 | 3593 |
3609 } // namespace internal | 3594 } // namespace internal |
3610 } // namespace v8 | 3595 } // namespace v8 |
3611 | 3596 |
3612 #endif // V8_AST_AST_H_ | 3597 #endif // V8_AST_AST_H_ |
OLD | NEW |