Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 dart2js.compiler_base; | 5 library dart2js.compiler_base; |
| 6 | 6 |
| 7 import 'dart:async' show | 7 import 'dart:async' show |
| 8 EventSink, | 8 EventSink, |
| 9 Future; | 9 Future; |
| 10 | 10 |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 339 /// The [int.fromEnvironment] constructor. | 339 /// The [int.fromEnvironment] constructor. |
| 340 ConstructorElement intEnvironment; | 340 ConstructorElement intEnvironment; |
| 341 | 341 |
| 342 /// The [bool.fromEnvironment] constructor. | 342 /// The [bool.fromEnvironment] constructor. |
| 343 ConstructorElement boolEnvironment; | 343 ConstructorElement boolEnvironment; |
| 344 | 344 |
| 345 /// The [String.fromEnvironment] constructor. | 345 /// The [String.fromEnvironment] constructor. |
| 346 ConstructorElement stringEnvironment; | 346 ConstructorElement stringEnvironment; |
| 347 | 347 |
| 348 /// Tracks elements with compile-time errors. | 348 /// Tracks elements with compile-time errors. |
| 349 final Set<Element> elementsWithCompileTimeErrors = new Set<Element>(); | 349 final Map<Element, DiagnosticMessage> elementsWithCompileTimeErrors = |
| 350 new Map<Element, DiagnosticMessage>(); | |
| 350 | 351 |
| 351 fromEnvironment(String name) => null; | 352 fromEnvironment(String name) => null; |
| 352 | 353 |
| 353 Element get currentElement => _reporter.currentElement; | 354 Element get currentElement => _reporter.currentElement; |
| 354 | 355 |
| 355 List<CompilerTask> tasks; | 356 List<CompilerTask> tasks; |
| 356 ScannerTask scanner; | 357 ScannerTask scanner; |
| 357 DietParserTask dietParser; | 358 DietParserTask dietParser; |
| 358 ParserTask parser; | 359 ParserTask parser; |
| 359 PatchParserTask patchParser; | 360 PatchParserTask patchParser; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 401 bool get shouldPrintProgress { | 402 bool get shouldPrintProgress { |
| 402 return verbose && progress.elapsedMilliseconds > 500; | 403 return verbose && progress.elapsedMilliseconds > 500; |
| 403 } | 404 } |
| 404 | 405 |
| 405 static const int PHASE_SCANNING = 0; | 406 static const int PHASE_SCANNING = 0; |
| 406 static const int PHASE_RESOLVING = 1; | 407 static const int PHASE_RESOLVING = 1; |
| 407 static const int PHASE_DONE_RESOLVING = 2; | 408 static const int PHASE_DONE_RESOLVING = 2; |
| 408 static const int PHASE_COMPILING = 3; | 409 static const int PHASE_COMPILING = 3; |
| 409 int phase; | 410 int phase; |
| 410 | 411 |
| 411 bool compilationFailedInternal = false; | 412 bool compilationFailed = false; |
| 412 | |
| 413 bool get compilationFailed => compilationFailedInternal; | |
| 414 | |
| 415 void set compilationFailed(bool value) { | |
| 416 if (value) { | |
| 417 elementsWithCompileTimeErrors.add(currentElement); | |
| 418 } | |
| 419 compilationFailedInternal = value; | |
| 420 } | |
| 421 | 413 |
| 422 /// Set by the backend if real reflection is detected in use of dart:mirrors. | 414 /// Set by the backend if real reflection is detected in use of dart:mirrors. |
| 423 bool disableTypeInferenceForMirrors = false; | 415 bool disableTypeInferenceForMirrors = false; |
| 424 | 416 |
| 425 Compiler({this.enableTypeAssertions: false, | 417 Compiler({this.enableTypeAssertions: false, |
| 426 this.enableUserAssertions: false, | 418 this.enableUserAssertions: false, |
| 427 this.trustTypeAnnotations: false, | 419 this.trustTypeAnnotations: false, |
| 428 this.trustPrimitives: false, | 420 this.trustPrimitives: false, |
| 429 bool disableTypeInferenceFlag: false, | 421 bool disableTypeInferenceFlag: false, |
| 430 this.maxConcreteTypeSize: 5, | 422 this.maxConcreteTypeSize: 5, |
| (...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1416 enqueuer.forgetElement(element); | 1408 enqueuer.forgetElement(element); |
| 1417 if (element is MemberElement) { | 1409 if (element is MemberElement) { |
| 1418 for (Element closure in element.nestedClosures) { | 1410 for (Element closure in element.nestedClosures) { |
| 1419 // TODO(ahe): It would be nice to reuse names of nested closures. | 1411 // TODO(ahe): It would be nice to reuse names of nested closures. |
| 1420 closureToClassMapper.forgetElement(closure); | 1412 closureToClassMapper.forgetElement(closure); |
| 1421 } | 1413 } |
| 1422 } | 1414 } |
| 1423 backend.forgetElement(element); | 1415 backend.forgetElement(element); |
| 1424 } | 1416 } |
| 1425 | 1417 |
| 1418 /// Returns [true] if a compile-time error has been reported for element. | |
| 1419 /// | |
| 1420 /// This function should only be called when | |
| 1421 /// [generateCodeWithCompileTimeErrors] is true. | |
| 1426 bool elementHasCompileTimeError(Element element) { | 1422 bool elementHasCompileTimeError(Element element) { |
| 1427 return elementsWithCompileTimeErrors.contains(element); | 1423 assert(generateCodeWithCompileTimeErrors); |
|
Johnni Winther
2015/12/14 11:31:20
Change the approach to only store message when [ge
sigurdm
2015/12/14 12:07:43
Done.
| |
| 1424 return elementsWithCompileTimeErrors.containsKey(element); | |
| 1428 } | 1425 } |
| 1429 | 1426 |
| 1430 EventSink<String> outputProvider(String name, String extension) { | 1427 EventSink<String> outputProvider(String name, String extension) { |
| 1431 if (compilationFailed) { | 1428 if (compilationFailed) { |
| 1432 if (!generateCodeWithCompileTimeErrors || testMode) { | 1429 if (!generateCodeWithCompileTimeErrors || testMode) { |
| 1433 // Disable output in test mode: The build bot currently uses the time | 1430 // Disable output in test mode: The build bot currently uses the time |
| 1434 // stamp of the generated file to determine whether the output is | 1431 // stamp of the generated file to determine whether the output is |
| 1435 // up-to-date. | 1432 // up-to-date. |
| 1436 return new NullSink('$name.$extension'); | 1433 return new NullSink('$name.$extension'); |
| 1437 } | 1434 } |
| (...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1686 reportDiagnostic(message, infos, kind); | 1683 reportDiagnostic(message, infos, kind); |
| 1687 } | 1684 } |
| 1688 | 1685 |
| 1689 void reportDiagnostic(DiagnosticMessage message, | 1686 void reportDiagnostic(DiagnosticMessage message, |
| 1690 List<DiagnosticMessage> infos, | 1687 List<DiagnosticMessage> infos, |
| 1691 api.Diagnostic kind) { | 1688 api.Diagnostic kind) { |
| 1692 if (kind == api.Diagnostic.ERROR || | 1689 if (kind == api.Diagnostic.ERROR || |
| 1693 kind == api.Diagnostic.CRASH || | 1690 kind == api.Diagnostic.CRASH || |
| 1694 (options.fatalWarnings && | 1691 (options.fatalWarnings && |
| 1695 kind == api.Diagnostic.WARNING)) { | 1692 kind == api.Diagnostic.WARNING)) { |
| 1693 compiler.elementsWithCompileTimeErrors[currentElement] = message; | |
| 1696 compiler.compilationFailed = true; | 1694 compiler.compilationFailed = true; |
| 1697 } | 1695 } |
| 1698 compiler.reportDiagnostic(message, infos, kind); | 1696 compiler.reportDiagnostic(message, infos, kind); |
| 1699 } | 1697 } |
| 1700 | 1698 |
| 1701 /** | 1699 /** |
| 1702 * Perform an operation, [f], returning the return value from [f]. If an | 1700 * Perform an operation, [f], returning the return value from [f]. If an |
| 1703 * error occurs then report it as having occurred during compilation of | 1701 * error occurs then report it as having occurred during compilation of |
| 1704 * [element]. Can be nested. | 1702 * [element]. Can be nested. |
| 1705 */ | 1703 */ |
| (...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2077 if (_otherDependencies == null) { | 2075 if (_otherDependencies == null) { |
| 2078 _otherDependencies = new Setlet<Element>(); | 2076 _otherDependencies = new Setlet<Element>(); |
| 2079 } | 2077 } |
| 2080 _otherDependencies.add(element.implementation); | 2078 _otherDependencies.add(element.implementation); |
| 2081 } | 2079 } |
| 2082 | 2080 |
| 2083 Iterable<Element> get otherDependencies { | 2081 Iterable<Element> get otherDependencies { |
| 2084 return _otherDependencies != null ? _otherDependencies : const <Element>[]; | 2082 return _otherDependencies != null ? _otherDependencies : const <Element>[]; |
| 2085 } | 2083 } |
| 2086 } | 2084 } |
| OLD | NEW |