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 f = new self::Closure#C#f#function::•(null); | 6 field dynamic f = MakeClosure<() → dynamic>(self::closure#C#f#function, null); |
7 constructor •() → void | 7 constructor •() → void |
8 : super core::Object::•() | 8 : super core::Object::•() |
9 ; | 9 ; |
10 get g() → dynamic { | 10 get g() → dynamic { |
11 return new self::Closure#C#g#function::•(null); | 11 return MakeClosure<(dynamic) → dynamic>(self::closure#C#g#function, null); |
12 } | 12 } |
13 method a() → dynamic { | 13 method a() → dynamic { |
14 return "a"; | 14 return "a"; |
15 } | 15 } |
16 method b(dynamic x) → dynamic { | 16 method b(dynamic x) → dynamic { |
17 return x; | 17 return x; |
18 } | 18 } |
19 method c(dynamic x, [dynamic y = 2]) → dynamic { | 19 method c(dynamic x, [dynamic y = 2]) → dynamic { |
20 return x.+(y); | 20 return x.+(y); |
21 } | 21 } |
22 method d(dynamic x, {dynamic y = 2}) → dynamic { | 22 method d(dynamic x, {dynamic y = 2}) → dynamic { |
23 return x.+(y); | 23 return x.+(y); |
24 } | 24 } |
25 get a#get() → dynamic | 25 method a#get() → dynamic { |
26 return new self::Closure#C#a::•(this); | 26 final Vector #context = MakeVector(2); |
27 get b#get() → dynamic | 27 #context[1] = this; |
28 return new self::Closure#C#b::•(this); | 28 return MakeClosure<() → dynamic>(self::closure#C#a, #context); |
29 get c#get() → dynamic | 29 } |
30 return new self::Closure#C#c::•(this); | 30 method b#get() → dynamic { |
31 get d#get() → dynamic | 31 final Vector #context = MakeVector(2); |
32 return new self::Closure#C#d::•(this); | 32 #context[1] = this; |
| 33 return MakeClosure<(dynamic) → dynamic>(self::closure#C#b, #context); |
| 34 } |
| 35 method c#get() → dynamic { |
| 36 final Vector #context = MakeVector(2); |
| 37 #context[1] = this; |
| 38 return MakeClosure<(dynamic, [dynamic]) → dynamic>(self::closure#C#c, #conte
xt); |
| 39 } |
| 40 method d#get() → dynamic { |
| 41 final Vector #context = MakeVector(2); |
| 42 #context[1] = this; |
| 43 return MakeClosure<(dynamic, {y: dynamic}) → dynamic>(self::closure#C#d, #co
ntext); |
| 44 } |
33 } | 45 } |
34 class D<T extends core::Object> extends core::Object { | 46 class D<T extends core::Object> extends core::Object { |
35 field dynamic f = new self::Closure#D#f#function::•(null); | 47 field dynamic f = MakeClosure<() → dynamic>(self::closure#D#f#function, null); |
36 constructor •() → void | 48 constructor •() → void |
37 : super core::Object::•() | 49 : super core::Object::•() |
38 ; | 50 ; |
39 get g() → dynamic { | 51 get g() → dynamic { |
40 return new self::Closure#D#g#function::•(null); | 52 return MakeClosure<(dynamic) → dynamic>(self::closure#D#g#function, null); |
41 } | 53 } |
42 method a() → dynamic { | 54 method a() → dynamic { |
43 return "a"; | 55 return "a"; |
44 } | 56 } |
45 method b(dynamic x) → dynamic { | 57 method b(dynamic x) → dynamic { |
46 return x; | 58 return x; |
47 } | 59 } |
48 method c(dynamic x, [dynamic y = 2]) → dynamic { | 60 method c(dynamic x, [dynamic y = 2]) → dynamic { |
49 return x.+(y); | 61 return x.+(y); |
50 } | 62 } |
51 method d(dynamic x, {dynamic y = 2}) → dynamic { | 63 method d(dynamic x, {dynamic y = 2}) → dynamic { |
52 return x.+(y); | 64 return x.+(y); |
53 } | 65 } |
54 get a#get() → dynamic | 66 method a#get() → dynamic { |
55 return new self::Closure#D#a::•<self::D::T>(this); | 67 final Vector #context = MakeVector(2); |
56 get b#get() → dynamic | 68 #context[1] = this; |
57 return new self::Closure#D#b::•<self::D::T>(this); | 69 return MakeClosure<() → dynamic>(self::closure#D#a, #context); |
58 get c#get() → dynamic | 70 } |
59 return new self::Closure#D#c::•<self::D::T>(this); | 71 method b#get() → dynamic { |
60 get d#get() → dynamic | 72 final Vector #context = MakeVector(2); |
61 return new self::Closure#D#d::•<self::D::T>(this); | 73 #context[1] = this; |
| 74 return MakeClosure<(dynamic) → dynamic>(self::closure#D#b, #context); |
| 75 } |
| 76 method c#get() → dynamic { |
| 77 final Vector #context = MakeVector(2); |
| 78 #context[1] = this; |
| 79 return MakeClosure<(dynamic, [dynamic]) → dynamic>(self::closure#D#c, #conte
xt); |
| 80 } |
| 81 method d#get() → dynamic { |
| 82 final Vector #context = MakeVector(2); |
| 83 #context[1] = this; |
| 84 return MakeClosure<(dynamic, {y: dynamic}) → dynamic>(self::closure#D#d, #co
ntext); |
| 85 } |
62 } | 86 } |
63 class E<T extends core::Object> extends core::Object { | 87 class E<T extends core::Object> extends core::Object { |
64 field dynamic f = new self::Closure#E#f#function::•(null); | 88 field dynamic f = MakeClosure<() → dynamic>(self::closure#E#f#function, null); |
65 constructor •() → void | 89 constructor •() → void |
66 : super core::Object::•() | 90 : super core::Object::•() |
67 ; | 91 ; |
68 get g() → dynamic { | 92 get g() → dynamic { |
69 return new self::Closure#E#g#function::•<self::E::T>(null); | 93 return MakeClosure<(dynamic) → dynamic>(self::closure#E#g#function, null); |
70 } | 94 } |
71 method a() → dynamic { | 95 method a() → dynamic { |
72 return "a"; | 96 return "a"; |
73 } | 97 } |
74 method b(self::E::T x) → dynamic { | 98 method b(self::E::T x) → dynamic { |
75 return x; | 99 return x; |
76 } | 100 } |
77 method c(self::E::T x, [self::E::T y = 2]) → dynamic { | 101 method c(self::E::T x, [self::E::T y = 2]) → dynamic { |
78 return x.+(y); | 102 return x.+(y); |
79 } | 103 } |
80 method d(self::E::T x, {self::E::T y = 2}) → dynamic { | 104 method d(self::E::T x, {self::E::T y = 2}) → dynamic { |
81 return x.+(y); | 105 return x.+(y); |
82 } | 106 } |
83 get a#get() → dynamic | 107 method a#get() → dynamic { |
84 return new self::Closure#E#a::•<self::E::T>(this); | 108 final Vector #context = MakeVector(2); |
85 get b#get() → dynamic | 109 #context[1] = this; |
86 return new self::Closure#E#b::•<self::E::T>(this); | 110 return MakeClosure<() → dynamic>(self::closure#E#a, #context); |
87 get c#get() → dynamic | |
88 return new self::Closure#E#c::•<self::E::T>(this); | |
89 get d#get() → dynamic | |
90 return new self::Closure#E#d::•<self::E::T>(this); | |
91 } | |
92 class Closure#C#g#function extends core::Object implements core::Function { | |
93 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
94 field Vector context; | |
95 constructor •(final Vector context) → dynamic | |
96 : self::Closure#C#g#function::context = context | |
97 ; | |
98 method call(dynamic x) → dynamic { | |
99 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
100 final Vector #contextParameter = this.{self::Closure#C#g#function::context}; | |
101 return "g(${x})"; | |
102 } | 111 } |
103 } | 112 method b#get() → dynamic { |
104 class Closure#C#a extends core::Object implements core::Function { | 113 final Vector #context = MakeVector(2); |
105 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | 114 #context[1] = this; |
106 field self::C self; | 115 return MakeClosure<(self::E::T) → dynamic>(self::closure#E#b, #context); |
107 constructor •(final self::C self) → dynamic | |
108 : self::Closure#C#a::self = self | |
109 ; | |
110 method call() → dynamic | |
111 return this.{self::Closure#C#a::self}.{self::C::a}(); | |
112 } | |
113 class Closure#C#b extends core::Object implements core::Function { | |
114 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
115 field self::C self; | |
116 constructor •(final self::C self) → dynamic | |
117 : self::Closure#C#b::self = self | |
118 ; | |
119 method call(dynamic x) → dynamic | |
120 return this.{self::Closure#C#b::self}.{self::C::b}(x); | |
121 } | |
122 class Closure#C#c extends core::Object implements core::Function { | |
123 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
124 field self::C self; | |
125 constructor •(final self::C self) → dynamic | |
126 : self::Closure#C#c::self = self | |
127 ; | |
128 method call(dynamic x, [dynamic y = 2]) → dynamic | |
129 return this.{self::Closure#C#c::self}.{self::C::c}(x, y); | |
130 } | |
131 class Closure#C#d extends core::Object implements core::Function { | |
132 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
133 field self::C self; | |
134 constructor •(final self::C self) → dynamic | |
135 : self::Closure#C#d::self = self | |
136 ; | |
137 method call(dynamic x, {dynamic y = 2}) → dynamic | |
138 return this.{self::Closure#C#d::self}.{self::C::d}(x, y: y); | |
139 } | |
140 class Closure#C#f#function extends core::Object implements core::Function { | |
141 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
142 field Vector context; | |
143 constructor •(final Vector context) → dynamic | |
144 : self::Closure#C#f#function::context = context | |
145 ; | |
146 method call() → dynamic { | |
147 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
148 final Vector #contextParameter = this.{self::Closure#C#f#function::context}; | |
149 return "f"; | |
150 } | 116 } |
151 } | 117 method c#get() → dynamic { |
152 class Closure#D#g#function extends core::Object implements core::Function { | 118 final Vector #context = MakeVector(2); |
153 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | 119 #context[1] = this; |
154 field Vector context; | 120 return MakeClosure<(self::E::T, [self::E::T]) → dynamic>(self::closure#E#c,
#context); |
155 constructor •(final Vector context) → dynamic | |
156 : self::Closure#D#g#function::context = context | |
157 ; | |
158 method call(dynamic x) → dynamic { | |
159 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
160 final Vector #contextParameter = this.{self::Closure#D#g#function::context}; | |
161 return "g(${x})"; | |
162 } | 121 } |
163 } | 122 method d#get() → dynamic { |
164 class Closure#D#a<T extends core::Object> extends core::Object implements core::
Function { | 123 final Vector #context = MakeVector(2); |
165 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | 124 #context[1] = this; |
166 field self::D<self::Closure#D#a::T> self; | 125 return MakeClosure<(self::E::T, {y: self::E::T}) → dynamic>(self::closure#E#
d, #context); |
167 constructor •(final self::D<self::Closure#D#a::T> self) → dynamic | |
168 : self::Closure#D#a::self = self | |
169 ; | |
170 method call() → dynamic | |
171 return this.{self::Closure#D#a::self}.{self::D::a}(); | |
172 } | |
173 class Closure#D#b<T extends core::Object> extends core::Object implements core::
Function { | |
174 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
175 field self::D<self::Closure#D#b::T> self; | |
176 constructor •(final self::D<self::Closure#D#b::T> self) → dynamic | |
177 : self::Closure#D#b::self = self | |
178 ; | |
179 method call(dynamic x) → dynamic | |
180 return this.{self::Closure#D#b::self}.{self::D::b}(x); | |
181 } | |
182 class Closure#D#c<T extends core::Object> extends core::Object implements core::
Function { | |
183 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
184 field self::D<self::Closure#D#c::T> self; | |
185 constructor •(final self::D<self::Closure#D#c::T> self) → dynamic | |
186 : self::Closure#D#c::self = self | |
187 ; | |
188 method call(dynamic x, [dynamic y = 2]) → dynamic | |
189 return this.{self::Closure#D#c::self}.{self::D::c}(x, y); | |
190 } | |
191 class Closure#D#d<T extends core::Object> extends core::Object implements core::
Function { | |
192 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
193 field self::D<self::Closure#D#d::T> self; | |
194 constructor •(final self::D<self::Closure#D#d::T> self) → dynamic | |
195 : self::Closure#D#d::self = self | |
196 ; | |
197 method call(dynamic x, {dynamic y = 2}) → dynamic | |
198 return this.{self::Closure#D#d::self}.{self::D::d}(x, y: y); | |
199 } | |
200 class Closure#D#f#function extends core::Object implements core::Function { | |
201 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
202 field Vector context; | |
203 constructor •(final Vector context) → dynamic | |
204 : self::Closure#D#f#function::context = context | |
205 ; | |
206 method call() → dynamic { | |
207 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
208 final Vector #contextParameter = this.{self::Closure#D#f#function::context}; | |
209 return "f"; | |
210 } | |
211 } | |
212 class Closure#E#g#function<T extends core::Object> extends core::Object implemen
ts core::Function { | |
213 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
214 field Vector context; | |
215 constructor •(final Vector context) → dynamic | |
216 : self::Closure#E#g#function::context = context | |
217 ; | |
218 method call(self::Closure#E#g#function::T x) → dynamic { | |
219 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
220 final Vector #contextParameter = this.{self::Closure#E#g#function::context}; | |
221 return "g(${x})"; | |
222 } | |
223 } | |
224 class Closure#E#a<T extends core::Object> extends core::Object implements core::
Function { | |
225 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
226 field self::E<self::Closure#E#a::T> self; | |
227 constructor •(final self::E<self::Closure#E#a::T> self) → dynamic | |
228 : self::Closure#E#a::self = self | |
229 ; | |
230 method call() → dynamic | |
231 return this.{self::Closure#E#a::self}.{self::E::a}(); | |
232 } | |
233 class Closure#E#b<T extends core::Object> extends core::Object implements core::
Function { | |
234 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
235 field self::E<self::Closure#E#b::T> self; | |
236 constructor •(final self::E<self::Closure#E#b::T> self) → dynamic | |
237 : self::Closure#E#b::self = self | |
238 ; | |
239 method call(self::Closure#E#b::T x) → dynamic | |
240 return this.{self::Closure#E#b::self}.{self::E::b}(x); | |
241 } | |
242 class Closure#E#c<T extends core::Object> extends core::Object implements core::
Function { | |
243 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
244 field self::E<self::Closure#E#c::T> self; | |
245 constructor •(final self::E<self::Closure#E#c::T> self) → dynamic | |
246 : self::Closure#E#c::self = self | |
247 ; | |
248 method call(self::Closure#E#c::T x, [self::Closure#E#c::T y = 2]) → dynamic | |
249 return this.{self::Closure#E#c::self}.{self::E::c}(x, y); | |
250 } | |
251 class Closure#E#d<T extends core::Object> extends core::Object implements core::
Function { | |
252 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
253 field self::E<self::Closure#E#d::T> self; | |
254 constructor •(final self::E<self::Closure#E#d::T> self) → dynamic | |
255 : self::Closure#E#d::self = self | |
256 ; | |
257 method call(self::Closure#E#d::T x, {self::Closure#E#d::T y = 2}) → dynamic | |
258 return this.{self::Closure#E#d::self}.{self::E::d}(x, y: y); | |
259 } | |
260 class Closure#E#f#function extends core::Object implements core::Function { | |
261 field core::String note = "This is temporary. The VM doesn't need closure clas
ses."; | |
262 field Vector context; | |
263 constructor •(final Vector context) → dynamic | |
264 : self::Closure#E#f#function::context = context | |
265 ; | |
266 method call() → dynamic { | |
267 "This is a temporary solution. In the VM, this will become an additional par
ameter."; | |
268 final Vector #contextParameter = this.{self::Closure#E#f#function::context}; | |
269 return "f"; | |
270 } | 126 } |
271 } | 127 } |
272 static method expect(dynamic expected, dynamic actual) → dynamic { | 128 static method expect(dynamic expected, dynamic actual) → dynamic { |
273 core::print("Expecting '${expected}' and got '${actual}'"); | 129 core::print("Expecting '${expected}' and got '${actual}'"); |
274 if(!expected.==(actual)) { | 130 if(!expected.==(actual)) { |
275 core::print("Expected '${expected}' but got '${actual}'"); | 131 core::print("Expected '${expected}' but got '${actual}'"); |
276 throw "Expected '${expected}' but got '${actual}'"; | 132 throw "Expected '${expected}' but got '${actual}'"; |
277 } | 133 } |
278 } | 134 } |
279 static method test(dynamic o) → dynamic { | 135 static method test(dynamic o) → dynamic { |
280 self::expect("f", o.f()); | 136 self::expect("f", o.f()); |
281 self::expect("f", o.f.call()); | 137 self::expect("f", o.f.call()); |
282 self::expect("g(42)", o.g(42)); | 138 self::expect("g(42)", o.g(42)); |
283 self::expect("g(42)", o.g.call(42)); | 139 self::expect("g(42)", o.g.call(42)); |
284 self::expect("a", o.a()); | 140 self::expect("a", o.a()); |
285 self::expect("a", o.a#get.call()); | 141 self::expect("a", o.a#get().call()); |
286 self::expect(42, o.b(42)); | 142 self::expect(42, o.b(42)); |
287 self::expect(42, o.b#get.call(42)); | 143 self::expect(42, o.b#get().call(42)); |
288 self::expect(42, o.c(40)); | 144 self::expect(42, o.c(40)); |
289 self::expect(42, o.c#get.call(40)); | 145 self::expect(42, o.c#get().call(40)); |
290 self::expect(87, o.c(80, 7)); | 146 self::expect(87, o.c(80, 7)); |
291 self::expect(87, o.c#get.call(80, 7)); | 147 self::expect(87, o.c#get().call(80, 7)); |
292 self::expect(42, o.d(40)); | 148 self::expect(42, o.d(40)); |
293 self::expect(42, o.d#get.call(40)); | 149 self::expect(42, o.d#get().call(40)); |
294 self::expect(87, o.d(80, y: 7)); | 150 self::expect(87, o.d(80, y: 7)); |
295 self::expect(87, o.d#get.call(80, y: 7)); | 151 self::expect(87, o.d#get().call(80, y: 7)); |
296 } | 152 } |
297 static method main(dynamic arguments) → dynamic { | 153 static method main(dynamic arguments) → dynamic { |
298 self::test(new self::C::•()); | 154 self::test(new self::C::•()); |
299 self::test(new self::D::•<core::int>()); | 155 self::test(new self::D::•<core::int>()); |
300 self::test(new self::E::•<core::int>()); | 156 self::test(new self::E::•<core::int>()); |
301 } | 157 } |
| 158 static method closure#C#g#function(Vector #contextParameter, dynamic x) → dynami
c { |
| 159 return "g(${x})"; |
| 160 } |
| 161 static method closure#C#a(Vector #contextParameter) → dynamic |
| 162 return (#contextParameter[1]).{self::C::a}(); |
| 163 static method closure#C#b(Vector #contextParameter, dynamic x) → dynamic |
| 164 return (#contextParameter[1]).{self::C::b}(x); |
| 165 static method closure#C#c(Vector #contextParameter, dynamic x, [dynamic y = 2])
→ dynamic |
| 166 return (#contextParameter[1]).{self::C::c}(x, y); |
| 167 static method closure#C#d(Vector #contextParameter, dynamic x, {dynamic y = 2})
→ dynamic |
| 168 return (#contextParameter[1]).{self::C::d}(x, y: y); |
| 169 static method closure#C#f#function(Vector #contextParameter) → dynamic { |
| 170 return "f"; |
| 171 } |
| 172 static method closure#D#g#function(Vector #contextParameter, dynamic x) → dynami
c { |
| 173 return "g(${x})"; |
| 174 } |
| 175 static method closure#D#a(Vector #contextParameter) → dynamic |
| 176 return (#contextParameter[1]).{self::D::a}(); |
| 177 static method closure#D#b(Vector #contextParameter, dynamic x) → dynamic |
| 178 return (#contextParameter[1]).{self::D::b}(x); |
| 179 static method closure#D#c(Vector #contextParameter, dynamic x, [dynamic y = 2])
→ dynamic |
| 180 return (#contextParameter[1]).{self::D::c}(x, y); |
| 181 static method closure#D#d(Vector #contextParameter, dynamic x, {dynamic y = 2})
→ dynamic |
| 182 return (#contextParameter[1]).{self::D::d}(x, y: y); |
| 183 static method closure#D#f#function(Vector #contextParameter) → dynamic { |
| 184 return "f"; |
| 185 } |
| 186 static method closure#E#g#function(Vector #contextParameter, dynamic x) → dynami
c { |
| 187 return "g(${x})"; |
| 188 } |
| 189 static method closure#E#a(Vector #contextParameter) → dynamic |
| 190 return (#contextParameter[1]).{self::E::a}(); |
| 191 static method closure#E#b(Vector #contextParameter, dynamic x) → dynamic |
| 192 return (#contextParameter[1]).{self::E::b}(x); |
| 193 static method closure#E#c(Vector #contextParameter, dynamic x, [dynamic y = 2])
→ dynamic |
| 194 return (#contextParameter[1]).{self::E::c}(x, y); |
| 195 static method closure#E#d(Vector #contextParameter, dynamic x, {dynamic y = 2})
→ dynamic |
| 196 return (#contextParameter[1]).{self::E::d}(x, y: y); |
| 197 static method closure#E#f#function(Vector #contextParameter) → dynamic { |
| 198 return "f"; |
| 199 } |
OLD | NEW |