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

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

Issue 1525603002: Associate compile-time errors with elements (Closed) Base URL: git@github.com:dart-lang/sdk.git@_temporary_fletch_patches
Patch Set: Address review Created 5 years 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 | « no previous file | pkg/compiler/lib/src/js_backend/backend.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 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
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
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
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.
1426 bool elementHasCompileTimeError(Element element) { 1419 bool elementHasCompileTimeError(Element element) {
1427 return elementsWithCompileTimeErrors.contains(element); 1420 return elementsWithCompileTimeErrors.containsKey(element);
1421 }
1422
1423 /// Associate [element] with a compile-time error [message].
1424 void registerCompiletimeError(Element element, DiagnosticMessage message) {
1425 // The information is only needed if [generateCodeWithCompileTimeErrors].
1426 if (generateCodeWithCompileTimeErrors) {
1427 elementsWithCompileTimeErrors[element] = message;
1428 }
1428 } 1429 }
1429 1430
1430 EventSink<String> outputProvider(String name, String extension) { 1431 EventSink<String> outputProvider(String name, String extension) {
1431 if (compilationFailed) { 1432 if (compilationFailed) {
1432 if (!generateCodeWithCompileTimeErrors || testMode) { 1433 if (!generateCodeWithCompileTimeErrors || testMode) {
1433 // Disable output in test mode: The build bot currently uses the time 1434 // Disable output in test mode: The build bot currently uses the time
1434 // stamp of the generated file to determine whether the output is 1435 // stamp of the generated file to determine whether the output is
1435 // up-to-date. 1436 // up-to-date.
1436 return new NullSink('$name.$extension'); 1437 return new NullSink('$name.$extension');
1437 } 1438 }
(...skipping 248 matching lines...) Expand 10 before | Expand all | Expand 10 after
1686 reportDiagnostic(message, infos, kind); 1687 reportDiagnostic(message, infos, kind);
1687 } 1688 }
1688 1689
1689 void reportDiagnostic(DiagnosticMessage message, 1690 void reportDiagnostic(DiagnosticMessage message,
1690 List<DiagnosticMessage> infos, 1691 List<DiagnosticMessage> infos,
1691 api.Diagnostic kind) { 1692 api.Diagnostic kind) {
1692 if (kind == api.Diagnostic.ERROR || 1693 if (kind == api.Diagnostic.ERROR ||
1693 kind == api.Diagnostic.CRASH || 1694 kind == api.Diagnostic.CRASH ||
1694 (options.fatalWarnings && 1695 (options.fatalWarnings &&
1695 kind == api.Diagnostic.WARNING)) { 1696 kind == api.Diagnostic.WARNING)) {
1697 compiler.registerCompiletimeError(currentElement, message);
1696 compiler.compilationFailed = true; 1698 compiler.compilationFailed = true;
1697 } 1699 }
1698 compiler.reportDiagnostic(message, infos, kind); 1700 compiler.reportDiagnostic(message, infos, kind);
1699 } 1701 }
1700 1702
1701 /** 1703 /**
1702 * Perform an operation, [f], returning the return value from [f]. If an 1704 * Perform an operation, [f], returning the return value from [f]. If an
1703 * error occurs then report it as having occurred during compilation of 1705 * error occurs then report it as having occurred during compilation of
1704 * [element]. Can be nested. 1706 * [element]. Can be nested.
1705 */ 1707 */
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 if (_otherDependencies == null) { 2079 if (_otherDependencies == null) {
2078 _otherDependencies = new Setlet<Element>(); 2080 _otherDependencies = new Setlet<Element>();
2079 } 2081 }
2080 _otherDependencies.add(element.implementation); 2082 _otherDependencies.add(element.implementation);
2081 } 2083 }
2082 2084
2083 Iterable<Element> get otherDependencies { 2085 Iterable<Element> get otherDependencies {
2084 return _otherDependencies != null ? _otherDependencies : const <Element>[]; 2086 return _otherDependencies != null ? _otherDependencies : const <Element>[];
2085 } 2087 }
2086 } 2088 }
OLDNEW
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698