Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(472)

Side by Side Diff: vm/object.h

Issue 11411341: Fix for issue 7089 (Symbols::New was not quite working correctly (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « vm/double_conversion.cc ('k') | vm/object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 3801 matching lines...) Expand 10 before | Expand all | Expand 10 after
3812 // an Array object or a regular Object so that it can be traversed during 3812 // an Array object or a regular Object so that it can be traversed during
3813 // garbage collection. 3813 // garbage collection.
3814 RawString* MakeExternal(void* array, 3814 RawString* MakeExternal(void* array,
3815 intptr_t length, 3815 intptr_t length,
3816 void* peer, 3816 void* peer,
3817 Dart_PeerFinalizer cback) const; 3817 Dart_PeerFinalizer cback) const;
3818 3818
3819 3819
3820 // Creates a new String object from a C string that is assumed to contain 3820 // Creates a new String object from a C string that is assumed to contain
3821 // UTF-8 encoded characters and '\0' is considered a termination character. 3821 // UTF-8 encoded characters and '\0' is considered a termination character.
3822 // TODO(7123) - Rename this to FromCString(....).
3822 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew); 3823 static RawString* New(const char* cstr, Heap::Space space = Heap::kNew);
3823 3824
3824 // Creates a new String object from an array of UTF-8 encoded characters. 3825 // Creates a new String object from an array of UTF-8 encoded characters.
3825 static RawString* New(const uint8_t* utf8_array, 3826 static RawString* FromUTF8(const uint8_t* utf8_array,
3827 intptr_t array_len,
3828 Heap::Space space = Heap::kNew);
3829
3830 // Creates a new String object from an array of Latin-1 encoded characters.
3831 // TODO(7123) - Rename this to FromLatin1(....).
3832 static RawString* New(const uint8_t* latin1_array,
3826 intptr_t array_len, 3833 intptr_t array_len,
3827 Heap::Space space = Heap::kNew); 3834 Heap::Space space = Heap::kNew);
3828 3835
3829 // Creates a new String object from an array of UTF-16 encoded characters. 3836 // Creates a new String object from an array of UTF-16 encoded characters.
3837 // TODO(7123) - Rename this to FromUTF16(....).
3830 static RawString* New(const uint16_t* utf16_array, 3838 static RawString* New(const uint16_t* utf16_array,
3831 intptr_t array_len, 3839 intptr_t array_len,
3832 Heap::Space space = Heap::kNew); 3840 Heap::Space space = Heap::kNew);
3833 3841
3834 // Creates a new String object from an array of UTF-32 encoded characters. 3842 // Creates a new String object from an array of UTF-32 encoded characters.
3843 // TODO(7123) - Rename this to FromUTF32(....).
3835 static RawString* New(const int32_t* utf32_array, 3844 static RawString* New(const int32_t* utf32_array,
3836 intptr_t array_len, 3845 intptr_t array_len,
3837 Heap::Space space = Heap::kNew); 3846 Heap::Space space = Heap::kNew);
3838 3847
3839 // Create a new String object from another Dart String instance. 3848 // Create a new String object from another Dart String instance.
3840 static RawString* New(const String& str, Heap::Space space = Heap::kNew); 3849 static RawString* New(const String& str, Heap::Space space = Heap::kNew);
3841 3850
3842 // Creates a new External String object using the specified array of 3851 // Creates a new External String object using the specified array of
3843 // UTF-8 encoded characters as the external reference. 3852 // UTF-8 encoded characters as the external reference.
3844 static RawString* NewExternal(const uint8_t* utf8_array, 3853 static RawString* NewExternal(const uint8_t* utf8_array,
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
3909 // heap allocation. 3918 // heap allocation.
3910 raw_ptr()->length_ = Smi::New(value); 3919 raw_ptr()->length_ = Smi::New(value);
3911 } 3920 }
3912 3921
3913 void SetHash(intptr_t value) const { 3922 void SetHash(intptr_t value) const {
3914 // This is only safe because we create a new Smi, which does not cause 3923 // This is only safe because we create a new Smi, which does not cause
3915 // heap allocation. 3924 // heap allocation.
3916 raw_ptr()->hash_ = Smi::New(value); 3925 raw_ptr()->hash_ = Smi::New(value);
3917 } 3926 }
3918 3927
3919 template<typename HandleType, typename ElementType> 3928 template<typename StringType, typename CharacterType>
3920 static void ReadFromImpl(SnapshotReader* reader, 3929 static void ReadFromImpl(SnapshotReader* reader,
3921 String* str_obj, 3930 String* str_obj,
3922 intptr_t len, 3931 intptr_t len,
3923 intptr_t tags, 3932 intptr_t tags,
3924 Snapshot::Kind kind); 3933 Snapshot::Kind kind);
3925 3934
3926 HEAP_OBJECT_IMPLEMENTATION(String, Instance); 3935 HEAP_OBJECT_IMPLEMENTATION(String, Instance);
3927 3936
3928 friend class Class; 3937 friend class Class;
3929 friend class Symbols; 3938 friend class Symbols;
(...skipping 2043 matching lines...) Expand 10 before | Expand all | Expand 10 after
5973 if (this->CharAt(i) != str.CharAt(begin_index + i)) { 5982 if (this->CharAt(i) != str.CharAt(begin_index + i)) {
5974 return false; 5983 return false;
5975 } 5984 }
5976 } 5985 }
5977 return true; 5986 return true;
5978 } 5987 }
5979 5988
5980 } // namespace dart 5989 } // namespace dart
5981 5990
5982 #endif // VM_OBJECT_H_ 5991 #endif // VM_OBJECT_H_
OLDNEW
« no previous file with comments | « vm/double_conversion.cc ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698