| 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 16 matching lines...) Expand all Loading... |
| 27 ClassBuilder, | 27 ClassBuilder, |
| 28 EnumBuilder, | 28 EnumBuilder, |
| 29 LibraryBuilder, | 29 LibraryBuilder, |
| 30 NamedTypeBuilder, | 30 NamedTypeBuilder, |
| 31 TypeBuilder; | 31 TypeBuilder; |
| 32 | 32 |
| 33 import '../compiler_context.dart' show CompilerContext; | 33 import '../compiler_context.dart' show CompilerContext; |
| 34 | 34 |
| 35 import '../deprecated_problems.dart' show deprecated_inputError; | 35 import '../deprecated_problems.dart' show deprecated_inputError; |
| 36 | 36 |
| 37 import '../problems.dart' show internalProblem; | |
| 38 | |
| 39 import '../export.dart' show Export; | 37 import '../export.dart' show Export; |
| 40 | 38 |
| 41 import '../fasta_codes.dart' | 39 import '../fasta_codes.dart' |
| 42 show | 40 show |
| 43 Message, | 41 Message, |
| 44 templateCyclicClassHierarchy, | 42 templateCyclicClassHierarchy, |
| 45 templateExtendingEnum, | 43 templateExtendingEnum, |
| 46 templateExtendingRestricted, | 44 templateExtendingRestricted, |
| 47 templateIllegalMixin, | 45 templateIllegalMixin, |
| 48 templateIllegalMixinDueToConstructors, | 46 templateIllegalMixinDueToConstructors, |
| 49 templateIllegalMixinDueToConstructorsCause, | 47 templateIllegalMixinDueToConstructorsCause, |
| 50 templateInternalProblemUriMissingScheme, | |
| 51 templateUnspecified; | 48 templateUnspecified; |
| 52 | 49 |
| 53 import '../kernel/kernel_shadow_ast.dart' show KernelTypeInferenceEngine; | 50 import '../kernel/kernel_shadow_ast.dart' show KernelTypeInferenceEngine; |
| 54 | 51 |
| 55 import '../kernel/kernel_target.dart' show KernelTarget; | 52 import '../kernel/kernel_target.dart' show KernelTarget; |
| 56 | 53 |
| 57 import '../loader.dart' show Loader; | 54 import '../loader.dart' show Loader; |
| 58 | 55 |
| 59 import '../parser/class_member_parser.dart' show ClassMemberParser; | 56 import '../parser/class_member_parser.dart' show ClassMemberParser; |
| 60 | 57 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 92 TypeInferenceEngine typeInferenceEngine; | 89 TypeInferenceEngine typeInferenceEngine; |
| 93 | 90 |
| 94 Instrumentation instrumentation; | 91 Instrumentation instrumentation; |
| 95 | 92 |
| 96 SourceLoader(this.fileSystem, this.includeComments, KernelTarget target) | 93 SourceLoader(this.fileSystem, this.includeComments, KernelTarget target) |
| 97 : super(target); | 94 : super(target); |
| 98 | 95 |
| 99 Future<Token> tokenize(SourceLibraryBuilder library, | 96 Future<Token> tokenize(SourceLibraryBuilder library, |
| 100 {bool suppressLexicalErrors: false}) async { | 97 {bool suppressLexicalErrors: false}) async { |
| 101 Uri uri = library.fileUri; | 98 Uri uri = library.fileUri; |
| 102 if (uri == null) { | 99 // TODO(sigmund): source-loader shouldn't check schemes, but defer to the |
| 100 // underlying file system to decide whether it is supported. |
| 101 if (uri == null || uri.scheme != "file" && uri.scheme != "multi-root") { |
| 103 return deprecated_inputError( | 102 return deprecated_inputError( |
| 104 library.uri, -1, "Not found: ${library.uri}."); | 103 library.uri, -1, "Not found: ${library.uri}."); |
| 105 } else if (!uri.hasScheme) { | |
| 106 return internalProblem( | |
| 107 templateInternalProblemUriMissingScheme.withArguments(uri), | |
| 108 -1, | |
| 109 library.uri); | |
| 110 } | 104 } |
| 111 | 105 |
| 112 // Get the library text from the cache, or read from the file system. | 106 // Get the library text from the cache, or read from the file system. |
| 113 List<int> bytes = sourceBytes[uri]; | 107 List<int> bytes = sourceBytes[uri]; |
| 114 if (bytes == null) { | 108 if (bytes == null) { |
| 115 try { | 109 try { |
| 116 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes(); | 110 List<int> rawBytes = await fileSystem.entityForUri(uri).readAsBytes(); |
| 117 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1); | 111 Uint8List zeroTerminatedBytes = new Uint8List(rawBytes.length + 1); |
| 118 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes); | 112 zeroTerminatedBytes.setRange(0, rawBytes.length, rawBytes); |
| 119 bytes = zeroTerminatedBytes; | 113 bytes = zeroTerminatedBytes; |
| (...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 Expression throwCompileConstantError(Expression error) { | 546 Expression throwCompileConstantError(Expression error) { |
| 553 return target.backendTarget.throwCompileConstantError(coreTypes, error); | 547 return target.backendTarget.throwCompileConstantError(coreTypes, error); |
| 554 } | 548 } |
| 555 | 549 |
| 556 Expression buildCompileTimeError(Message message, int offset, Uri uri) { | 550 Expression buildCompileTimeError(Message message, int offset, Uri uri) { |
| 557 String text = target.context | 551 String text = target.context |
| 558 .format(message.withLocation(uri, offset), Severity.error); | 552 .format(message.withLocation(uri, offset), Severity.error); |
| 559 return target.backendTarget.buildCompileTimeError(coreTypes, text, offset); | 553 return target.backendTarget.buildCompileTimeError(coreTypes, text, offset); |
| 560 } | 554 } |
| 561 } | 555 } |
| OLD | NEW |