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

Unified Diff: pkg/fasta/lib/src/dill/dill_loader.dart

Issue 2623033007: Fasta targets and loaders. (Closed)
Patch Set: Address review comments. Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/fasta/lib/src/dill/dill_target.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/fasta/lib/src/dill/dill_loader.dart
diff --git a/pkg/fasta/lib/src/dill/dill_loader.dart b/pkg/fasta/lib/src/dill/dill_loader.dart
new file mode 100644
index 0000000000000000000000000000000000000000..2a71829d513050e8ca271ca909cc92fa6e7a313f
--- /dev/null
+++ b/pkg/fasta/lib/src/dill/dill_loader.dart
@@ -0,0 +1,60 @@
+// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library fasta.dill_loader;
+
+import 'dart:async' show
+ Future;
+
+import 'dart:io' show
+ File;
+
+import 'package:kernel/kernel.dart' show
+ loadProgramFromBinary;
+
+import 'package:kernel/ast.dart' show
+ Library,
+ Program;
+
+import '../loader.dart' show
+ Loader;
+
+import '../target_implementation.dart' show
+ TargetImplementation;
+
+import 'dill_library_builder.dart' show
+ DillLibraryBuilder;
+
+class DillLoader extends Loader<Library> {
+ Uri input;
+
+ Program program;
+
+ DillLoader(TargetImplementation target)
+ : super(target);
+
+ DillLibraryBuilder read(Uri uri) => super.read(uri);
+
+ Future<Null> buildOutline(DillLibraryBuilder builder) async {
+ if (program == null) {
+ byteCount = await new File.fromUri(input).length();
+ setProgram(await loadProgramFromBinary(input.toFilePath()));
+ }
+ builder.library.classes.forEach(builder.addClass);
+ builder.library.procedures.forEach(builder.addMember);
+ builder.library.fields.forEach(builder.addMember);
+ }
+
+ Future<Null> buildBody(DillLibraryBuilder builder, _) {
+ return buildOutline(builder);
+ }
+
+ void setProgram(Program program) {
+ assert(input != null);
+ this.program = program;
+ for (Library library in program.libraries) {
+ read(library.importUri).library = library;
+ }
+ }
+}
« no previous file with comments | « no previous file | pkg/fasta/lib/src/dill/dill_target.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698