| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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/bootstrap_natives.h" | 5 #include "vm/bootstrap_natives.h" |
| 6 | 6 |
| 7 #include "vm/exceptions.h" | 7 #include "vm/exceptions.h" |
| 8 #include "vm/native_entry.h" | 8 #include "vm/native_entry.h" |
| 9 #include "vm/object.h" | 9 #include "vm/object.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| 11 #include "vm/unicode.h" | 11 #include "vm/unicode.h" |
| 12 | 12 |
| 13 namespace dart { | 13 namespace dart { |
| 14 | 14 |
| 15 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { | 15 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
| 16 GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0)); | 16 GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0)); |
| 17 if (!list.IsGrowableObjectArray() && !list.IsArray()) { | 17 if (!list.IsGrowableObjectArray() && !list.IsArray()) { |
| 18 const Array& args = Array::Handle(Array::New(1)); | 18 const Array& args = Array::Handle(Array::New(1)); |
| 19 args.SetAt(0, list); | 19 args.SetAt(0, list); |
| 20 Exceptions::ThrowByType(Exceptions::kArgument, args); | 20 Exceptions::ThrowByType(Exceptions::kArgument, args); |
| 21 } | 21 } |
| 22 // TODO(srdjan): Check that parameterized type is an int. | |
| 23 | 22 |
| 24 Array& a = Array::Handle(); | 23 Array& a = Array::Handle(); |
| 25 intptr_t array_len; | 24 intptr_t array_len; |
| 26 if (list.IsGrowableObjectArray()) { | 25 if (list.IsGrowableObjectArray()) { |
| 27 const GrowableObjectArray& growableArray = GrowableObjectArray::Cast(list); | 26 const GrowableObjectArray& growableArray = GrowableObjectArray::Cast(list); |
| 28 a ^= growableArray.data(); | 27 a ^= growableArray.data(); |
| 29 array_len = growableArray.Length(); | 28 array_len = growableArray.Length(); |
| 30 } else { | 29 } else { |
| 31 a ^= Array::Cast(list).raw(); | 30 a ^= Array::Cast(list).raw(); |
| 32 array_len = a.Length(); | 31 array_len = a.Length(); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) | 228 ? String::Handle(OneByteString::New(length_value, Heap::kNew)) |
| 230 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); | 229 : String::Handle(TwoByteString::New(length_value, Heap::kNew)); |
| 231 NoGCScope no_gc; | 230 NoGCScope no_gc; |
| 232 | 231 |
| 233 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); | 232 uint16_t* data_position = reinterpret_cast<uint16_t*>(codeUnits.DataAddr(0)); |
| 234 String::Copy(result, 0, data_position, length_value); | 233 String::Copy(result, 0, data_position, length_value); |
| 235 return result.raw(); | 234 return result.raw(); |
| 236 } | 235 } |
| 237 | 236 |
| 238 } // namespace dart | 237 } // namespace dart |
| OLD | NEW |