Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: tests/compiler/dart2js/backend_dart/opt_constprop_test.dart

Issue 574683002: Use ConstExp for storing constants. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments. Created 6 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 import 'dart:async'; 5 import 'dart:async';
6 import '../mock_compiler.dart'; 6 import '../mock_compiler.dart';
7 import 'sexpr_unstringifier.dart'; 7 import 'sexpr_unstringifier.dart';
8 import 'package:async_helper/async_helper.dart'; 8 import 'package:async_helper/async_helper.dart';
9 import "package:expect/expect.dart"; 9 import "package:expect/expect.dart";
10 import 'package:compiler/implementation/cps_ir/cps_ir_nodes_sexpr.dart'; 10 import 'package:compiler/implementation/cps_ir/cps_ir_nodes_sexpr.dart';
(...skipping 10 matching lines...) Expand all
21 // int j; 21 // int j;
22 // if (i == 1) { 22 // if (i == 1) {
23 // j = 2; 23 // j = 2;
24 // } else { 24 // } else {
25 // j = 3; 25 // j = 3;
26 // } 26 // }
27 // return j; 27 // return j;
28 // } 28 // }
29 29
30 String CP1_IN = """ 30 String CP1_IN = """
31 (FunctionDefinition main (return) (LetPrim v0 (Constant 1)) 31 (FunctionDefinition main (return) (LetPrim v0 (Constant IntConstant(1)))
32 (LetPrim v1 (Constant 1)) 32 (LetPrim v1 (Constant IntConstant(1)))
33 (LetCont (k0 v2) 33 (LetCont (k0 v2)
34 (LetCont (k1) (LetPrim v3 (Constant 2)) 34 (LetCont (k1) (LetPrim v3 (Constant IntConstant(2)))
35 (InvokeContinuation return v3)) 35 (InvokeContinuation return v3))
36 (LetCont (k2) (LetPrim v4 (Constant 3)) 36 (LetCont (k2) (LetPrim v4 (Constant IntConstant(3)))
37 (InvokeContinuation return v4)) 37 (InvokeContinuation return v4))
38 (Branch (IsTrue v2) k1 k2)) 38 (Branch (IsTrue v2) k1 k2))
39 (InvokeMethod v0 == v1 k0)) 39 (InvokeMethod v0 == v1 k0))
40 """; 40 """;
41 String CP1_OUT = """ 41 String CP1_OUT = """
42 (FunctionDefinition main ( return) 42 (FunctionDefinition main ( return)
43 (LetPrim v0 (Constant 1)) 43 (LetPrim v0 (Constant IntConstant(1)))
44 (LetPrim v1 (Constant 1)) 44 (LetPrim v1 (Constant IntConstant(1)))
45 (LetCont (k0 v2) 45 (LetCont (k0 v2)
46 (LetCont (k1) 46 (LetCont (k1)
47 (LetPrim v3 (Constant 2)) 47 (LetPrim v3 (Constant IntConstant(2)))
48 (InvokeContinuation return v3)) 48 (InvokeContinuation return v3))
49 (LetCont (k2) 49 (LetCont (k2)
50 (LetPrim v4 (Constant 3)) 50 (LetPrim v4 (Constant IntConstant(3)))
51 (InvokeContinuation return v4)) 51 (InvokeContinuation return v4))
52 (InvokeContinuation k1 )) 52 (InvokeContinuation k1 ))
53 (LetPrim v5 (Constant true)) 53 (LetPrim v5 (Constant BoolConstant(true)))
54 (InvokeContinuation k0 v5)) 54 (InvokeContinuation k0 v5))
55 """; 55 """;
56 56
57 // CP2 represents the following incoming dart code: 57 // CP2 represents the following incoming dart code:
58 // 58 //
59 // int main() { 59 // int main() {
60 // int i = 1; 60 // int i = 1;
61 // while (true) { 61 // while (true) {
62 // if (false || false) { 62 // if (false || false) {
63 // return i; 63 // return i;
64 // } 64 // }
65 // if (true && i == 1) { 65 // if (true && i == 1) {
66 // return i; 66 // return i;
67 // } 67 // }
68 // } 68 // }
69 // return 42; 69 // return 42;
70 // } 70 // }
71 71
72 String CP2_IN = """ 72 String CP2_IN = """
73 (FunctionDefinition main (return) (LetPrim v0 (Constant 1)) 73 (FunctionDefinition main (return) (LetPrim v0 (Constant IntConstant(1)))
74 (LetCont* (k0) 74 (LetCont* (k0)
75 (LetCont (k1) (LetPrim v1 (Constant 42)) 75 (LetCont (k1) (LetPrim v1 (Constant IntConstant(42)))
76 (InvokeContinuation return v1)) 76 (InvokeContinuation return v1))
77 (LetCont (k2) (LetPrim v2 (Constant false)) 77 (LetCont (k2) (LetPrim v2 (Constant BoolConstant(false)))
78 (LetCont (k3 v3) 78 (LetCont (k3 v3)
79 (LetCont (k4) (InvokeContinuation return v0)) 79 (LetCont (k4) (InvokeContinuation return v0))
80 (LetCont (k5) (LetPrim v4 (Constant true)) 80 (LetCont (k5) (LetPrim v4 (Constant BoolConstant(true)))
81 (LetCont (k6 v5) 81 (LetCont (k6 v5)
82 (LetCont (k7) (InvokeContinuation return v0)) 82 (LetCont (k7) (InvokeContinuation return v0))
83 (LetCont (k8) (InvokeContinuation* k0)) 83 (LetCont (k8) (InvokeContinuation* k0))
84 (Branch (IsTrue v5) k7 k8)) 84 (Branch (IsTrue v5) k7 k8))
85 (LetCont (k9) (LetPrim v6 (Constant 1)) 85 (LetCont (k9) (LetPrim v6 (Constant IntConstant(1)))
86 (LetCont (k10 v7) 86 (LetCont (k10 v7)
87 (LetCont (k11) (LetPrim v8 (Constant true)) 87 (LetCont (k11) (LetPrim v8 (Constant BoolConstant(true)))
88 (InvokeContinuation k6 v8)) 88 (InvokeContinuation k6 v8))
89 (LetCont (k12) (LetPrim v9 (Constant false)) 89 (LetCont (k12) (LetPrim v9 (Constant BoolConstant(false)))
90 (InvokeContinuation k6 v9)) 90 (InvokeContinuation k6 v9))
91 (Branch (IsTrue v7) k11 k12)) 91 (Branch (IsTrue v7) k11 k12))
92 (InvokeMethod v0 == v6 k10)) 92 (InvokeMethod v0 == v6 k10))
93 (LetCont (k13) (LetPrim v10 (Constant false)) 93 (LetCont (k13) (LetPrim v10 (Constant BoolConstant(false)))
94 (InvokeContinuation k6 v10)) 94 (InvokeContinuation k6 v10))
95 (Branch (IsTrue v4) k9 k13)) 95 (Branch (IsTrue v4) k9 k13))
96 (Branch (IsTrue v3) k4 k5)) 96 (Branch (IsTrue v3) k4 k5))
97 (LetCont (k14) (LetPrim v11 (Constant true)) 97 (LetCont (k14) (LetPrim v11 (Constant BoolConstant(true)))
98 (InvokeContinuation k3 v11)) 98 (InvokeContinuation k3 v11))
99 (LetCont (k15) (LetPrim v12 (Constant false)) 99 (LetCont (k15) (LetPrim v12 (Constant BoolConstant(false)))
100 (LetCont (k16) (LetPrim v13 (Constant true)) 100 (LetCont (k16) (LetPrim v13 (Constant BoolConstant(true)))
101 (InvokeContinuation k3 v13)) 101 (InvokeContinuation k3 v13))
102 (LetCont (k17) (LetPrim v14 (Constant false)) 102 (LetCont (k17) (LetPrim v14 (Constant BoolConstant(false)))
103 (InvokeContinuation k3 v14)) 103 (InvokeContinuation k3 v14))
104 (Branch (IsTrue v12) k16 k17)) 104 (Branch (IsTrue v12) k16 k17))
105 (Branch (IsTrue v2) k14 k15)) 105 (Branch (IsTrue v2) k14 k15))
106 (LetPrim v15 (Constant true)) 106 (LetPrim v15 (Constant BoolConstant(true)))
107 (Branch (IsTrue v15) k2 k1)) 107 (Branch (IsTrue v15) k2 k1))
108 (InvokeContinuation k0)) 108 (InvokeContinuation k0))
109 """; 109 """;
110 String CP2_OUT = """ 110 String CP2_OUT = """
111 (FunctionDefinition main ( return) 111 (FunctionDefinition main ( return)
112 (LetPrim v0 (Constant 1)) 112 (LetPrim v0 (Constant IntConstant(1)))
113 (LetCont* (k0) 113 (LetCont* (k0)
114 (LetCont (k1) (LetPrim v1 (Constant 42)) 114 (LetCont (k1) (LetPrim v1 (Constant IntConstant(42)))
115 (InvokeContinuation return v1)) 115 (InvokeContinuation return v1))
116 (LetCont (k2) 116 (LetCont (k2)
117 (LetPrim v2 (Constant false)) 117 (LetPrim v2 (Constant BoolConstant(false)))
118 (LetCont (k3 v3) 118 (LetCont (k3 v3)
119 (LetCont (k4) (InvokeContinuation return v0)) 119 (LetCont (k4) (InvokeContinuation return v0))
120 (LetCont (k5) 120 (LetCont (k5)
121 (LetPrim v4 (Constant true)) 121 (LetPrim v4 (Constant BoolConstant(true)))
122 (LetCont (k6 v5) 122 (LetCont (k6 v5)
123 (LetCont (k7) (InvokeContinuation return v0)) 123 (LetCont (k7) (InvokeContinuation return v0))
124 (LetCont (k8) (InvokeContinuation* k0 )) 124 (LetCont (k8) (InvokeContinuation* k0 ))
125 (InvokeContinuation k7 )) 125 (InvokeContinuation k7 ))
126 (LetCont (k9) 126 (LetCont (k9)
127 (LetPrim v6 (Constant 1)) 127 (LetPrim v6 (Constant IntConstant(1)))
128 (LetCont (k10 v7) 128 (LetCont (k10 v7)
129 (LetCont (k11) 129 (LetCont (k11)
130 (LetPrim v8 (Constant true)) 130 (LetPrim v8 (Constant BoolConstant(true)))
131 (InvokeContinuation k6 v8)) 131 (InvokeContinuation k6 v8))
132 (LetCont (k12) (LetPrim v9 (Constant false)) 132 (LetCont (k12) (LetPrim v9 (Constant BoolConstant(false)))
133 (InvokeContinuation k6 v9)) 133 (InvokeContinuation k6 v9))
134 (InvokeContinuation k11 )) 134 (InvokeContinuation k11 ))
135 (LetPrim v10 (Constant true)) 135 (LetPrim v10 (Constant BoolConstant(true)))
136 (InvokeContinuation k10 v10)) 136 (InvokeContinuation k10 v10))
137 (LetCont (k13) (LetPrim v11 (Constant false)) 137 (LetCont (k13) (LetPrim v11 (Constant BoolConstant(false)))
138 (InvokeContinuation k6 v11)) 138 (InvokeContinuation k6 v11))
139 (InvokeContinuation k9 )) 139 (InvokeContinuation k9 ))
140 (InvokeContinuation k5 )) 140 (InvokeContinuation k5 ))
141 (LetCont (k14) (LetPrim v12 (Constant true)) 141 (LetCont (k14) (LetPrim v12 (Constant BoolConstant(true)))
142 (InvokeContinuation k3 v12)) 142 (InvokeContinuation k3 v12))
143 (LetCont (k15) 143 (LetCont (k15)
144 (LetPrim v13 (Constant false)) 144 (LetPrim v13 (Constant BoolConstant(false)))
145 (LetCont (k16) (LetPrim v14 (Constant true)) 145 (LetCont (k16) (LetPrim v14 (Constant BoolConstant(true)))
146 (InvokeContinuation k3 v14)) 146 (InvokeContinuation k3 v14))
147 (LetCont (k17) 147 (LetCont (k17)
148 (LetPrim v15 (Constant false)) 148 (LetPrim v15 (Constant BoolConstant(false)))
149 (InvokeContinuation k3 v15)) 149 (InvokeContinuation k3 v15))
150 (InvokeContinuation k17 )) 150 (InvokeContinuation k17 ))
151 (InvokeContinuation k15 )) 151 (InvokeContinuation k15 ))
152 (LetPrim v16 (Constant true)) 152 (LetPrim v16 (Constant BoolConstant(true)))
153 (InvokeContinuation k2 )) 153 (InvokeContinuation k2 ))
154 (InvokeContinuation k0 )) 154 (InvokeContinuation k0 ))
155 """; 155 """;
156 156
157 // CP3 represents the following incoming dart code: 157 // CP3 represents the following incoming dart code:
158 // 158 //
159 // int main() { 159 // int main() {
160 // int i = 1; 160 // int i = 1;
161 // i = f(); 161 // i = f();
162 // if (i == 1) { 162 // if (i == 1) {
163 // return 42; 163 // return 42;
164 // } 164 // }
165 // return i; 165 // return i;
166 // } 166 // }
167 167
168 String CP3_IN = """ 168 String CP3_IN = """
169 (FunctionDefinition main ( return) (LetPrim v0 (Constant 1)) 169 (FunctionDefinition main ( return) (LetPrim v0 (Constant IntConstant(1)))
170 (LetCont (k0 v1) (LetPrim v2 (Constant 1)) 170 (LetCont (k0 v1) (LetPrim v2 (Constant IntConstant(1)))
171 (LetCont (k1 v3) 171 (LetCont (k1 v3)
172 (LetCont (k2) (LetPrim v4 (Constant 42)) 172 (LetCont (k2) (LetPrim v4 (Constant IntConstant(42)))
173 (InvokeContinuation return v4)) 173 (InvokeContinuation return v4))
174 (LetCont (k3) (InvokeContinuation return v1)) 174 (LetCont (k3) (InvokeContinuation return v1))
175 (Branch (IsTrue v3) k2 k3)) 175 (Branch (IsTrue v3) k2 k3))
176 (InvokeMethod v1 == v2 k1)) 176 (InvokeMethod v1 == v2 k1))
177 (InvokeStatic f k0)) 177 (InvokeStatic f k0))
178 """; 178 """;
179 String CP3_OUT = CP3_IN; 179 String CP3_OUT = CP3_IN;
180 180
181 // Addition. 181 // Addition.
182 182
183 String CP4_IN = """ 183 String CP4_IN = """
184 (FunctionDefinition main ( return) 184 (FunctionDefinition main ( return)
185 (LetPrim v0 (Constant 1)) 185 (LetPrim v0 (Constant IntConstant(1)))
186 (LetPrim v1 (Constant 2)) 186 (LetPrim v1 (Constant IntConstant(2)))
187 (LetCont (k0 v2) 187 (LetCont (k0 v2)
188 (InvokeContinuation return v2)) 188 (InvokeContinuation return v2))
189 (InvokeMethod v0 + v1 k0)) 189 (InvokeMethod v0 + v1 k0))
190 """; 190 """;
191 String CP4_OUT = """ 191 String CP4_OUT = """
192 (FunctionDefinition main ( return) 192 (FunctionDefinition main ( return)
193 (LetPrim v0 (Constant 1)) 193 (LetPrim v0 (Constant IntConstant(1)))
194 (LetPrim v1 (Constant 2)) 194 (LetPrim v1 (Constant IntConstant(2)))
195 (LetCont (k0 v2) 195 (LetCont (k0 v2)
196 (InvokeContinuation return v2)) 196 (InvokeContinuation return v2))
197 (LetPrim v3 (Constant 3)) 197 (LetPrim v3 (Constant IntConstant(3)))
198 (InvokeContinuation k0 v3)) 198 (InvokeContinuation k0 v3))
199 """; 199 """;
200 200
201 // Array access operator (no optimization). 201 // Array access operator (no optimization).
202 202
203 String CP5_IN = """ 203 String CP5_IN = """
204 (FunctionDefinition main ( return) 204 (FunctionDefinition main ( return)
205 (LetPrim v0 (Constant 1)) 205 (LetPrim v0 (Constant IntConstant(1)))
206 (LetPrim v1 (Constant 2)) 206 (LetPrim v1 (Constant IntConstant(2)))
207 (LetCont (k0 v2) 207 (LetCont (k0 v2)
208 (InvokeContinuation return v2)) 208 (InvokeContinuation return v2))
209 (InvokeMethod v0 [] v1 k0)) 209 (InvokeMethod v0 [] v1 k0))
210 """; 210 """;
211 String CP5_OUT = CP5_IN; 211 String CP5_OUT = CP5_IN;
212 212
213 // Division by 0. 213 // Division by 0.
214 214
215 String CP6_IN = """ 215 String CP6_IN = """
216 (FunctionDefinition main ( return) 216 (FunctionDefinition main ( return)
217 (LetPrim v0 (Constant 1)) 217 (LetPrim v0 (Constant IntConstant(1)))
218 (LetPrim v1 (Constant 0)) 218 (LetPrim v1 (Constant IntConstant(0)))
219 (LetCont (k0 v2) 219 (LetCont (k0 v2)
220 (InvokeContinuation return v2)) 220 (InvokeContinuation return v2))
221 (InvokeMethod v0 / v1 k0)) 221 (InvokeMethod v0 / v1 k0))
222 """; 222 """;
223 String CP6_OUT = """ 223 String CP6_OUT = """
224 (FunctionDefinition main ( return) 224 (FunctionDefinition main ( return)
225 (LetPrim v0 (Constant 1)) 225 (LetPrim v0 (Constant IntConstant(1)))
226 (LetPrim v1 (Constant 0)) 226 (LetPrim v1 (Constant IntConstant(0)))
227 (LetCont (k0 v2) 227 (LetCont (k0 v2)
228 (InvokeContinuation return v2)) 228 (InvokeContinuation return v2))
229 (LetPrim v3 (Constant Infinity)) 229 (LetPrim v3 (Constant DoubleConstant(Infinity)))
230 (InvokeContinuation k0 v3)) 230 (InvokeContinuation k0 v3))
231 """; 231 """;
232 232
233 // Concatenate strings. 233 // Concatenate strings.
234 234
235 String CP7_IN = """ 235 String CP7_IN = """
236 (FunctionDefinition main ( return) 236 (FunctionDefinition main ( return)
237 (LetPrim v0 (Constant StringConstant("b"))) 237 (LetPrim v0 (Constant StringConstant("b")))
238 (LetPrim v1 (Constant StringConstant("d"))) 238 (LetPrim v1 (Constant StringConstant("d")))
239 (LetPrim v2 (Constant StringConstant("a"))) 239 (LetPrim v2 (Constant StringConstant("a")))
(...skipping 20 matching lines...) Expand all
260 (InvokeContinuation k0 v7)) 260 (InvokeContinuation k0 v7))
261 """; 261 """;
262 262
263 // TODO(jgruber): We can't test is-check optimization because the unstringifier 263 // TODO(jgruber): We can't test is-check optimization because the unstringifier
264 // does not recreate accurate types for the TypeOperator node. 264 // does not recreate accurate types for the TypeOperator node.
265 265
266 // Simple branch removal. 266 // Simple branch removal.
267 267
268 String CP8_IN = """ 268 String CP8_IN = """
269 (FunctionDefinition main ( return) 269 (FunctionDefinition main ( return)
270 (LetPrim v0 (Constant 1)) 270 (LetPrim v0 (Constant IntConstant(1)))
271 (LetPrim v1 (Constant 1)) 271 (LetPrim v1 (Constant IntConstant(1)))
272 (LetCont (k0 v2) 272 (LetCont (k0 v2)
273 (LetCont (k1) 273 (LetCont (k1)
274 (LetPrim v3 (Constant 42)) 274 (LetPrim v3 (Constant IntConstant(42)))
275 (InvokeContinuation return v3)) 275 (InvokeContinuation return v3))
276 (LetCont (k2) 276 (LetCont (k2)
277 (InvokeContinuation return v0)) 277 (InvokeContinuation return v0))
278 (Branch (IsTrue v2) k1 k2)) 278 (Branch (IsTrue v2) k1 k2))
279 (InvokeMethod v0 == v1 k0)) 279 (InvokeMethod v0 == v1 k0))
280 """; 280 """;
281 String CP8_OUT = """ 281 String CP8_OUT = """
282 (FunctionDefinition main ( return) 282 (FunctionDefinition main ( return)
283 (LetPrim v0 (Constant 1)) 283 (LetPrim v0 (Constant IntConstant(1)))
284 (LetPrim v1 (Constant 1)) 284 (LetPrim v1 (Constant IntConstant(1)))
285 (LetCont (k0 v2) 285 (LetCont (k0 v2)
286 (LetCont (k1) (LetPrim v3 (Constant 42)) 286 (LetCont (k1) (LetPrim v3 (Constant IntConstant(42)))
287 (InvokeContinuation return v3)) 287 (InvokeContinuation return v3))
288 (LetCont (k2) (InvokeContinuation return v0)) 288 (LetCont (k2) (InvokeContinuation return v0))
289 (InvokeContinuation k1 )) 289 (InvokeContinuation k1 ))
290 (LetPrim v4 (Constant true)) 290 (LetPrim v4 (Constant BoolConstant(true)))
291 (InvokeContinuation k0 v4)) 291 (InvokeContinuation k0 v4))
292 """; 292 """;
293 293
294 // While loop. 294 // While loop.
295 295
296 String CP9_IN = """ 296 String CP9_IN = """
297 (FunctionDefinition main ( return) 297 (FunctionDefinition main ( return)
298 (LetPrim v0 (Constant 1)) 298 (LetPrim v0 (Constant IntConstant(1)))
299 (LetCont* (k0 v1) 299 (LetCont* (k0 v1)
300 (LetCont (k1) 300 (LetCont (k1)
301 (InvokeContinuation return v1)) 301 (InvokeContinuation return v1))
302 (LetCont (k2) 302 (LetCont (k2)
303 (LetPrim v2 (Constant 1)) 303 (LetPrim v2 (Constant IntConstant(1)))
304 (LetCont (k3 v3) 304 (LetCont (k3 v3)
305 (LetCont (k4 v4) 305 (LetCont (k4 v4)
306 (LetCont (k5) 306 (LetCont (k5)
307 (LetPrim v5 (Constant 42)) 307 (LetPrim v5 (Constant IntConstant(42)))
308 (InvokeContinuation return v5)) 308 (InvokeContinuation return v5))
309 (LetCont (k6) 309 (LetCont (k6)
310 (LetPrim v6 (Constant 1)) 310 (LetPrim v6 (Constant IntConstant(1)))
311 (LetCont (k7 v7) 311 (LetCont (k7 v7)
312 (InvokeContinuation* k0 v7)) 312 (InvokeContinuation* k0 v7))
313 (InvokeMethod v1 + v6 k7)) 313 (InvokeMethod v1 + v6 k7))
314 (Branch (IsTrue v4) k5 k6)) 314 (Branch (IsTrue v4) k5 k6))
315 (LetCont (k8) 315 (LetCont (k8)
316 (LetPrim v8 (Constant false)) 316 (LetPrim v8 (Constant BoolConstant(false)))
317 (InvokeContinuation k4 v8)) 317 (InvokeContinuation k4 v8))
318 (LetCont (k9) 318 (LetCont (k9)
319 (LetPrim v9 (Constant true)) 319 (LetPrim v9 (Constant BoolConstant(true)))
320 (InvokeContinuation k4 v9)) 320 (InvokeContinuation k4 v9))
321 (Branch (IsTrue v3) k8 k9)) 321 (Branch (IsTrue v3) k8 k9))
322 (InvokeMethod v1 == v2 k3)) 322 (InvokeMethod v1 == v2 k3))
323 (LetPrim v10 (Constant true)) 323 (LetPrim v10 (Constant BoolConstant(true)))
324 (Branch (IsTrue v10) k2 k1)) 324 (Branch (IsTrue v10) k2 k1))
325 (InvokeContinuation k0 v0)) 325 (InvokeContinuation k0 v0))
326 """; 326 """;
327 String CP9_OUT = """ 327 String CP9_OUT = """
328 (FunctionDefinition main ( return) 328 (FunctionDefinition main ( return)
329 (LetPrim v0 (Constant 1)) 329 (LetPrim v0 (Constant IntConstant(1)))
330 (LetCont* (k0 v1) 330 (LetCont* (k0 v1)
331 (LetCont (k1) 331 (LetCont (k1)
332 (InvokeContinuation return v1)) 332 (InvokeContinuation return v1))
333 (LetCont (k2) 333 (LetCont (k2)
334 (LetPrim v2 (Constant 1)) 334 (LetPrim v2 (Constant IntConstant(1)))
335 (LetCont (k3 v3) 335 (LetCont (k3 v3)
336 (LetCont (k4 v4) 336 (LetCont (k4 v4)
337 (LetCont (k5) 337 (LetCont (k5)
338 (LetPrim v5 (Constant 42)) 338 (LetPrim v5 (Constant IntConstant(42)))
339 (InvokeContinuation return v5)) 339 (InvokeContinuation return v5))
340 (LetCont (k6) 340 (LetCont (k6)
341 (LetPrim v6 (Constant 1)) 341 (LetPrim v6 (Constant IntConstant(1)))
342 (LetCont (k7 v7) 342 (LetCont (k7 v7)
343 (InvokeContinuation* k0 v7)) 343 (InvokeContinuation* k0 v7))
344 (InvokeMethod v1 + v6 k7)) 344 (InvokeMethod v1 + v6 k7))
345 (Branch (IsTrue v4) k5 k6)) 345 (Branch (IsTrue v4) k5 k6))
346 (LetCont (k8) 346 (LetCont (k8)
347 (LetPrim v8 (Constant false)) 347 (LetPrim v8 (Constant BoolConstant(false)))
348 (InvokeContinuation k4 v8)) 348 (InvokeContinuation k4 v8))
349 (LetCont (k9) 349 (LetCont (k9)
350 (LetPrim v9 (Constant true)) 350 (LetPrim v9 (Constant BoolConstant(true)))
351 (InvokeContinuation k4 v9)) 351 (InvokeContinuation k4 v9))
352 (Branch (IsTrue v3) k8 k9)) 352 (Branch (IsTrue v3) k8 k9))
353 (InvokeMethod v1 == v2 k3)) 353 (InvokeMethod v1 == v2 k3))
354 (LetPrim v10 (Constant true)) 354 (LetPrim v10 (Constant BoolConstant(true)))
355 (InvokeContinuation k2 )) 355 (InvokeContinuation k2 ))
356 (InvokeContinuation k0 v0)) 356 (InvokeContinuation k0 v0))
357 """; 357 """;
358 358
359 // While loop, from: 359 // While loop, from:
360 // 360 //
361 // int main() { 361 // int main() {
362 // for (int i = 0; i < 2; i++) { 362 // for (int i = 0; i < 2; i++) {
363 // print(42 + i); 363 // print(42 + i);
364 // } 364 // }
365 // } 365 // }
366 366
367 String CP10_IN = """ 367 String CP10_IN = """
368 (FunctionDefinition main ( return) 368 (FunctionDefinition main ( return)
369 (LetPrim v0 (Constant 0)) 369 (LetPrim v0 (Constant IntConstant(0)))
370 (LetCont* (k0 v1) 370 (LetCont* (k0 v1)
371 (LetCont (k1) 371 (LetCont (k1)
372 (LetPrim v2 (Constant null)) 372 (LetPrim v2 (Constant NullConstant))
373 (InvokeContinuation return v2)) 373 (InvokeContinuation return v2))
374 (LetCont (k2) 374 (LetCont (k2)
375 (LetPrim v3 (Constant 42)) 375 (LetPrim v3 (Constant IntConstant(42)))
376 (LetCont (k3 v4) 376 (LetCont (k3 v4)
377 (LetCont (k4 v5) 377 (LetCont (k4 v5)
378 (LetPrim v6 (Constant 1)) 378 (LetPrim v6 (Constant IntConstant(1)))
379 (LetCont (k5 v7) 379 (LetCont (k5 v7)
380 (InvokeContinuation* k0 v7)) 380 (InvokeContinuation* k0 v7))
381 (InvokeMethod v1 + v6 k5)) 381 (InvokeMethod v1 + v6 k5))
382 (InvokeStatic print v4 k4)) 382 (InvokeStatic print v4 k4))
383 (InvokeMethod v3 + v1 k3)) 383 (InvokeMethod v3 + v1 k3))
384 (LetPrim v8 (Constant 2)) 384 (LetPrim v8 (Constant IntConstant(2)))
385 (LetCont (k6 v9) 385 (LetCont (k6 v9)
386 (Branch (IsTrue v9) k2 k1)) 386 (Branch (IsTrue v9) k2 k1))
387 (InvokeMethod v1 < v8 k6)) 387 (InvokeMethod v1 < v8 k6))
388 (InvokeContinuation k0 v0)) 388 (InvokeContinuation k0 v0))
389 """; 389 """;
390 String CP10_OUT = CP10_IN; 390 String CP10_OUT = CP10_IN;
391 391
392 /// Normalizes whitespace by replacing all whitespace sequences by a single 392 /// Normalizes whitespace by replacing all whitespace sequences by a single
393 /// space and trimming leading and trailing whitespace. 393 /// space and trimming leading and trailing whitespace.
394 String normalizeSExpr(String input) { 394 String normalizeSExpr(String input) {
(...skipping 27 matching lines...) Expand all
422 asyncTest(() => testConstantPropagator(CP2_IN, CP2_OUT)); 422 asyncTest(() => testConstantPropagator(CP2_IN, CP2_OUT));
423 asyncTest(() => testConstantPropagator(CP3_IN, CP3_OUT)); 423 asyncTest(() => testConstantPropagator(CP3_IN, CP3_OUT));
424 asyncTest(() => testConstantPropagator(CP4_IN, CP4_OUT)); 424 asyncTest(() => testConstantPropagator(CP4_IN, CP4_OUT));
425 asyncTest(() => testConstantPropagator(CP5_IN, CP5_OUT)); 425 asyncTest(() => testConstantPropagator(CP5_IN, CP5_OUT));
426 asyncTest(() => testConstantPropagator(CP6_IN, CP6_OUT)); 426 asyncTest(() => testConstantPropagator(CP6_IN, CP6_OUT));
427 asyncTest(() => testConstantPropagator(CP7_IN, CP7_OUT)); 427 asyncTest(() => testConstantPropagator(CP7_IN, CP7_OUT));
428 asyncTest(() => testConstantPropagator(CP8_IN, CP8_OUT)); 428 asyncTest(() => testConstantPropagator(CP8_IN, CP8_OUT));
429 asyncTest(() => testConstantPropagator(CP9_IN, CP9_OUT)); 429 asyncTest(() => testConstantPropagator(CP9_IN, CP9_OUT));
430 asyncTest(() => testConstantPropagator(CP10_IN, CP10_OUT)); 430 asyncTest(() => testConstantPropagator(CP10_IN, CP10_OUT));
431 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698