| 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 10033 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10044 | 10044 |
| 10045 | 10045 |
| 10046 RawInstance* String::Canonicalize() const { | 10046 RawInstance* String::Canonicalize() const { |
| 10047 if (IsCanonical()) { | 10047 if (IsCanonical()) { |
| 10048 return this->raw(); | 10048 return this->raw(); |
| 10049 } | 10049 } |
| 10050 return Symbols::New(*this); | 10050 return Symbols::New(*this); |
| 10051 } | 10051 } |
| 10052 | 10052 |
| 10053 | 10053 |
| 10054 RawString* String::New(const char* str, Heap::Space space) { | 10054 RawString* String::New(const char* cstr, Heap::Space space) { |
| 10055 ASSERT(str != NULL); | 10055 ASSERT(cstr != NULL); |
| 10056 intptr_t array_len = strlen(str); | 10056 intptr_t array_len = strlen(cstr); |
| 10057 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str); | 10057 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr); |
| 10058 return String::New(utf8_array, array_len, space); | 10058 return String::FromUTF8(utf8_array, array_len, space); |
| 10059 } | 10059 } |
| 10060 | 10060 |
| 10061 | 10061 |
| 10062 RawString* String::New(const uint8_t* utf8_array, | 10062 RawString* String::FromUTF8(const uint8_t* utf8_array, |
| 10063 intptr_t array_len, | 10063 intptr_t array_len, |
| 10064 Heap::Space space) { | 10064 Heap::Space space) { |
| 10065 Utf8::Type type; | 10065 Utf8::Type type; |
| 10066 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); | 10066 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); |
| 10067 if (type == Utf8::kLatin1) { | 10067 if (type == Utf8::kLatin1) { |
| 10068 const String& strobj = String::Handle(OneByteString::New(len, space)); | 10068 const String& strobj = String::Handle(OneByteString::New(len, space)); |
| 10069 if (len > 0) { | 10069 if (len > 0) { |
| 10070 NoGCScope no_gc; | 10070 NoGCScope no_gc; |
| 10071 Utf8::DecodeToLatin1(utf8_array, array_len, | 10071 Utf8::DecodeToLatin1(utf8_array, array_len, |
| 10072 OneByteString::CharAddr(strobj, 0), len); | 10072 OneByteString::CharAddr(strobj, 0), len); |
| 10073 } | 10073 } |
| 10074 return strobj.raw(); | 10074 return strobj.raw(); |
| 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, |
| 10086 intptr_t array_len, |
| 10087 Heap::Space space) { |
| 10088 return OneByteString::New(latin1_array, array_len, space); |
| 10089 } |
| 10090 |
| 10091 |
| 10085 RawString* String::New(const uint16_t* utf16_array, | 10092 RawString* String::New(const uint16_t* utf16_array, |
| 10086 intptr_t array_len, | 10093 intptr_t array_len, |
| 10087 Heap::Space space) { | 10094 Heap::Space space) { |
| 10088 bool is_one_byte_string = true; | 10095 bool is_one_byte_string = true; |
| 10089 for (intptr_t i = 0; i < array_len; ++i) { | 10096 for (intptr_t i = 0; i < array_len; ++i) { |
| 10090 if (!Utf::IsLatin1(utf16_array[i])) { | 10097 if (!Utf::IsLatin1(utf16_array[i])) { |
| 10091 is_one_byte_string = false; | 10098 is_one_byte_string = false; |
| 10092 break; | 10099 break; |
| 10093 } | 10100 } |
| 10094 } | 10101 } |
| (...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 12083 } | 12090 } |
| 12084 return result.raw(); | 12091 return result.raw(); |
| 12085 } | 12092 } |
| 12086 | 12093 |
| 12087 | 12094 |
| 12088 const char* WeakProperty::ToCString() const { | 12095 const char* WeakProperty::ToCString() const { |
| 12089 return "_WeakProperty"; | 12096 return "_WeakProperty"; |
| 12090 } | 12097 } |
| 12091 | 12098 |
| 12092 } // namespace dart | 12099 } // namespace dart |
| OLD | NEW |