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

Side by Side Diff: pkg/compiler/lib/src/apiimpl.dart

Issue 2938823002: Starting making dart2js strong mode clean. (Closed)
Patch Set: Address some comments. Created 3 years, 6 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
« no previous file with comments | « pkg/compiler/analysis_options_strong.yaml ('k') | pkg/compiler/lib/src/closure.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 'package:package_config/packages.dart'; 9 import 'package:package_config/packages.dart';
10 import 'package:package_config/packages_file.dart' as pkgs; 10 import 'package:package_config/packages_file.dart' as pkgs;
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 }); 112 });
113 } 113 }
114 return _synthesizeScript(readableUri); 114 return _synthesizeScript(readableUri);
115 } 115 }
116 116
117 // TODO(johnniwinther): Wrap the result from [provider] in a specialized 117 // TODO(johnniwinther): Wrap the result from [provider] in a specialized
118 // [Future] to ensure that we never execute an asynchronous action without 118 // [Future] to ensure that we never execute an asynchronous action without
119 // setting up the current element of the compiler. 119 // setting up the current element of the compiler.
120 return new Future.sync( 120 return new Future.sync(
121 () => callUserProvider(resourceUri, api.InputKind.utf8)) 121 () => callUserProvider(resourceUri, api.InputKind.utf8))
122 .then((SourceFile sourceFile) { 122 .then((api.Input sourceFile) {
123 // We use [readableUri] as the URI for the script since need to preserve 123 // We use [readableUri] as the URI for the script since need to preserve
124 // the scheme in the script because [Script.uri] is used for resolving 124 // the scheme in the script because [Script.uri] is used for resolving
125 // relative URIs mentioned in the script. See the comment on 125 // relative URIs mentioned in the script. See the comment on
126 // [LibraryLoader] for more details. 126 // [LibraryLoader] for more details.
127 return new Script(readableUri, resourceUri, sourceFile); 127 return new Script(readableUri, resourceUri, sourceFile);
128 }).catchError((error) { 128 }).catchError((error) {
129 _reportReadError(readableUri, element, node, error); 129 _reportReadError(readableUri, element, node, error);
130 return _synthesizeScript(readableUri); 130 return _synthesizeScript(readableUri);
131 }); 131 });
132 } 132 }
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 .analyzeUri(uri, skipLibraryWithPartOfTag: skipLibraryWithPartOfTag); 192 .analyzeUri(uri, skipLibraryWithPartOfTag: skipLibraryWithPartOfTag);
193 }); 193 });
194 } 194 }
195 195
196 Future setupPackages(Uri uri) { 196 Future setupPackages(Uri uri) {
197 if (options.packageRoot != null) { 197 if (options.packageRoot != null) {
198 // Use "non-file" packages because the file version requires a [Directory] 198 // Use "non-file" packages because the file version requires a [Directory]
199 // and we can't depend on 'dart:io' classes. 199 // and we can't depend on 'dart:io' classes.
200 packages = new NonFilePackagesDirectoryPackages(options.packageRoot); 200 packages = new NonFilePackagesDirectoryPackages(options.packageRoot);
201 } else if (options.packageConfig != null) { 201 } else if (options.packageConfig != null) {
202 return callUserProvider(options.packageConfig, api.InputKind.binary) 202 Future<Binary> future =
203 .then((Binary binary) { 203 callUserProvider(options.packageConfig, api.InputKind.binary);
204 return future.then((Binary binary) {
204 packages = 205 packages =
205 new MapPackages(pkgs.parse(binary.data, options.packageConfig)); 206 new MapPackages(pkgs.parse(binary.data, options.packageConfig));
206 }).catchError((error) { 207 }).catchError((error) {
207 reporter.reportErrorMessage( 208 reporter.reportErrorMessage(
208 NO_LOCATION_SPANNABLE, 209 NO_LOCATION_SPANNABLE,
209 MessageKind.INVALID_PACKAGE_CONFIG, 210 MessageKind.INVALID_PACKAGE_CONFIG,
210 {'uri': options.packageConfig, 'exception': error}); 211 {'uri': options.packageConfig, 'exception': error});
211 packages = Packages.noPackages; 212 packages = Packages.noPackages;
212 }); 213 });
213 } else { 214 } else {
214 if (options.packagesDiscoveryProvider == null) { 215 if (options.packagesDiscoveryProvider == null) {
215 packages = Packages.noPackages; 216 packages = Packages.noPackages;
216 } else { 217 } else {
217 return callUserPackagesDiscovery(uri).then((p) { 218 return callUserPackagesDiscovery(uri).then((p) {
218 packages = p; 219 packages = p;
219 }); 220 });
220 } 221 }
221 } 222 }
222 return new Future.value(); 223 return new Future.value();
223 } 224 }
224 225
225 Future<Null> setupSdk() { 226 Future<Null> setupSdk() {
226 Future future = new Future.value(null); 227 Future future = new Future.value(null);
227 if (options.resolutionInputs != null) { 228 if (options.resolutionInputs != null) {
228 future = Future.forEach(options.resolutionInputs, (Uri resolutionInput) { 229 future = Future.forEach(options.resolutionInputs, (Uri resolutionInput) {
229 reporter.log('Reading serialized data from ${resolutionInput}'); 230 reporter.log('Reading serialized data from ${resolutionInput}');
230 return callUserProvider(resolutionInput, api.InputKind.utf8) 231 Future<SourceFile> future =
231 .then((SourceFile sourceFile) { 232 callUserProvider(resolutionInput, api.InputKind.utf8);
233 return future.then((SourceFile sourceFile) {
232 serialization.deserializeFromText( 234 serialization.deserializeFromText(
233 resolutionInput, sourceFile.slowText()); 235 resolutionInput, sourceFile.slowText());
234 }); 236 });
235 }); 237 });
236 } 238 }
237 if (resolvedUriTranslator.isNotSet) { 239 if (resolvedUriTranslator.isNotSet) {
238 future = future.then((_) { 240 future = future.then((_) {
239 return platform_configuration 241 return platform_configuration
240 .load(options.platformConfigUri, provider) 242 .load(options.platformConfigUri, provider)
241 .then((Map<String, Uri> mapping) { 243 .then((Map<String, Uri> mapping) {
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 } 418 }
417 } 419 }
418 420
419 /// For every 'dart:' library, a corresponding environment variable is set 421 /// For every 'dart:' library, a corresponding environment variable is set
420 /// to "true". The environment variable's name is the concatenation of 422 /// to "true". The environment variable's name is the concatenation of
421 /// this prefix and the name (without the 'dart:'. 423 /// this prefix and the name (without the 'dart:'.
422 /// 424 ///
423 /// For example 'dart:html' has the environment variable 'dart.library.html' set 425 /// For example 'dart:html' has the environment variable 'dart.library.html' set
424 /// to "true". 426 /// to "true".
425 const String _dartLibraryEnvironmentPrefix = 'dart.library.'; 427 const String _dartLibraryEnvironmentPrefix = 'dart.library.';
OLDNEW
« no previous file with comments | « pkg/compiler/analysis_options_strong.yaml ('k') | pkg/compiler/lib/src/closure.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698