Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 leg_apiimpl; | 5 library leg_apiimpl; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import '../compiler.dart' as api; | 9 import '../compiler.dart' as api; |
| 10 import 'dart2jslib.dart' as leg; | 10 import 'dart2jslib.dart' as leg; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 167 node: node); | 167 node: node); |
| 168 } | 168 } |
| 169 return fileReadingTask.measure(() { | 169 return fileReadingTask.measure(() { |
| 170 Uri resourceUri = translateUri(readableUri, node); | 170 Uri resourceUri = translateUri(readableUri, node); |
| 171 String text = ""; | 171 String text = ""; |
| 172 try { | 172 try { |
| 173 // TODO(ahe): We expect the future to be complete and call value | 173 // TODO(ahe): We expect the future to be complete and call value |
| 174 // directly. In effect, we don't support truly asynchronous API. | 174 // directly. In effect, we don't support truly asynchronous API. |
| 175 text = deprecatedFutureValue(provider(resourceUri)); | 175 text = deprecatedFutureValue(provider(resourceUri)); |
| 176 } catch (exception) { | 176 } catch (exception) { |
| 177 if (node != null) { | 177 reportError( |
| 178 cancel("$exception", node: node); | 178 node, |
| 179 } else { | |
| 180 reportError( | |
| 181 null, | |
| 182 leg.MessageKind.GENERIC, {'text': 'Error: $exception'}); | 179 leg.MessageKind.GENERIC, {'text': 'Error: $exception'}); |
|
ahe
2013/08/06 15:01:00
Could you turn this into a non-generic message?
F
Johnni Winther
2013/08/19 08:05:19
Done.
| |
| 183 throw new leg.CompilerCancelledException("$exception"); | 180 return null; |
| 184 } | |
| 185 } | 181 } |
| 186 SourceFile sourceFile = new SourceFile(resourceUri.toString(), text); | 182 SourceFile sourceFile = new SourceFile(resourceUri.toString(), text); |
| 187 // We use [readableUri] as the URI for the script since need to preserve | 183 // We use [readableUri] as the URI for the script since need to preserve |
| 188 // the scheme in the script because [Script.uri] is used for resolving | 184 // the scheme in the script because [Script.uri] is used for resolving |
| 189 // relative URIs mentioned in the script. See the comment on | 185 // relative URIs mentioned in the script. See the comment on |
| 190 // [LibraryLoader] for more details. | 186 // [LibraryLoader] for more details. |
| 191 return new leg.Script(readableUri, sourceFile); | 187 return new leg.Script(readableUri, sourceFile); |
| 192 }); | 188 }); |
| 193 } | 189 } |
| 194 | 190 |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 213 bool allowInternalLibraryAccess = false; | 209 bool allowInternalLibraryAccess = false; |
| 214 if (importingLibrary != null) { | 210 if (importingLibrary != null) { |
| 215 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { | 211 if (importingLibrary.isPlatformLibrary || importingLibrary.isPatch) { |
| 216 allowInternalLibraryAccess = true; | 212 allowInternalLibraryAccess = true; |
| 217 } else if (importingLibrary.canonicalUri.path.contains( | 213 } else if (importingLibrary.canonicalUri.path.contains( |
| 218 'dart/tests/compiler/dart2js_native')) { | 214 'dart/tests/compiler/dart2js_native')) { |
| 219 allowInternalLibraryAccess = true; | 215 allowInternalLibraryAccess = true; |
| 220 } | 216 } |
| 221 } | 217 } |
| 222 if (!allowInternalLibraryAccess) { | 218 if (!allowInternalLibraryAccess) { |
| 223 if (node != null && importingLibrary != null) { | 219 if (importingLibrary != null) { |
| 224 reportError( | 220 reportError( |
| 225 node, | 221 node, |
| 226 leg.MessageKind.GENERIC, | 222 leg.MessageKind.INTERNAL_LIBRARY_FROM, |
| 227 {'text': | 223 {'resolvedUri': resolvedUri, |
| 228 'Error: Internal library $resolvedUri is not accessible from ' | 224 'importingUri': importingLibrary.canonicalUri}); |
| 229 '${importingLibrary.canonicalUri}.'}); | |
| 230 } else { | 225 } else { |
| 231 reportError( | 226 reportError( |
| 232 null, | 227 node, |
| 233 leg.MessageKind.GENERIC, | 228 leg.MessageKind.INTERNAL_LIBRARY, |
| 234 {'text': | 229 {'resolvedUri': resolvedUri}); |
| 235 'Error: Internal library $resolvedUri is not accessible.'}); | |
| 236 } | 230 } |
| 237 } | 231 } |
| 238 } | 232 } |
| 239 if (path == null) { | 233 if (path == null) { |
| 240 if (node != null) { | 234 reportError(node, leg.MessageKind.LIBRARY_NOT_FOUND, |
| 241 reportFatalError( | 235 {'resolvedUri': resolvedUri}); |
| 242 node, | |
| 243 leg.MessageKind.GENERIC, | |
| 244 {'text': 'Error: Library not found ${resolvedUri}.'}); | |
| 245 } else { | |
| 246 reportFatalError( | |
| 247 null, | |
| 248 leg.MessageKind.GENERIC, | |
| 249 {'text': 'Error: Library not found ${resolvedUri}.'}); | |
| 250 } | |
| 251 return null; | 236 return null; |
| 252 } | 237 } |
| 253 if (resolvedUri.path == 'html' || | 238 if (resolvedUri.path == 'html' || |
| 254 resolvedUri.path == 'io') { | 239 resolvedUri.path == 'io') { |
| 255 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart | 240 // TODO(ahe): Get rid of mockableLibraryUsed when test.dart |
| 256 // supports this use case better. | 241 // supports this use case better. |
| 257 mockableLibraryUsed = true; | 242 mockableLibraryUsed = true; |
| 258 } | 243 } |
| 259 return libraryRoot.resolve(path); | 244 return libraryRoot.resolve(path); |
| 260 } | 245 } |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 301 handler(translateUri(span.uri, null), span.begin, span.end, | 286 handler(translateUri(span.uri, null), span.begin, span.end, |
| 302 message, kind); | 287 message, kind); |
| 303 } | 288 } |
| 304 } | 289 } |
| 305 | 290 |
| 306 bool get isMockCompilation { | 291 bool get isMockCompilation { |
| 307 return mockableLibraryUsed | 292 return mockableLibraryUsed |
| 308 && (options.indexOf('--allow-mock-compilation') != -1); | 293 && (options.indexOf('--allow-mock-compilation') != -1); |
| 309 } | 294 } |
| 310 } | 295 } |
| OLD | NEW |