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 817 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
828 ZoneList<Label*>* targets() { return &targets_; } | 828 ZoneList<Label*>* targets() { return &targets_; } |
829 virtual bool IsInlineable() const; | 829 virtual bool IsInlineable() const; |
830 | 830 |
831 private: | 831 private: |
832 ZoneList<Label*> targets_; | 832 ZoneList<Label*> targets_; |
833 }; | 833 }; |
834 | 834 |
835 | 835 |
836 class TryStatement: public Statement { | 836 class TryStatement: public Statement { |
837 public: | 837 public: |
838 explicit TryStatement(int index, Block* try_block) | 838 explicit TryStatement(Block* try_block) |
839 : index_(index), | 839 : try_block_(try_block), escaping_targets_(NULL) { } |
840 try_block_(try_block), | |
841 escaping_targets_(NULL) { | |
842 } | |
843 | 840 |
844 void set_escaping_targets(ZoneList<Label*>* targets) { | 841 void set_escaping_targets(ZoneList<Label*>* targets) { |
845 escaping_targets_ = targets; | 842 escaping_targets_ = targets; |
846 } | 843 } |
847 | 844 |
848 int index() const { return index_; } | |
849 Block* try_block() const { return try_block_; } | 845 Block* try_block() const { return try_block_; } |
850 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } | 846 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } |
851 virtual bool IsInlineable() const; | 847 virtual bool IsInlineable() const; |
852 | 848 |
853 private: | 849 private: |
854 // Unique (per-function) index of this handler. This is not an AST ID. | |
855 int index_; | |
856 | |
857 Block* try_block_; | 850 Block* try_block_; |
858 ZoneList<Label*>* escaping_targets_; | 851 ZoneList<Label*>* escaping_targets_; |
859 }; | 852 }; |
860 | 853 |
861 | 854 |
862 class TryCatchStatement: public TryStatement { | 855 class TryCatchStatement: public TryStatement { |
863 public: | 856 public: |
864 TryCatchStatement(int index, | 857 TryCatchStatement(Block* try_block, |
865 Block* try_block, | |
866 Scope* scope, | 858 Scope* scope, |
867 Variable* variable, | 859 Variable* variable, |
868 Block* catch_block) | 860 Block* catch_block) |
869 : TryStatement(index, try_block), | 861 : TryStatement(try_block), |
870 scope_(scope), | 862 scope_(scope), |
871 variable_(variable), | 863 variable_(variable), |
872 catch_block_(catch_block) { | 864 catch_block_(catch_block) { |
873 } | 865 } |
874 | 866 |
875 DECLARE_NODE_TYPE(TryCatchStatement) | 867 DECLARE_NODE_TYPE(TryCatchStatement) |
876 | 868 |
877 Scope* scope() { return scope_; } | 869 Scope* scope() { return scope_; } |
878 Variable* variable() { return variable_; } | 870 Variable* variable() { return variable_; } |
879 Block* catch_block() const { return catch_block_; } | 871 Block* catch_block() const { return catch_block_; } |
880 virtual bool IsInlineable() const; | 872 virtual bool IsInlineable() const; |
881 | 873 |
882 private: | 874 private: |
883 Scope* scope_; | 875 Scope* scope_; |
884 Variable* variable_; | 876 Variable* variable_; |
885 Block* catch_block_; | 877 Block* catch_block_; |
886 }; | 878 }; |
887 | 879 |
888 | 880 |
889 class TryFinallyStatement: public TryStatement { | 881 class TryFinallyStatement: public TryStatement { |
890 public: | 882 public: |
891 TryFinallyStatement(int index, Block* try_block, Block* finally_block) | 883 TryFinallyStatement(Block* try_block, Block* finally_block) |
892 : TryStatement(index, try_block), | 884 : TryStatement(try_block), |
893 finally_block_(finally_block) { } | 885 finally_block_(finally_block) { } |
894 | 886 |
895 DECLARE_NODE_TYPE(TryFinallyStatement) | 887 DECLARE_NODE_TYPE(TryFinallyStatement) |
896 | 888 |
897 Block* finally_block() const { return finally_block_; } | 889 Block* finally_block() const { return finally_block_; } |
898 virtual bool IsInlineable() const; | 890 virtual bool IsInlineable() const; |
899 | 891 |
900 private: | 892 private: |
901 Block* finally_block_; | 893 Block* finally_block_; |
902 }; | 894 }; |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1645 NAMED_EXPRESSION, | 1637 NAMED_EXPRESSION, |
1646 DECLARATION | 1638 DECLARATION |
1647 }; | 1639 }; |
1648 | 1640 |
1649 FunctionLiteral(Isolate* isolate, | 1641 FunctionLiteral(Isolate* isolate, |
1650 Handle<String> name, | 1642 Handle<String> name, |
1651 Scope* scope, | 1643 Scope* scope, |
1652 ZoneList<Statement*>* body, | 1644 ZoneList<Statement*>* body, |
1653 int materialized_literal_count, | 1645 int materialized_literal_count, |
1654 int expected_property_count, | 1646 int expected_property_count, |
1655 int handler_count, | |
1656 bool has_only_simple_this_property_assignments, | 1647 bool has_only_simple_this_property_assignments, |
1657 Handle<FixedArray> this_property_assignments, | 1648 Handle<FixedArray> this_property_assignments, |
1658 int parameter_count, | 1649 int parameter_count, |
1659 Type type, | 1650 Type type, |
1660 bool has_duplicate_parameters) | 1651 bool has_duplicate_parameters) |
1661 : Expression(isolate), | 1652 : Expression(isolate), |
1662 name_(name), | 1653 name_(name), |
1663 scope_(scope), | 1654 scope_(scope), |
1664 body_(body), | 1655 body_(body), |
1665 this_property_assignments_(this_property_assignments), | 1656 this_property_assignments_(this_property_assignments), |
1666 inferred_name_(isolate->factory()->empty_string()), | 1657 inferred_name_(isolate->factory()->empty_string()), |
1667 materialized_literal_count_(materialized_literal_count), | 1658 materialized_literal_count_(materialized_literal_count), |
1668 expected_property_count_(expected_property_count), | 1659 expected_property_count_(expected_property_count), |
1669 handler_count_(handler_count), | |
1670 parameter_count_(parameter_count), | 1660 parameter_count_(parameter_count), |
1671 function_token_position_(RelocInfo::kNoPosition) { | 1661 function_token_position_(RelocInfo::kNoPosition) { |
1672 bitfield_ = | 1662 bitfield_ = |
1673 HasOnlySimpleThisPropertyAssignments::encode( | 1663 HasOnlySimpleThisPropertyAssignments::encode( |
1674 has_only_simple_this_property_assignments) | | 1664 has_only_simple_this_property_assignments) | |
1675 IsExpression::encode(type != DECLARATION) | | 1665 IsExpression::encode(type != DECLARATION) | |
1676 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | | 1666 IsAnonymous::encode(type == ANONYMOUS_EXPRESSION) | |
1677 Pretenure::encode(false) | | 1667 Pretenure::encode(false) | |
1678 HasDuplicateParameters::encode(has_duplicate_parameters); | 1668 HasDuplicateParameters::encode(has_duplicate_parameters); |
1679 } | 1669 } |
1680 | 1670 |
1681 DECLARE_NODE_TYPE(FunctionLiteral) | 1671 DECLARE_NODE_TYPE(FunctionLiteral) |
1682 | 1672 |
1683 Handle<String> name() const { return name_; } | 1673 Handle<String> name() const { return name_; } |
1684 Scope* scope() const { return scope_; } | 1674 Scope* scope() const { return scope_; } |
1685 ZoneList<Statement*>* body() const { return body_; } | 1675 ZoneList<Statement*>* body() const { return body_; } |
1686 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1676 void set_function_token_position(int pos) { function_token_position_ = pos; } |
1687 int function_token_position() const { return function_token_position_; } | 1677 int function_token_position() const { return function_token_position_; } |
1688 int start_position() const; | 1678 int start_position() const; |
1689 int end_position() const; | 1679 int end_position() const; |
1690 bool is_expression() const { return IsExpression::decode(bitfield_); } | 1680 bool is_expression() const { return IsExpression::decode(bitfield_); } |
1691 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } | 1681 bool is_anonymous() const { return IsAnonymous::decode(bitfield_); } |
1692 bool strict_mode() const { return strict_mode_flag() == kStrictMode; } | 1682 bool strict_mode() const { return strict_mode_flag() == kStrictMode; } |
1693 StrictModeFlag strict_mode_flag() const; | 1683 StrictModeFlag strict_mode_flag() const; |
1694 | 1684 |
1695 int materialized_literal_count() { return materialized_literal_count_; } | 1685 int materialized_literal_count() { return materialized_literal_count_; } |
1696 int expected_property_count() { return expected_property_count_; } | 1686 int expected_property_count() { return expected_property_count_; } |
1697 int handler_count() { return handler_count_; } | |
1698 bool has_only_simple_this_property_assignments() { | 1687 bool has_only_simple_this_property_assignments() { |
1699 return HasOnlySimpleThisPropertyAssignments::decode(bitfield_); | 1688 return HasOnlySimpleThisPropertyAssignments::decode(bitfield_); |
1700 } | 1689 } |
1701 Handle<FixedArray> this_property_assignments() { | 1690 Handle<FixedArray> this_property_assignments() { |
1702 return this_property_assignments_; | 1691 return this_property_assignments_; |
1703 } | 1692 } |
1704 int parameter_count() { return parameter_count_; } | 1693 int parameter_count() { return parameter_count_; } |
1705 | 1694 |
1706 bool AllowsLazyCompilation(); | 1695 bool AllowsLazyCompilation(); |
1707 | 1696 |
(...skipping 17 matching lines...) Expand all Loading... |
1725 | 1714 |
1726 private: | 1715 private: |
1727 Handle<String> name_; | 1716 Handle<String> name_; |
1728 Scope* scope_; | 1717 Scope* scope_; |
1729 ZoneList<Statement*>* body_; | 1718 ZoneList<Statement*>* body_; |
1730 Handle<FixedArray> this_property_assignments_; | 1719 Handle<FixedArray> this_property_assignments_; |
1731 Handle<String> inferred_name_; | 1720 Handle<String> inferred_name_; |
1732 | 1721 |
1733 int materialized_literal_count_; | 1722 int materialized_literal_count_; |
1734 int expected_property_count_; | 1723 int expected_property_count_; |
1735 int handler_count_; | |
1736 int parameter_count_; | 1724 int parameter_count_; |
1737 int function_token_position_; | 1725 int function_token_position_; |
1738 | 1726 |
1739 unsigned bitfield_; | 1727 unsigned bitfield_; |
1740 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {}; | 1728 class HasOnlySimpleThisPropertyAssignments: public BitField<bool, 0, 1> {}; |
1741 class IsExpression: public BitField<bool, 1, 1> {}; | 1729 class IsExpression: public BitField<bool, 1, 1> {}; |
1742 class IsAnonymous: public BitField<bool, 2, 1> {}; | 1730 class IsAnonymous: public BitField<bool, 2, 1> {}; |
1743 class Pretenure: public BitField<bool, 3, 1> {}; | 1731 class Pretenure: public BitField<bool, 3, 1> {}; |
1744 class HasDuplicateParameters: public BitField<bool, 4, 1> {}; | 1732 class HasDuplicateParameters: public BitField<bool, 4, 1> {}; |
1745 }; | 1733 }; |
(...skipping 421 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 | 2155 |
2168 private: | 2156 private: |
2169 Isolate* isolate_; | 2157 Isolate* isolate_; |
2170 bool stack_overflow_; | 2158 bool stack_overflow_; |
2171 }; | 2159 }; |
2172 | 2160 |
2173 | 2161 |
2174 } } // namespace v8::internal | 2162 } } // namespace v8::internal |
2175 | 2163 |
2176 #endif // V8_AST_H_ | 2164 #endif // V8_AST_H_ |
OLD | NEW |