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

Side by Side Diff: pkg/compiler/lib/src/kernel/elements.dart

Issue 2964683003: Split implementation of KernelToElementMapImpl (Closed)
Patch Set: Updated cf. comments 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 /// Entity model for elements derived from Kernel IR. 5 /// Entity interfaces for modeling elements derived from Kernel IR.
6 6
7 import '../elements/entities.dart'; 7 import '../elements/entities.dart';
8 import '../elements/names.dart';
9 import '../elements/types.dart';
10 8
11 class KLibrary implements LibraryEntity { 9 abstract class IndexedLibrary implements LibraryEntity {
12 /// Library index used for fast lookup in [KernelWorldBuilder]. 10 /// Library index used for fast lookup in [KernelToElementMapBase].
13 final int libraryIndex; 11 int get libraryIndex;
14 final String name;
15 final Uri canonicalUri;
16
17 KLibrary(this.libraryIndex, this.name, this.canonicalUri);
18
19 String toString() => 'library($name)';
20 } 12 }
21 13
22 class KClass implements ClassEntity { 14 abstract class IndexedClass implements ClassEntity {
23 final KLibrary library; 15 /// Class index used for fast lookup in [KernelToElementMapBase].
24 16 int get classIndex;
25 /// Class index used for fast lookup in [KernelWorldBuilder].
26 final int classIndex;
27
28 final String name;
29 final bool isAbstract;
30
31 KClass(this.library, this.classIndex, this.name, {this.isAbstract});
32
33 @override
34 bool get isClosure => false;
35
36 String toString() => 'class($name)';
37 } 17 }
38 18
39 abstract class KMember implements MemberEntity { 19 abstract class IndexedMember implements MemberEntity {
40 /// Member index used for fast lookup in [KernelWorldBuilder]. 20 /// Member index used for fast lookup in [KernelToElementMapBase].
41 final int memberIndex; 21 int get memberIndex;
42 final KLibrary library;
43 final KClass enclosingClass;
44 final Name _name;
45 final bool _isStatic;
46
47 KMember(this.memberIndex, this.library, this.enclosingClass, this._name,
48 {bool isStatic: false})
49 : _isStatic = isStatic;
50
51 String get name => _name.text;
52
53 Name get memberName => _name;
54
55 @override
56 bool get isAssignable => false;
57
58 @override
59 bool get isConst => false;
60
61 @override
62 bool get isAbstract => false;
63
64 @override
65 bool get isSetter => false;
66
67 @override
68 bool get isGetter => false;
69
70 @override
71 bool get isFunction => false;
72
73 @override
74 bool get isField => false;
75
76 @override
77 bool get isConstructor => false;
78
79 @override
80 bool get isInstanceMember => enclosingClass != null && !_isStatic;
81
82 @override
83 bool get isStatic => enclosingClass != null && _isStatic;
84
85 @override
86 bool get isTopLevel => enclosingClass == null;
87
88 String get _kind;
89
90 String toString() =>
91 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)';
92 } 22 }
93 23
94 abstract class KFunction extends KMember implements FunctionEntity { 24 abstract class IndexedFunction implements IndexedMember, FunctionEntity {}
95 final ParameterStructure parameterStructure;
96 final bool isExternal;
97 final AsyncMarker asyncMarker;
98 25
99 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name, 26 abstract class IndexedConstructor
100 this.parameterStructure, this.asyncMarker, 27 implements IndexedFunction, ConstructorEntity {}
101 {bool isStatic: false, this.isExternal: false})
102 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
103 }
104 28
105 abstract class KConstructor extends KFunction implements ConstructorEntity { 29 abstract class IndexedField implements IndexedMember, FieldEntity {}
106 final bool isConst;
107
108 KConstructor(int memberIndex, KClass enclosingClass, Name name,
109 ParameterStructure parameterStructure, {bool isExternal, this.isConst})
110 : super(memberIndex, enclosingClass.library, enclosingClass, name,
111 parameterStructure, AsyncMarker.SYNC,
112 isExternal: isExternal);
113
114 @override
115 bool get isConstructor => true;
116
117 @override
118 bool get isInstanceMember => false;
119
120 @override
121 bool get isStatic => false;
122
123 @override
124 bool get isTopLevel => false;
125
126 @override
127 bool get isFromEnvironmentConstructor => false;
128
129 String get _kind => 'constructor';
130 }
131
132 class KGenerativeConstructor extends KConstructor {
133 KGenerativeConstructor(int constructorIndex, KClass enclosingClass, Name name,
134 ParameterStructure parameterStructure, {bool isExternal, bool isConst})
135 : super(constructorIndex, enclosingClass, name, parameterStructure,
136 isExternal: isExternal, isConst: isConst);
137
138 @override
139 bool get isFactoryConstructor => false;
140
141 @override
142 bool get isGenerativeConstructor => true;
143 }
144
145 class KFactoryConstructor extends KConstructor {
146 @override
147 final bool isFromEnvironmentConstructor;
148
149 KFactoryConstructor(int memberIndex, KClass enclosingClass, Name name,
150 ParameterStructure parameterStructure,
151 {bool isExternal, bool isConst, this.isFromEnvironmentConstructor})
152 : super(memberIndex, enclosingClass, name, parameterStructure,
153 isExternal: isExternal, isConst: isConst);
154
155 @override
156 bool get isFactoryConstructor => true;
157
158 @override
159 bool get isGenerativeConstructor => false;
160 }
161
162 class KMethod extends KFunction {
163 final bool isAbstract;
164
165 KMethod(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
166 ParameterStructure parameterStructure, AsyncMarker asyncMarker,
167 {bool isStatic, bool isExternal, this.isAbstract})
168 : super(memberIndex, library, enclosingClass, name, parameterStructure,
169 asyncMarker,
170 isStatic: isStatic, isExternal: isExternal);
171
172 @override
173 bool get isFunction => true;
174
175 String get _kind => 'method';
176 }
177
178 class KGetter extends KFunction {
179 final bool isAbstract;
180
181 KGetter(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
182 AsyncMarker asyncMarker,
183 {bool isStatic, bool isExternal, this.isAbstract})
184 : super(memberIndex, library, enclosingClass, name,
185 const ParameterStructure.getter(), asyncMarker,
186 isStatic: isStatic, isExternal: isExternal);
187
188 @override
189 bool get isGetter => true;
190
191 String get _kind => 'getter';
192 }
193
194 class KSetter extends KFunction {
195 final bool isAbstract;
196
197 KSetter(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
198 {bool isStatic, bool isExternal, this.isAbstract})
199 : super(memberIndex, library, enclosingClass, name,
200 const ParameterStructure.setter(), AsyncMarker.SYNC,
201 isStatic: isStatic, isExternal: isExternal);
202
203 @override
204 bool get isAssignable => true;
205
206 @override
207 bool get isSetter => true;
208
209 String get _kind => 'setter';
210 }
211
212 class KField extends KMember implements FieldEntity {
213 final bool isAssignable;
214 final bool isConst;
215
216 KField(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
217 {bool isStatic, this.isAssignable, this.isConst})
218 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
219
220 @override
221 bool get isField => true;
222
223 String get _kind => 'field';
224 }
225
226 class KTypeVariable implements TypeVariableEntity {
227 final Entity typeDeclaration;
228 final String name;
229 final int index;
230
231 KTypeVariable(this.typeDeclaration, this.name, this.index);
232
233 String toString() => 'type_variable(${typeDeclaration.name}.$name)';
234 }
235
236 class KLocalFunction implements Local {
237 final String name;
238 final MemberEntity memberContext;
239 final Entity executableContext;
240 final FunctionType functionType;
241
242 KLocalFunction(
243 this.name, this.memberContext, this.executableContext, this.functionType);
244
245 String toString() =>
246 'local_function(${memberContext.name}.${name ?? '<anonymous>'})';
247 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/kernel/element_map_mixins.dart ('k') | pkg/compiler/lib/src/kernel/env.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698