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

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

Issue 1749213006: use Source.isInSystemLibrary (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: format Created 4 years, 9 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 | « lib/src/codegen/js_module_item_order.dart ('k') | lib/src/server/server.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) 2015, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2015, 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 /// Command line tool to run the checker on a Dart program. 5 /// Command line tool to run the checker on a Dart program.
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:convert' show JSON; 9 import 'dart:convert' show JSON;
10 import 'dart:math' as math; 10 import 'dart:math' as math;
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
159 // _pendingLibraries was recorded in post-order. Process from the end 159 // _pendingLibraries was recorded in post-order. Process from the end
160 // to ensure reverse post-order. This will ensure that we handle back 160 // to ensure reverse post-order. This will ensure that we handle back
161 // edges from the original depth-first search correctly. 161 // edges from the original depth-first search correctly.
162 162
163 while (_pendingLibraries.isNotEmpty) { 163 while (_pendingLibraries.isNotEmpty) {
164 var unit = _pendingLibraries.removeLast(); 164 var unit = _pendingLibraries.removeLast();
165 var library = unit.library.element.enclosingElement; 165 var library = unit.library.element.enclosingElement;
166 assert(_compilationRecord[library] == true || 166 assert(_compilationRecord[library] == true ||
167 options.codegenOptions.forceCompile); 167 options.codegenOptions.forceCompile);
168 168
169 // Process dependences one more time to propagate failure from cycles 169 // Process dependencies one more time to propagate failure from cycles
170 for (var import in library.imports) { 170 for (var import in library.imports) {
171 if (!_compilationRecord[import.importedLibrary]) { 171 if (!_compilationRecord[import.importedLibrary]) {
172 _compilationRecord[library] = false; 172 _compilationRecord[library] = false;
173 } 173 }
174 } 174 }
175 for (var export in library.exports) { 175 for (var export in library.exports) {
176 if (!_compilationRecord[export.exportedLibrary]) { 176 if (!_compilationRecord[export.exportedLibrary]) {
177 _compilationRecord[library] = false; 177 _compilationRecord[library] = false;
178 } 178 }
179 } 179 }
(...skipping 10 matching lines...) Expand all
190 bool _compileLibrary(LibraryElement library, CompilationNotifier notifier) { 190 bool _compileLibrary(LibraryElement library, CompilationNotifier notifier) {
191 var success = _compilationRecord[library]; 191 var success = _compilationRecord[library];
192 if (success != null) { 192 if (success != null) {
193 if (!success) _failure = true; 193 if (!success) _failure = true;
194 return success; 194 return success;
195 } 195 }
196 196
197 // Optimistically mark a library valid until proven otherwise 197 // Optimistically mark a library valid until proven otherwise
198 _compilationRecord[library] = true; 198 _compilationRecord[library] = true;
199 199
200 if (!options.checkSdk && library.source.uri.scheme == 'dart') { 200 if (!options.checkSdk && library.source.isInSystemLibrary) {
201 // We assume the Dart SDK is always valid 201 // We assume the Dart SDK is always valid
202 if (_jsGen != null) _copyDartRuntime(); 202 if (_jsGen != null) _copyDartRuntime();
203 return true; 203 return true;
204 } 204 }
205 205
206 // Check dependences to determine if this library type checks 206 // Check dependences to determine if this library type checks
207 // TODO(jmesserly): in incremental mode, we can skip the transitive 207 // TODO(jmesserly): in incremental mode, we can skip the transitive
208 // compile of imports/exports. 208 // compile of imports/exports.
209 _compileLibrary(_dartCore, notifier); // implicit dart:core dependency 209 _compileLibrary(_dartCore, notifier); // implicit dart:core dependency
210 for (var import in library.imports) { 210 for (var import in library.imports) {
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
441 return filepath; 441 return filepath;
442 } 442 }
443 } 443 }
444 444
445 /// Log any errors encountered when resolving [source] and return whether any 445 /// Log any errors encountered when resolving [source] and return whether any
446 /// errors were found. 446 /// errors were found.
447 bool computeErrors(Source source) { 447 bool computeErrors(Source source) {
448 AnalysisContext errorContext = context; 448 AnalysisContext errorContext = context;
449 // TODO(jmesserly): should this be a fix somewhere in analyzer? 449 // TODO(jmesserly): should this be a fix somewhere in analyzer?
450 // otherwise we fail to find the parts. 450 // otherwise we fail to find the parts.
451 if (source.uri.scheme == 'dart') { 451 if (source.isInSystemLibrary) {
452 errorContext = context.sourceFactory.dartSdk.context; 452 errorContext = context.sourceFactory.dartSdk.context;
453 } 453 }
454 List<AnalysisError> errors = errorContext.computeErrors(source); 454 List<AnalysisError> errors = errorContext.computeErrors(source);
455 bool failure = false; 455 bool failure = false;
456 for (var error in errors) { 456 for (var error in errors) {
457 ErrorCode code = error.errorCode; 457 ErrorCode code = error.errorCode;
458 // Always skip TODOs. 458 // Always skip TODOs.
459 if (code.type == ErrorType.TODO) continue; 459 if (code.type == ErrorType.TODO) continue;
460 460
461 // TODO(jmesserly): for now, treat DDC errors as having a different 461 // TODO(jmesserly): for now, treat DDC errors as having a different
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 var files = [ 533 var files = [
534 'harmony_feature_check.js', 534 'harmony_feature_check.js',
535 'dart_library.js', 535 'dart_library.js',
536 'dart/_runtime.js', 536 'dart/_runtime.js',
537 ]; 537 ];
538 files.addAll(corelibOrder.map(coreToFile)); 538 files.addAll(corelibOrder.map(coreToFile));
539 return files; 539 return files;
540 }(); 540 }();
541 541
542 final _log = new Logger('dev_compiler.src.compiler'); 542 final _log = new Logger('dev_compiler.src.compiler');
OLDNEW
« no previous file with comments | « lib/src/codegen/js_module_item_order.dart ('k') | lib/src/server/server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698