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 | 11 |
12 namespace dart { | 12 namespace dart { |
13 | 13 |
14 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { | 14 DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
15 GET_NATIVE_ARGUMENT(Array, a, arguments->NativeArgAt(0)); | 15 GET_NATIVE_ARGUMENT(Array, a, arguments->NativeArgAt(0)); |
16 // TODO(srdjan): Check that parameterized type is an int. | 16 // TODO(srdjan): Check that parameterized type is an int. |
17 Zone* zone = isolate->current_zone(); | 17 Zone* zone = isolate->current_zone(); |
18 intptr_t array_len = a.Length(); | 18 intptr_t array_len = a.Length(); |
19 | 19 |
20 // Unbox the array and determine the maximum element width. | 20 // Unbox the array and determine the maximum element width. |
21 bool is_one_byte_string = true; | 21 bool is_one_byte_string = true; |
22 intptr_t utf16_len = array_len; | 22 intptr_t utf16_len = array_len; |
23 uint32_t* utf32_array = zone->Alloc<uint32_t>(array_len); | 23 int32_t* utf32_array = zone->Alloc<int32_t>(array_len); |
24 Object& index_object = Object::Handle(isolate); | 24 Object& index_object = Object::Handle(isolate); |
25 for (intptr_t i = 0; i < array_len; i++) { | 25 for (intptr_t i = 0; i < array_len; i++) { |
26 index_object = a.At(i); | 26 index_object = a.At(i); |
27 if (!index_object.IsSmi()) { | 27 if (!index_object.IsSmi()) { |
28 GrowableArray<const Object*> args; | 28 GrowableArray<const Object*> args; |
29 args.Add(&index_object); | 29 args.Add(&index_object); |
30 Exceptions::ThrowByType(Exceptions::kArgument, args); | 30 Exceptions::ThrowByType(Exceptions::kArgument, args); |
31 } | 31 } |
32 intptr_t value = Smi::Cast(index_object).Value(); | 32 intptr_t value = Smi::Cast(index_object).Value(); |
33 if (value < 0) { | 33 if (value < 0) { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 if (!elem.IsString()) { | 151 if (!elem.IsString()) { |
152 GrowableArray<const Object*> args; | 152 GrowableArray<const Object*> args; |
153 args.Add(&elem); | 153 args.Add(&elem); |
154 Exceptions::ThrowByType(Exceptions::kArgument, args); | 154 Exceptions::ThrowByType(Exceptions::kArgument, args); |
155 } | 155 } |
156 } | 156 } |
157 return String::ConcatAll(strings); | 157 return String::ConcatAll(strings); |
158 } | 158 } |
159 | 159 |
160 } // namespace dart | 160 } // namespace dart |
OLD | NEW |