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

Unified Diff: runtime/lib/function.cc

Issue 888463004: Add support for sync* and yield (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 5 years, 10 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 | « runtime/lib/core_patch.dart ('k') | runtime/lib/function.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/lib/function.cc
===================================================================
--- runtime/lib/function.cc (revision 43515)
+++ runtime/lib/function.cc (working copy)
@@ -74,4 +74,28 @@
return Object::null();
}
+
+DEFINE_NATIVE_ENTRY(FunctionImpl_clone, 1) {
+ const Instance& receiver = Instance::CheckedHandle(
+ isolate, arguments->NativeArgAt(0));
+ ASSERT(receiver.IsClosure());
+ if (receiver.IsClosure()) {
+ const Function& func =
+ Function::Handle(isolate, Closure::function(receiver));
+ const Context& ctx =
+ Context::Handle(isolate, Closure::context(receiver));
+ Context& cloned_ctx =
+ Context::Handle(isolate, Context::New(ctx.num_variables()));
+ cloned_ctx.set_parent(Context::Handle(isolate, ctx.parent()));
+ Object& inst = Object::Handle(isolate);
+ for (int i = 0; i < ctx.num_variables(); i++) {
+ inst = ctx.At(i);
+ cloned_ctx.SetAt(i, inst);
+ }
+ return Closure::New(func, cloned_ctx);
+ }
+ return Object::null();
+}
+
+
} // namespace dart
« no previous file with comments | « runtime/lib/core_patch.dart ('k') | runtime/lib/function.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698