Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(312)

Unified Diff: runtime/lib/array.cc

Issue 139663003: Fix 16099: Invocation's positionalArguments contains an immutable array. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | runtime/lib/array.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/array.cc
===================================================================
--- runtime/lib/array.cc (revision 31843)
+++ runtime/lib/array.cc (working copy)
@@ -110,4 +110,23 @@
return Object::null();
}
+
+// Private factory, expects correct arguments.
+DEFINE_NATIVE_ENTRY(ImmutableList_from, 4) {
+ // Ignore first argument of a thsi factory (type argument).
+ 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
« no previous file with comments | « no previous file | runtime/lib/array.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698