OLD | NEW |
(Empty) | |
| 1 library; |
| 2 import self as self; |
| 3 import "dart:core" as core; |
| 4 |
| 5 static method range(core::int high) → dynamic { |
| 6 final Vector #context = MakeVector(3); |
| 7 #context[2] = high; |
| 8 final (core::int) → dynamic iter = MakeClosure<(core::int) → dynamic>(self::cl
osure#range#iter, #context); |
| 9 return iter; |
| 10 } |
| 11 static method main() → dynamic { |
| 12 dynamic sum = 0; |
| 13 for (dynamic x in self::range(10).call(2)) |
| 14 sum = sum.+(x); |
| 15 if(!sum.==(44)) { |
| 16 throw core::Exception::•("Incorrect output."); |
| 17 } |
| 18 } |
| 19 static method closure#range#iter(Vector #contextParameter, core::int low) → dyna
mic /* originally sync* */ { |
| 20 final Vector #context = MakeVector(3); |
| 21 #context[1] = #contextParameter; |
| 22 #context[2] = low; |
| 23 dynamic :await_jump_var = 0; |
| 24 dynamic :await_ctx_var; |
| 25 dynamic :sync_op = (core::Iterator<dynamic> :iterator) → core::bool yielding { |
| 26 { |
| 27 while ((let final dynamic #t1 = #contextParameter[2] in let final dynamic
#t2 = #contextParameter[2] = #t1.-(1) in #t1).>(#context[2])) { |
| 28 :iterator._current = #context[1][2]; |
| 29 [yield] true; |
| 30 } |
| 31 } |
| 32 return false; |
| 33 }; |
| 34 return new core::_SyncIterable::•(:sync_op); |
| 35 } |
OLD | NEW |