| 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.md file. | 3 // BSD-style license that can be found in the LICENSE.md file. |
| 4 | 4 |
| 5 library test.kernel.reify.suite; | 5 library test.kernel.reify.suite; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:io' show Directory, File, Platform; | 9 import 'dart:io' show Directory, File, Platform; |
| 10 | 10 |
| 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; | 11 import 'package:analyzer/src/generated/sdk.dart' show DartSdk; |
| 12 | 12 |
| 13 import 'package:analyzer/src/kernel/loader.dart' | 13 import 'package:analyzer/src/kernel/loader.dart' |
| 14 show DartLoader, DartOptions, createDartSdk; | 14 show DartLoader, DartOptions, createDartSdk; |
| 15 | 15 |
| 16 import 'package:kernel/core_types.dart' show CoreTypes; |
| 17 |
| 16 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; | 18 import 'package:kernel/target/targets.dart' show Target, TargetFlags, getTarget; |
| 17 | 19 |
| 18 import 'package:kernel/target/vmcc.dart' show VmClosureConvertedTarget; | 20 import 'package:kernel/target/vmcc.dart' show VmClosureConvertedTarget; |
| 19 | 21 |
| 20 import 'kernel_chain.dart' | 22 import 'kernel_chain.dart' |
| 21 show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill; | 23 show MatchExpectation, Print, ReadDill, SanityCheck, WriteDill; |
| 22 | 24 |
| 23 import 'package:testing/testing.dart' | 25 import 'package:testing/testing.dart' |
| 24 show | 26 show |
| 25 Chain, | 27 Chain, |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 | 147 |
| 146 @override | 148 @override |
| 147 String get name => "not reified target"; | 149 String get name => "not reified target"; |
| 148 | 150 |
| 149 // Tree shaking needs to be disabled, because Generic Types Reification | 151 // Tree shaking needs to be disabled, because Generic Types Reification |
| 150 // transformation relies on certain runtime libraries to be present in | 152 // transformation relies on certain runtime libraries to be present in |
| 151 // the program that is being transformed. If the tree shaker is enabled, | 153 // the program that is being transformed. If the tree shaker is enabled, |
| 152 // it just deletes everything from those libraries, because they aren't | 154 // it just deletes everything from those libraries, because they aren't |
| 153 // used in the program being transform prior to the transformation. | 155 // used in the program being transform prior to the transformation. |
| 154 @override | 156 @override |
| 155 void performTreeShaking(Program program) {} | 157 void performTreeShaking(CoreTypes coreTypes, Program program) {} |
| 156 | 158 |
| 157 // Erasure needs to be disabled, because it removes the necessary information | 159 // Erasure needs to be disabled, because it removes the necessary information |
| 158 // about type arguments for generic methods. | 160 // about type arguments for generic methods. |
| 159 @override | 161 @override |
| 160 void performErasure(Program program) {} | 162 void performErasure(Program program) {} |
| 161 | 163 |
| 162 // Adds the necessary runtime libraries. | 164 // Adds the necessary runtime libraries. |
| 163 @override | 165 @override |
| 164 List<String> get extraRequiredLibraries { | 166 List<String> get extraRequiredLibraries { |
| 165 Target reifyTarget = getTarget("vmreify", this.flags); | 167 Target reifyTarget = getTarget("vmreify", this.flags); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 184 strongMode: true, | 186 strongMode: true, |
| 185 kernelRuntime: Platform.script.resolve("../../runtime/"))); | 187 kernelRuntime: Platform.script.resolve("../../runtime/"))); |
| 186 | 188 |
| 187 String path = description.file.path; | 189 String path = description.file.path; |
| 188 Uri uri = Uri.base.resolve(path); | 190 Uri uri = Uri.base.resolve(path); |
| 189 loader.loadProgram(uri, target: target); | 191 loader.loadProgram(uri, target: target); |
| 190 var program = loader.program; | 192 var program = loader.program; |
| 191 for (var error in loader.errors) { | 193 for (var error in loader.errors) { |
| 192 return fail(program, "$error"); | 194 return fail(program, "$error"); |
| 193 } | 195 } |
| 196 var coreTypes = new CoreTypes(program); |
| 194 target | 197 target |
| 195 ..performModularTransformations(program) | 198 ..performModularTransformations(coreTypes, program) |
| 196 ..performGlobalTransformations(program); | 199 ..performGlobalTransformations(coreTypes, program); |
| 197 return pass(program); | 200 return pass(program); |
| 198 } catch (e, s) { | 201 } catch (e, s) { |
| 199 return crash(e, s); | 202 return crash(e, s); |
| 200 } | 203 } |
| 201 } | 204 } |
| 202 } | 205 } |
| 203 | 206 |
| 204 class GenericTypesReification extends Step<Program, Program, TestContext> { | 207 class GenericTypesReification extends Step<Program, Program, TestContext> { |
| 205 const GenericTypesReification(); | 208 const GenericTypesReification(); |
| 206 | 209 |
| 207 String get name => "generic types reification"; | 210 String get name => "generic types reification"; |
| 208 | 211 |
| 209 Future<Result<Program>> run(Program program, TestContext testContext) async { | 212 Future<Result<Program>> run(Program program, TestContext testContext) async { |
| 210 try { | 213 try { |
| 211 program = generic_types_reification.transformProgram(program); | 214 CoreTypes coreTypes = new CoreTypes(program); |
| 215 program = generic_types_reification.transformProgram(coreTypes, program); |
| 212 return pass(program); | 216 return pass(program); |
| 213 } catch (e, s) { | 217 } catch (e, s) { |
| 214 return crash(e, s); | 218 return crash(e, s); |
| 215 } | 219 } |
| 216 } | 220 } |
| 217 } | 221 } |
| 218 | 222 |
| 219 class Run extends Step<Uri, int, TestContext> { | 223 class Run extends Step<Uri, int, TestContext> { |
| 220 const Run(); | 224 const Run(); |
| 221 | 225 |
| 222 String get name => "run"; | 226 String get name => "run"; |
| 223 | 227 |
| 224 Future<Result<int>> run(Uri uri, TestContext context) async { | 228 Future<Result<int>> run(Uri uri, TestContext context) async { |
| 225 File generated = new File.fromUri(uri); | 229 File generated = new File.fromUri(uri); |
| 226 StdioProcess process; | 230 StdioProcess process; |
| 227 try { | 231 try { |
| 228 process = | 232 process = |
| 229 await StdioProcess.run(context.vm.toFilePath(), [generated.path]); | 233 await StdioProcess.run(context.vm.toFilePath(), [generated.path]); |
| 230 print(process.output); | 234 print(process.output); |
| 231 } finally { | 235 } finally { |
| 232 generated.parent.delete(recursive: true); | 236 generated.parent.delete(recursive: true); |
| 233 } | 237 } |
| 234 return process.toResult(); | 238 return process.toResult(); |
| 235 } | 239 } |
| 236 } | 240 } |
| 237 | 241 |
| 238 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); | 242 main(List<String> arguments) => runMe(arguments, createContext, "testing.json"); |
| OLD | NEW |