OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 /// Test boxing/captures for nested closures. | 5 /// Test boxing/captures for nested closures. |
6 | 6 |
7 /*useOne:box=(box0 which holds [b1])*/ useOne(/*boxed*/ b1) { | 7 /*element: useOne:box=(box0 which holds [b1])*/ useOne(/*boxed*/ b1) { |
8 /*box=(box1 which holds [b2]),free=[b1,box0]*/ () { | 8 /*box=(box1 which holds [b2]),free=[b1,box0]*/ () { |
9 var /*boxed*/ b2 = (b1 = 1); | 9 var /*boxed*/ b2 = (b1 = 1); |
10 | 10 |
11 /*free=[b2,box1]*/ () { | 11 /*free=[b2,box1]*/ () { |
12 return (b2 = 2); | 12 return (b2 = 2); |
13 }; | 13 }; |
14 | 14 |
15 return b2; | 15 return b2; |
16 }; | 16 }; |
17 return b1; | 17 return b1; |
18 } | 18 } |
19 | 19 |
20 /*useBoth:box=(box0 which holds [b1])*/ useBoth(/*boxed*/ b1) { | 20 /*element: useBoth:box=(box0 which holds [b1])*/ useBoth(/*boxed*/ b1) { |
21 /*box=(box1 which holds [b2]),free=[b1,box0]*/ () { | 21 /*box=(box1 which holds [b2]),free=[b1,box0]*/ () { |
22 var /*boxed*/ b2 = (b1 = 1); | 22 var /*boxed*/ b2 = (b1 = 1); |
23 | 23 |
24 /*free=[b1,b2,box0,box1]*/ () { | 24 /*free=[b1,b2,box0,box1]*/ () { |
25 return b1 + (b2 = 2); | 25 return b1 + (b2 = 2); |
26 }; | 26 }; |
27 | 27 |
28 return b2; | 28 return b2; |
29 }; | 29 }; |
30 return b1; | 30 return b1; |
31 } | 31 } |
32 | 32 |
33 /*useMany:box=(box0 which holds [b1,b2,b3])*/ useMany(c1, /*boxed*/ b1) { | 33 /*element: useMany:box=(box0 which holds [b1,b2,b3])*/ |
| 34 useMany(c1, /*boxed*/ b1) { |
34 var /*boxed*/ b2 = 2; | 35 var /*boxed*/ b2 = 2; |
35 var /*boxed*/ b3 = 3; | 36 var /*boxed*/ b3 = 3; |
36 var c2 = 2; | 37 var c2 = 2; |
37 var c3 = 3; | 38 var c3 = 3; |
38 /*box=(box1 which holds [b4]),free=[b1,b2,b3,box0,c1,c2,c3]*/ () { | 39 /*box=(box1 which holds [b4]),free=[b1,b2,b3,box0,c1,c2,c3]*/ () { |
39 var c4 = c1 + c2 + c3; | 40 var c4 = c1 + c2 + c3; |
40 var /*boxed*/ b4 = (b1 = 1) + (b2 = 2) + (b3 = 3); | 41 var /*boxed*/ b4 = (b1 = 1) + (b2 = 2) + (b3 = 3); |
41 | 42 |
42 /*free=[b1,b2,b4,box0,box1,c4]*/ () { | 43 /*free=[b1,b2,b4,box0,box1,c4]*/ () { |
43 return c4 + (b1 = 1) + (b2 = 2) + (b4 = 4); | 44 return c4 + (b1 = 1) + (b2 = 2) + (b4 = 4); |
44 }; | 45 }; |
45 | 46 |
46 return b4; | 47 return b4; |
47 }; | 48 }; |
48 return b1 + b2 + b3 + c1 + c2 + c3; | 49 return b1 + b2 + b3 + c1 + c2 + c3; |
49 } | 50 } |
50 | 51 |
51 main() { | 52 main() { |
52 useOne(1); | 53 useOne(1); |
53 useBoth(1); | 54 useBoth(1); |
54 useMany(1, 2); | 55 useMany(1, 2); |
55 } | 56 } |
OLD | NEW |