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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 1618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1629 ZoneList<Expression*>* values_; | 1629 ZoneList<Expression*>* values_; |
1630 const BailoutId first_element_id_; | 1630 const BailoutId first_element_id_; |
1631 }; | 1631 }; |
1632 | 1632 |
1633 | 1633 |
1634 class VariableProxy FINAL : public Expression { | 1634 class VariableProxy FINAL : public Expression { |
1635 public: | 1635 public: |
1636 DECLARE_NODE_TYPE(VariableProxy) | 1636 DECLARE_NODE_TYPE(VariableProxy) |
1637 | 1637 |
1638 virtual bool IsValidReferenceExpression() const OVERRIDE { | 1638 virtual bool IsValidReferenceExpression() const OVERRIDE { |
1639 return var_ == NULL ? true : var_->IsValidReference(); | 1639 return !is_resolved() || var()->IsValidReference(); |
1640 } | 1640 } |
1641 | 1641 |
1642 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } | 1642 bool IsArguments() const { return is_resolved() && var()->is_arguments(); } |
1643 | 1643 |
1644 Handle<String> name() const { return name_->string(); } | 1644 Handle<String> name() const { return raw_name()->string(); } |
1645 const AstRawString* raw_name() const { return name_; } | 1645 const AstRawString* raw_name() const { |
1646 Variable* var() const { return var_; } | 1646 return is_resolved() ? var_->raw_name() : raw_name_; |
| 1647 } |
| 1648 |
| 1649 Variable* var() const { |
| 1650 DCHECK(is_resolved()); |
| 1651 return var_; |
| 1652 } |
| 1653 void set_var(Variable* v) { |
| 1654 DCHECK(!is_resolved()); |
| 1655 DCHECK_NOT_NULL(v); |
| 1656 var_ = v; |
| 1657 } |
| 1658 |
1647 bool is_this() const { return is_this_; } | 1659 bool is_this() const { return is_this_; } |
1648 Interface* interface() const { return interface_; } | |
1649 | 1660 |
1650 bool is_assigned() const { return is_assigned_; } | 1661 bool is_assigned() const { return is_assigned_; } |
1651 void set_is_assigned() { is_assigned_ = true; } | 1662 void set_is_assigned() { is_assigned_ = true; } |
1652 | 1663 |
| 1664 bool is_resolved() const { return is_resolved_; } |
| 1665 void set_is_resolved() { is_resolved_ = true; } |
| 1666 |
| 1667 Interface* interface() const { return interface_; } |
| 1668 |
1653 // Bind this proxy to the variable var. Interfaces must match. | 1669 // Bind this proxy to the variable var. Interfaces must match. |
1654 void BindTo(Variable* var); | 1670 void BindTo(Variable* var); |
1655 | 1671 |
1656 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1672 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
1657 virtual void SetFirstFeedbackSlot(int slot) { | 1673 virtual void SetFirstFeedbackSlot(int slot) { |
1658 variable_feedback_slot_ = slot; | 1674 variable_feedback_slot_ = slot; |
1659 } | 1675 } |
1660 | 1676 |
1661 int VariableFeedbackSlot() { return variable_feedback_slot_; } | 1677 int VariableFeedbackSlot() { return variable_feedback_slot_; } |
1662 | 1678 |
1663 protected: | 1679 protected: |
1664 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); | 1680 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); |
1665 | 1681 |
1666 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1682 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
1667 Interface* interface, int position, IdGen* id_gen); | 1683 Interface* interface, int position, IdGen* id_gen); |
1668 | 1684 |
1669 const AstRawString* name_; | 1685 union { |
1670 Variable* var_; // resolved variable, or NULL | 1686 const AstRawString* raw_name_; // if !is_resolved_ |
1671 bool is_this_; | 1687 Variable* var_; // if is_resolved_ |
1672 bool is_assigned_; | 1688 }; |
1673 Interface* interface_; | 1689 Interface* interface_; |
1674 int variable_feedback_slot_; | 1690 int variable_feedback_slot_; |
| 1691 bool is_this_ : 1; |
| 1692 bool is_assigned_ : 1; |
| 1693 bool is_resolved_ : 1; |
1675 }; | 1694 }; |
1676 | 1695 |
1677 | 1696 |
1678 class Property FINAL : public Expression { | 1697 class Property FINAL : public Expression { |
1679 public: | 1698 public: |
1680 DECLARE_NODE_TYPE(Property) | 1699 DECLARE_NODE_TYPE(Property) |
1681 | 1700 |
1682 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1701 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
1683 | 1702 |
1684 Expression* obj() const { return obj_; } | 1703 Expression* obj() const { return obj_; } |
(...skipping 1862 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3547 Zone* zone_; | 3566 Zone* zone_; |
3548 Visitor visitor_; | 3567 Visitor visitor_; |
3549 AstValueFactory* ast_value_factory_; | 3568 AstValueFactory* ast_value_factory_; |
3550 AstNode::IdGen* id_gen_; | 3569 AstNode::IdGen* id_gen_; |
3551 }; | 3570 }; |
3552 | 3571 |
3553 | 3572 |
3554 } } // namespace v8::internal | 3573 } } // namespace v8::internal |
3555 | 3574 |
3556 #endif // V8_AST_H_ | 3575 #endif // V8_AST_H_ |
OLD | NEW |