OLD | NEW |
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 library dev_compiler.src.compiler; | 6 library dev_compiler.src.compiler; |
7 | 7 |
8 import 'dart:async'; | 8 import 'dart:async'; |
9 import 'dart:collection'; | 9 import 'dart:collection'; |
10 import 'dart:convert' show JSON; | 10 import 'dart:convert' show JSON; |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 (_compilationRecord[library] || | 182 (_compilationRecord[library] || |
183 options.codegenOptions.forceCompile)) { | 183 options.codegenOptions.forceCompile)) { |
184 _jsGen.generateLibrary(unit); | 184 _jsGen.generateLibrary(unit); |
185 } | 185 } |
186 } | 186 } |
187 } | 187 } |
188 | 188 |
189 bool _compileLibrary(LibraryElement library, CompilationNotifier notifier) { | 189 bool _compileLibrary(LibraryElement library, CompilationNotifier notifier) { |
190 var success = _compilationRecord[library]; | 190 var success = _compilationRecord[library]; |
191 if (success != null) { | 191 if (success != null) { |
192 if (!success) _failure = true; | 192 if (!success) { |
| 193 _failure = true; |
| 194 } |
193 return success; | 195 return success; |
194 } | 196 } |
195 | 197 |
196 // Optimistically mark a library valid until proven otherwise | 198 // Optimistically mark a library valid until proven otherwise |
197 _compilationRecord[library] = true; | 199 _compilationRecord[library] = true; |
198 | 200 |
199 if (!options.checkSdk && library.source.uri.scheme == 'dart') { | 201 if (!options.checkSdk && library.source.uri.scheme == 'dart') { |
200 // We assume the Dart SDK is always valid | 202 // We assume the Dart SDK is always valid |
201 if (_jsGen != null) _copyDartRuntime(); | 203 if (_jsGen != null) _copyDartRuntime(); |
202 return true; | 204 return true; |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
243 // it's cached out. We should refactor common logic in | 245 // it's cached out. We should refactor common logic in |
244 // server/dependency_graph and perhaps the analyzer itself. | 246 // server/dependency_graph and perhaps the analyzer itself. |
245 success = _compilationRecord[library]; | 247 success = _compilationRecord[library]; |
246 if (success || options.codegenOptions.forceCompile) { | 248 if (success || options.codegenOptions.forceCompile) { |
247 var unit = units.first; | 249 var unit = units.first; |
248 var parts = units.skip(1).toList(); | 250 var parts = units.skip(1).toList(); |
249 _pendingLibraries.add(new LibraryUnit(unit, parts)); | 251 _pendingLibraries.add(new LibraryUnit(unit, parts)); |
250 } | 252 } |
251 | 253 |
252 // Return tentative success status. | 254 // Return tentative success status. |
253 if (!success) _failure = true; | 255 if (!success) { |
| 256 _failure = true; |
| 257 } |
254 return success; | 258 return success; |
255 } | 259 } |
256 | 260 |
257 void _copyDartRuntime() { | 261 void _copyDartRuntime() { |
258 if (_sdkCopied) return; | 262 if (_sdkCopied) return; |
259 _sdkCopied = true; | 263 _sdkCopied = true; |
260 for (var file in defaultRuntimeFiles) { | 264 for (var file in defaultRuntimeFiles) { |
261 var input = new File(path.join(options.runtimeDir, file)); | 265 var input = new File(path.join(options.runtimeDir, file)); |
262 var output = new File(path.join(_runtimeOutputDir, file)); | 266 var output = new File(path.join(_runtimeOutputDir, file)); |
263 if (output.existsSync() && | 267 if (output.existsSync() && |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 errorContext = context.sourceFactory.dartSdk.context; | 456 errorContext = context.sourceFactory.dartSdk.context; |
453 } | 457 } |
454 List<AnalysisError> errors = errorContext.computeErrors(source); | 458 List<AnalysisError> errors = errorContext.computeErrors(source); |
455 bool failure = false; | 459 bool failure = false; |
456 for (var error in errors) { | 460 for (var error in errors) { |
457 // Always skip TODOs. | 461 // Always skip TODOs. |
458 if (error.errorCode.type == ErrorType.TODO) continue; | 462 if (error.errorCode.type == ErrorType.TODO) continue; |
459 | 463 |
460 // TODO(jmesserly): for now, treat DDC errors as having a different | 464 // TODO(jmesserly): for now, treat DDC errors as having a different |
461 // error level from Analayzer ones. | 465 // error level from Analayzer ones. |
462 if (error.errorCode.name.startsWith('dev_compiler')) { | 466 if (error.errorCode.name.startsWith('STRONG_MODE')) { |
463 reporter.onError(error); | 467 reporter.onError(error); |
464 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { | 468 if (error.errorCode.errorSeverity == ErrorSeverity.ERROR) { |
465 failure = true; | 469 failure = true; |
466 } | 470 } |
467 } else if (error.errorCode.errorSeverity.ordinal >= | 471 } else if (error.errorCode.errorSeverity.ordinal >= |
468 ErrorSeverity.WARNING.ordinal) { | 472 ErrorSeverity.WARNING.ordinal) { |
469 // All analyzer warnings or errors are errors for DDC. | 473 // All analyzer warnings or errors are errors for DDC. |
470 failure = true; | 474 failure = true; |
471 reporter.onError(error); | 475 reporter.onError(error); |
472 } else { | 476 } else { |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 'dart/_rtti.js', | 544 'dart/_rtti.js', |
541 'dart/_classes.js', | 545 'dart/_classes.js', |
542 'dart/_operations.js', | 546 'dart/_operations.js', |
543 'dart/_runtime.js', | 547 'dart/_runtime.js', |
544 ]; | 548 ]; |
545 files.addAll(corelibOrder.map(coreToFile)); | 549 files.addAll(corelibOrder.map(coreToFile)); |
546 return files; | 550 return files; |
547 }(); | 551 }(); |
548 | 552 |
549 final _log = new Logger('dev_compiler.src.compiler'); | 553 final _log = new Logger('dev_compiler.src.compiler'); |
OLD | NEW |