| 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 x = null; | 6 field dynamic x = null; |
| 7 constructor •() → void | 7 constructor •() → void |
| 8 : super core::Object::•() | 8 : super core::Object::•() |
| 9 ; | 9 ; |
| 10 method m() → dynamic { | 10 method m() → dynamic { |
| 11 final Vector #context = MakeVector(2); | 11 final Vector #context = MakeVector(2); |
| 12 #context[1] = this; | 12 #context[1] = this; |
| 13 return new self::Closure#C#m#function::•(#context); | 13 return MakeClosure<(dynamic) → dynamic>(self::closure#C#m#function, #context
); |
| 14 } | 14 } |
| 15 method f() → dynamic { | 15 method f() → dynamic { |
| 16 final Vector #context = MakeVector(2); | 16 final Vector #context = MakeVector(2); |
| 17 #context[1] = this; | 17 #context[1] = this; |
| 18 return new self::Closure#C#f#function::•(#context); | 18 return MakeClosure<() → dynamic>(self::closure#C#f#function, #context); |
| 19 } | |
| 20 } | |
| 21 class Closure#C#m#function extends core::Object implements core::Function { | |
| 22 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
| 23 field Vector context; | |
| 24 constructor •(final Vector context) → dynamic | |
| 25 : self::Closure#C#m#function::context = context | |
| 26 ; | |
| 27 method call(dynamic v) → dynamic { | |
| 28 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
| 29 final Vector #contextParameter = this.{self::Closure#C#m#function::context}; | |
| 30 return (#contextParameter[1]).x = v; | |
| 31 } | |
| 32 } | |
| 33 class Closure#C#f#function#function extends core::Object implements core::Functi
on { | |
| 34 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
| 35 field Vector context; | |
| 36 constructor •(final Vector context) → dynamic | |
| 37 : self::Closure#C#f#function#function::context = context | |
| 38 ; | |
| 39 method call() → dynamic { | |
| 40 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
| 41 final Vector #contextParameter = this.{self::Closure#C#f#function#function::
context}; | |
| 42 return (#contextParameter[1]).x; | |
| 43 } | |
| 44 } | |
| 45 class Closure#C#f#function extends core::Object implements core::Function { | |
| 46 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
| 47 field Vector context; | |
| 48 constructor •(final Vector context) → dynamic | |
| 49 : self::Closure#C#f#function::context = context | |
| 50 ; | |
| 51 method call() → dynamic { | |
| 52 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
| 53 final Vector #contextParameter = this.{self::Closure#C#f#function::context}; | |
| 54 return new self::Closure#C#f#function#function::•(#contextParameter); | |
| 55 } | 19 } |
| 56 } | 20 } |
| 57 static method main() → dynamic { | 21 static method main() → dynamic { |
| 58 self::C c = new self::C::•(); | 22 self::C c = new self::C::•(); |
| 59 c.x = 41; | 23 c.x = 41; |
| 60 c.m().call(42); | 24 c.m().call(42); |
| 61 if(!42.==(c.x)) | 25 if(!42.==(c.x)) |
| 62 throw "Unexpected value in c.x: ${c.x}"; | 26 throw "Unexpected value in c.x: ${c.x}"; |
| 63 dynamic result = c.f().call().call(); | 27 dynamic result = c.f().call().call(); |
| 64 if(!42.==(result)) | 28 if(!42.==(result)) |
| 65 throw "Unexpected value from c.f()()(): ${result}"; | 29 throw "Unexpected value from c.f()()(): ${result}"; |
| 66 } | 30 } |
| 31 static method closure#C#m#function(Vector #contextParameter, dynamic v) → dynami
c { |
| 32 return (#contextParameter[1]).x = v; |
| 33 } |
| 34 static method closure#C#f#function#function(Vector #contextParameter) → dynamic
{ |
| 35 return (#contextParameter[1]).x; |
| 36 } |
| 37 static method closure#C#f#function(Vector #contextParameter) → dynamic { |
| 38 return MakeClosure<() → dynamic>(self::closure#C#f#function#function, #context
Parameter); |
| 39 } |
| OLD | NEW |