Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // BSD-style license that can be found in the LICENSE file. | |
| 4 | |
| 5 library fasta.get_dependencies; | |
| 6 | |
| 7 import 'dart:async' show Future; | |
| 8 | |
| 9 import 'package:kernel/kernel.dart' show loadProgramFromBytes; | |
| 10 | |
| 11 import 'package:kernel/target/targets.dart' show Target; | |
| 12 | |
| 13 import '../../compiler_options.dart' show CompilerOptions; | |
| 14 | |
| 15 import '../../file_system.dart' show FileSystem; | |
| 16 | |
| 17 import '../base/processed_options.dart' show ProcessedOptions; | |
| 18 | |
| 19 import 'compiler_context.dart' show CompilerContext; | |
| 20 | |
| 21 import 'dill/dill_target.dart' show DillTarget; | |
| 22 | |
| 23 import 'kernel/kernel_target.dart' show KernelTarget; | |
| 24 | |
| 25 import 'uri_translator.dart' show UriTranslator; | |
| 26 | |
| 27 // TODO(sigmund): reimplement this API using the directive listener intead. | |
| 28 Future<List<Uri>> getDependencies(Uri script, FileSystem fileSystem, | |
|
Siggi Cherem (dart-lang)
2017/08/23 20:17:35
let's remove this argument, just use `c.options.fi
ahe
2017/08/24 11:52:01
Done. Great catch!
| |
| 29 {Uri sdk, | |
| 30 Uri packages, | |
| 31 Uri platform, | |
| 32 bool verbose: false, | |
| 33 Target target}) async { | |
| 34 var options = new CompilerOptions() | |
| 35 ..target = target | |
| 36 ..verbose = verbose | |
| 37 ..packagesFileUri = packages | |
| 38 ..sdkSummary = platform | |
| 39 ..sdkRoot = sdk; | |
| 40 var pOptions = new ProcessedOptions(options); | |
| 41 return await CompilerContext.runWithOptions(pOptions, | |
| 42 (CompilerContext c) async { | |
| 43 UriTranslator uriTranslator = await c.options.getUriTranslator(); | |
| 44 c.options.ticker.logMs("Read packages file"); | |
| 45 DillTarget dillTarget = | |
| 46 new DillTarget(c.options.ticker, uriTranslator, c.options.target); | |
| 47 if (platform != null) { | |
| 48 var bytes = await fileSystem.entityForUri(platform).readAsBytes(); | |
| 49 var platformProgram = loadProgramFromBytes(bytes); | |
| 50 platformProgram.unbindCanonicalNames(); | |
| 51 dillTarget.loader.appendLibraries(platformProgram); | |
| 52 } | |
| 53 KernelTarget kernelTarget = new KernelTarget( | |
| 54 fileSystem, false, dillTarget, uriTranslator, c.uriToSource); | |
| 55 | |
| 56 kernelTarget.read(script); | |
| 57 await dillTarget.buildOutlines(); | |
| 58 await kernelTarget.loader.buildOutlines(); | |
| 59 return await kernelTarget.loader.getDependencies(); | |
| 60 }); | |
| 61 } | |
| OLD | NEW |