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

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

Issue 2964683003: Split implementation of KernelToElementMapImpl (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 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 model for elements derived from Kernel IR.
6 6
7 import '../elements/entities.dart'; 7 import '../elements/entities.dart';
8 import '../elements/names.dart'; 8 import '../elements/names.dart';
9 import '../elements/types.dart'; 9 import '../elements/types.dart';
10 import 'elements.dart';
10 11
11 class KLibrary implements LibraryEntity { 12 class KLibrary implements IndexedLibrary {
12 /// Library index used for fast lookup in [KernelWorldBuilder]. 13 /// Library index used for fast lookup in [KernelWorldBuilder].
13 final int libraryIndex; 14 final int libraryIndex;
14 final String name; 15 final String name;
15 final Uri canonicalUri; 16 final Uri canonicalUri;
16 17
17 KLibrary(this.libraryIndex, this.name, this.canonicalUri); 18 KLibrary(this.libraryIndex, this.name, this.canonicalUri);
18 19
19 String toString() => 'library($name)'; 20 String toString() => 'library($name)';
20 } 21 }
21 22
22 class KClass implements ClassEntity { 23 class KClass implements IndexedClass {
23 final KLibrary library; 24 final KLibrary library;
24 25
25 /// Class index used for fast lookup in [KernelWorldBuilder]. 26 /// Class index used for fast lookup in [KernelWorldBuilder].
26 final int classIndex; 27 final int classIndex;
27 28
28 final String name; 29 final String name;
29 final bool isAbstract; 30 final bool isAbstract;
30 31
31 KClass(this.library, this.classIndex, this.name, {this.isAbstract}); 32 KClass(this.library, this.classIndex, this.name, {this.isAbstract});
32 33
33 @override 34 @override
34 bool get isClosure => false; 35 bool get isClosure => false;
35 36
36 String toString() => 'class($name)'; 37 String toString() => 'class($name)';
37 } 38 }
38 39
39 abstract class KMember implements MemberEntity { 40 abstract class KMember implements IndexedMember {
40 /// Member index used for fast lookup in [KernelWorldBuilder]. 41 /// Member index used for fast lookup in [KernelWorldBuilder].
41 final int memberIndex; 42 final int memberIndex;
42 final KLibrary library; 43 final KLibrary library;
43 final KClass enclosingClass; 44 final KClass enclosingClass;
44 final Name _name; 45 final Name _name;
45 final bool _isStatic; 46 final bool _isStatic;
46 47
47 KMember(this.memberIndex, this.library, this.enclosingClass, this._name, 48 KMember(this.memberIndex, this.library, this.enclosingClass, this._name,
48 {bool isStatic: false}) 49 {bool isStatic: false})
49 : _isStatic = isStatic; 50 : _isStatic = isStatic;
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 85
85 @override 86 @override
86 bool get isTopLevel => enclosingClass == null; 87 bool get isTopLevel => enclosingClass == null;
87 88
88 String get _kind; 89 String get _kind;
89 90
90 String toString() => 91 String toString() =>
91 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; 92 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)';
92 } 93 }
93 94
94 abstract class KFunction extends KMember implements FunctionEntity { 95 abstract class KFunction extends KMember
96 implements FunctionEntity, IndexedFunction {
95 final ParameterStructure parameterStructure; 97 final ParameterStructure parameterStructure;
96 final bool isExternal; 98 final bool isExternal;
97 final AsyncMarker asyncMarker; 99 final AsyncMarker asyncMarker;
98 100
99 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name, 101 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
100 this.parameterStructure, this.asyncMarker, 102 this.parameterStructure, this.asyncMarker,
101 {bool isStatic: false, this.isExternal: false}) 103 {bool isStatic: false, this.isExternal: false})
102 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); 104 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
103 } 105 }
104 106
105 abstract class KConstructor extends KFunction implements ConstructorEntity { 107 abstract class KConstructor extends KFunction
108 implements ConstructorEntity, IndexedConstructor {
106 final bool isConst; 109 final bool isConst;
107 110
108 KConstructor(int memberIndex, KClass enclosingClass, Name name, 111 KConstructor(int memberIndex, KClass enclosingClass, Name name,
109 ParameterStructure parameterStructure, {bool isExternal, this.isConst}) 112 ParameterStructure parameterStructure, {bool isExternal, this.isConst})
110 : super(memberIndex, enclosingClass.library, enclosingClass, name, 113 : super(memberIndex, enclosingClass.library, enclosingClass, name,
111 parameterStructure, AsyncMarker.SYNC, 114 parameterStructure, AsyncMarker.SYNC,
112 isExternal: isExternal); 115 isExternal: isExternal);
113 116
114 @override 117 @override
115 bool get isConstructor => true; 118 bool get isConstructor => true;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 205
203 @override 206 @override
204 bool get isAssignable => true; 207 bool get isAssignable => true;
205 208
206 @override 209 @override
207 bool get isSetter => true; 210 bool get isSetter => true;
208 211
209 String get _kind => 'setter'; 212 String get _kind => 'setter';
210 } 213 }
211 214
212 class KField extends KMember implements FieldEntity { 215 class KField extends KMember implements FieldEntity, IndexedField {
213 final bool isAssignable; 216 final bool isAssignable;
214 final bool isConst; 217 final bool isConst;
215 218
216 KField(int memberIndex, KLibrary library, KClass enclosingClass, Name name, 219 KField(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
217 {bool isStatic, this.isAssignable, this.isConst}) 220 {bool isStatic, this.isAssignable, this.isConst})
218 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic); 221 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
219 222
220 @override 223 @override
221 bool get isField => true; 224 bool get isField => true;
222 225
(...skipping 15 matching lines...) Expand all
238 final MemberEntity memberContext; 241 final MemberEntity memberContext;
239 final Entity executableContext; 242 final Entity executableContext;
240 final FunctionType functionType; 243 final FunctionType functionType;
241 244
242 KLocalFunction( 245 KLocalFunction(
243 this.name, this.memberContext, this.executableContext, this.functionType); 246 this.name, this.memberContext, this.executableContext, this.functionType);
244 247
245 String toString() => 248 String toString() =>
246 'local_function(${memberContext.name}.${name ?? '<anonymous>'})'; 249 'local_function(${memberContext.name}.${name ?? '<anonymous>'})';
247 } 250 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698