Chromium Code Reviews| Index: runtime/lib/array.cc |
| =================================================================== |
| --- runtime/lib/array.cc (revision 31835) |
| +++ runtime/lib/array.cc (working copy) |
| @@ -110,4 +110,22 @@ |
| return Object::null(); |
| } |
| + |
| +// Private factory, expects correct arguments. |
|
siva
2014/01/15 18:35:09
We should add a comment here that the first argume
srdjan
2014/01/15 19:04:26
Done.
|
| +DEFINE_NATIVE_ENTRY(ImmutableList_from, 4) { |
| + const Array& from_array = Array::CheckedHandle(arguments->NativeArgAt(1)); |
| + const Smi& smi_offset = Smi::CheckedHandle(arguments->NativeArgAt(2)); |
| + const Smi& smi_length = Smi::CheckedHandle(arguments->NativeArgAt(3)); |
| + const intptr_t length = smi_length.Value(); |
| + const intptr_t offset = smi_offset.Value(); |
| + const Array& result = Array::Handle(Array::New(length)); |
| + Object& temp = Object::Handle(); |
| + for (intptr_t i = 0; i < length; i++) { |
| + temp = from_array.At(i + offset); |
| + result.SetAt(i, temp); |
| + } |
| + result.MakeImmutable(); |
| + return result.raw(); |
| +} |
| + |
| } // namespace dart |