Chromium Code Reviews| Index: runtime/lib/string.cc |
| diff --git a/runtime/lib/string.cc b/runtime/lib/string.cc |
| index 48b81e96fb72e94bebc075241071b3fb7dc97098..df06206e64fb41b55a4ddd10f182322a2342c6fd 100644 |
| --- a/runtime/lib/string.cc |
| +++ b/runtime/lib/string.cc |
| @@ -13,10 +13,21 @@ |
| namespace dart { |
| DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
| - GET_NON_NULL_NATIVE_ARGUMENT(Array, a, arguments->NativeArgAt(0)); |
| + GET_NON_NULL_NATIVE_ARGUMENT(Instance, list, arguments->NativeArgAt(0)); |
| + bool is_growable = list.IsGrowableObjectArray(); |
| + if (!is_growable && !list.IsArray()) { |
| + const Array& args = Array::Handle(Array::New(1)); |
| + args.SetAt(0, list); |
| + Exceptions::ThrowByType(Exceptions::kArgument, args); |
| + } |
| // TODO(srdjan): Check that parameterized type is an int. |
| + Array& a = Array::Handle( |
| + is_growable ? GrowableObjectArray::Cast(list).data() |
| + : Array::Cast(list).raw()); |
| + intptr_t array_len = is_growable ? GrowableObjectArray::Cast(list).Length() |
| + : a.Length(); |
|
siva
2013/03/14 15:56:02
I would structure this code as:
if (!list.IsGrowab
Lasse Reichstein Nielsen
2013/03/15 06:58:40
Much better. Done!
|
| + |
| Zone* zone = isolate->current_zone(); |
| - intptr_t array_len = a.Length(); |
| // Unbox the array and determine the maximum element width. |
| bool is_one_byte_string = true; |
| @@ -49,7 +60,6 @@ DEFINE_NATIVE_ENTRY(StringBase_createFromCodePoints, 1) { |
| return TwoByteString::New(utf16_len, utf32_array, array_len, Heap::kNew); |
| } |
|
siva
2013/03/14 15:56:02
Why remove the blank line here, we normally have 2
Lasse Reichstein Nielsen
2013/03/15 06:58:40
No reason. I moved the body of the method into a h
|
| - |
| DEFINE_NATIVE_ENTRY(StringBase_substringUnchecked, 3) { |
| const String& receiver = String::CheckedHandle(arguments->NativeArgAt(0)); |
| GET_NON_NULL_NATIVE_ARGUMENT(Smi, start_obj, arguments->NativeArgAt(1)); |