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 C1 extends core::Object { | 5 class C1 extends core::Object { |
6 field dynamic x; | 6 field dynamic x; |
7 constructor •(dynamic y) → void | 7 constructor •(dynamic y) → void |
8 : self::C1::x = let final Vector #context = MakeVector(2) in let dynamic #t1
= #context[1] = y in new self::Closure#C1##function::•(#context), super core::O
bject::•() | 8 : self::C1::x = let final Vector #context = MakeVector(2) in let dynamic #t1
= #context[1] = y in MakeClosure<() → dynamic>(self::closure#C1##function, #con
text), super core::Object::•() |
9 ; | 9 ; |
10 } | 10 } |
11 class C2 extends core::Object { | 11 class C2 extends core::Object { |
12 field dynamic x = null; | 12 field dynamic x = null; |
13 constructor •(dynamic y) → void | 13 constructor •(dynamic y) → void |
14 : super core::Object::•() { | 14 : super core::Object::•() { |
15 final Vector #context = MakeVector(2); | 15 final Vector #context = MakeVector(2); |
16 #context[1] = y; | 16 #context[1] = y; |
17 this.x = new self::Closure#C2#function#function::•(#context); | 17 this.x = MakeClosure<() → dynamic>(self::closure#C2#function#function, #cont
ext); |
18 } | |
19 } | |
20 class Closure#C1##function extends core::Object implements core::Function { | |
21 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
22 field Vector context; | |
23 constructor •(final Vector context) → dynamic | |
24 : self::Closure#C1##function::context = context | |
25 ; | |
26 method call() → dynamic { | |
27 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
28 final Vector #contextParameter = this.{self::Closure#C1##function::context}; | |
29 return core::print("Hello ${#contextParameter[1]}"); | |
30 } | |
31 } | |
32 class Closure#C2#function#function extends core::Object implements core::Functio
n { | |
33 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
34 field Vector context; | |
35 constructor •(final Vector context) → dynamic | |
36 : self::Closure#C2#function#function::context = context | |
37 ; | |
38 method call() → dynamic { | |
39 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
40 final Vector #contextParameter = this.{self::Closure#C2#function#function::c
ontext}; | |
41 return core::print("Hello ${#contextParameter[1]}"); | |
42 } | 18 } |
43 } | 19 } |
44 static method main() → dynamic { | 20 static method main() → dynamic { |
45 new self::C1::•("hest").x(); | 21 new self::C1::•("hest").x(); |
46 new self::C2::•("naebdyr").x(); | 22 new self::C2::•("naebdyr").x(); |
47 } | 23 } |
| 24 static method closure#C1##function(Vector #contextParameter) → dynamic { |
| 25 return core::print("Hello ${#contextParameter[1]}"); |
| 26 } |
| 27 static method closure#C2#function#function(Vector #contextParameter) → dynamic { |
| 28 return core::print("Hello ${#contextParameter[1]}"); |
| 29 } |
OLD | NEW |