| 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 #include "vm/object.h" | 5 #include "vm/object.h" |
| 6 | 6 |
| 7 #include "include/dart_api.h" | 7 #include "include/dart_api.h" |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/assembler.h" | 9 #include "vm/assembler.h" |
| 10 #include "vm/bigint_operations.h" | 10 #include "vm/bigint_operations.h" |
| (...skipping 10064 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10075 } | 10075 } |
| 10076 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); | 10076 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); |
| 10077 const String& strobj = String::Handle(TwoByteString::New(len, space)); | 10077 const String& strobj = String::Handle(TwoByteString::New(len, space)); |
| 10078 NoGCScope no_gc; | 10078 NoGCScope no_gc; |
| 10079 Utf8::DecodeToUTF16(utf8_array, array_len, | 10079 Utf8::DecodeToUTF16(utf8_array, array_len, |
| 10080 TwoByteString::CharAddr(strobj, 0), len); | 10080 TwoByteString::CharAddr(strobj, 0), len); |
| 10081 return strobj.raw(); | 10081 return strobj.raw(); |
| 10082 } | 10082 } |
| 10083 | 10083 |
| 10084 | 10084 |
| 10085 RawString* String::New(const uint8_t* latin1_array, | 10085 RawString* String::FromLatin1(const uint8_t* latin1_array, |
| 10086 intptr_t array_len, | 10086 intptr_t array_len, |
| 10087 Heap::Space space) { | 10087 Heap::Space space) { |
| 10088 return OneByteString::New(latin1_array, array_len, space); | 10088 return OneByteString::New(latin1_array, array_len, space); |
| 10089 } | 10089 } |
| 10090 | 10090 |
| 10091 | 10091 |
| 10092 RawString* String::New(const uint16_t* utf16_array, | 10092 RawString* String::FromUTF16(const uint16_t* utf16_array, |
| 10093 intptr_t array_len, | 10093 intptr_t array_len, |
| 10094 Heap::Space space) { | 10094 Heap::Space space) { |
| 10095 bool is_one_byte_string = true; | 10095 bool is_one_byte_string = true; |
| 10096 for (intptr_t i = 0; i < array_len; ++i) { | 10096 for (intptr_t i = 0; i < array_len; ++i) { |
| 10097 if (!Utf::IsLatin1(utf16_array[i])) { | 10097 if (!Utf::IsLatin1(utf16_array[i])) { |
| 10098 is_one_byte_string = false; | 10098 is_one_byte_string = false; |
| 10099 break; | 10099 break; |
| 10100 } | 10100 } |
| 10101 } | 10101 } |
| 10102 if (is_one_byte_string) { | 10102 if (is_one_byte_string) { |
| 10103 return OneByteString::New(utf16_array, array_len, space); | 10103 return OneByteString::New(utf16_array, array_len, space); |
| 10104 } | 10104 } |
| 10105 return TwoByteString::New(utf16_array, array_len, space); | 10105 return TwoByteString::New(utf16_array, array_len, space); |
| 10106 } | 10106 } |
| 10107 | 10107 |
| 10108 | 10108 |
| 10109 RawString* String::New(const int32_t* utf32_array, | 10109 RawString* String::FromUTF32(const int32_t* utf32_array, |
| 10110 intptr_t array_len, | 10110 intptr_t array_len, |
| 10111 Heap::Space space) { | 10111 Heap::Space space) { |
| 10112 bool is_one_byte_string = true; | 10112 bool is_one_byte_string = true; |
| 10113 intptr_t utf16_len = array_len; | 10113 intptr_t utf16_len = array_len; |
| 10114 for (intptr_t i = 0; i < array_len; ++i) { | 10114 for (intptr_t i = 0; i < array_len; ++i) { |
| 10115 if (!Utf::IsLatin1(utf32_array[i])) { | 10115 if (!Utf::IsLatin1(utf32_array[i])) { |
| 10116 is_one_byte_string = false; | 10116 is_one_byte_string = false; |
| 10117 if (Utf::IsSupplementary(utf32_array[i])) { | 10117 if (Utf::IsSupplementary(utf32_array[i])) { |
| 10118 utf16_len += 1; | 10118 utf16_len += 1; |
| 10119 } | 10119 } |
| 10120 } | 10120 } |
| 10121 } | 10121 } |
| (...skipping 1997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12119 } | 12119 } |
| 12120 return result.raw(); | 12120 return result.raw(); |
| 12121 } | 12121 } |
| 12122 | 12122 |
| 12123 | 12123 |
| 12124 const char* WeakProperty::ToCString() const { | 12124 const char* WeakProperty::ToCString() const { |
| 12125 return "_WeakProperty"; | 12125 return "_WeakProperty"; |
| 12126 } | 12126 } |
| 12127 | 12127 |
| 12128 } // namespace dart | 12128 } // namespace dart |
| OLD | NEW |