OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_OBJECT_H_ | 5 #ifndef VM_OBJECT_H_ |
6 #define VM_OBJECT_H_ | 6 #define VM_OBJECT_H_ |
7 | 7 |
8 #include "include/dart_api.h" | 8 #include "include/dart_api.h" |
9 #include "platform/assert.h" | 9 #include "platform/assert.h" |
10 #include "platform/utils.h" | 10 #include "platform/utils.h" |
(...skipping 1784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1795 intptr_t token_pos); | 1795 intptr_t token_pos); |
1796 | 1796 |
1797 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } | 1797 static intptr_t value_offset() { return OFFSET_OF(RawField, value_); } |
1798 | 1798 |
1799 intptr_t token_pos() const { return raw_ptr()->token_pos_; } | 1799 intptr_t token_pos() const { return raw_ptr()->token_pos_; } |
1800 | 1800 |
1801 bool has_initializer() const { | 1801 bool has_initializer() const { |
1802 return HasInitializerBit::decode(raw_ptr()->kind_bits_); | 1802 return HasInitializerBit::decode(raw_ptr()->kind_bits_); |
1803 } | 1803 } |
1804 void set_has_initializer(bool has_initializer) const { | 1804 void set_has_initializer(bool has_initializer) const { |
1805 uword bits = raw_ptr()->kind_bits_; | 1805 raw_ptr()->kind_bits_ = static_cast<uint8_t>( |
1806 raw_ptr()->kind_bits_ = HasInitializerBit::update(has_initializer, bits); | 1806 HasInitializerBit::update(has_initializer, raw_ptr()->kind_bits_)); |
1807 } | 1807 } |
1808 | 1808 |
1809 // Constructs getter and setter names for fields and vice versa. | 1809 // Constructs getter and setter names for fields and vice versa. |
1810 static RawString* GetterName(const String& field_name); | 1810 static RawString* GetterName(const String& field_name); |
1811 static RawString* GetterSymbol(const String& field_name); | 1811 static RawString* GetterSymbol(const String& field_name); |
1812 static RawString* SetterName(const String& field_name); | 1812 static RawString* SetterName(const String& field_name); |
1813 static RawString* SetterSymbol(const String& field_name); | 1813 static RawString* SetterSymbol(const String& field_name); |
1814 static RawString* NameFromGetter(const String& getter_name); | 1814 static RawString* NameFromGetter(const String& getter_name); |
1815 static RawString* NameFromSetter(const String& setter_name); | 1815 static RawString* NameFromSetter(const String& setter_name); |
1816 static bool IsGetterName(const String& function_name); | 1816 static bool IsGetterName(const String& function_name); |
1817 static bool IsSetterName(const String& function_name); | 1817 static bool IsSetterName(const String& function_name); |
1818 | 1818 |
1819 private: | 1819 private: |
1820 enum { | 1820 enum { |
1821 kConstBit = 1, | 1821 kConstBit = 1, |
1822 kStaticBit, | 1822 kStaticBit, |
1823 kFinalBit, | 1823 kFinalBit, |
1824 kHasInitializerBit, | 1824 kHasInitializerBit, |
1825 }; | 1825 }; |
1826 class ConstBit : public BitField<bool, kConstBit, 1> {}; | 1826 class ConstBit : public BitField<bool, kConstBit, 1> {}; |
1827 class StaticBit : public BitField<bool, kStaticBit, 1> {}; | 1827 class StaticBit : public BitField<bool, kStaticBit, 1> {}; |
1828 class FinalBit : public BitField<bool, kFinalBit, 1> {}; | 1828 class FinalBit : public BitField<bool, kFinalBit, 1> {}; |
1829 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {}; | 1829 class HasInitializerBit : public BitField<bool, kHasInitializerBit, 1> {}; |
1830 | 1830 |
1831 void set_name(const String& value) const; | 1831 void set_name(const String& value) const; |
1832 void set_is_static(bool is_static) const { | 1832 void set_is_static(bool is_static) const { |
1833 uword bits = raw_ptr()->kind_bits_; | 1833 set_kind_bits(StaticBit::update(is_static, raw_ptr()->kind_bits_)); |
1834 raw_ptr()->kind_bits_ = StaticBit::update(is_static, bits); | |
1835 } | 1834 } |
1836 void set_is_final(bool is_final) const { | 1835 void set_is_final(bool is_final) const { |
1837 uword bits = raw_ptr()->kind_bits_; | 1836 set_kind_bits(FinalBit::update(is_final, raw_ptr()->kind_bits_)); |
1838 raw_ptr()->kind_bits_ = FinalBit::update(is_final, bits); | |
1839 } | 1837 } |
1840 void set_is_const(bool value) const { | 1838 void set_is_const(bool value) const { |
1841 uword bits = raw_ptr()->kind_bits_; | 1839 set_kind_bits(ConstBit::update(value, raw_ptr()->kind_bits_)); |
1842 raw_ptr()->kind_bits_ = ConstBit::update(value, bits); | |
1843 } | 1840 } |
1844 void set_owner(const Class& value) const { | 1841 void set_owner(const Class& value) const { |
1845 StorePointer(&raw_ptr()->owner_, value.raw()); | 1842 StorePointer(&raw_ptr()->owner_, value.raw()); |
1846 } | 1843 } |
1847 void set_token_pos(intptr_t token_pos) const { | 1844 void set_token_pos(intptr_t token_pos) const { |
1848 raw_ptr()->token_pos_ = token_pos; | 1845 raw_ptr()->token_pos_ = token_pos; |
1849 } | 1846 } |
1850 void set_kind_bits(intptr_t value) const { | 1847 void set_kind_bits(intptr_t value) const { |
1851 raw_ptr()->kind_bits_ = value; | 1848 raw_ptr()->kind_bits_ = static_cast<uint8_t>(value); |
1852 } | 1849 } |
1853 static RawField* New(); | 1850 static RawField* New(); |
1854 | 1851 |
1855 HEAP_OBJECT_IMPLEMENTATION(Field, Object); | 1852 HEAP_OBJECT_IMPLEMENTATION(Field, Object); |
1856 friend class Class; | 1853 friend class Class; |
1857 friend class HeapProfiler; | 1854 friend class HeapProfiler; |
1858 }; | 1855 }; |
1859 | 1856 |
1860 | 1857 |
1861 class LiteralToken : public Object { | 1858 class LiteralToken : public Object { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1928 RawObject* CurrentToken() const; | 1925 RawObject* CurrentToken() const; |
1929 RawString* CurrentLiteral() const; | 1926 RawString* CurrentLiteral() const; |
1930 RawString* MakeLiteralToken(const Object& obj) const; | 1927 RawString* MakeLiteralToken(const Object& obj) const; |
1931 | 1928 |
1932 private: | 1929 private: |
1933 // Read token from the token stream (could be a simple token or an index | 1930 // Read token from the token stream (could be a simple token or an index |
1934 // into the token objects array for IDENT or literal tokens). | 1931 // into the token objects array for IDENT or literal tokens). |
1935 intptr_t ReadToken() { | 1932 intptr_t ReadToken() { |
1936 int64_t value = stream_.ReadUnsigned(); | 1933 int64_t value = stream_.ReadUnsigned(); |
1937 ASSERT((value >= 0) && (value <= kIntptrMax)); | 1934 ASSERT((value >= 0) && (value <= kIntptrMax)); |
1938 return value; | 1935 return static_cast<intptr_t>(value); |
1939 } | 1936 } |
1940 | 1937 |
1941 const TokenStream& tokens_; | 1938 const TokenStream& tokens_; |
1942 const ExternalUint8Array& data_; | 1939 const ExternalUint8Array& data_; |
1943 ReadStream stream_; | 1940 ReadStream stream_; |
1944 Array& token_objects_; | 1941 Array& token_objects_; |
1945 Object& obj_; | 1942 Object& obj_; |
1946 intptr_t cur_token_pos_; | 1943 intptr_t cur_token_pos_; |
1947 Token::Kind cur_token_kind_; | 1944 Token::Kind cur_token_kind_; |
1948 intptr_t cur_token_obj_index_; | 1945 intptr_t cur_token_obj_index_; |
(...skipping 3701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5650 if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5647 if (this->CharAt(i) != str.CharAt(begin_index + i)) { |
5651 return false; | 5648 return false; |
5652 } | 5649 } |
5653 } | 5650 } |
5654 return true; | 5651 return true; |
5655 } | 5652 } |
5656 | 5653 |
5657 } // namespace dart | 5654 } // namespace dart |
5658 | 5655 |
5659 #endif // VM_OBJECT_H_ | 5656 #endif // VM_OBJECT_H_ |
OLD | NEW |