OLD | NEW |
1 // Copyright 2006-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2008 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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
179 // needed if false. | 179 // needed if false. |
180 kTestValue | 180 kTestValue |
181 }; | 181 }; |
182 | 182 |
183 static const int kNoLabel = -1; | 183 static const int kNoLabel = -1; |
184 | 184 |
185 Expression() : num_(kNoLabel) {} | 185 Expression() : num_(kNoLabel) {} |
186 | 186 |
187 virtual Expression* AsExpression() { return this; } | 187 virtual Expression* AsExpression() { return this; } |
188 | 188 |
189 virtual bool IsValidJSON() { return false; } | |
190 virtual bool IsValidLeftHandSide() { return false; } | 189 virtual bool IsValidLeftHandSide() { return false; } |
191 | 190 |
192 // Symbols that cannot be parsed as array indices are considered property | 191 // Symbols that cannot be parsed as array indices are considered property |
193 // names. We do not treat symbols that can be array indexes as property | 192 // names. We do not treat symbols that can be array indexes as property |
194 // names because [] for string objects is handled only by keyed ICs. | 193 // names because [] for string objects is handled only by keyed ICs. |
195 virtual bool IsPropertyName() { return false; } | 194 virtual bool IsPropertyName() { return false; } |
196 | 195 |
197 // Mark the expression as being compiled as an expression | 196 // Mark the expression as being compiled as an expression |
198 // statement. This is used to transform postfix increments to | 197 // statement. This is used to transform postfix increments to |
199 // (faster) prefix increments. | 198 // (faster) prefix increments. |
(...skipping 506 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 virtual void Accept(AstVisitor* v); | 705 virtual void Accept(AstVisitor* v); |
707 | 706 |
708 // Type testing & conversion. | 707 // Type testing & conversion. |
709 virtual Literal* AsLiteral() { return this; } | 708 virtual Literal* AsLiteral() { return this; } |
710 | 709 |
711 // Check if this literal is identical to the other literal. | 710 // Check if this literal is identical to the other literal. |
712 bool IsIdenticalTo(const Literal* other) const { | 711 bool IsIdenticalTo(const Literal* other) const { |
713 return handle_.is_identical_to(other->handle_); | 712 return handle_.is_identical_to(other->handle_); |
714 } | 713 } |
715 | 714 |
716 virtual bool IsValidJSON() { return true; } | |
717 | |
718 virtual bool IsPropertyName() { | 715 virtual bool IsPropertyName() { |
719 if (handle_->IsSymbol()) { | 716 if (handle_->IsSymbol()) { |
720 uint32_t ignored; | 717 uint32_t ignored; |
721 return !String::cast(*handle_)->AsArrayIndex(&ignored); | 718 return !String::cast(*handle_)->AsArrayIndex(&ignored); |
722 } | 719 } |
723 return false; | 720 return false; |
724 } | 721 } |
725 | 722 |
726 // Identity testers. | 723 // Identity testers. |
727 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } | 724 bool IsNull() const { return handle_.is_identical_to(Factory::null_value()); } |
(...skipping 16 matching lines...) Expand all Loading... |
744 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} | 741 : literal_index_(literal_index), is_simple_(is_simple), depth_(depth) {} |
745 | 742 |
746 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 743 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
747 | 744 |
748 int literal_index() { return literal_index_; } | 745 int literal_index() { return literal_index_; } |
749 | 746 |
750 // A materialized literal is simple if the values consist of only | 747 // A materialized literal is simple if the values consist of only |
751 // constants and simple object and array literals. | 748 // constants and simple object and array literals. |
752 bool is_simple() const { return is_simple_; } | 749 bool is_simple() const { return is_simple_; } |
753 | 750 |
754 virtual bool IsValidJSON() { return true; } | |
755 | |
756 int depth() const { return depth_; } | 751 int depth() const { return depth_; } |
757 | 752 |
758 private: | 753 private: |
759 int literal_index_; | 754 int literal_index_; |
760 bool is_simple_; | 755 bool is_simple_; |
761 int depth_; | 756 int depth_; |
762 }; | 757 }; |
763 | 758 |
764 | 759 |
765 // An object literal has a boilerplate object that is used | 760 // An object literal has a boilerplate object that is used |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 ZoneList<Property*>* properties, | 794 ZoneList<Property*>* properties, |
800 int literal_index, | 795 int literal_index, |
801 bool is_simple, | 796 bool is_simple, |
802 int depth) | 797 int depth) |
803 : MaterializedLiteral(literal_index, is_simple, depth), | 798 : MaterializedLiteral(literal_index, is_simple, depth), |
804 constant_properties_(constant_properties), | 799 constant_properties_(constant_properties), |
805 properties_(properties) {} | 800 properties_(properties) {} |
806 | 801 |
807 virtual ObjectLiteral* AsObjectLiteral() { return this; } | 802 virtual ObjectLiteral* AsObjectLiteral() { return this; } |
808 virtual void Accept(AstVisitor* v); | 803 virtual void Accept(AstVisitor* v); |
809 virtual bool IsValidJSON(); | |
810 | 804 |
811 Handle<FixedArray> constant_properties() const { | 805 Handle<FixedArray> constant_properties() const { |
812 return constant_properties_; | 806 return constant_properties_; |
813 } | 807 } |
814 ZoneList<Property*>* properties() const { return properties_; } | 808 ZoneList<Property*>* properties() const { return properties_; } |
815 | 809 |
816 private: | 810 private: |
817 Handle<FixedArray> constant_properties_; | 811 Handle<FixedArray> constant_properties_; |
818 ZoneList<Property*>* properties_; | 812 ZoneList<Property*>* properties_; |
819 }; | 813 }; |
(...skipping 27 matching lines...) Expand all Loading... |
847 ZoneList<Expression*>* values, | 841 ZoneList<Expression*>* values, |
848 int literal_index, | 842 int literal_index, |
849 bool is_simple, | 843 bool is_simple, |
850 int depth) | 844 int depth) |
851 : MaterializedLiteral(literal_index, is_simple, depth), | 845 : MaterializedLiteral(literal_index, is_simple, depth), |
852 constant_elements_(constant_elements), | 846 constant_elements_(constant_elements), |
853 values_(values) {} | 847 values_(values) {} |
854 | 848 |
855 virtual void Accept(AstVisitor* v); | 849 virtual void Accept(AstVisitor* v); |
856 virtual ArrayLiteral* AsArrayLiteral() { return this; } | 850 virtual ArrayLiteral* AsArrayLiteral() { return this; } |
857 virtual bool IsValidJSON(); | |
858 | 851 |
859 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 852 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
860 ZoneList<Expression*>* values() const { return values_; } | 853 ZoneList<Expression*>* values() const { return values_; } |
861 | 854 |
862 private: | 855 private: |
863 Handle<FixedArray> constant_elements_; | 856 Handle<FixedArray> constant_elements_; |
864 ZoneList<Expression*>* values_; | 857 ZoneList<Expression*>* values_; |
865 }; | 858 }; |
866 | 859 |
867 | 860 |
(...skipping 942 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1810 #undef DEF_VISIT | 1803 #undef DEF_VISIT |
1811 | 1804 |
1812 private: | 1805 private: |
1813 bool stack_overflow_; | 1806 bool stack_overflow_; |
1814 }; | 1807 }; |
1815 | 1808 |
1816 | 1809 |
1817 } } // namespace v8::internal | 1810 } } // namespace v8::internal |
1818 | 1811 |
1819 #endif // V8_AST_H_ | 1812 #endif // V8_AST_H_ |
OLD | NEW |