Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2016, 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.dill_loader; | |
| 6 | |
| 7 import 'dart:async' show | |
| 8 Future; | |
| 9 | |
| 10 import 'dart:io' show | |
| 11 File; | |
| 12 | |
| 13 import 'package:kernel/kernel.dart' show | |
| 14 loadProgramFromBinary; | |
| 15 | |
| 16 import 'package:kernel/ast.dart' show | |
| 17 Library, | |
| 18 Program; | |
| 19 | |
| 20 import '../loader.dart' show | |
| 21 Loader; | |
| 22 | |
| 23 import '../target_implementation.dart' show | |
| 24 TargetImplementation; | |
| 25 | |
| 26 import 'dill_library_builder.dart' show | |
| 27 DillLibraryBuilder; | |
| 28 | |
| 29 class DillLoader extends Loader<Library> { | |
| 30 Uri input; | |
| 31 | |
| 32 Program program; | |
| 33 | |
| 34 DillLoader(TargetImplementation target) | |
| 35 : super(target); | |
| 36 | |
| 37 DillLibraryBuilder read(Uri uri) => super.read(uri); | |
| 38 | |
| 39 Future<Null> buildOutline(DillLibraryBuilder builder) async { | |
| 40 if (program == null) { | |
| 41 byteCount = await new File.fromUri(input).length(); | |
| 42 setProgram(await loadProgramFromBinary(input.toFilePath())); | |
| 43 } | |
| 44 builder.library.classes.forEach(builder.addClass); | |
| 45 builder.library.procedures.forEach(builder.addMember); | |
| 46 builder.library.fields.forEach(builder.addMember); | |
| 47 } | |
| 48 | |
| 49 Future<Null> buildBody(DillLibraryBuilder builder, _) { | |
| 50 return buildOutline(builder); | |
| 51 } | |
| 52 | |
| 53 void setProgram(Program program) { | |
| 54 if (input == null) { | |
| 55 input = Uri.parse("org.dartlang:platform"); | |
|
Johnni Winther
2017/01/19 09:21:33
Add a comment about the semantics of this value.
ahe
2017/01/19 10:48:30
I've moved this code to pkg/fasta/lib/testing/suit
| |
| 56 } | |
| 57 this.program = program; | |
| 58 for (Library library in program.libraries) { | |
| 59 read(library.importUri).library = library; | |
| 60 } | |
| 61 } | |
| 62 } | |
| OLD | NEW |