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

Side by Side Diff: pkg/analyzer/lib/src/generated/engine.dart

Issue 1329743005: Abstract over the type system. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 3 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
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 engine; 5 library engine;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 import 'dart:math' as math; 9 import 'dart:math' as math;
10 10
(...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 */ 422 */
423 List<Source> get sources; 423 List<Source> get sources;
424 424
425 /** 425 /**
426 * Return a type provider for this context or throw [AnalysisException] if 426 * Return a type provider for this context or throw [AnalysisException] if
427 * either `dart:core` or `dart:async` cannot be resolved. 427 * either `dart:core` or `dart:async` cannot be resolved.
428 */ 428 */
429 TypeProvider get typeProvider; 429 TypeProvider get typeProvider;
430 430
431 /** 431 /**
432 * Return a type system for this context.
433 */
434 TypeSystem get typeSystem;
435
436 /**
432 * Add the given [listener] to the list of objects that are to be notified 437 * Add the given [listener] to the list of objects that are to be notified
433 * when various analysis results are produced in this context. 438 * when various analysis results are produced in this context.
434 */ 439 */
435 void addListener(AnalysisListener listener); 440 void addListener(AnalysisListener listener);
436 441
437 /** 442 /**
438 * Apply the given [delta] to change the level of analysis that will be 443 * Apply the given [delta] to change the level of analysis that will be
439 * performed for the sources known to this context. 444 * performed for the sources known to this context.
440 */ 445 */
441 void applyAnalysisDelta(AnalysisDelta delta); 446 void applyAnalysisDelta(AnalysisDelta delta);
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1033 * Cached information used in incremental analysis or `null` if none. 1038 * Cached information used in incremental analysis or `null` if none.
1034 */ 1039 */
1035 IncrementalAnalysisCache _incrementalAnalysisCache; 1040 IncrementalAnalysisCache _incrementalAnalysisCache;
1036 1041
1037 /** 1042 /**
1038 * The [TypeProvider] for this context, `null` if not yet created. 1043 * The [TypeProvider] for this context, `null` if not yet created.
1039 */ 1044 */
1040 TypeProvider _typeProvider; 1045 TypeProvider _typeProvider;
1041 1046
1042 /** 1047 /**
1048 * The [TypeSystem] for this context, `null` if not yet created.
1049 */
1050 TypeSystem _typeSystem;
1051
1052 /**
1043 * The object used to manage the list of sources that need to be analyzed. 1053 * The object used to manage the list of sources that need to be analyzed.
1044 */ 1054 */
1045 WorkManager _workManager = new WorkManager(); 1055 WorkManager _workManager = new WorkManager();
1046 1056
1047 /** 1057 /**
1048 * The [Stopwatch] of the current "perform tasks cycle". 1058 * The [Stopwatch] of the current "perform tasks cycle".
1049 */ 1059 */
1050 Stopwatch _performAnalysisTaskStopwatch; 1060 Stopwatch _performAnalysisTaskStopwatch;
1051 1061
1052 /** 1062 /**
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after
1543 } 1553 }
1544 1554
1545 /** 1555 /**
1546 * Sets the [TypeProvider] for this context. 1556 * Sets the [TypeProvider] for this context.
1547 */ 1557 */
1548 void set typeProvider(TypeProvider typeProvider) { 1558 void set typeProvider(TypeProvider typeProvider) {
1549 _typeProvider = typeProvider; 1559 _typeProvider = typeProvider;
1550 } 1560 }
1551 1561
1552 @override 1562 @override
1563 TypeSystem get typeSystem {
1564 if (_typeSystem == null) {
1565 _typeSystem = new TypeSystemImpl(typeProvider);
1566 }
1567 return _typeSystem;
1568 }
1569
1570 @override
1553 void addListener(AnalysisListener listener) { 1571 void addListener(AnalysisListener listener) {
1554 if (!_listeners.contains(listener)) { 1572 if (!_listeners.contains(listener)) {
1555 _listeners.add(listener); 1573 _listeners.add(listener);
1556 } 1574 }
1557 } 1575 }
1558 1576
1559 @override 1577 @override
1560 void applyAnalysisDelta(AnalysisDelta delta) { 1578 void applyAnalysisDelta(AnalysisDelta delta) {
1561 ChangeSet changeSet = new ChangeSet(); 1579 ChangeSet changeSet = new ChangeSet();
1562 delta.analysisLevels.forEach((Source source, AnalysisLevel level) { 1580 delta.analysisLevels.forEach((Source source, AnalysisLevel level) {
(...skipping 6902 matching lines...) Expand 10 before | Expand all | Expand 10 after
8465 @override 8483 @override
8466 accept(AnalysisTaskVisitor visitor) => 8484 accept(AnalysisTaskVisitor visitor) =>
8467 visitor.visitGenerateDartErrorsTask(this); 8485 visitor.visitGenerateDartErrorsTask(this);
8468 8486
8469 @override 8487 @override
8470 void internalPerform() { 8488 void internalPerform() {
8471 PerformanceStatistics.errors.makeCurrentWhile(() { 8489 PerformanceStatistics.errors.makeCurrentWhile(() {
8472 RecordingErrorListener errorListener = new RecordingErrorListener(); 8490 RecordingErrorListener errorListener = new RecordingErrorListener();
8473 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 8491 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
8474 TypeProvider typeProvider = context.typeProvider; 8492 TypeProvider typeProvider = context.typeProvider;
8493 TypeSystem typeSystem = context.typeSystem;
8475 // 8494 //
8476 // Validate the directives 8495 // Validate the directives
8477 // 8496 //
8478 validateDirectives(context, source, _unit, errorListener); 8497 validateDirectives(context, source, _unit, errorListener);
8479 // 8498 //
8480 // Use the ConstantVerifier to verify the use of constants. 8499 // Use the ConstantVerifier to verify the use of constants.
8481 // This needs to happen before using the ErrorVerifier because some error 8500 // This needs to happen before using the ErrorVerifier because some error
8482 // codes need the computed constant values. 8501 // codes need the computed constant values.
8483 // 8502 //
8484 // TODO(paulberry): as a temporary workaround for issue 21572, 8503 // TODO(paulberry): as a temporary workaround for issue 21572,
8485 // ConstantVerifier is being run right after ConstantValueComputer, so we 8504 // ConstantVerifier is being run right after ConstantValueComputer, so we
8486 // don't need to run it here. Once issue 21572 is fixed, re-enable the 8505 // don't need to run it here. Once issue 21572 is fixed, re-enable the
8487 // call to ConstantVerifier. 8506 // call to ConstantVerifier.
8488 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, libraryElement, typeProvider); 8507 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, libraryElement, typeProvider);
8489 // _unit.accept(constantVerifier); 8508 // _unit.accept(constantVerifier);
8490 // 8509 //
8491 // Use the ErrorVerifier to compute the rest of the errors. 8510 // Use the ErrorVerifier to compute the rest of the errors.
8492 // 8511 //
8493 ErrorVerifier errorVerifier = new ErrorVerifier( 8512 ErrorVerifier errorVerifier = new ErrorVerifier(
8494 errorReporter, 8513 errorReporter,
8495 libraryElement, 8514 libraryElement,
8496 typeProvider, 8515 typeProvider,
8516 typeSystem,
8497 new InheritanceManager(libraryElement), 8517 new InheritanceManager(libraryElement),
8498 context.analysisOptions.enableSuperMixins); 8518 context.analysisOptions.enableSuperMixins);
8499 _unit.accept(errorVerifier); 8519 _unit.accept(errorVerifier);
8500 _errors = errorListener.getErrorsForSource(source); 8520 _errors = errorListener.getErrorsForSource(source);
8501 }); 8521 });
8502 } 8522 }
8503 8523
8504 /** 8524 /**
8505 * Check each directive in the given compilation unit to see if the referenced source exists and 8525 * Check each directive in the given compilation unit to see if the referenced source exists and
8506 * report an error if it does not. 8526 * report an error if it does not.
(...skipping 2398 matching lines...) Expand 10 before | Expand all | Expand 10 after
10905 } 10925 }
10906 return "resolve unit ${librarySource.fullName}"; 10926 return "resolve unit ${librarySource.fullName}";
10907 } 10927 }
10908 10928
10909 @override 10929 @override
10910 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); 10930 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this);
10911 10931
10912 @override 10932 @override
10913 void internalPerform() { 10933 void internalPerform() {
10914 TypeProvider typeProvider = _libraryElement.context.typeProvider; 10934 TypeProvider typeProvider = _libraryElement.context.typeProvider;
10935 TypeSystem typeSystem = _libraryElement.context.typeSystem;
10915 CompilationUnit unit = context.computeResolvableCompilationUnit(source); 10936 CompilationUnit unit = context.computeResolvableCompilationUnit(source);
10916 if (unit == null) { 10937 if (unit == null) {
10917 throw new AnalysisException( 10938 throw new AnalysisException(
10918 "Internal error: computeResolvableCompilationUnit returned a value wit hout a parsed Dart unit"); 10939 "Internal error: computeResolvableCompilationUnit returned a value wit hout a parsed Dart unit");
10919 } 10940 }
10920 // 10941 //
10921 // Resolve names in declarations. 10942 // Resolve names in declarations.
10922 // 10943 //
10923 new DeclarationResolver().resolve(unit, _find(_libraryElement, source)); 10944 new DeclarationResolver().resolve(unit, _find(_libraryElement, source));
10924 // 10945 //
(...skipping 14 matching lines...) Expand all
10939 unit.accept(resolverVisitor); 10960 unit.accept(resolverVisitor);
10940 // 10961 //
10941 // Perform additional error checking. 10962 // Perform additional error checking.
10942 // 10963 //
10943 PerformanceStatistics.errors.makeCurrentWhile(() { 10964 PerformanceStatistics.errors.makeCurrentWhile(() {
10944 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 10965 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
10945 ErrorVerifier errorVerifier = new ErrorVerifier( 10966 ErrorVerifier errorVerifier = new ErrorVerifier(
10946 errorReporter, 10967 errorReporter,
10947 _libraryElement, 10968 _libraryElement,
10948 typeProvider, 10969 typeProvider,
10970 typeSystem,
10949 inheritanceManager, 10971 inheritanceManager,
10950 context.analysisOptions.enableSuperMixins); 10972 context.analysisOptions.enableSuperMixins);
10951 unit.accept(errorVerifier); 10973 unit.accept(errorVerifier);
10952 // TODO(paulberry): as a temporary workaround for issue 21572, 10974 // TODO(paulberry): as a temporary workaround for issue 21572,
10953 // ConstantVerifier is being run right after ConstantValueComputer, so we 10975 // ConstantVerifier is being run right after ConstantValueComputer, so we
10954 // don't need to run it here. Once issue 21572 is fixed, re-enable the 10976 // don't need to run it here. Once issue 21572 is fixed, re-enable the
10955 // call to ConstantVerifier. 10977 // call to ConstantVerifier.
10956 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider); 10978 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider);
10957 // unit.accept(constantVerifier); 10979 // unit.accept(constantVerifier);
10958 }); 10980 });
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
12034 PendingFuture pendingFuture = 12056 PendingFuture pendingFuture =
12035 new PendingFuture<T>(_context, source, computeValue); 12057 new PendingFuture<T>(_context, source, computeValue);
12036 if (!pendingFuture.evaluate(sourceEntry)) { 12058 if (!pendingFuture.evaluate(sourceEntry)) {
12037 _context._pendingFutureSources 12059 _context._pendingFutureSources
12038 .putIfAbsent(source, () => <PendingFuture>[]) 12060 .putIfAbsent(source, () => <PendingFuture>[])
12039 .add(pendingFuture); 12061 .add(pendingFuture);
12040 } 12062 }
12041 return pendingFuture.future; 12063 return pendingFuture.future;
12042 } 12064 }
12043 } 12065 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698