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

Unified Diff: pkg/compiler/lib/src/common_elements.dart

Issue 2775223002: Derive CommonElements directly from ElementEnvironment. (Closed)
Patch Set: Fix. Created 3 years, 9 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 | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/common_elements.dart
diff --git a/pkg/compiler/lib/src/common_elements.dart b/pkg/compiler/lib/src/common_elements.dart
index 19cfb0e1d0c534240a1077c9003d46b7f9c3e89e..dd243bccbaec99177dbae87d83801b5aaefd54c4 100644
--- a/pkg/compiler/lib/src/common_elements.dart
+++ b/pkg/compiler/lib/src/common_elements.dart
@@ -6,6 +6,7 @@
library dart2js.type_system;
import 'common.dart';
+import 'common/names.dart' show Uris;
import 'elements/types.dart';
import 'elements/entities.dart';
@@ -208,7 +209,7 @@ abstract class CommonElements {
/// Interface for accessing libraries, classes and members.
///
-/// The environment makes private and injected members directly available and
+/// The _env makes private and injected members directly available and
/// should therefore not be used to determine scopes.
abstract class ElementEnvironment {
/// Returns the main library for the compilation.
@@ -245,6 +246,11 @@ abstract class ElementEnvironment {
InterfaceType createInterfaceType(
ClassEntity cls, List<DartType> typeArguments);
+ /// Returns the `dynamic` type.
+ // TODO(johnniwinther): Remove this when `ResolutionDynamicType` is no longer
+ // needed.
+ DartType get dynamicType;
+
/// Returns the 'raw type' of [cls]. That is, the instantiation of [cls]
/// where all types arguments are `dynamic`.
InterfaceType getRawType(ClassEntity cls);
@@ -254,42 +260,64 @@ abstract class ElementEnvironment {
InterfaceType getThisType(ClassEntity cls);
}
-abstract class CommonElementsMixin implements CommonElements {
- ElementEnvironment get environment;
+class CommonElementsImpl implements CommonElements {
+ final ElementEnvironment _env;
+
+ CommonElementsImpl(this._env);
ClassEntity findClass(LibraryEntity library, String name,
{bool required: true}) {
- return environment.lookupClass(library, name, required: required);
+ if (library == null) return null;
+ return _env.lookupClass(library, name, required: required);
}
MemberEntity findLibraryMember(LibraryEntity library, String name,
{bool setter: false, bool required: true}) {
- return environment.lookupLibraryMember(library, name,
+ if (library == null) return null;
+ return _env.lookupLibraryMember(library, name,
setter: setter, required: required);
}
MemberEntity findClassMember(ClassEntity cls, String name,
{bool setter: false, bool required: true}) {
- return environment.lookupClassMember(cls, name,
+ return _env.lookupClassMember(cls, name,
setter: setter, required: required);
}
ConstructorEntity findConstructor(ClassEntity cls, String name,
{bool required: true}) {
- return environment.lookupConstructor(cls, name, required: required);
+ return _env.lookupConstructor(cls, name, required: required);
}
+ DartType get dynamicType => _env.dynamicType;
+
/// Return the raw type of [cls].
InterfaceType getRawType(ClassEntity cls) {
- return environment.getRawType(cls);
+ return _env.getRawType(cls);
}
/// Create the instantiation of [cls] with the given [typeArguments].
InterfaceType createInterfaceType(
ClassEntity cls, List<DartType> typeArguments) {
- return environment.createInterfaceType(cls, typeArguments);
+ return _env.createInterfaceType(cls, typeArguments);
}
+ LibraryEntity _coreLibrary;
+ LibraryEntity get coreLibrary =>
+ _coreLibrary ??= _env.lookupLibrary(Uris.dart_core, required: true);
+
+ LibraryEntity _typedDataLibrary;
+ LibraryEntity get typedDataLibrary =>
+ _typedDataLibrary ??= _env.lookupLibrary(Uris.dart__native_typed_data);
+
+ LibraryEntity _mirrorsLibrary;
+ LibraryEntity get mirrorsLibrary =>
+ _mirrorsLibrary ??= _env.lookupLibrary(Uris.dart_mirrors);
+
+ LibraryEntity _asyncLibrary;
+ LibraryEntity get asyncLibrary =>
+ _asyncLibrary ??= _env.lookupLibrary(Uris.dart_async);
+
// From dart:core
ClassEntity _objectClass;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/compiler.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698