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