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 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1672 } | 1672 } |
1673 | 1673 |
1674 HoleCheckMode hole_check_mode() const { | 1674 HoleCheckMode hole_check_mode() const { |
1675 return HoleCheckModeField::decode(bit_field_); | 1675 return HoleCheckModeField::decode(bit_field_); |
1676 } | 1676 } |
1677 void set_needs_hole_check() { | 1677 void set_needs_hole_check() { |
1678 bit_field_ = | 1678 bit_field_ = |
1679 HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired); | 1679 HoleCheckModeField::update(bit_field_, HoleCheckMode::kRequired); |
1680 } | 1680 } |
1681 | 1681 |
1682 int end_position() const { return end_position_; } | |
1683 | |
1684 // Bind this proxy to the variable var. | 1682 // Bind this proxy to the variable var. |
1685 void BindTo(Variable* var); | 1683 void BindTo(Variable* var); |
1686 | 1684 |
1687 bool UsesVariableFeedbackSlot() const { | 1685 bool UsesVariableFeedbackSlot() const { |
1688 return var()->IsUnallocated() || var()->IsLookupSlot(); | 1686 return var()->IsUnallocated() || var()->IsLookupSlot(); |
1689 } | 1687 } |
1690 | 1688 |
1691 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1689 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1692 FeedbackVectorSlotCache* cache); | 1690 FeedbackVectorSlotCache* cache); |
1693 | 1691 |
1694 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } | 1692 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } |
1695 | 1693 |
1696 static int num_ids() { return parent_num_ids() + 1; } | 1694 static int num_ids() { return parent_num_ids() + 1; } |
1697 BailoutId BeforeId() const { return BailoutId(local_id(0)); } | 1695 BailoutId BeforeId() const { return BailoutId(local_id(0)); } |
1698 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } | 1696 void set_next_unresolved(VariableProxy* next) { next_unresolved_ = next; } |
1699 VariableProxy* next_unresolved() { return next_unresolved_; } | 1697 VariableProxy* next_unresolved() { return next_unresolved_; } |
1700 | 1698 |
1701 private: | 1699 private: |
1702 friend class AstNodeFactory; | 1700 friend class AstNodeFactory; |
1703 | 1701 |
1704 VariableProxy(Variable* var, int start_position, int end_position); | 1702 VariableProxy(Variable* var, int start_position); |
1705 VariableProxy(const AstRawString* name, VariableKind variable_kind, | 1703 VariableProxy(const AstRawString* name, VariableKind variable_kind, |
1706 int start_position, int end_position); | 1704 int start_position); |
1707 explicit VariableProxy(const VariableProxy* copy_from); | 1705 explicit VariableProxy(const VariableProxy* copy_from); |
1708 | 1706 |
1709 static int parent_num_ids() { return Expression::num_ids(); } | 1707 static int parent_num_ids() { return Expression::num_ids(); } |
1710 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1708 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1711 | 1709 |
1712 class IsThisField : public BitField<bool, Expression::kNextBitFieldIndex, 1> { | 1710 class IsThisField : public BitField<bool, Expression::kNextBitFieldIndex, 1> { |
1713 }; | 1711 }; |
1714 class IsAssignedField : public BitField<bool, IsThisField::kNext, 1> {}; | 1712 class IsAssignedField : public BitField<bool, IsThisField::kNext, 1> {}; |
1715 class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {}; | 1713 class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {}; |
1716 class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {}; | 1714 class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {}; |
1717 class HoleCheckModeField | 1715 class HoleCheckModeField |
1718 : public BitField<HoleCheckMode, IsNewTargetField::kNext, 1> {}; | 1716 : public BitField<HoleCheckMode, IsNewTargetField::kNext, 1> {}; |
1719 | 1717 |
1720 // Position is stored in the AstNode superclass, but VariableProxy needs to | |
1721 // know its end position too (for error messages). It cannot be inferred from | |
1722 // the variable name length because it can contain escapes. | |
1723 int end_position_; | |
1724 FeedbackVectorSlot variable_feedback_slot_; | 1718 FeedbackVectorSlot variable_feedback_slot_; |
1725 union { | 1719 union { |
1726 const AstRawString* raw_name_; // if !is_resolved_ | 1720 const AstRawString* raw_name_; // if !is_resolved_ |
1727 Variable* var_; // if is_resolved_ | 1721 Variable* var_; // if is_resolved_ |
1728 }; | 1722 }; |
1729 VariableProxy* next_unresolved_; | 1723 VariableProxy* next_unresolved_; |
1730 }; | 1724 }; |
1731 | 1725 |
1732 | 1726 |
1733 // Left-hand side can only be a property, a global or a (parameter or local) | 1727 // Left-hand side can only be a property, a global or a (parameter or local) |
(...skipping 1600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3334 } | 3328 } |
3335 | 3329 |
3336 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3330 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
3337 int first_spread_index, int literal_index, | 3331 int first_spread_index, int literal_index, |
3338 int pos) { | 3332 int pos) { |
3339 return new (zone_) | 3333 return new (zone_) |
3340 ArrayLiteral(values, first_spread_index, literal_index, pos); | 3334 ArrayLiteral(values, first_spread_index, literal_index, pos); |
3341 } | 3335 } |
3342 | 3336 |
3343 VariableProxy* NewVariableProxy(Variable* var, | 3337 VariableProxy* NewVariableProxy(Variable* var, |
3344 int start_position = kNoSourcePosition, | 3338 int start_position = kNoSourcePosition) { |
3345 int end_position = kNoSourcePosition) { | 3339 return new (zone_) VariableProxy(var, start_position); |
3346 return new (zone_) VariableProxy(var, start_position, end_position); | |
3347 } | 3340 } |
3348 | 3341 |
3349 VariableProxy* NewVariableProxy(const AstRawString* name, | 3342 VariableProxy* NewVariableProxy(const AstRawString* name, |
3350 VariableKind variable_kind, | 3343 VariableKind variable_kind, |
3351 int start_position = kNoSourcePosition, | 3344 int start_position = kNoSourcePosition) { |
3352 int end_position = kNoSourcePosition) { | |
3353 DCHECK_NOT_NULL(name); | 3345 DCHECK_NOT_NULL(name); |
3354 return new (zone_) | 3346 return new (zone_) VariableProxy(name, variable_kind, start_position); |
3355 VariableProxy(name, variable_kind, start_position, end_position); | |
3356 } | 3347 } |
3357 | 3348 |
3358 // Recreates the VariableProxy in this Zone. | 3349 // Recreates the VariableProxy in this Zone. |
3359 VariableProxy* CopyVariableProxy(VariableProxy* proxy) { | 3350 VariableProxy* CopyVariableProxy(VariableProxy* proxy) { |
3360 return new (zone_) VariableProxy(proxy); | 3351 return new (zone_) VariableProxy(proxy); |
3361 } | 3352 } |
3362 | 3353 |
3363 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3354 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
3364 return new (zone_) Property(obj, key, pos); | 3355 return new (zone_) Property(obj, key, pos); |
3365 } | 3356 } |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3603 : NULL; \ | 3594 : NULL; \ |
3604 } | 3595 } |
3605 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3596 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3606 #undef DECLARE_NODE_FUNCTIONS | 3597 #undef DECLARE_NODE_FUNCTIONS |
3607 | 3598 |
3608 | 3599 |
3609 } // namespace internal | 3600 } // namespace internal |
3610 } // namespace v8 | 3601 } // namespace v8 |
3611 | 3602 |
3612 #endif // V8_AST_AST_H_ | 3603 #endif // V8_AST_AST_H_ |
OLD | NEW |