Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(15)

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_target.dart

Issue 2865843002: Use FileSystem to read files in SourceLoader and TranslateUri. (Closed)
Patch Set: Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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.kernel_target; 5 library fasta.kernel_target;
6 6
7 import 'dart:async' show Future; 7 import 'dart:async' show Future;
8 8
9 import 'dart:io' show File, IOSink; 9 import 'dart:io' show File, IOSink;
10 10
11 import 'package:front_end/file_system.dart';
11 import 'package:kernel/ast.dart' 12 import 'package:kernel/ast.dart'
12 show 13 show
13 Arguments, 14 Arguments,
14 AsyncMarker, 15 AsyncMarker,
15 Class, 16 Class,
16 Constructor, 17 Constructor,
17 DartType, 18 DartType,
18 DynamicType, 19 DynamicType,
19 EmptyStatement, 20 EmptyStatement,
20 Expression, 21 Expression,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 MemberBuilder, 83 MemberBuilder,
83 MixinApplicationBuilder, 84 MixinApplicationBuilder,
84 NamedMixinApplicationBuilder, 85 NamedMixinApplicationBuilder,
85 NamedTypeBuilder, 86 NamedTypeBuilder,
86 TypeBuilder, 87 TypeBuilder,
87 TypeVariableBuilder; 88 TypeVariableBuilder;
88 89
89 import 'verifier.dart' show verifyProgram; 90 import 'verifier.dart' show verifyProgram;
90 91
91 class KernelTarget extends TargetImplementation { 92 class KernelTarget extends TargetImplementation {
93 /// The [FileSystem] which should be used to access files.
94 final FileSystem fileSystem;
95
92 final bool strongMode; 96 final bool strongMode;
93 97
94 final DillTarget dillTarget; 98 final DillTarget dillTarget;
95 99
96 /// Shared with [CompilerContext]. 100 /// Shared with [CompilerContext].
97 final Map<String, Source> uriToSource; 101 final Map<String, Source> uriToSource;
98 102
99 SourceLoader<Library> loader; 103 SourceLoader<Library> loader;
100 Program program; 104 Program program;
101 105
102 final List errors = []; 106 final List errors = [];
103 107
104 final TypeBuilder dynamicType = 108 final TypeBuilder dynamicType =
105 new KernelNamedTypeBuilder("dynamic", null, -1, null); 109 new KernelNamedTypeBuilder("dynamic", null, -1, null);
106 110
107 KernelTarget( 111 KernelTarget(this.fileSystem, DillTarget dillTarget,
108 DillTarget dillTarget, TranslateUri uriTranslator, this.strongMode, 112 TranslateUri uriTranslator, this.strongMode,
109 [Map<String, Source> uriToSource]) 113 [Map<String, Source> uriToSource])
110 : dillTarget = dillTarget, 114 : dillTarget = dillTarget,
111 uriToSource = uriToSource ?? CompilerContext.current.uriToSource, 115 uriToSource = uriToSource ?? CompilerContext.current.uriToSource,
112 super(dillTarget.ticker, uriTranslator) { 116 super(dillTarget.ticker, uriTranslator) {
113 resetCrashReporting(); 117 resetCrashReporting();
114 loader = createLoader(); 118 loader = createLoader();
115 } 119 }
116 120
117 void addError(file, int charOffset, String message) { 121 void addError(file, int charOffset, String message) {
118 Uri uri = file is String ? Uri.parse(file) : file; 122 Uri uri = file is String ? Uri.parse(file) : file;
119 InputError error = new InputError(uri, charOffset, message); 123 InputError error = new InputError(uri, charOffset, message);
120 print(error.format()); 124 print(error.format());
121 errors.add(error); 125 errors.add(error);
122 } 126 }
123 127
124 SourceLoader<Library> createLoader() => new SourceLoader<Library>(this); 128 SourceLoader<Library> createLoader() =>
129 new SourceLoader<Library>(fileSystem, this);
125 130
126 void addSourceInformation( 131 void addSourceInformation(
127 Uri uri, List<int> lineStarts, List<int> sourceCode) { 132 Uri uri, List<int> lineStarts, List<int> sourceCode) {
128 String fileUri = relativizeUri(uri); 133 String fileUri = relativizeUri(uri);
129 uriToSource[fileUri] = new Source(lineStarts, sourceCode); 134 uriToSource[fileUri] = new Source(lineStarts, sourceCode);
130 } 135 }
131 136
132 void read(Uri uri) { 137 void read(Uri uri) {
133 loader.read(uri); 138 loader.read(uri);
134 } 139 }
(...skipping 587 matching lines...) Expand 10 before | Expand all | Expand 10 after
722 } 727 }
723 for (Constructor constructor in superclass.constructors) { 728 for (Constructor constructor in superclass.constructors) {
724 if (constructor.name.name.isEmpty) { 729 if (constructor.name.name.isEmpty) {
725 return constructor.function.requiredParameterCount == 0 730 return constructor.function.requiredParameterCount == 0
726 ? constructor 731 ? constructor
727 : null; 732 : null;
728 } 733 }
729 } 734 }
730 return null; 735 return null;
731 } 736 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698