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 = MakeClosure<() → core::String>(self::closure#C#f#function, n
ull); | 6 field dynamic f = MakeClosure<() → core::String>(self::closure#C#f#function, n
ull); |
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 MakeClosure<(dynamic) → core::String>(self::closure#C#g#function, nul
l); | 11 return MakeClosure<(dynamic) → core::String>(self::closure#C#g#function, nul
l); |
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 method a#get() → dynamic { | |
26 final Vector #context = MakeVector(2); | |
27 #context[1] = this; | |
28 return MakeClosure<() → dynamic>(self::closure#C#a, #context); | |
29 } | |
30 method b#get() → dynamic { | |
31 final Vector #context = MakeVector(2); | |
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 } | |
45 } | 25 } |
46 class D<T extends core::Object> extends core::Object { | 26 class D<T extends core::Object> extends core::Object { |
47 field dynamic f = MakeClosure<() → core::String>(self::closure#D#f#function, n
ull); | 27 field dynamic f = MakeClosure<() → core::String>(self::closure#D#f#function, n
ull); |
48 constructor •() → void | 28 constructor •() → void |
49 : super core::Object::•() | 29 : super core::Object::•() |
50 ; | 30 ; |
51 get g() → dynamic { | 31 get g() → dynamic { |
52 return MakeClosure<(dynamic) → core::String>(self::closure#D#g#function, nul
l); | 32 return MakeClosure<(dynamic) → core::String>(self::closure#D#g#function, nul
l); |
53 } | 33 } |
54 method a() → dynamic { | 34 method a() → dynamic { |
55 return "a"; | 35 return "a"; |
56 } | 36 } |
57 method b(dynamic x) → dynamic { | 37 method b(dynamic x) → dynamic { |
58 return x; | 38 return x; |
59 } | 39 } |
60 method c(dynamic x, [dynamic y = 2]) → dynamic { | 40 method c(dynamic x, [dynamic y = 2]) → dynamic { |
61 return x.+(y); | 41 return x.+(y); |
62 } | 42 } |
63 method d(dynamic x, {dynamic y = 2}) → dynamic { | 43 method d(dynamic x, {dynamic y = 2}) → dynamic { |
64 return x.+(y); | 44 return x.+(y); |
65 } | 45 } |
66 method a#get() → dynamic { | |
67 final Vector #context = MakeVector(2); | |
68 #context[1] = this; | |
69 return MakeClosure<() → dynamic>(self::closure#D#a, #context); | |
70 } | |
71 method b#get() → dynamic { | |
72 final Vector #context = MakeVector(2); | |
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 } | |
86 } | 46 } |
87 class E<T extends core::Object> extends core::Object { | 47 class E<T extends core::Object> extends core::Object { |
88 field dynamic f = MakeClosure<() → core::String>(self::closure#E#f#function, n
ull); | 48 field dynamic f = MakeClosure<() → core::String>(self::closure#E#f#function, n
ull); |
89 constructor •() → void | 49 constructor •() → void |
90 : super core::Object::•() | 50 : super core::Object::•() |
91 ; | 51 ; |
92 get g() → dynamic { | 52 get g() → dynamic { |
93 return MakeClosure<(dynamic) → core::String>(self::closure#E#g#function, nul
l); | 53 return MakeClosure<(dynamic) → core::String>(self::closure#E#g#function, nul
l); |
94 } | 54 } |
95 method a() → dynamic { | 55 method a() → dynamic { |
96 return "a"; | 56 return "a"; |
97 } | 57 } |
98 method b(self::E::T x) → dynamic { | 58 method b(self::E::T x) → dynamic { |
99 return x; | 59 return x; |
100 } | 60 } |
101 method c(self::E::T x, [self::E::T y = 2]) → dynamic { | 61 method c(self::E::T x, [self::E::T y = 2]) → dynamic { |
102 return x.+(y); | 62 return x.+(y); |
103 } | 63 } |
104 method d(self::E::T x, {self::E::T y = 2}) → dynamic { | 64 method d(self::E::T x, {self::E::T y = 2}) → dynamic { |
105 return x.+(y); | 65 return x.+(y); |
106 } | 66 } |
107 method a#get() → dynamic { | |
108 final Vector #context = MakeVector(2); | |
109 #context[1] = this; | |
110 return MakeClosure<() → dynamic>(self::closure#E#a, #context); | |
111 } | |
112 method b#get() → dynamic { | |
113 final Vector #context = MakeVector(2); | |
114 #context[1] = this; | |
115 return MakeClosure<(self::E::T) → dynamic>(self::closure#E#b, #context); | |
116 } | |
117 method c#get() → dynamic { | |
118 final Vector #context = MakeVector(2); | |
119 #context[1] = this; | |
120 return MakeClosure<(self::E::T, [self::E::T]) → dynamic>(self::closure#E#c,
#context); | |
121 } | |
122 method d#get() → dynamic { | |
123 final Vector #context = MakeVector(2); | |
124 #context[1] = this; | |
125 return MakeClosure<(self::E::T, {y: self::E::T}) → dynamic>(self::closure#E#
d, #context); | |
126 } | |
127 } | 67 } |
128 static method expect(dynamic expected, dynamic actual) → dynamic { | 68 static method expect(dynamic expected, dynamic actual) → dynamic { |
129 core::print("Expecting '${expected}' and got '${actual}'"); | 69 core::print("Expecting '${expected}' and got '${actual}'"); |
130 if(!expected.==(actual)) { | 70 if(!expected.==(actual)) { |
131 core::print("Expected '${expected}' but got '${actual}'"); | 71 core::print("Expected '${expected}' but got '${actual}'"); |
132 throw "Expected '${expected}' but got '${actual}'"; | 72 throw "Expected '${expected}' but got '${actual}'"; |
133 } | 73 } |
134 } | 74 } |
135 static method test(dynamic o) → dynamic { | 75 static method test(dynamic o) → dynamic { |
136 self::expect("f", o.f()); | 76 self::expect("f", o.f()); |
137 self::expect("f", o.f.call()); | 77 self::expect("f", o.f.call()); |
138 self::expect("g(42)", o.g(42)); | 78 self::expect("g(42)", o.g(42)); |
139 self::expect("g(42)", o.g.call(42)); | 79 self::expect("g(42)", o.g.call(42)); |
140 self::expect("a", o.a()); | 80 self::expect("a", o.a()); |
141 self::expect("a", o.a#get().call()); | 81 self::expect("a", o.a.call()); |
142 self::expect(42, o.b(42)); | 82 self::expect(42, o.b(42)); |
143 self::expect(42, o.b#get().call(42)); | 83 self::expect(42, o.b.call(42)); |
144 self::expect(42, o.c(40)); | 84 self::expect(42, o.c(40)); |
145 self::expect(42, o.c#get().call(40)); | 85 self::expect(42, o.c.call(40)); |
146 self::expect(87, o.c(80, 7)); | 86 self::expect(87, o.c(80, 7)); |
147 self::expect(87, o.c#get().call(80, 7)); | 87 self::expect(87, o.c.call(80, 7)); |
148 self::expect(42, o.d(40)); | 88 self::expect(42, o.d(40)); |
149 self::expect(42, o.d#get().call(40)); | 89 self::expect(42, o.d.call(40)); |
150 self::expect(87, o.d(80, y: 7)); | 90 self::expect(87, o.d(80, y: 7)); |
151 self::expect(87, o.d#get().call(80, y: 7)); | 91 self::expect(87, o.d.call(80, y: 7)); |
152 } | 92 } |
153 static method main(dynamic arguments) → dynamic { | 93 static method main(dynamic arguments) → dynamic { |
154 self::test(new self::C::•()); | 94 self::test(new self::C::•()); |
155 self::test(new self::D::•<core::int>()); | 95 self::test(new self::D::•<core::int>()); |
156 self::test(new self::E::•<core::int>()); | 96 self::test(new self::E::•<core::int>()); |
157 } | 97 } |
158 static method closure#C#g#function(Vector #contextParameter, dynamic x) → core::
String { | 98 static method closure#C#g#function(Vector #contextParameter, dynamic x) → core::
String { |
159 return "g(${x})"; | 99 return "g(${x})"; |
160 } | 100 } |
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) → core::String { | 101 static method closure#C#f#function(Vector #contextParameter) → core::String { |
170 return "f"; | 102 return "f"; |
171 } | 103 } |
172 static method closure#D#g#function(Vector #contextParameter, dynamic x) → core::
String { | 104 static method closure#D#g#function(Vector #contextParameter, dynamic x) → core::
String { |
173 return "g(${x})"; | 105 return "g(${x})"; |
174 } | 106 } |
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) → core::String { | 107 static method closure#D#f#function(Vector #contextParameter) → core::String { |
184 return "f"; | 108 return "f"; |
185 } | 109 } |
186 static method closure#E#g#function(Vector #contextParameter, dynamic x) → core::
String { | 110 static method closure#E#g#function(Vector #contextParameter, dynamic x) → core::
String { |
187 return "g(${x})"; | 111 return "g(${x})"; |
188 } | 112 } |
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) → core::String { | 113 static method closure#E#f#function(Vector #contextParameter) → core::String { |
198 return "f"; | 114 return "f"; |
199 } | 115 } |
OLD | NEW |