| 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.target_implementation; | 5 library fasta.target_implementation; |
| 6 | 6 |
| 7 import 'builder/builder.dart' show | 7 import 'builder/builder.dart' show |
| 8 Builder, |
| 8 ClassBuilder, | 9 ClassBuilder, |
| 9 LibraryBuilder; | 10 LibraryBuilder; |
| 10 | 11 |
| 12 import 'loader.dart' show |
| 13 Loader; |
| 14 |
| 11 import 'target.dart' show | 15 import 'target.dart' show |
| 12 Target; | 16 Target; |
| 13 | 17 |
| 14 import 'ticker.dart' show | 18 import 'ticker.dart' show |
| 15 Ticker; | 19 Ticker; |
| 16 | 20 |
| 17 import 'translate_uri.dart' show | 21 import 'translate_uri.dart' show |
| 18 TranslateUri; | 22 TranslateUri; |
| 19 | 23 |
| 20 /// Provides the implementation details used by a loader for a target. | 24 /// Provides the implementation details used by a loader for a target. |
| 21 abstract class TargetImplementation extends Target { | 25 abstract class TargetImplementation extends Target { |
| 22 final TranslateUri uriTranslator; | 26 final TranslateUri uriTranslator; |
| 27 Builder cachedCompileTimeError; |
| 23 | 28 |
| 24 TargetImplementation(Ticker ticker, this.uriTranslator) | 29 TargetImplementation(Ticker ticker, this.uriTranslator) |
| 25 : super(ticker); | 30 : super(ticker); |
| 26 | 31 |
| 27 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist | 32 /// Creates a [LibraryBuilder] corresponding to [uri], if one doesn't exist |
| 28 /// already. | 33 /// already. |
| 29 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri); | 34 LibraryBuilder createLibraryBuilder(Uri uri, Uri fileUri); |
| 30 | 35 |
| 31 /// Add the classes extended or implemented directly by [cls] to [set]. | 36 /// Add the classes extended or implemented directly by [cls] to [set]. |
| 32 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set); | 37 void addDirectSupertype(ClassBuilder cls, Set<ClassBuilder> set); |
| 33 | 38 |
| 34 /// Returns all classes that will be included in the resulting program. | 39 /// Returns all classes that will be included in the resulting program. |
| 35 List<ClassBuilder> collectAllClasses(); | 40 List<ClassBuilder> collectAllClasses(); |
| 36 | 41 |
| 37 /// The class [cls] is involved in a cyclic definition. This method should | 42 /// The class [cls] is involved in a cyclic definition. This method should |
| 38 /// ensure that the cycle is broken, for example, by removing superclass and | 43 /// ensure that the cycle is broken, for example, by removing superclass and |
| 39 /// implemented interfaces. | 44 /// implemented interfaces. |
| 40 void breakCycle(ClassBuilder cls); | 45 void breakCycle(ClassBuilder cls); |
| 41 | 46 |
| 42 Uri translateUri(Uri uri) => uriTranslator.translate(uri); | 47 Uri translateUri(Uri uri) => uriTranslator.translate(uri); |
| 48 |
| 49 /// Returns a reference to the constructor used for creating a compile-time |
| 50 /// error. The constructor is expected to accept a single argument of type |
| 51 /// String, which is the compile-time error message. |
| 52 Builder getCompileTimeError(Loader loader) { |
| 53 if (cachedCompileTimeError != null) return cachedCompileTimeError; |
| 54 return cachedCompileTimeError = |
| 55 loader.coreLibrary.getConstructor("_CompileTimeError", isPrivate: true); |
| 56 } |
| 43 } | 57 } |
| OLD | NEW |