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 2222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2233 const char* prefix, | 2233 const char* prefix, |
2234 intptr_t prefix_length, | 2234 intptr_t prefix_length, |
2235 const String& accessor_name) { | 2235 const String& accessor_name) { |
2236 intptr_t name_len = name.Length(); | 2236 intptr_t name_len = name.Length(); |
2237 intptr_t accessor_name_len = accessor_name.Length(); | 2237 intptr_t accessor_name_len = accessor_name.Length(); |
2238 | 2238 |
2239 if (name_len != (accessor_name_len + prefix_length)) { | 2239 if (name_len != (accessor_name_len + prefix_length)) { |
2240 return false; | 2240 return false; |
2241 } | 2241 } |
2242 for (intptr_t i = 0; i < prefix_length; i++) { | 2242 for (intptr_t i = 0; i < prefix_length; i++) { |
2243 if (name.CharAt(i) != static_cast<int32_t>(prefix[i])) { | 2243 if (name.CharAt(i) != prefix[i]) { |
2244 return false; | 2244 return false; |
2245 } | 2245 } |
2246 } | 2246 } |
2247 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) { | 2247 for (intptr_t i = 0, j = prefix_length; i < accessor_name_len; i++, j++) { |
2248 if (name.CharAt(j) != accessor_name.CharAt(i)) { | 2248 if (name.CharAt(j) != accessor_name.CharAt(i)) { |
2249 return false; | 2249 return false; |
2250 } | 2250 } |
2251 } | 2251 } |
2252 return true; | 2252 return true; |
2253 } | 2253 } |
(...skipping 6947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9201 | 9201 |
9202 | 9202 |
9203 const char* Integer::ToCString() const { | 9203 const char* Integer::ToCString() const { |
9204 // Integer is an interface. No instances of Integer should exist. | 9204 // Integer is an interface. No instances of Integer should exist. |
9205 UNREACHABLE(); | 9205 UNREACHABLE(); |
9206 return "Integer"; | 9206 return "Integer"; |
9207 } | 9207 } |
9208 | 9208 |
9209 | 9209 |
9210 RawInteger* Integer::New(const String& str, Heap::Space space) { | 9210 RawInteger* Integer::New(const String& str, Heap::Space space) { |
9211 // We are not supposed to have integers represented as two byte strings. | 9211 // We are not supposed to have integers represented as two byte or |
| 9212 // four byte strings. |
9212 ASSERT(str.IsOneByteString()); | 9213 ASSERT(str.IsOneByteString()); |
9213 int64_t value; | 9214 int64_t value; |
9214 if (!OS::StringToInt64(str.ToCString(), &value)) { | 9215 if (!OS::StringToInt64(str.ToCString(), &value)) { |
9215 const Bigint& big = Bigint::Handle(Bigint::New(str, space)); | 9216 const Bigint& big = Bigint::Handle(Bigint::New(str, space)); |
9216 ASSERT(!BigintOperations::FitsIntoSmi(big)); | 9217 ASSERT(!BigintOperations::FitsIntoSmi(big)); |
9217 ASSERT(!BigintOperations::FitsIntoMint(big)); | 9218 ASSERT(!BigintOperations::FitsIntoMint(big)); |
9218 return big.raw(); | 9219 return big.raw(); |
9219 } | 9220 } |
9220 return Integer::New(value, space); | 9221 return Integer::New(value, space); |
9221 } | 9222 } |
(...skipping 742 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
9964 intptr_t String::Hash(const uint8_t* characters, intptr_t len) { | 9965 intptr_t String::Hash(const uint8_t* characters, intptr_t len) { |
9965 return HashImpl(characters, len); | 9966 return HashImpl(characters, len); |
9966 } | 9967 } |
9967 | 9968 |
9968 | 9969 |
9969 intptr_t String::Hash(const uint16_t* characters, intptr_t len) { | 9970 intptr_t String::Hash(const uint16_t* characters, intptr_t len) { |
9970 return HashImpl(characters, len); | 9971 return HashImpl(characters, len); |
9971 } | 9972 } |
9972 | 9973 |
9973 | 9974 |
9974 intptr_t String::Hash(const int32_t* characters, intptr_t len) { | 9975 intptr_t String::Hash(const uint32_t* characters, intptr_t len) { |
9975 return HashImpl(characters, len); | 9976 return HashImpl(characters, len); |
9976 } | 9977 } |
9977 | 9978 |
9978 | 9979 |
9979 int32_t String::CharAt(intptr_t index) const { | 9980 int32_t String::CharAt(intptr_t index) const { |
9980 intptr_t class_id = raw()->GetClassId(); | 9981 intptr_t class_id = raw()->GetClassId(); |
9981 ASSERT(RawObject::IsStringClassId(class_id)); | 9982 ASSERT(RawObject::IsStringClassId(class_id)); |
9982 NoGCScope no_gc; | 9983 NoGCScope no_gc; |
9983 if (class_id == kOneByteStringCid) { | 9984 if (class_id == kOneByteStringCid) { |
9984 return *OneByteString::CharAddr(*this, index); | 9985 return *OneByteString::CharAddr(*this, index); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10040 for (intptr_t i = 0; i < this->Length(); ++i) { | 10041 for (intptr_t i = 0; i < this->Length(); ++i) { |
10041 if (*utf8_array == '\0') { | 10042 if (*utf8_array == '\0') { |
10042 // Lengths don't match. | 10043 // Lengths don't match. |
10043 return false; | 10044 return false; |
10044 } | 10045 } |
10045 int32_t ch; | 10046 int32_t ch; |
10046 intptr_t consumed = Utf8::Decode( | 10047 intptr_t consumed = Utf8::Decode( |
10047 reinterpret_cast<const uint8_t*>(utf8_array), | 10048 reinterpret_cast<const uint8_t*>(utf8_array), |
10048 len, | 10049 len, |
10049 &ch); | 10050 &ch); |
10050 if (consumed == 0) return false; | 10051 if (consumed == 0 || this->CharAt(i) != ch) { |
10051 | 10052 return false; |
10052 if (ch <= Utf16::kMaxCodeUnit) { | |
10053 if (this->CharAt(i) != ch) return false; | |
10054 } else { | |
10055 if (Utf16::CodePointAt(*this, i) != ch) return false; | |
10056 i++; | |
10057 } | 10053 } |
10058 utf8_array += consumed; | 10054 utf8_array += consumed; |
10059 len -= consumed; | 10055 len -= consumed; |
10060 } | 10056 } |
10061 return *utf8_array == '\0'; | 10057 return *utf8_array == '\0'; |
10062 } | 10058 } |
10063 | 10059 |
10064 | 10060 |
10065 bool String::Equals(const uint8_t* latin1_array, intptr_t len) const { | 10061 bool String::Equals(const uint8_t* latin1_array, intptr_t len) const { |
10066 if (len != this->Length()) { | 10062 if (len != this->Length()) { |
(...skipping 18 matching lines...) Expand all Loading... |
10085 | 10081 |
10086 for (intptr_t i = 0; i < len; i++) { | 10082 for (intptr_t i = 0; i < len; i++) { |
10087 if (this->CharAt(i) != utf16_array[i]) { | 10083 if (this->CharAt(i) != utf16_array[i]) { |
10088 return false; | 10084 return false; |
10089 } | 10085 } |
10090 } | 10086 } |
10091 return true; | 10087 return true; |
10092 } | 10088 } |
10093 | 10089 |
10094 | 10090 |
| 10091 bool String::Equals(const uint32_t* utf32_array, intptr_t len) const { |
| 10092 CodePointIterator it(*this); |
| 10093 intptr_t i = 0; |
| 10094 while (it.Next()) { |
| 10095 if (it.Current() != static_cast<int32_t>(utf32_array[i])) { |
| 10096 return false; |
| 10097 } |
| 10098 ++i; |
| 10099 } |
| 10100 if (i != len) { |
| 10101 return false; |
| 10102 } |
| 10103 return true; |
| 10104 } |
| 10105 |
| 10106 |
10095 intptr_t String::CompareTo(const String& other) const { | 10107 intptr_t String::CompareTo(const String& other) const { |
10096 const intptr_t this_len = this->Length(); | 10108 const intptr_t this_len = this->Length(); |
10097 const intptr_t other_len = other.IsNull() ? 0 : other.Length(); | 10109 const intptr_t other_len = other.IsNull() ? 0 : other.Length(); |
10098 const intptr_t len = (this_len < other_len) ? this_len : other_len; | 10110 const intptr_t len = (this_len < other_len) ? this_len : other_len; |
10099 // UTF-16 has the high surrogate before the low surrogate so we can compare | |
10100 // one code unit at a time for efficiency and still get the right ordering. | |
10101 for (intptr_t i = 0; i < len; i++) { | 10111 for (intptr_t i = 0; i < len; i++) { |
10102 int32_t this_code_unit = this->CharAt(i); | 10112 int32_t this_code_point = this->CharAt(i); |
10103 int32_t other_code_unit = other.CharAt(i); | 10113 int32_t other_code_point = other.CharAt(i); |
10104 if (this_code_unit < other_code_unit) { | 10114 if (this_code_point < other_code_point) { |
10105 return -1; | 10115 return -1; |
10106 } | 10116 } |
10107 if (this_code_unit > other_code_unit) { | 10117 if (this_code_point > other_code_point) { |
10108 return 1; | 10118 return 1; |
10109 } | 10119 } |
10110 } | 10120 } |
10111 if (this_len < other_len) return -1; | 10121 if (this_len < other_len) return -1; |
10112 if (this_len > other_len) return 1; | 10122 if (this_len > other_len) return 1; |
10113 return 0; | 10123 return 0; |
10114 } | 10124 } |
10115 | 10125 |
10116 | 10126 |
10117 bool String::StartsWith(const String& other) const { | 10127 bool String::StartsWith(const String& other) const { |
(...skipping 23 matching lines...) Expand all Loading... |
10141 intptr_t array_len = strlen(str); | 10151 intptr_t array_len = strlen(str); |
10142 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str); | 10152 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(str); |
10143 return String::New(utf8_array, array_len, space); | 10153 return String::New(utf8_array, array_len, space); |
10144 } | 10154 } |
10145 | 10155 |
10146 | 10156 |
10147 RawString* String::New(const uint8_t* utf8_array, | 10157 RawString* String::New(const uint8_t* utf8_array, |
10148 intptr_t array_len, | 10158 intptr_t array_len, |
10149 Heap::Space space) { | 10159 Heap::Space space) { |
10150 Utf8::Type type; | 10160 Utf8::Type type; |
10151 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); | 10161 intptr_t len = Utf8::CodePointCount(utf8_array, array_len, &type); |
10152 if (type == Utf8::kLatin1) { | 10162 if (type == Utf8::kLatin1) { |
10153 const String& strobj = String::Handle(OneByteString::New(len, space)); | 10163 const String& strobj = String::Handle(OneByteString::New(len, space)); |
10154 if (len > 0) { | 10164 if (len > 0) { |
10155 NoGCScope no_gc; | 10165 NoGCScope no_gc; |
10156 Utf8::DecodeToLatin1(utf8_array, array_len, | 10166 Utf8::DecodeToLatin1(utf8_array, array_len, |
10157 OneByteString::CharAddr(strobj, 0), len); | 10167 OneByteString::CharAddr(strobj, 0), len); |
10158 } | 10168 } |
10159 return strobj.raw(); | 10169 return strobj.raw(); |
10160 } | 10170 } |
10161 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); | 10171 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); |
(...skipping 15 matching lines...) Expand all Loading... |
10177 break; | 10187 break; |
10178 } | 10188 } |
10179 } | 10189 } |
10180 if (is_one_byte_string) { | 10190 if (is_one_byte_string) { |
10181 return OneByteString::New(utf16_array, array_len, space); | 10191 return OneByteString::New(utf16_array, array_len, space); |
10182 } | 10192 } |
10183 return TwoByteString::New(utf16_array, array_len, space); | 10193 return TwoByteString::New(utf16_array, array_len, space); |
10184 } | 10194 } |
10185 | 10195 |
10186 | 10196 |
10187 RawString* String::New(const int32_t* utf32_array, | 10197 RawString* String::New(const uint32_t* utf32_array, |
10188 intptr_t array_len, | 10198 intptr_t array_len, |
10189 Heap::Space space) { | 10199 Heap::Space space) { |
10190 bool is_one_byte_string = true; | 10200 bool is_one_byte_string = true; |
10191 intptr_t utf16_len = array_len; | 10201 intptr_t utf16_len = array_len; |
10192 for (intptr_t i = 0; i < array_len; ++i) { | 10202 for (intptr_t i = 0; i < array_len; ++i) { |
10193 if (utf32_array[i] > 0xFF) { | 10203 if (utf32_array[i] > 0xFF) { |
10194 is_one_byte_string = false; | 10204 is_one_byte_string = false; |
10195 } | 10205 } |
10196 if (utf32_array[i] > 0xFFFF) { | 10206 if (utf32_array[i] > 0xFFFF) { |
10197 utf16_len += 1; | 10207 utf16_len += 1; |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10542 return this->raw(); | 10552 return this->raw(); |
10543 } | 10553 } |
10544 | 10554 |
10545 | 10555 |
10546 RawString* String::Transform(int32_t (*mapping)(int32_t ch), | 10556 RawString* String::Transform(int32_t (*mapping)(int32_t ch), |
10547 const String& str, | 10557 const String& str, |
10548 Heap::Space space) { | 10558 Heap::Space space) { |
10549 ASSERT(!str.IsNull()); | 10559 ASSERT(!str.IsNull()); |
10550 bool has_mapping = false; | 10560 bool has_mapping = false; |
10551 int32_t dst_max = 0; | 10561 int32_t dst_max = 0; |
10552 intptr_t out_len = 0; | |
10553 CodePointIterator it(str); | 10562 CodePointIterator it(str); |
10554 while (it.Next()) { | 10563 while (it.Next()) { |
10555 int32_t src = it.Current(); | 10564 int32_t src = it.Current(); |
10556 int32_t dst = mapping(src); | 10565 int32_t dst = mapping(src); |
10557 if (src != dst) { | 10566 if (src != dst) { |
10558 has_mapping = true; | 10567 has_mapping = true; |
10559 } | 10568 } |
10560 dst_max = Utils::Maximum(dst_max, dst); | 10569 dst_max = Utils::Maximum(dst_max, dst); |
10561 out_len += dst > Utf16::kMaxBmpCodepoint ? 2 : 1; | |
10562 } | 10570 } |
10563 if (!has_mapping) { | 10571 if (!has_mapping) { |
10564 return str.raw(); | 10572 return str.raw(); |
10565 } | 10573 } |
10566 if (dst_max <= 0xFF) { | 10574 if (dst_max <= 0xFF) { |
10567 return OneByteString::Transform(mapping, str, out_len, space); | 10575 return OneByteString::Transform(mapping, str, space); |
10568 } | 10576 } |
10569 ASSERT(dst_max > 0xFF); | 10577 ASSERT(dst_max > 0xFF); |
10570 return TwoByteString::Transform(mapping, str, out_len, space); | 10578 return TwoByteString::Transform(mapping, str, space); |
10571 } | 10579 } |
10572 | 10580 |
10573 | 10581 |
10574 RawString* String::ToUpperCase(const String& str, Heap::Space space) { | 10582 RawString* String::ToUpperCase(const String& str, Heap::Space space) { |
10575 // TODO(cshapiro): create a fast-path for OneByteString instances. | 10583 // TODO(cshapiro): create a fast-path for OneByteString instances. |
10576 return Transform(CaseMapping::ToUpper, str, space); | 10584 return Transform(CaseMapping::ToUpper, str, space); |
10577 } | 10585 } |
10578 | 10586 |
10579 | 10587 |
10580 RawString* String::ToLowerCase(const String& str, Heap::Space space) { | 10588 RawString* String::ToLowerCase(const String& str, Heap::Space space) { |
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10733 Heap::Space space) { | 10741 Heap::Space space) { |
10734 const String& result =String::Handle(OneByteString::New(len, space)); | 10742 const String& result =String::Handle(OneByteString::New(len, space)); |
10735 for (intptr_t i = 0; i < len; ++i) { | 10743 for (intptr_t i = 0; i < len; ++i) { |
10736 ASSERT(characters[i] <= 0xFF); | 10744 ASSERT(characters[i] <= 0xFF); |
10737 *CharAddr(result, i) = characters[i]; | 10745 *CharAddr(result, i) = characters[i]; |
10738 } | 10746 } |
10739 return OneByteString::raw(result); | 10747 return OneByteString::raw(result); |
10740 } | 10748 } |
10741 | 10749 |
10742 | 10750 |
10743 RawOneByteString* OneByteString::New(const int32_t* characters, | 10751 RawOneByteString* OneByteString::New(const uint32_t* characters, |
10744 intptr_t len, | 10752 intptr_t len, |
10745 Heap::Space space) { | 10753 Heap::Space space) { |
10746 const String& result = String::Handle(OneByteString::New(len, space)); | 10754 const String& result = String::Handle(OneByteString::New(len, space)); |
10747 for (intptr_t i = 0; i < len; ++i) { | 10755 for (intptr_t i = 0; i < len; ++i) { |
10748 ASSERT(characters[i] <= 0xFF); | 10756 ASSERT(characters[i] <= 0xFF); |
10749 *CharAddr(result, i) = characters[i]; | 10757 *CharAddr(result, i) = characters[i]; |
10750 } | 10758 } |
10751 return OneByteString::raw(result); | 10759 return OneByteString::raw(result); |
10752 } | 10760 } |
10753 | 10761 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10786 intptr_t str_len = str.Length(); | 10794 intptr_t str_len = str.Length(); |
10787 String::Copy(result, pos, str, 0, str_len); | 10795 String::Copy(result, pos, str, 0, str_len); |
10788 pos += str_len; | 10796 pos += str_len; |
10789 } | 10797 } |
10790 return OneByteString::raw(result); | 10798 return OneByteString::raw(result); |
10791 } | 10799 } |
10792 | 10800 |
10793 | 10801 |
10794 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), | 10802 RawOneByteString* OneByteString::Transform(int32_t (*mapping)(int32_t ch), |
10795 const String& str, | 10803 const String& str, |
10796 intptr_t out_length, | |
10797 Heap::Space space) { | 10804 Heap::Space space) { |
10798 ASSERT(!str.IsNull()); | 10805 ASSERT(!str.IsNull()); |
10799 intptr_t len = str.Length(); | 10806 intptr_t len = str.Length(); |
10800 const String& result = | 10807 const String& result = String::Handle(OneByteString::New(len, space)); |
10801 String::Handle(OneByteString::New(out_length, space)); | 10808 for (intptr_t i = 0; i < len; ++i) { |
10802 for (intptr_t i = 0, j = 0; i < len; ++i, j++) { | 10809 int32_t ch = mapping(str.CharAt(i)); |
10803 int32_t old_ch = str.CharAt(i); | 10810 ASSERT(ch >= 0 && ch <= 0xFF); |
10804 if (old_ch > Utf16::kMaxCodeUnit) i++; | 10811 *CharAddr(result, i) = ch; |
10805 int32_t ch = mapping(old_ch); | |
10806 ASSERT(ch <= 0xFF); | |
10807 *CharAddr(result, j) = ch; | |
10808 } | 10812 } |
10809 return OneByteString::raw(result); | 10813 return OneByteString::raw(result); |
10810 } | 10814 } |
10811 | 10815 |
10812 | 10816 |
10813 RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str, | 10817 RawTwoByteString* TwoByteString::EscapeSpecialCharacters(const String& str, |
10814 bool raw_str) { | 10818 bool raw_str) { |
10815 intptr_t len = str.Length(); | 10819 intptr_t len = str.Length(); |
10816 if (len > 0) { | 10820 if (len > 0) { |
10817 intptr_t num_escapes = 0; | 10821 intptr_t num_escapes = 0; |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10872 const String& result = String::Handle(TwoByteString::New(array_len, space)); | 10876 const String& result = String::Handle(TwoByteString::New(array_len, space)); |
10873 { | 10877 { |
10874 NoGCScope no_gc; | 10878 NoGCScope no_gc; |
10875 memmove(CharAddr(result, 0), utf16_array, (array_len * 2)); | 10879 memmove(CharAddr(result, 0), utf16_array, (array_len * 2)); |
10876 } | 10880 } |
10877 return TwoByteString::raw(result); | 10881 return TwoByteString::raw(result); |
10878 } | 10882 } |
10879 | 10883 |
10880 | 10884 |
10881 RawTwoByteString* TwoByteString::New(intptr_t utf16_len, | 10885 RawTwoByteString* TwoByteString::New(intptr_t utf16_len, |
10882 const int32_t* utf32_array, | 10886 const uint32_t* utf32_array, |
10883 intptr_t array_len, | 10887 intptr_t array_len, |
10884 Heap::Space space) { | 10888 Heap::Space space) { |
10885 ASSERT((array_len > 0) && (utf16_len >= array_len)); | 10889 ASSERT((array_len > 0) && (utf16_len >= array_len)); |
10886 const String& result = String::Handle(TwoByteString::New(utf16_len, space)); | 10890 const String& result = String::Handle(TwoByteString::New(utf16_len, space)); |
10887 { | 10891 { |
10888 NoGCScope no_gc; | 10892 NoGCScope no_gc; |
10889 intptr_t j = 0; | 10893 intptr_t j = 0; |
10890 for (intptr_t i = 0; i < array_len; ++i) { | 10894 for (intptr_t i = 0; i < array_len; ++i) { |
10891 int32_t code_point = utf32_array[i]; | 10895 if (utf32_array[i] > 0xffff) { |
10892 if (code_point > Utf16::kMaxCodeUnit) { | |
10893 ASSERT(j < (utf16_len - 1)); | 10896 ASSERT(j < (utf16_len - 1)); |
10894 Utf16::Encode(utf32_array[i], CharAddr(result, j)); | 10897 Utf16::Encode(utf32_array[i], CharAddr(result, j)); |
10895 j += 2; | 10898 j += 2; |
10896 } else { | 10899 } else { |
10897 ASSERT(j < utf16_len); | 10900 ASSERT(j < utf16_len); |
10898 *CharAddr(result, j) = utf32_array[i]; | 10901 *CharAddr(result, j) = utf32_array[i]; |
10899 j += 1; | 10902 j += 1; |
10900 } | 10903 } |
10901 } | 10904 } |
10902 } | 10905 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10938 intptr_t str_len = str.Length(); | 10941 intptr_t str_len = str.Length(); |
10939 String::Copy(result, pos, str, 0, str_len); | 10942 String::Copy(result, pos, str, 0, str_len); |
10940 pos += str_len; | 10943 pos += str_len; |
10941 } | 10944 } |
10942 return TwoByteString::raw(result); | 10945 return TwoByteString::raw(result); |
10943 } | 10946 } |
10944 | 10947 |
10945 | 10948 |
10946 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), | 10949 RawTwoByteString* TwoByteString::Transform(int32_t (*mapping)(int32_t ch), |
10947 const String& str, | 10950 const String& str, |
10948 intptr_t out_length, | |
10949 Heap::Space space) { | 10951 Heap::Space space) { |
10950 ASSERT(!str.IsNull()); | 10952 ASSERT(!str.IsNull()); |
10951 intptr_t len = str.Length(); | 10953 intptr_t len = str.Length(); |
10952 const String& result = String::Handle(TwoByteString::New(len, space)); | 10954 const String& result = String::Handle(TwoByteString::New(len, space)); |
10953 String::CodePointIterator it(str); | 10955 String::CodePointIterator it(str); |
10954 intptr_t i = 0; | 10956 intptr_t i = 0; |
10955 while (it.Next()) { | 10957 while (it.Next()) { |
10956 int32_t src = it.Current(); | 10958 int32_t src = it.Current(); |
10957 int32_t dst = mapping(src); | 10959 int32_t dst = mapping(src); |
10958 ASSERT(dst >= 0 && dst <= 0x10FFFF); | 10960 ASSERT(dst >= 0 && dst <= 0x10FFFF); |
(...skipping 1200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
12159 } | 12161 } |
12160 return result.raw(); | 12162 return result.raw(); |
12161 } | 12163 } |
12162 | 12164 |
12163 | 12165 |
12164 const char* WeakProperty::ToCString() const { | 12166 const char* WeakProperty::ToCString() const { |
12165 return "_WeakProperty"; | 12167 return "_WeakProperty"; |
12166 } | 12168 } |
12167 | 12169 |
12168 } // namespace dart | 12170 } // namespace dart |
OLD | NEW |