| 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/symbols.h" | 5 #include "vm/symbols.h" |
| 6 | 6 |
| 7 #include "vm/handles.h" | 7 #include "vm/handles.h" |
| 8 #include "vm/handles_impl.h" | 8 #include "vm/handles_impl.h" |
| 9 #include "vm/hash_table.h" | 9 #include "vm/hash_table.h" |
| 10 #include "vm/isolate.h" | 10 #include "vm/isolate.h" |
| (...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 343 } | 343 } |
| 344 | 344 |
| 345 | 345 |
| 346 RawString* Symbols::FromUTF8(const uint8_t* utf8_array, intptr_t array_len) { | 346 RawString* Symbols::FromUTF8(const uint8_t* utf8_array, intptr_t array_len) { |
| 347 if (array_len == 0 || utf8_array == NULL) { | 347 if (array_len == 0 || utf8_array == NULL) { |
| 348 return FromLatin1(reinterpret_cast<uint8_t*>(NULL), 0); | 348 return FromLatin1(reinterpret_cast<uint8_t*>(NULL), 0); |
| 349 } | 349 } |
| 350 Utf8::Type type; | 350 Utf8::Type type; |
| 351 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); | 351 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); |
| 352 ASSERT(len != 0); | 352 ASSERT(len != 0); |
| 353 Zone* zone = Isolate::Current()->current_zone(); | 353 Zone* zone = Thread::Current()->zone(); |
| 354 if (type == Utf8::kLatin1) { | 354 if (type == Utf8::kLatin1) { |
| 355 uint8_t* characters = zone->Alloc<uint8_t>(len); | 355 uint8_t* characters = zone->Alloc<uint8_t>(len); |
| 356 Utf8::DecodeToLatin1(utf8_array, array_len, characters, len); | 356 Utf8::DecodeToLatin1(utf8_array, array_len, characters, len); |
| 357 return FromLatin1(characters, len); | 357 return FromLatin1(characters, len); |
| 358 } | 358 } |
| 359 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); | 359 ASSERT((type == Utf8::kBMP) || (type == Utf8::kSupplementary)); |
| 360 uint16_t* characters = zone->Alloc<uint16_t>(len); | 360 uint16_t* characters = zone->Alloc<uint16_t>(len); |
| 361 Utf8::DecodeToUTF16(utf8_array, array_len, characters, len); | 361 Utf8::DecodeToUTF16(utf8_array, array_len, characters, len); |
| 362 return FromUTF16(characters, len); | 362 return FromUTF16(characters, len); |
| 363 } | 363 } |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 457 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 457 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 458 ASSERT(IsVMSymbolId(object_id)); | 458 ASSERT(IsVMSymbolId(object_id)); |
| 459 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 459 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 460 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 460 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 461 return symbol_handles_[i]->raw(); | 461 return symbol_handles_[i]->raw(); |
| 462 } | 462 } |
| 463 return Object::null(); | 463 return Object::null(); |
| 464 } | 464 } |
| 465 | 465 |
| 466 } // namespace dart | 466 } // namespace dart |
| OLD | NEW |