| 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.source_loader; | 5 library fasta.source_loader; |
| 6 | 6 |
| 7 import 'dart:async' show Future; | 7 import 'dart:async' show Future; |
| 8 | 8 |
| 9 import 'dart:typed_data' show Uint8List; | 9 import 'dart:typed_data' show Uint8List; |
| 10 | 10 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 73 | 73 |
| 74 TypeInferenceEngine typeInferenceEngine; | 74 TypeInferenceEngine typeInferenceEngine; |
| 75 | 75 |
| 76 Instrumentation instrumentation; | 76 Instrumentation instrumentation; |
| 77 | 77 |
| 78 SourceLoader(this.fileSystem, KernelTarget target) : super(target); | 78 SourceLoader(this.fileSystem, KernelTarget target) : super(target); |
| 79 | 79 |
| 80 Future<Token> tokenize(SourceLibraryBuilder library, | 80 Future<Token> tokenize(SourceLibraryBuilder library, |
| 81 {bool suppressLexicalErrors: false}) async { | 81 {bool suppressLexicalErrors: false}) async { |
| 82 Uri uri = library.fileUri; | 82 Uri uri = library.fileUri; |
| 83 if (uri == null || uri.scheme != "file") { | 83 String scheme = uri?.scheme; |
| 84 |
| 85 // TODO(sigmund): source-loader shouldn't check schemes, but defer to the |
| 86 // underlying file system to decide whether it is supported. |
| 87 if (uri == null || (scheme != "file" && scheme != "multi-root")) { |
| 84 return inputError(library.uri, -1, "Not found: ${library.uri}."); | 88 return inputError(library.uri, -1, "Not found: ${library.uri}."); |
| 85 } | 89 } |
| 86 | 90 |
| 87 // Get the library text from the cache, or read from the file system. | 91 // Get the library text from the cache, or read from the file system. |
| 88 List<int> bytes = sourceBytes[uri]; | 92 List<int> bytes = sourceBytes[uri]; |
| 89 if (bytes == null) { | 93 if (bytes == null) { |
| 90 try { | 94 try { |
| 91 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes(); | 95 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes(); |
| 92 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1); | 96 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1); |
| 93 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes); | 97 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes); |
| (...skipping 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 512 | 516 |
| 513 Expression throwCompileConstantError(Expression error) { | 517 Expression throwCompileConstantError(Expression error) { |
| 514 return target.backendTarget.throwCompileConstantError(coreTypes, error); | 518 return target.backendTarget.throwCompileConstantError(coreTypes, error); |
| 515 } | 519 } |
| 516 | 520 |
| 517 Expression buildCompileTimeError(String message, int offset) { | 521 Expression buildCompileTimeError(String message, int offset) { |
| 518 return target.backendTarget | 522 return target.backendTarget |
| 519 .buildCompileTimeError(coreTypes, message, offset); | 523 .buildCompileTimeError(coreTypes, message, offset); |
| 520 } | 524 } |
| 521 } | 525 } |
| OLD | NEW |