OLD | NEW |
1 library; | 1 library; |
2 import self as self; | 2 import self as self; |
3 import "dart:core" as core; | 3 import "dart:core" as core; |
4 | 4 |
5 class C extends core::Object { | 5 class C extends core::Object { |
6 field dynamic t; | 6 field dynamic t; |
7 constructor foo(dynamic f) → void | 7 constructor foo(dynamic f) → void |
8 : self::C::t = let final Vector #context = MakeVector(2) in let dynamic #t1
= #context[1] = f in new self::Closure#C#foo#function::•(#context), super core::
Object::•() { | 8 : self::C::t = let final Vector #context = MakeVector(2) in let dynamic #t1
= #context[1] = f in MakeClosure<() → dynamic>(self::closure#C#foo#function, #co
ntext), super core::Object::•() { |
9 final Vector #context = MakeVector(2); | 9 final Vector #context = MakeVector(2); |
10 #context[1] = f; | 10 #context[1] = f; |
11 core::print(1); | 11 core::print(1); |
12 } | 12 } |
13 } | 13 } |
14 class Closure#C#foo#function#function extends core::Object implements core::Func
tion { | |
15 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
16 field Vector context; | |
17 constructor •(final Vector context) → dynamic | |
18 : self::Closure#C#foo#function#function::context = context | |
19 ; | |
20 method call(dynamic x) → dynamic { | |
21 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
22 final Vector #contextParameter = this.{self::Closure#C#foo#function#function
::context}; | |
23 (#contextParameter[0][1]).call("${#contextParameter[1]}${x}"); | |
24 } | |
25 } | |
26 class Closure#C#foo#function extends core::Object implements core::Function { | |
27 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
28 field Vector context; | |
29 constructor •(final Vector context) → dynamic | |
30 : self::Closure#C#foo#function::context = context | |
31 ; | |
32 method call() → dynamic { | |
33 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
34 final Vector #contextParameter = this.{self::Closure#C#foo#function::context
}; | |
35 final Vector #context = MakeVector(2); | |
36 #context[0] = #contextParameter; | |
37 #context[1] = null; | |
38 dynamic g = new self::Closure#C#foo#function#function::•(#context); | |
39 #context[1] = "hest"; | |
40 return g; | |
41 } | |
42 } | |
43 class Closure#main#function extends core::Object implements core::Function { | |
44 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
45 field Vector context; | |
46 constructor •(final Vector context) → dynamic | |
47 : self::Closure#main#function::context = context | |
48 ; | |
49 method call(dynamic x) → dynamic { | |
50 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
51 final Vector #contextParameter = this.{self::Closure#main#function::context}
; | |
52 return core::print(x); | |
53 } | |
54 } | |
55 static method main() → dynamic { | 14 static method main() → dynamic { |
56 core::print(0); | 15 core::print(0); |
57 dynamic c = new self::C::foo(new self::Closure#main#function::•(null)); | 16 dynamic c = new self::C::foo(MakeClosure<(dynamic) → dynamic>(self::closure#ma
in#function, null)); |
58 core::print(2); | 17 core::print(2); |
59 c.t().call("fisk"); | 18 c.t().call("fisk"); |
60 core::print(3); | 19 core::print(3); |
61 } | 20 } |
| 21 static method closure#C#foo#function#function(Vector #contextParameter, dynamic
x) → dynamic { |
| 22 (#contextParameter[0][1]).call("${#contextParameter[1]}${x}"); |
| 23 } |
| 24 static method closure#C#foo#function(Vector #contextParameter) → dynamic { |
| 25 final Vector #context = MakeVector(2); |
| 26 #context[0] = #contextParameter; |
| 27 #context[1] = null; |
| 28 dynamic g = MakeClosure<(dynamic) → dynamic>(self::closure#C#foo#function#func
tion, #context); |
| 29 #context[1] = "hest"; |
| 30 return g; |
| 31 } |
| 32 static method closure#main#function(Vector #contextParameter, dynamic x) → dynam
ic { |
| 33 return core::print(x); |
| 34 } |
OLD | NEW |