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

Unified Diff: runtime/vm/code_generator.cc

Issue 8490019: Capturing for loop variables correctly (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 9 years, 1 month 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
Index: runtime/vm/code_generator.cc
===================================================================
--- runtime/vm/code_generator.cc (revision 1268)
+++ runtime/vm/code_generator.cc (working copy)
@@ -291,6 +291,23 @@
}
+// Make a copy of the given context, including the value of the captured
regis 2011/11/07 22:31:47 values
hausner 2011/11/07 22:36:35 Done.
+// variables.
+// Arg0: the context to be cloned.
+// Return value: newly allocated context.
+DEFINE_RUNTIME_ENTRY(CloneContext, 1) {
+ CHECK_STACK_ALIGNMENT;
+ ASSERT(arguments.Count() == kCloneContextRuntimeEntry.argument_count());
+ const Context& ctx = Context::CheckedHandle(arguments.At(0));
+ Context& cloned_ctx = Context::Handle(Context::New(ctx.num_variables()));
+ cloned_ctx.set_parent(Context::Handle(ctx.parent()));
+ for (int i = 0; i < ctx.num_variables(); i++) {
+ cloned_ctx.SetAt(i, Instance::Handle(ctx.At(i)));
+ }
+ arguments.SetReturn(cloned_ctx);
+}
+
+
// Check that the given instance is an instance of the given type.
// Tested instance may not be null, because the null test is inlined.
// Arg0: instance being checked.

Powered by Google App Engine
This is Rietveld 408576698