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

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

Issue 2464103002: Introduce ClassLike, MemberLike, FieldLike and FunctionLike (Closed)
Patch Set: Created 4 years, 1 month 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/js_backend/backend.dart » ('j') | pkg/compiler/lib/src/ssa/optimize.dart » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/compiler/lib/src/elements/elements.dart
diff --git a/pkg/compiler/lib/src/elements/elements.dart b/pkg/compiler/lib/src/elements/elements.dart
index e854e4d17c07de57c311944412d782f0acef2206..7b7ab77a74362fc385a374178417d285e8ceabad 100644
--- a/pkg/compiler/lib/src/elements/elements.dart
+++ b/pkg/compiler/lib/src/elements/elements.dart
@@ -128,6 +128,41 @@ abstract class Entity implements Spannable {
String get name;
}
+/// Stripped down super interface for class like entities.
+///
+/// Currently only [ClassElement] but later also kernel based Dart classes
+/// and/or Dart-in-JS classes.
+abstract class ClassLike extends Entity {
Siggi Cherem (dart-lang) 2016/11/03 00:52:30 maybe it is too early to tell, but how much from C
Johnni Winther 2016/11/03 09:55:06 Not much: I plan to move most queries on relations
+ bool get isClosure;
+ void forEachInstanceField(f(ClassLike cls, FieldLike field),
+ {bool includeSuperAndInjectedMembers: false});
+}
+
+/// Stripped down super interface for member like entities, that is,
+/// constructors, methods, fields etc.
+///
+/// Currently only [MemberElement] but later also kernel based Dart members
+/// and/or Dart-in-JS properties.
+abstract class MemberLike extends Entity {
+ bool get isField;
+ bool get isFunction;
+ bool get isGetter;
+ bool get isAssignable;
+ ClassLike get enclosingClass;
+}
+
+/// Stripped down super interface for field like entities.
+///
+/// Currently only [FieldElement] but later also kernel based Dart fields
+/// and/or Dart-in-JS field-like properties.
+abstract class FieldLike extends MemberLike {}
+
+/// Stripped down super interface for function like entities.
+///
+/// Currently only [FieldElement] but later also kernel based Dart constructors
+/// and methods and/or Dart-in-JS function-like properties.
+abstract class FunctionLike extends MemberLike {}
Siggi Cherem (dart-lang) 2016/11/03 00:52:30 I'm not yet convinced on using the "XLike" names :
Johnni Winther 2016/11/03 09:55:06 Moved to 'entities.dart', use 'Entity' as suffix.
+
/**
* A declared element of a program.
*
@@ -1047,7 +1082,8 @@ abstract class ExecutableElement extends Element
///
/// A [MemberElement] is the outermost executable element for any executable
/// context.
-abstract class MemberElement extends Element implements ExecutableElement {
+abstract class MemberElement extends Element
+ implements ExecutableElement, MemberLike {
/// The local functions defined within this member.
List<FunctionElement> get nestedClosures;
@@ -1100,7 +1136,8 @@ abstract class LocalVariableElement extends VariableElement
implements LocalElement {}
/// A top-level, static or instance field.
-abstract class FieldElement extends VariableElement implements MemberElement {}
+abstract class FieldElement extends VariableElement
+ implements MemberElement, FieldLike {}
/// A parameter-like element of a function signature.
///
@@ -1291,15 +1328,15 @@ class AsyncMarker {
}
/// A top level, static or instance function.
-abstract class MethodElement extends FunctionElement implements MemberElement {}
+abstract class MethodElement extends FunctionElement
+ implements MemberElement, FunctionLike {}
/// A local function or closure (anonymous local function).
abstract class LocalFunctionElement extends FunctionElement
implements LocalElement {}
/// A constructor.
-abstract class ConstructorElement extends FunctionElement
- implements MemberElement {
+abstract class ConstructorElement extends MethodElement {
/// Returns `true` if [effectiveTarget] has been computed for this
/// constructor.
bool get hasEffectiveTarget;
@@ -1470,7 +1507,7 @@ abstract class TypeDeclarationElement extends GenericElement {
}
abstract class ClassElement extends TypeDeclarationElement
- implements ScopeContainerElement {
+ implements ScopeContainerElement, ClassLike {
/// The length of the longest inheritance path from [:Object:].
int get hierarchyDepth;
« no previous file with comments | « no previous file | pkg/compiler/lib/src/js_backend/backend.dart » ('j') | pkg/compiler/lib/src/ssa/optimize.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698