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