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

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

Issue 1383483006: Extract DiagnosticReporter implementation from Compiler. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fixes after rebase. Created 5 years, 2 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) 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 dart_types; 5 library dart_types;
6 6
7 import 'dart:math' show min; 7 import 'dart:math' show min;
8 8
9 import 'common/resolution.dart' show 9 import 'common/resolution.dart' show
10 Resolution; 10 Resolution;
11 import 'compiler.dart' show 11 import 'compiler.dart' show
12 Compiler; 12 Compiler;
13 import 'core_types.dart'; 13 import 'core_types.dart';
14 import 'diagnostics/diagnostic_listener.dart' show
15 DiagnosticReporter;
14 import 'diagnostics/invariant.dart' show 16 import 'diagnostics/invariant.dart' show
15 invariant; 17 invariant;
16 import 'diagnostics/spannable.dart' show 18 import 'diagnostics/spannable.dart' show
17 CURRENT_ELEMENT_SPANNABLE, 19 CURRENT_ELEMENT_SPANNABLE,
18 NO_LOCATION_SPANNABLE; 20 NO_LOCATION_SPANNABLE;
19 import 'elements/modelx.dart' show 21 import 'elements/modelx.dart' show
20 LibraryElementX, 22 LibraryElementX,
21 TypeDeclarationElementX, 23 TypeDeclarationElementX,
22 TypedefElementX; 24 TypedefElementX;
23 import 'elements/elements.dart'; 25 import 'elements/elements.dart';
(...skipping 1211 matching lines...) Expand 10 before | Expand all | Expand 10 after
1235 } 1237 }
1236 1238
1237 class Types implements DartTypes { 1239 class Types implements DartTypes {
1238 // TODO(johnniwinther): Replace by [CoreTypes]. 1240 // TODO(johnniwinther): Replace by [CoreTypes].
1239 final Compiler compiler; 1241 final Compiler compiler;
1240 final MoreSpecificVisitor moreSpecificVisitor; 1242 final MoreSpecificVisitor moreSpecificVisitor;
1241 final SubtypeVisitor subtypeVisitor; 1243 final SubtypeVisitor subtypeVisitor;
1242 final PotentialSubtypeVisitor potentialSubtypeVisitor; 1244 final PotentialSubtypeVisitor potentialSubtypeVisitor;
1243 1245
1244 CoreTypes get coreTypes => compiler.coreTypes; 1246 CoreTypes get coreTypes => compiler.coreTypes;
1247
1248 DiagnosticReporter get reporter => compiler.reporter;
1249
1245 Resolution get resolution => compiler.resolution; 1250 Resolution get resolution => compiler.resolution;
1246 1251
1247 Types(Compiler compiler) 1252 Types(Compiler compiler)
1248 : this.compiler = compiler, 1253 : this.compiler = compiler,
1249 this.moreSpecificVisitor = new MoreSpecificVisitor(compiler), 1254 this.moreSpecificVisitor = new MoreSpecificVisitor(compiler),
1250 this.subtypeVisitor = new SubtypeVisitor(compiler), 1255 this.subtypeVisitor = new SubtypeVisitor(compiler),
1251 this.potentialSubtypeVisitor = new PotentialSubtypeVisitor(compiler); 1256 this.potentialSubtypeVisitor = new PotentialSubtypeVisitor(compiler);
1252 1257
1253 Types copy(Compiler compiler) { 1258 Types copy(Compiler compiler) {
1254 return new Types(compiler); 1259 return new Types(compiler);
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after
1536 int maxCommonDepth = min(aClass.hierarchyDepth, bClass.hierarchyDepth); 1541 int maxCommonDepth = min(aClass.hierarchyDepth, bClass.hierarchyDepth);
1537 for (int depth = maxCommonDepth; depth >= 0; depth--) { 1542 for (int depth = maxCommonDepth; depth >= 0; depth--) {
1538 Set<DartType> aTypeSet = getSupertypesAtDepth(a, depth); 1543 Set<DartType> aTypeSet = getSupertypesAtDepth(a, depth);
1539 Set<DartType> bTypeSet = getSupertypesAtDepth(b, depth); 1544 Set<DartType> bTypeSet = getSupertypesAtDepth(b, depth);
1540 Set<DartType> intersection = aTypeSet..retainAll(bTypeSet); 1545 Set<DartType> intersection = aTypeSet..retainAll(bTypeSet);
1541 if (intersection.length == 1) { 1546 if (intersection.length == 1) {
1542 return intersection.first; 1547 return intersection.first;
1543 } 1548 }
1544 } 1549 }
1545 1550
1546 compiler.internalError(CURRENT_ELEMENT_SPANNABLE, 1551 reporter.internalError(CURRENT_ELEMENT_SPANNABLE,
1547 'No least upper bound computed for $a and $b.'); 1552 'No least upper bound computed for $a and $b.');
1548 return null; 1553 return null;
1549 } 1554 }
1550 1555
1551 /// Computes the least upper bound of the types in the longest prefix of [a] 1556 /// Computes the least upper bound of the types in the longest prefix of [a]
1552 /// and [b]. 1557 /// and [b].
1553 List<DartType> computeLeastUpperBoundsTypes(List<DartType> a, 1558 List<DartType> computeLeastUpperBoundsTypes(List<DartType> a,
1554 List<DartType> b) { 1559 List<DartType> b) {
1555 if (a.isEmpty || b.isEmpty) return const <DartType>[]; 1560 if (a.isEmpty || b.isEmpty) return const <DartType>[];
1556 int prefixLength = min(a.length, b.length); 1561 int prefixLength = min(a.length, b.length);
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1959 } 1964 }
1960 namedParameterTypes[index].accept(this, namedParameters[index]); 1965 namedParameterTypes[index].accept(this, namedParameters[index]);
1961 needsComma = true; 1966 needsComma = true;
1962 } 1967 }
1963 sb.write('}'); 1968 sb.write('}');
1964 } 1969 }
1965 sb.write(')'); 1970 sb.write(')');
1966 } 1971 }
1967 } 1972 }
1968 1973
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/dart_backend/placeholder_collector.dart ('k') | pkg/compiler/lib/src/deferred_load.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698