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

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

Issue 2972523002: Implement JsKernelToElementMap through KernelToElementMapBase (Closed)
Patch Set: Created 3 years, 5 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/env.dart
diff --git a/pkg/compiler/lib/src/kernel/env.dart b/pkg/compiler/lib/src/kernel/env.dart
index 74ec5ba43b58f626a36da6dce42f71f749a1f618..c0185a45434ac3be54037621559f494c51983413 100644
--- a/pkg/compiler/lib/src/kernel/env.dart
+++ b/pkg/compiler/lib/src/kernel/env.dart
@@ -23,15 +23,15 @@ import 'element_map_mixins.dart';
/// Environment for fast lookup of program libraries.
class ProgramEnv {
- final Set<ir.Program> programs = new Set<ir.Program>();
+ final Set<ir.Program> _programs = new Set<ir.Program>();
Map<Uri, LibraryEnv> _libraryMap;
/// TODO(johnniwinther): Handle arbitrary load order if needed.
- ir.Member get mainMethod => programs.first?.mainMethod;
+ ir.Member get mainMethod => _programs.first?.mainMethod;
void addProgram(ir.Program program) {
- if (programs.add(program)) {
+ if (_programs.add(program)) {
if (_libraryMap != null) {
_addLibraries(program);
}
@@ -47,7 +47,7 @@ class ProgramEnv {
void _ensureLibraryMap() {
if (_libraryMap == null) {
_libraryMap = <Uri, LibraryEnv>{};
- for (ir.Program program in programs) {
+ for (ir.Program program in _programs) {
_addLibraries(program);
}
}
@@ -70,6 +70,14 @@ class ProgramEnv {
_ensureLibraryMap();
return _libraryMap.length;
}
+
+ /// Copy all [LibraryEnv]s from [other] to this environment.
+ void copyFrom(ProgramEnv other) {
+ if (other._libraryMap == null) return;
+ _programs.addAll(other._programs);
+ _libraryMap ??= <Uri, LibraryEnv>{};
+ _libraryMap.addAll(other._libraryMap);
+ }
}
/// Environment for fast lookup of library classes and members.

Powered by Google App Engine
This is Rietveld 408576698