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

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: Address comments 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 = TypeSystem.create(this);
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 2416 matching lines...) Expand 10 before | Expand all | Expand 10 after
10923 } 10943 }
10924 return "resolve unit ${librarySource.fullName}"; 10944 return "resolve unit ${librarySource.fullName}";
10925 } 10945 }
10926 10946
10927 @override 10947 @override
10928 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this); 10948 accept(AnalysisTaskVisitor visitor) => visitor.visitResolveDartUnitTask(this);
10929 10949
10930 @override 10950 @override
10931 void internalPerform() { 10951 void internalPerform() {
10932 TypeProvider typeProvider = _libraryElement.context.typeProvider; 10952 TypeProvider typeProvider = _libraryElement.context.typeProvider;
10953 TypeSystem typeSystem = _libraryElement.context.typeSystem;
10933 CompilationUnit unit = context.computeResolvableCompilationUnit(source); 10954 CompilationUnit unit = context.computeResolvableCompilationUnit(source);
10934 if (unit == null) { 10955 if (unit == null) {
10935 throw new AnalysisException( 10956 throw new AnalysisException(
10936 "Internal error: computeResolvableCompilationUnit returned a value wit hout a parsed Dart unit"); 10957 "Internal error: computeResolvableCompilationUnit returned a value wit hout a parsed Dart unit");
10937 } 10958 }
10938 // 10959 //
10939 // Resolve names in declarations. 10960 // Resolve names in declarations.
10940 // 10961 //
10941 new DeclarationResolver().resolve(unit, _find(_libraryElement, source)); 10962 new DeclarationResolver().resolve(unit, _find(_libraryElement, source));
10942 // 10963 //
10943 // Resolve the type names. 10964 // Resolve the type names.
10944 // 10965 //
10945 RecordingErrorListener errorListener = new RecordingErrorListener(); 10966 RecordingErrorListener errorListener = new RecordingErrorListener();
10946 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor( 10967 TypeResolverVisitor typeResolverVisitor = new TypeResolverVisitor(
10947 _libraryElement, source, typeProvider, errorListener); 10968 _libraryElement, source, typeProvider, errorListener);
10948 unit.accept(typeResolverVisitor); 10969 unit.accept(typeResolverVisitor);
10949 // 10970 //
10950 // Resolve the rest of the structure 10971 // Resolve the rest of the structure
10951 // 10972 //
10952 InheritanceManager inheritanceManager = 10973 InheritanceManager inheritanceManager =
10953 new InheritanceManager(_libraryElement); 10974 new InheritanceManager(_libraryElement);
10954 ResolverVisitor resolverVisitor = new ResolverVisitor( 10975 ResolverVisitor resolverVisitor = new ResolverVisitor(
10955 _libraryElement, source, typeProvider, errorListener, 10976 _libraryElement, source, typeProvider, typeSystem, errorListener,
10956 inheritanceManager: inheritanceManager); 10977 inheritanceManager: inheritanceManager);
10957 unit.accept(resolverVisitor); 10978 unit.accept(resolverVisitor);
10958 // 10979 //
10959 // Perform additional error checking. 10980 // Perform additional error checking.
10960 // 10981 //
10961 PerformanceStatistics.errors.makeCurrentWhile(() { 10982 PerformanceStatistics.errors.makeCurrentWhile(() {
10962 ErrorReporter errorReporter = new ErrorReporter(errorListener, source); 10983 ErrorReporter errorReporter = new ErrorReporter(errorListener, source);
10963 ErrorVerifier errorVerifier = new ErrorVerifier( 10984 ErrorVerifier errorVerifier = new ErrorVerifier(
10964 errorReporter, 10985 errorReporter,
10965 _libraryElement, 10986 _libraryElement,
10966 typeProvider, 10987 typeProvider,
10988 typeSystem,
10967 inheritanceManager, 10989 inheritanceManager,
10968 context.analysisOptions.enableSuperMixins); 10990 context.analysisOptions.enableSuperMixins);
10969 unit.accept(errorVerifier); 10991 unit.accept(errorVerifier);
10970 // TODO(paulberry): as a temporary workaround for issue 21572, 10992 // TODO(paulberry): as a temporary workaround for issue 21572,
10971 // ConstantVerifier is being run right after ConstantValueComputer, so we 10993 // ConstantVerifier is being run right after ConstantValueComputer, so we
10972 // don't need to run it here. Once issue 21572 is fixed, re-enable the 10994 // don't need to run it here. Once issue 21572 is fixed, re-enable the
10973 // call to ConstantVerifier. 10995 // call to ConstantVerifier.
10974 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider); 10996 // ConstantVerifier constantVerifier = new ConstantVerifier(errorReporter, _libraryElement, typeProvider);
10975 // unit.accept(constantVerifier); 10997 // unit.accept(constantVerifier);
10976 }); 10998 });
(...skipping 1075 matching lines...) Expand 10 before | Expand all | Expand 10 after
12052 PendingFuture pendingFuture = 12074 PendingFuture pendingFuture =
12053 new PendingFuture<T>(_context, source, computeValue); 12075 new PendingFuture<T>(_context, source, computeValue);
12054 if (!pendingFuture.evaluate(sourceEntry)) { 12076 if (!pendingFuture.evaluate(sourceEntry)) {
12055 _context._pendingFutureSources 12077 _context._pendingFutureSources
12056 .putIfAbsent(source, () => <PendingFuture>[]) 12078 .putIfAbsent(source, () => <PendingFuture>[])
12057 .add(pendingFuture); 12079 .add(pendingFuture);
12058 } 12080 }
12059 return pendingFuture.future; 12081 return pendingFuture.future;
12060 } 12082 }
12061 } 12083 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/generated/constant.dart ('k') | pkg/analyzer/lib/src/generated/error_verifier.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698