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

Unified Diff: pkg/compiler/lib/src/kernel/world_builder.dart

Issue 2668623003: Check equivalence on impact computed with KernelWorldBuilder. (Closed)
Patch Set: Created 3 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/compiler/lib/src/kernel/elements.dart ('k') | pkg/compiler/lib/src/serialization/equivalence.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/kernel/world_builder.dart
diff --git a/pkg/compiler/lib/src/kernel/world_builder.dart b/pkg/compiler/lib/src/kernel/world_builder.dart
index 408e323160570dce57a96773e843308d245d3c11..fa83e31b80623cb54282a1c198ddc1d2abea45df 100644
--- a/pkg/compiler/lib/src/kernel/world_builder.dart
+++ b/pkg/compiler/lib/src/kernel/world_builder.dart
@@ -30,6 +30,10 @@ class KernelWorldBuilder extends KernelElementAdapterMixin {
/// fast lookup into library classes and members.
List<KLibraryEnv> _libraryEnvs = <KLibraryEnv>[];
+ /// List of class environments by `KClass.classIndex`. This is used for
+ /// fast lookup into class members.
+ List<KClassEnv> _classEnvs = <KClassEnv>[];
+
Map<ir.Library, KLibrary> _libraryMap = <ir.Library, KLibrary>{};
Map<ir.Class, KClass> _classMap = <ir.Class, KClass>{};
Map<ir.TypeParameter, KTypeVariable> _typeVariableMap =
@@ -56,7 +60,8 @@ class KernelWorldBuilder extends KernelElementAdapterMixin {
KLibrary _getLibrary(ir.Library node, [KLibraryEnv libraryEnv]) {
return _libraryMap.putIfAbsent(node, () {
_libraryEnvs.add(libraryEnv ?? _env.lookupLibrary(node.importUri));
- return new KLibrary(_libraryMap.length, node.name, node.fileUri);
+ return new KLibrary(_libraryMap.length, node.name ?? '${node.importUri}',
+ node.name ?? node.fileUri ?? '${node.importUri}');
});
}
@@ -68,7 +73,12 @@ class KernelWorldBuilder extends KernelElementAdapterMixin {
KClass _getClass(ir.Class node, [KClassEnv classEnv]) {
return _classMap.putIfAbsent(node, () {
- return new KClass(node.name);
+ if (classEnv == null) {
+ KLibrary library = _getLibrary(node.enclosingLibrary);
+ classEnv = _libraryEnvs[library.libraryIndex].lookupClass(node.name);
+ }
+ _classEnvs.add(classEnv);
+ return new KClass(_classMap.length, node.name);
});
}
@@ -473,3 +483,38 @@ class DartTypeConverter extends ir.DartTypeVisitor<DartType> {
return const DynamicType();
}
}
+
+// Interface for testing equivalence of Kernel-based entities.
+class WorldDeconstructionForTesting {
+ final KernelWorldBuilder builder;
+
+ WorldDeconstructionForTesting(this.builder);
+
+ Uri getLibraryUri(KLibrary library) {
+ return builder._libraryEnvs[library.libraryIndex].library.importUri;
+ }
+
+ KLibrary getLibraryForClass(KClass cls) {
+ KClassEnv env = builder._classEnvs[cls.classIndex];
+ return builder.getLibrary(env.cls.enclosingLibrary);
+ }
+
+ KLibrary _getLibrary<E>(E member, Map<ir.Member, E> map) {
+ ir.Library library;
+ map.forEach((ir.Member node, E other) {
+ if (library == null && member == other) {
+ library = node.enclosingLibrary;
+ }
+ });
+ if (library == null) {
+ throw new ArgumentError("No library found for $member");
+ }
+ return builder._getLibrary(library);
+ }
+
+ KLibrary getLibraryForFunction(KFunction function) =>
+ _getLibrary(function, builder._methodMap);
+
+ KLibrary getLibraryForField(KField field) =>
+ _getLibrary(field, builder._fieldMap);
+}
« no previous file with comments | « pkg/compiler/lib/src/kernel/elements.dart ('k') | pkg/compiler/lib/src/serialization/equivalence.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698