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

Side by Side Diff: pkg/kernel/testcases/closures/for_variable_capture_test.dart.expect

Issue 2778223002: Add primitive to create closures and use it for closure conversion (Closed)
Patch Set: Skip context param in closure type construction, rather than remove it Created 3 years, 8 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 unified diff | Download patch
OLDNEW
1 library; 1 library;
2 import self as self; 2 import self as self;
3 import "dart:core" as core;
4 3
5 class Closure#main#function extends core::Object implements core::Function {
6 field core::String note = "This is temporary. The VM doesn't need closure clas ses.";
7 field Vector context;
8 constructor •(final Vector context) → dynamic
9 : self::Closure#main#function::context = context
10 ;
11 method call() → dynamic {
12 "This is a temporary solution. In the VM, this will become an additional par ameter.";
13 final Vector #contextParameter = this.{self::Closure#main#function::context} ;
14 return #contextParameter[1];
15 }
16 }
17 static method main() → dynamic { 4 static method main() → dynamic {
18 dynamic closure; 5 dynamic closure;
19 { 6 {
20 Vector #context = MakeVector(2); 7 Vector #context = MakeVector(2);
21 #context[1] = 0; 8 #context[1] = 0;
22 dynamic fn = new self::Closure#main#function::•(#context); 9 dynamic fn = MakeClosure<() → dynamic>(self::closure#main#function, #context );
23 for (; (#context[1]).<(3); #context = CopyVector(#context), #context[1] = (# context[1]).+(1)) { 10 for (; (#context[1]).<(3); #context = CopyVector(#context), #context[1] = (# context[1]).+(1)) {
24 #context[1] = (#context[1]).+(1); 11 #context[1] = (#context[1]).+(1);
25 closure = fn; 12 closure = fn;
26 } 13 }
27 } 14 }
28 dynamic x = closure.call(); 15 dynamic x = closure.call();
29 if(!x.==(1)) { 16 if(!x.==(1)) {
30 throw "Expected 1, but got ${x}."; 17 throw "Expected 1, but got ${x}.";
31 } 18 }
32 } 19 }
20 static method closure#main#function(Vector #contextParameter) → dynamic {
21 return #contextParameter[1];
22 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698