| 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/isolate.h" | 9 #include "vm/isolate.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 void Symbols::Add(const Array& symbol_table, const String& str) { | 144 void Symbols::Add(const Array& symbol_table, const String& str) { |
| 145 // Should only be run by the vm isolate. | 145 // Should only be run by the vm isolate. |
| 146 ASSERT(Isolate::Current() == Dart::vm_isolate()); | 146 ASSERT(Isolate::Current() == Dart::vm_isolate()); |
| 147 intptr_t hash = str.Hash(); | 147 intptr_t hash = str.Hash(); |
| 148 intptr_t index = FindIndex(symbol_table, str, 0, str.Length(), hash); | 148 intptr_t index = FindIndex(symbol_table, str, 0, str.Length(), hash); |
| 149 ASSERT(symbol_table.At(index) == String::null()); | 149 ASSERT(symbol_table.At(index) == String::null()); |
| 150 InsertIntoSymbolTable(symbol_table, str, index); | 150 InsertIntoSymbolTable(symbol_table, str, index); |
| 151 } | 151 } |
| 152 | 152 |
| 153 | 153 |
| 154 RawString* Symbols::New(const char* cstr) { | 154 RawString* Symbols::New(const char* cstr, intptr_t len) { |
| 155 ASSERT(cstr != NULL); | 155 ASSERT((cstr != NULL) && (len >= 0)); |
| 156 intptr_t array_len = strlen(cstr); | |
| 157 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr); | 156 const uint8_t* utf8_array = reinterpret_cast<const uint8_t*>(cstr); |
| 158 return Symbols::FromUTF8(utf8_array, array_len); | 157 return Symbols::FromUTF8(utf8_array, len); |
| 159 } | 158 } |
| 160 | 159 |
| 161 | 160 |
| 162 RawString* Symbols::FromUTF8(const uint8_t* utf8_array, intptr_t array_len) { | 161 RawString* Symbols::FromUTF8(const uint8_t* utf8_array, intptr_t array_len) { |
| 163 if (array_len == 0 || utf8_array == NULL) { | 162 if (array_len == 0 || utf8_array == NULL) { |
| 164 return FromLatin1(reinterpret_cast<uint8_t*>(NULL), 0); | 163 return FromLatin1(reinterpret_cast<uint8_t*>(NULL), 0); |
| 165 } | 164 } |
| 166 Utf8::Type type; | 165 Utf8::Type type; |
| 167 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); | 166 intptr_t len = Utf8::CodeUnitCount(utf8_array, array_len, &type); |
| 168 ASSERT(len != 0); | 167 ASSERT(len != 0); |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { | 473 RawObject* Symbols::GetVMSymbol(intptr_t object_id) { |
| 475 ASSERT(IsVMSymbolId(object_id)); | 474 ASSERT(IsVMSymbolId(object_id)); |
| 476 intptr_t i = (object_id - kMaxPredefinedObjectIds); | 475 intptr_t i = (object_id - kMaxPredefinedObjectIds); |
| 477 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { | 476 if ((i > kIllegal) && (i < Symbols::kMaxPredefinedId)) { |
| 478 return symbol_handles_[i]->raw(); | 477 return symbol_handles_[i]->raw(); |
| 479 } | 478 } |
| 480 return Object::null(); | 479 return Object::null(); |
| 481 } | 480 } |
| 482 | 481 |
| 483 } // namespace dart | 482 } // namespace dart |
| OLD | NEW |