OLD | NEW |
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file | 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 | 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 library fasta.dill_target; | 5 library fasta.dill_target; |
6 | 6 |
7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
8 | 8 |
9 import 'package:kernel/ast.dart' show Class; | 9 import 'package:kernel/ast.dart' show Class; |
10 | 10 |
11 import 'dill_loader.dart' show DillLoader; | 11 import 'dill_loader.dart' show DillLoader; |
12 | 12 |
13 import '../errors.dart' show inputError, internalError; | 13 import '../errors.dart' show inputError, internalError; |
14 | 14 |
15 import '../target_implementation.dart' show TargetImplementation; | 15 import '../target_implementation.dart' show TargetImplementation; |
16 | 16 |
17 import '../ticker.dart' show Ticker; | 17 import '../ticker.dart' show Ticker; |
18 | 18 |
19 import '../translate_uri.dart' show TranslateUri; | 19 import '../translate_uri.dart' show TranslateUri; |
20 | 20 |
21 import '../ast_kind.dart' show AstKind; | |
22 | |
23 import '../kernel/kernel_builder.dart' show ClassBuilder, KernelClassBuilder; | 21 import '../kernel/kernel_builder.dart' show ClassBuilder, KernelClassBuilder; |
24 | 22 |
25 import 'dill_library_builder.dart' show DillLibraryBuilder; | 23 import 'dill_library_builder.dart' show DillLibraryBuilder; |
26 | 24 |
27 class DillTarget extends TargetImplementation { | 25 class DillTarget extends TargetImplementation { |
28 bool isLoaded = false; | 26 bool isLoaded = false; |
29 DillLoader loader; | 27 DillLoader loader; |
30 | 28 |
31 DillTarget(Ticker ticker, TranslateUri uriTranslator) | 29 DillTarget(Ticker ticker, TranslateUri uriTranslator) |
32 : super(ticker, uriTranslator) { | 30 : super(ticker, uriTranslator) { |
33 loader = new DillLoader(this); | 31 loader = new DillLoader(this); |
34 } | 32 } |
35 | 33 |
36 void addLineStarts(Uri uri, List<int> lineStarts) { | 34 void addLineStarts(Uri uri, List<int> lineStarts) { |
37 internalError("Unsupported operation."); | 35 internalError("Unsupported operation."); |
38 } | 36 } |
39 | 37 |
40 void read(Uri uri) { | 38 void read(Uri uri) { |
41 if (loader.input == null) { | 39 if (loader.input == null) { |
42 loader.input = uri; | 40 loader.input = uri; |
43 } else { | 41 } else { |
44 inputError(uri, -1, "Can only read one dill file."); | 42 inputError(uri, -1, "Can only read one dill file."); |
45 } | 43 } |
46 } | 44 } |
47 | 45 |
48 Future<Null> writeProgram(Uri uri, AstKind kind) { | 46 Future<Null> writeProgram(Uri uri) { |
49 return internalError("not implemented."); | 47 return internalError("not implemented."); |
50 } | 48 } |
51 | 49 |
52 Future<Null> writeOutline(Uri uri) async { | 50 Future<Null> writeOutline(Uri uri) async { |
53 if (loader.input == null) return null; | 51 if (loader.input == null) return null; |
54 await loader.buildOutlines(); | 52 await loader.buildOutlines(); |
55 isLoaded = true; | 53 isLoaded = true; |
56 return null; | 54 return null; |
57 } | 55 } |
58 | 56 |
59 DillLibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri) { | 57 DillLibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri) { |
60 return new DillLibraryBuilder(uri, loader); | 58 return new DillLibraryBuilder(uri, loader); |
61 } | 59 } |
62 | 60 |
63 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) {} | 61 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set) {} |
64 | 62 |
65 List<ClassBuilder> collectAllClasses() { | 63 List<ClassBuilder> collectAllClasses() { |
66 return null; | 64 return null; |
67 } | 65 } |
68 | 66 |
69 void breakCycle(ClassBuilder cls) {} | 67 void breakCycle(ClassBuilder cls) {} |
70 | 68 |
71 Class get objectClass { | 69 Class get objectClass { |
72 KernelClassBuilder builder = loader.coreLibrary.exports["Object"]; | 70 KernelClassBuilder builder = loader.coreLibrary.exports["Object"]; |
73 return builder.cls; | 71 return builder.cls; |
74 } | 72 } |
75 } | 73 } |
OLD | NEW |