| 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.loader; | 5 library fasta.loader; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:collection' show Queue; | 9 import 'dart:collection' show Queue; |
| 10 | 10 |
| 11 import 'builder/builder.dart' show Builder, LibraryBuilder; | 11 import 'builder/builder.dart' show Builder, LibraryBuilder; |
| 12 | 12 |
| 13 import 'errors.dart' show InputError, firstSourceUri, printUnexpected; | 13 import 'deprecated_problems.dart' |
| 14 show deprecated_InputError, firstSourceUri, deprecated_printUnexpected; |
| 14 | 15 |
| 15 import 'target_implementation.dart' show TargetImplementation; | 16 import 'target_implementation.dart' show TargetImplementation; |
| 16 | 17 |
| 17 import 'ticker.dart' show Ticker; | 18 import 'ticker.dart' show Ticker; |
| 18 | 19 |
| 19 abstract class Loader<L> { | 20 abstract class Loader<L> { |
| 20 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{}; | 21 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{}; |
| 21 | 22 |
| 22 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>(); | 23 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>(); |
| 23 | 24 |
| 24 final List<L> libraries = <L>[]; | 25 final List<L> libraries = <L>[]; |
| 25 | 26 |
| 26 final TargetImplementation target; | 27 final TargetImplementation target; |
| 27 | 28 |
| 28 /// List of all handled compile-time errors seen so far by libraries loaded | 29 /// List of all handled compile-time errors seen so far by libraries loaded |
| 29 /// by this loader. | 30 /// by this loader. |
| 30 /// | 31 /// |
| 31 /// A handled error is an error that has been added to the generated AST | 32 /// A handled error is an error that has been added to the generated AST |
| 32 /// already, for example, as a throw expression. | 33 /// already, for example, as a throw expression. |
| 33 final List<InputError> handledErrors = <InputError>[]; | 34 final List<deprecated_InputError> handledErrors = <deprecated_InputError>[]; |
| 34 | 35 |
| 35 /// List of all unhandled compile-time errors seen so far by libraries loaded | 36 /// List of all unhandled compile-time errors seen so far by libraries loaded |
| 36 /// by this loader. | 37 /// by this loader. |
| 37 /// | 38 /// |
| 38 /// An unhandled error is an error that hasn't been handled, see | 39 /// An unhandled error is an error that hasn't been handled, see |
| 39 /// [handledErrors]. | 40 /// [handledErrors]. |
| 40 final List<InputError> unhandledErrors = <InputError>[]; | 41 final List<deprecated_InputError> unhandledErrors = <deprecated_InputError>[]; |
| 41 | 42 |
| 42 LibraryBuilder coreLibrary; | 43 LibraryBuilder coreLibrary; |
| 43 | 44 |
| 44 LibraryBuilder first; | 45 LibraryBuilder first; |
| 45 | 46 |
| 46 int byteCount = 0; | 47 int byteCount = 0; |
| 47 | 48 |
| 48 Uri currentUriForCrashReporting; | 49 Uri currentUriForCrashReporting; |
| 49 | 50 |
| 50 Loader(this.target); | 51 Loader(this.target); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 90 first ??= library; | 91 first ??= library; |
| 91 if (library.loader == this) { | 92 if (library.loader == this) { |
| 92 unparsedLibraries.addLast(library); | 93 unparsedLibraries.addLast(library); |
| 93 } | 94 } |
| 94 return library; | 95 return library; |
| 95 }); | 96 }); |
| 96 if (accessor != null && | 97 if (accessor != null && |
| 97 uri.scheme == "dart" && | 98 uri.scheme == "dart" && |
| 98 uri.path.startsWith("_") && | 99 uri.path.startsWith("_") && |
| 99 accessor.uri.scheme != "dart") { | 100 accessor.uri.scheme != "dart") { |
| 100 accessor.addCompileTimeError( | 101 accessor.deprecated_addCompileTimeError( |
| 101 charOffset, "Can't access platform private library."); | 102 charOffset, "Can't access platform private library."); |
| 102 } | 103 } |
| 103 return builder; | 104 return builder; |
| 104 } | 105 } |
| 105 | 106 |
| 106 void ensureCoreLibrary() { | 107 void ensureCoreLibrary() { |
| 107 if (coreLibrary == null) { | 108 if (coreLibrary == null) { |
| 108 read(Uri.parse("dart:core"), -1); | 109 read(Uri.parse("dart:core"), -1); |
| 109 assert(coreLibrary != null); | 110 assert(coreLibrary != null); |
| 110 } | 111 } |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 157 /// Builds all the method bodies found in the given [library]. | 158 /// Builds all the method bodies found in the given [library]. |
| 158 Future<Null> buildBody(covariant LibraryBuilder library); | 159 Future<Null> buildBody(covariant LibraryBuilder library); |
| 159 | 160 |
| 160 /// Register [message] as a compile-time error. | 161 /// Register [message] as a compile-time error. |
| 161 /// | 162 /// |
| 162 /// If [silent] is true, no error is printed as it is assumed the error has | 163 /// If [silent] is true, no error is printed as it is assumed the error has |
| 163 /// been previously reported. | 164 /// been previously reported. |
| 164 /// | 165 /// |
| 165 /// If [wasHandled] is true, this error is added to [handledErrors], | 166 /// If [wasHandled] is true, this error is added to [handledErrors], |
| 166 /// otherwise it is added to [unhandledErrors]. | 167 /// otherwise it is added to [unhandledErrors]. |
| 167 void addCompileTimeError(Uri fileUri, int charOffset, Object message, | 168 void deprecated_addCompileTimeError( |
| 169 Uri fileUri, int charOffset, Object message, |
| 168 {bool silent: false, bool wasHandled: false}) { | 170 {bool silent: false, bool wasHandled: false}) { |
| 169 if (!silent) { | 171 if (!silent) { |
| 170 printUnexpected(fileUri, charOffset, message); | 172 deprecated_printUnexpected(fileUri, charOffset, message); |
| 171 } | 173 } |
| 172 (wasHandled ? handledErrors : unhandledErrors) | 174 (wasHandled ? handledErrors : unhandledErrors) |
| 173 .add(new InputError(fileUri, charOffset, message)); | 175 .add(new deprecated_InputError(fileUri, charOffset, message)); |
| 174 } | 176 } |
| 175 | 177 |
| 176 Builder getAbstractClassInstantiationError() { | 178 Builder getAbstractClassInstantiationError() { |
| 177 return target.getAbstractClassInstantiationError(this); | 179 return target.getAbstractClassInstantiationError(this); |
| 178 } | 180 } |
| 179 | 181 |
| 180 Builder getCompileTimeError() => target.getCompileTimeError(this); | 182 Builder getCompileTimeError() => target.getCompileTimeError(this); |
| 181 | 183 |
| 182 Builder getDuplicatedFieldInitializerError() { | 184 Builder getDuplicatedFieldInitializerError() { |
| 183 return target.getDuplicatedFieldInitializerError(this); | 185 return target.getDuplicatedFieldInitializerError(this); |
| 184 } | 186 } |
| 185 | 187 |
| 186 Builder getNativeAnnotation() => target.getNativeAnnotation(this); | 188 Builder getNativeAnnotation() => target.getNativeAnnotation(this); |
| 187 } | 189 } |
| 188 | 190 |
| 189 String format(double d, int fractionDigits, int width) { | 191 String format(double d, int fractionDigits, int width) { |
| 190 return d.toStringAsFixed(fractionDigits).padLeft(width); | 192 return d.toStringAsFixed(fractionDigits).padLeft(width); |
| 191 } | 193 } |
| OLD | NEW |