| library; |
| import self as self; |
| import "dart:core" as core; |
| |
| static const field core::int max = 100; |
| static method main() → dynamic { |
| dynamic closures = <dynamic>[]; |
| dynamic closures2 = <dynamic>[]; |
| final Vector #context = MakeVector(2); |
| #context[1] = null; |
| { |
| Vector #context = MakeVector(2); |
| #context[0] = #context; |
| #context[1] = 0; |
| for (; (#context[1]).<(self::max); #context = CopyVector(#context), #context[1] = (#context[1]).+(1)) { |
| closures.add(MakeClosure<() → dynamic>(self::closure#main#function, #context)); |
| closures2.add(MakeClosure<() → dynamic>(self::closure#main#function#1, #context)); |
| } |
| } |
| core::int sum = 0; |
| for (core::Function f in closures) { |
| sum = sum.+(f.call()); |
| } |
| for (core::Function f in closures2) { |
| f.call(); |
| } |
| core::int expectedSum = self::max.-(1).*(self::max).~/(2); |
| if(!expectedSum.==(sum)) { |
| throw core::Exception::•("Unexpected sum = ${sum} != ${expectedSum}"); |
| } |
| } |
| static method closure#main#function(Vector #contextParameter) → dynamic { |
| return #contextParameter[0][1] = #contextParameter[1]; |
| } |
| static method closure#main#function#1(Vector #contextParameter) → dynamic { |
| if(!(#contextParameter[0][1]).==(self::max.-(1))) |
| throw "last: ${#contextParameter[0][1]} != ${self::max.-(1)}"; |
| } |