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

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

Issue 2824123003: Make backend.setAnnotations (mostly) handle LibraryEntities. (Closed)
Patch Set: . Created 3 years, 8 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
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 5e9272a55585b5cb4b4b2fbf67c50c6c88cd31c0..3ccc6aef2b68b85ff3b63863368f4d4e03c652e1 100644
--- a/pkg/compiler/lib/src/kernel/world_builder.dart
+++ b/pkg/compiler/lib/src/kernel/world_builder.dart
@@ -105,6 +105,8 @@ class KernelWorldBuilder extends KernelElementAdapterMixin {
@override
native.BehaviorBuilder get nativeBehaviorBuilder => _nativeBehaviorBuilder;
+ KernelLookup get lookup => new KernelLookup._internal(_libraryMap, _classMap);
+
LibraryEntity lookupLibrary(Uri uri) {
KLibraryEnv libraryEnv = _env.lookupLibrary(uri);
return _getLibrary(libraryEnv.library, libraryEnv);
@@ -522,6 +524,26 @@ class KernelWorldBuilder extends KernelElementAdapterMixin {
}
}
+/// A glorified combination of maps for looking up the correspondence between a
+/// particular K-Entity and its corresponding Kernel Element object.
+class KernelLookup {
Emily Fortuna 2017/04/19 00:59:55 I'm guessing we want to have some sort of super in
Johnni Winther 2017/04/19 08:39:51 This functionality is already in KernelWorldBuilde
Siggi Cherem (dart-lang) 2017/04/19 15:36:29 Ah! some questions for Johnni... 1. is the idea t
Emily Fortuna 2017/04/19 22:35:46 Okay. You're still not exposing the ir.Library and
Johnni Winther 2017/04/20 07:19:27 1. I want IR based reasoning to be confined to the
+ Map<KLibrary, ir.Library> _libraryMap = <KLibrary, ir.Library>{};
+ Map<KClass, ir.Class> _classMap = <KClass, ir.Class>{};
+
+ KernelLookup._internal(Map<ir.Library, KLibrary> reverseLibraryMap,
+ Map<ir.Class, KClass> reverseClassMap) {
+ for (ir.Library library in reverseLibraryMap.keys) {
+ _libraryMap[reverseLibraryMap[library]] = library;
+ }
+ for (ir.Class class_entity in reverseClassMap.keys) {
+ _classMap[reverseClassMap[class_entity]] = class_entity;
+ }
+ }
+
+ ir.Class lookupClass(KClass entity) => _classMap[entity];
+ ir.Library lookupLibrary(KLibrary entity) => _libraryMap[entity];
+}
+
/// Environment for fast lookup of program libraries.
class KEnv {
final ir.Program program;

Powered by Google App Engine
This is Rietveld 408576698