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 'deprecated_problems.dart' | 13 import 'deprecated_problems.dart' |
14 show firstSourceUri, deprecated_printUnexpected; | 14 show firstSourceUri, deprecated_printUnexpected; |
15 | 15 |
16 import 'messages.dart' show LocatedMessage, Message, templateUnspecified; | 16 import 'messages.dart' |
| 17 show LocatedMessage, Message, messagePlatformPrivateLibraryAccess; |
17 | 18 |
18 import 'target_implementation.dart' show TargetImplementation; | 19 import 'target_implementation.dart' show TargetImplementation; |
19 | 20 |
20 import 'ticker.dart' show Ticker; | 21 import 'ticker.dart' show Ticker; |
21 | 22 |
22 abstract class Loader<L> { | 23 abstract class Loader<L> { |
23 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{}; | 24 final Map<Uri, LibraryBuilder> builders = <Uri, LibraryBuilder>{}; |
24 | 25 |
25 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>(); | 26 final Queue<LibraryBuilder> unparsedLibraries = new Queue<LibraryBuilder>(); |
26 | 27 |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 first ??= library; | 97 first ??= library; |
97 if (library.loader == this) { | 98 if (library.loader == this) { |
98 unparsedLibraries.addLast(library); | 99 unparsedLibraries.addLast(library); |
99 } | 100 } |
100 return library; | 101 return library; |
101 }); | 102 }); |
102 if (accessor != null && | 103 if (accessor != null && |
103 uri.scheme == "dart" && | 104 uri.scheme == "dart" && |
104 uri.path.startsWith("_") && | 105 uri.path.startsWith("_") && |
105 accessor.uri.scheme != "dart") { | 106 accessor.uri.scheme != "dart") { |
106 accessor.deprecated_addCompileTimeError( | 107 accessor.addCompileTimeError( |
107 charOffset, "Can't access platform private library."); | 108 messagePlatformPrivateLibraryAccess, charOffset, accessor.fileUri); |
108 } | 109 } |
109 return builder; | 110 return builder; |
110 } | 111 } |
111 | 112 |
112 void ensureCoreLibrary() { | 113 void ensureCoreLibrary() { |
113 if (coreLibrary == null) { | 114 if (coreLibrary == null) { |
114 read(Uri.parse("dart:core"), -1); | 115 read(Uri.parse("dart:core"), -1); |
115 assert(coreLibrary != null); | 116 assert(coreLibrary != null); |
116 } | 117 } |
117 } | 118 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
172 /// otherwise it is added to [unhandledErrors]. | 173 /// otherwise it is added to [unhandledErrors]. |
173 void addCompileTimeError(Message message, int charOffset, Uri fileUri, | 174 void addCompileTimeError(Message message, int charOffset, Uri fileUri, |
174 {bool silent: false, bool wasHandled: false}) { | 175 {bool silent: false, bool wasHandled: false}) { |
175 if (!silent) { | 176 if (!silent) { |
176 deprecated_printUnexpected(fileUri, charOffset, message.message); | 177 deprecated_printUnexpected(fileUri, charOffset, message.message); |
177 } | 178 } |
178 (wasHandled ? handledErrors : unhandledErrors) | 179 (wasHandled ? handledErrors : unhandledErrors) |
179 .add(message.withLocation(fileUri, charOffset)); | 180 .add(message.withLocation(fileUri, charOffset)); |
180 } | 181 } |
181 | 182 |
182 void deprecated_addCompileTimeError( | |
183 Uri fileUri, int charOffset, String message, | |
184 {bool silent: false, bool wasHandled: false}) { | |
185 if (!silent) { | |
186 deprecated_printUnexpected(fileUri, charOffset, message); | |
187 } | |
188 (wasHandled ? handledErrors : unhandledErrors).add(templateUnspecified | |
189 .withArguments(message) | |
190 .withLocation(fileUri, charOffset)); | |
191 } | |
192 | |
193 Builder getAbstractClassInstantiationError() { | 183 Builder getAbstractClassInstantiationError() { |
194 return target.getAbstractClassInstantiationError(this); | 184 return target.getAbstractClassInstantiationError(this); |
195 } | 185 } |
196 | 186 |
197 Builder getCompileTimeError() => target.getCompileTimeError(this); | 187 Builder getCompileTimeError() => target.getCompileTimeError(this); |
198 | 188 |
199 Builder getDuplicatedFieldInitializerError() { | 189 Builder getDuplicatedFieldInitializerError() { |
200 return target.getDuplicatedFieldInitializerError(this); | 190 return target.getDuplicatedFieldInitializerError(this); |
201 } | 191 } |
202 | 192 |
203 Builder getNativeAnnotation() => target.getNativeAnnotation(this); | 193 Builder getNativeAnnotation() => target.getNativeAnnotation(this); |
204 } | 194 } |
205 | 195 |
206 String format(double d, int fractionDigits, int width) { | 196 String format(double d, int fractionDigits, int width) { |
207 return d.toStringAsFixed(fractionDigits).padLeft(width); | 197 return d.toStringAsFixed(fractionDigits).padLeft(width); |
208 } | 198 } |
OLD | NEW |