| 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" | 
| 11 #include "vm/bitmap.h" | 11 #include "vm/bitmap.h" | 
| 12 #include "vm/dart.h" | 12 #include "vm/dart.h" | 
| 13 #include "vm/globals.h" | 13 #include "vm/globals.h" | 
| 14 #include "vm/handles.h" | 14 #include "vm/handles.h" | 
| 15 #include "vm/heap.h" | 15 #include "vm/heap.h" | 
| 16 #include "vm/isolate.h" | 16 #include "vm/isolate.h" | 
| 17 #include "vm/os.h" | 17 #include "vm/os.h" | 
| 18 #include "vm/raw_object.h" | 18 #include "vm/raw_object.h" | 
| 19 #include "vm/scanner.h" | 19 #include "vm/scanner.h" | 
|  | 20 #include "vm/unicode.h" | 
| 20 | 21 | 
| 21 namespace dart { | 22 namespace dart { | 
| 22 | 23 | 
| 23 // Forward declarations. | 24 // Forward declarations. | 
| 24 #define DEFINE_FORWARD_DECLARATION(clazz)                                      \ | 25 #define DEFINE_FORWARD_DECLARATION(clazz)                                      \ | 
| 25   class clazz; | 26   class clazz; | 
| 26 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 27 CLASS_LIST(DEFINE_FORWARD_DECLARATION) | 
| 27 #undef DEFINE_FORWARD_DECLARATION | 28 #undef DEFINE_FORWARD_DECLARATION | 
| 28 class Api; | 29 class Api; | 
| 29 class Assembler; | 30 class Assembler; | 
| (...skipping 3679 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3709   static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 3710   static const intptr_t kMaxElements = kSmiMax / kTwoByteChar; | 
| 3710 | 3711 | 
| 3711   intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 3712   intptr_t Length() const { return Smi::Value(raw_ptr()->length_); } | 
| 3712   static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 3713   static intptr_t length_offset() { return OFFSET_OF(RawString, length_); } | 
| 3713 | 3714 | 
| 3714   virtual intptr_t Hash() const; | 3715   virtual intptr_t Hash() const; | 
| 3715   static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 3716   static intptr_t hash_offset() { return OFFSET_OF(RawString, hash_); } | 
| 3716   static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 3717   static intptr_t Hash(const String& str, intptr_t begin_index, intptr_t len); | 
| 3717   static intptr_t Hash(const uint8_t* characters, intptr_t len); | 3718   static intptr_t Hash(const uint8_t* characters, intptr_t len); | 
| 3718   static intptr_t Hash(const uint16_t* characters, intptr_t len); | 3719   static intptr_t Hash(const uint16_t* characters, intptr_t len); | 
| 3719   static intptr_t Hash(const uint32_t* characters, intptr_t len); | 3720   static intptr_t Hash(const int32_t* characters, intptr_t len); | 
| 3720 | 3721 | 
|  | 3722   // Despite the name, this does not return the character.  It returns the | 
|  | 3723   // UTF-16 code unit at an index.  UTF-16 is a superset of ASCII (and Latin1) | 
|  | 3724   // so you can always use this if you are looking for ASCII.  If you need to | 
|  | 3725   // support arbitrary Unicode characters then you should perhaps be using | 
|  | 3726   // Utf16::CharCodeAt(string, index), which returns the full 21 bit code | 
|  | 3727   // point. | 
| 3721   int32_t CharAt(intptr_t index) const; | 3728   int32_t CharAt(intptr_t index) const; | 
| 3722 | 3729 | 
| 3723   intptr_t CharSize() const; | 3730   intptr_t CharSize() const; | 
| 3724 | 3731 | 
| 3725   inline bool Equals(const String& str) const; | 3732   inline bool Equals(const String& str) const; | 
| 3726   inline bool Equals(const String& str, | 3733   inline bool Equals(const String& str, | 
| 3727                      intptr_t begin_index,  // begin index on 'str'. | 3734                      intptr_t begin_index,  // begin index on 'str'. | 
| 3728                      intptr_t len) const;  // len on 'str'. | 3735                      intptr_t len) const;  // len on 'str'. | 
| 3729   bool Equals(const char* str) const; | 3736   bool Equals(const char* str) const; | 
| 3730   bool Equals(const uint8_t* characters, intptr_t len) const; | 3737   bool Equals(const uint8_t* characters, intptr_t len) const; | 
| 3731   bool Equals(const uint16_t* characters, intptr_t len) const; | 3738   bool Equals(const uint16_t* characters, intptr_t len) const; | 
| 3732   bool Equals(const uint32_t* characters, intptr_t len) const; |  | 
| 3733 | 3739 | 
| 3734   virtual bool Equals(const Instance& other) const; | 3740   virtual bool Equals(const Instance& other) const; | 
| 3735 | 3741 | 
| 3736   intptr_t CompareTo(const String& other) const; | 3742   intptr_t CompareTo(const String& other) const; | 
| 3737 | 3743 | 
| 3738   bool StartsWith(const String& other) const; | 3744   bool StartsWith(const String& other) const; | 
| 3739 | 3745 | 
| 3740   virtual RawInstance* Canonicalize() const; | 3746   virtual RawInstance* Canonicalize() const; | 
| 3741 | 3747 | 
| 3742   bool IsSymbol() const { return raw()->IsCanonical(); } | 3748   bool IsSymbol() const { return raw()->IsCanonical(); } | 
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3784   static RawString* New(const uint8_t* utf8_array, | 3790   static RawString* New(const uint8_t* utf8_array, | 
| 3785                         intptr_t array_len, | 3791                         intptr_t array_len, | 
| 3786                         Heap::Space space = Heap::kNew); | 3792                         Heap::Space space = Heap::kNew); | 
| 3787 | 3793 | 
| 3788   // Creates a new String object from an array of UTF-16 encoded characters. | 3794   // Creates a new String object from an array of UTF-16 encoded characters. | 
| 3789   static RawString* New(const uint16_t* utf16_array, | 3795   static RawString* New(const uint16_t* utf16_array, | 
| 3790                         intptr_t array_len, | 3796                         intptr_t array_len, | 
| 3791                         Heap::Space space = Heap::kNew); | 3797                         Heap::Space space = Heap::kNew); | 
| 3792 | 3798 | 
| 3793   // Creates a new String object from an array of UTF-32 encoded characters. | 3799   // Creates a new String object from an array of UTF-32 encoded characters. | 
| 3794   static RawString* New(const uint32_t* utf32_array, | 3800   static RawString* New(const int32_t* utf32_array, | 
| 3795                         intptr_t array_len, | 3801                         intptr_t array_len, | 
| 3796                         Heap::Space space = Heap::kNew); | 3802                         Heap::Space space = Heap::kNew); | 
| 3797 | 3803 | 
| 3798   // Create a new String object from another Dart String instance. | 3804   // Create a new String object from another Dart String instance. | 
| 3799   static RawString* New(const String& str, Heap::Space space = Heap::kNew); | 3805   static RawString* New(const String& str, Heap::Space space = Heap::kNew); | 
| 3800 | 3806 | 
| 3801   // Creates a new External String object using the specified array of | 3807   // Creates a new External String object using the specified array of | 
| 3802   // UTF-8 encoded characters as the external reference. | 3808   // UTF-8 encoded characters as the external reference. | 
| 3803   static RawString* NewExternal(const uint8_t* utf8_array, | 3809   static RawString* NewExternal(const uint8_t* utf8_array, | 
| 3804                                 intptr_t array_len, | 3810                                 intptr_t array_len, | 
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 3930     return New(reinterpret_cast<const uint8_t*>(c_string), | 3936     return New(reinterpret_cast<const uint8_t*>(c_string), | 
| 3931                strlen(c_string), | 3937                strlen(c_string), | 
| 3932                space); | 3938                space); | 
| 3933   } | 3939   } | 
| 3934   static RawOneByteString* New(const uint8_t* characters, | 3940   static RawOneByteString* New(const uint8_t* characters, | 
| 3935                                intptr_t len, | 3941                                intptr_t len, | 
| 3936                                Heap::Space space); | 3942                                Heap::Space space); | 
| 3937   static RawOneByteString* New(const uint16_t* characters, | 3943   static RawOneByteString* New(const uint16_t* characters, | 
| 3938                                intptr_t len, | 3944                                intptr_t len, | 
| 3939                                Heap::Space space); | 3945                                Heap::Space space); | 
| 3940   static RawOneByteString* New(const uint32_t* characters, | 3946   static RawOneByteString* New(const int32_t* characters, | 
| 3941                                intptr_t len, | 3947                                intptr_t len, | 
| 3942                                Heap::Space space); | 3948                                Heap::Space space); | 
| 3943   static RawOneByteString* New(const String& str, | 3949   static RawOneByteString* New(const String& str, | 
| 3944                                Heap::Space space); | 3950                                Heap::Space space); | 
| 3945 | 3951 | 
| 3946   static RawOneByteString* Concat(const String& str1, | 3952   static RawOneByteString* Concat(const String& str1, | 
| 3947                                   const String& str2, | 3953                                   const String& str2, | 
| 3948                                   Heap::Space space); | 3954                                   Heap::Space space); | 
| 3949   static RawOneByteString* ConcatAll(const Array& strings, | 3955   static RawOneByteString* ConcatAll(const Array& strings, | 
| 3950                                      intptr_t len, | 3956                                      intptr_t len, | 
| 3951                                      Heap::Space space); | 3957                                      Heap::Space space); | 
| 3952 | 3958 | 
| 3953   static RawOneByteString* Transform(int32_t (*mapping)(int32_t ch), | 3959   static RawOneByteString* Transform(int32_t (*mapping)(int32_t ch), | 
| 3954                                      const String& str, | 3960                                      const String& str, | 
|  | 3961                                      intptr_t out_length, | 
| 3955                                      Heap::Space space); | 3962                                      Heap::Space space); | 
| 3956 | 3963 | 
| 3957   static const ClassId kClassId = kOneByteStringCid; | 3964   static const ClassId kClassId = kOneByteStringCid; | 
| 3958 | 3965 | 
| 3959   static RawOneByteString* null() { | 3966   static RawOneByteString* null() { | 
| 3960     return reinterpret_cast<RawOneByteString*>(Object::null()); | 3967     return reinterpret_cast<RawOneByteString*>(Object::null()); | 
| 3961   } | 3968   } | 
| 3962 | 3969 | 
| 3963  private: | 3970  private: | 
| 3964   static RawOneByteString* raw(const String& str) { | 3971   static RawOneByteString* raw(const String& str) { | 
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 4013     return String::RoundedAllocationSize( | 4020     return String::RoundedAllocationSize( | 
| 4014         sizeof(RawTwoByteString) + (len * kBytesPerElement)); | 4021         sizeof(RawTwoByteString) + (len * kBytesPerElement)); | 
| 4015   } | 4022   } | 
| 4016 | 4023 | 
| 4017   static RawTwoByteString* New(intptr_t len, | 4024   static RawTwoByteString* New(intptr_t len, | 
| 4018                                Heap::Space space); | 4025                                Heap::Space space); | 
| 4019   static RawTwoByteString* New(const uint16_t* characters, | 4026   static RawTwoByteString* New(const uint16_t* characters, | 
| 4020                                intptr_t len, | 4027                                intptr_t len, | 
| 4021                                Heap::Space space); | 4028                                Heap::Space space); | 
| 4022   static RawTwoByteString* New(intptr_t utf16_len, | 4029   static RawTwoByteString* New(intptr_t utf16_len, | 
| 4023                                const uint32_t* characters, | 4030                                const int32_t* characters, | 
| 4024                                intptr_t len, | 4031                                intptr_t len, | 
| 4025                                Heap::Space space); | 4032                                Heap::Space space); | 
| 4026   static RawTwoByteString* New(const String& str, | 4033   static RawTwoByteString* New(const String& str, | 
| 4027                                Heap::Space space); | 4034                                Heap::Space space); | 
| 4028 | 4035 | 
| 4029   static RawTwoByteString* Concat(const String& str1, | 4036   static RawTwoByteString* Concat(const String& str1, | 
| 4030                                   const String& str2, | 4037                                   const String& str2, | 
| 4031                                   Heap::Space space); | 4038                                   Heap::Space space); | 
| 4032   static RawTwoByteString* ConcatAll(const Array& strings, | 4039   static RawTwoByteString* ConcatAll(const Array& strings, | 
| 4033                                      intptr_t len, | 4040                                      intptr_t len, | 
| 4034                                      Heap::Space space); | 4041                                      Heap::Space space); | 
| 4035 | 4042 | 
| 4036   static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), | 4043   static RawTwoByteString* Transform(int32_t (*mapping)(int32_t ch), | 
| 4037                                      const String& str, | 4044                                      const String& str, | 
|  | 4045                                      intptr_t out_length, | 
| 4038                                      Heap::Space space); | 4046                                      Heap::Space space); | 
| 4039 | 4047 | 
| 4040   static RawTwoByteString* null() { | 4048   static RawTwoByteString* null() { | 
| 4041     return reinterpret_cast<RawTwoByteString*>(Object::null()); | 4049     return reinterpret_cast<RawTwoByteString*>(Object::null()); | 
| 4042   } | 4050   } | 
| 4043 | 4051 | 
| 4044 | 4052 | 
| 4045   static const ClassId kClassId = kTwoByteStringCid; | 4053   static const ClassId kClassId = kTwoByteStringCid; | 
| 4046 | 4054 | 
| 4047  private: | 4055  private: | 
| (...skipping 1873 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5921     if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 5929     if (this->CharAt(i) != str.CharAt(begin_index + i)) { | 
| 5922       return false; | 5930       return false; | 
| 5923     } | 5931     } | 
| 5924   } | 5932   } | 
| 5925   return true; | 5933   return true; | 
| 5926 } | 5934 } | 
| 5927 | 5935 | 
| 5928 }  // namespace dart | 5936 }  // namespace dart | 
| 5929 | 5937 | 
| 5930 #endif  // VM_OBJECT_H_ | 5938 #endif  // VM_OBJECT_H_ | 
| OLD | NEW | 
|---|