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

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

Issue 2797173004: Remove use of Element in ResolutionEnqueuerListener. (Closed)
Patch Set: Created 3 years, 8 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/elements.dart'; 7 import '../elements/elements.dart';
8 import '../elements/entities.dart'; 8 import '../elements/entities.dart';
9 9
10 class KLibrary implements LibraryEntity { 10 class KLibrary implements LibraryEntity {
11 /// Library index used for fast lookup in [KernelWorldBuilder]. 11 /// Library index used for fast lookup in [KernelWorldBuilder].
12 final int libraryIndex; 12 final int libraryIndex;
13 final String name; 13 final String name;
14 final Uri canonicalUri;
14 15
15 KLibrary(this.libraryIndex, this.name); 16 KLibrary(this.libraryIndex, this.name, this.canonicalUri);
16 17
17 String toString() => 'library($name)'; 18 String toString() => 'library($name)';
18 } 19 }
19 20
20 class KClass implements ClassEntity { 21 class KClass implements ClassEntity {
21 final KLibrary library; 22 final KLibrary library;
22 23
23 /// Class index used for fast lookup in [KernelWorldBuilder]. 24 /// Class index used for fast lookup in [KernelWorldBuilder].
24 final int classIndex; 25 final int classIndex;
25 final String name; 26 final String name;
26 27
27 KClass(this.library, this.classIndex, this.name); 28 KClass(this.library, this.classIndex, this.name);
28 29
29 @override 30 @override
30 bool get isClosure => false; 31 bool get isClosure => false;
31 32
32 String toString() => 'class($name)'; 33 String toString() => 'class($name)';
33 } 34 }
34 35
35 abstract class KMember implements MemberEntity { 36 abstract class KMember implements MemberEntity {
37 /// Member index used for fast lookup in [KernelWorldBuilder].
38 final int memberIndex;
36 final KLibrary library; 39 final KLibrary library;
37 final KClass enclosingClass; 40 final KClass enclosingClass;
38 final Name _name; 41 final Name _name;
39 final bool _isStatic; 42 final bool _isStatic;
40 43
41 KMember(this.library, this.enclosingClass, this._name, {bool isStatic: false}) 44 KMember(this.memberIndex, this.library, this.enclosingClass, this._name,
45 {bool isStatic: false})
42 : _isStatic = isStatic; 46 : _isStatic = isStatic;
43 47
44 String get name => _name.text; 48 String get name => _name.text;
45 49
46 @override 50 @override
47 bool get isAssignable => false; 51 bool get isAssignable => false;
48 52
49 @override 53 @override
54 bool get isConst => false;
55
56 @override
50 bool get isSetter => false; 57 bool get isSetter => false;
51 58
52 @override 59 @override
53 bool get isGetter => false; 60 bool get isGetter => false;
54 61
55 @override 62 @override
56 bool get isFunction => false; 63 bool get isFunction => false;
57 64
58 @override 65 @override
59 bool get isField => false; 66 bool get isField => false;
(...skipping 12 matching lines...) Expand all
72 79
73 String get _kind; 80 String get _kind;
74 81
75 String toString() => 82 String toString() =>
76 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)'; 83 '$_kind(${enclosingClass != null ? '${enclosingClass.name}.' : ''}$name)';
77 } 84 }
78 85
79 abstract class KFunction extends KMember implements FunctionEntity { 86 abstract class KFunction extends KMember implements FunctionEntity {
80 final bool isExternal; 87 final bool isExternal;
81 88
82 KFunction(KLibrary library, KClass enclosingClass, Name name, 89 KFunction(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
83 {bool isStatic: false, this.isExternal: false}) 90 {bool isStatic: false, this.isExternal: false})
84 : super(library, enclosingClass, name, isStatic: isStatic); 91 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
85 } 92 }
86 93
87 abstract class KConstructor extends KFunction implements ConstructorEntity { 94 abstract class KConstructor extends KFunction implements ConstructorEntity {
88 /// Constructor index used for fast lookup in [KernelWorldBuilder]. 95 final bool isConst;
89 final int constructorIndex;
90 96
91 KConstructor(this.constructorIndex, KClass enclosingClass, Name name, 97 KConstructor(int memberIndex, KClass enclosingClass, Name name,
92 {bool isExternal}) 98 {bool isExternal, this.isConst})
93 : super(enclosingClass.library, enclosingClass, name, 99 : super(memberIndex, enclosingClass.library, enclosingClass, name,
94 isExternal: isExternal); 100 isExternal: isExternal);
95 101
96 @override 102 @override
97 bool get isConstructor => true; 103 bool get isConstructor => true;
98 104
99 @override 105 @override
100 bool get isInstanceMember => false; 106 bool get isInstanceMember => false;
101 107
102 @override 108 @override
103 bool get isStatic => false; 109 bool get isStatic => false;
104 110
105 @override 111 @override
106 bool get isTopLevel => false; 112 bool get isTopLevel => false;
107 113
108 String get _kind => 'constructor'; 114 String get _kind => 'constructor';
109 } 115 }
110 116
111 class KGenerativeConstructor extends KConstructor { 117 class KGenerativeConstructor extends KConstructor {
112 KGenerativeConstructor(int constructorIndex, KClass enclosingClass, Name name, 118 KGenerativeConstructor(int constructorIndex, KClass enclosingClass, Name name,
113 {bool isExternal}) 119 {bool isExternal, bool isConst})
114 : super(constructorIndex, enclosingClass, name, isExternal: isExternal); 120 : super(constructorIndex, enclosingClass, name,
121 isExternal: isExternal, isConst: isConst);
115 122
116 @override 123 @override
117 bool get isFactoryConstructor => false; 124 bool get isFactoryConstructor => false;
118 125
119 @override 126 @override
120 bool get isGenerativeConstructor => true; 127 bool get isGenerativeConstructor => true;
121 } 128 }
122 129
123 class KFactoryConstructor extends KConstructor { 130 class KFactoryConstructor extends KConstructor {
124 KFactoryConstructor(int constructorIndex, KClass enclosingClass, Name name, 131 KFactoryConstructor(int memberIndex, KClass enclosingClass, Name name,
125 {bool isExternal}) 132 {bool isExternal, bool isConst})
126 : super(constructorIndex, enclosingClass, name, isExternal: isExternal); 133 : super(memberIndex, enclosingClass, name,
134 isExternal: isExternal, isConst: isConst);
127 135
128 @override 136 @override
129 bool get isFactoryConstructor => true; 137 bool get isFactoryConstructor => true;
130 138
131 @override 139 @override
132 bool get isGenerativeConstructor => false; 140 bool get isGenerativeConstructor => false;
133 } 141 }
134 142
135 class KMethod extends KFunction { 143 class KMethod extends KFunction {
136 KMethod(KLibrary library, KClass enclosingClass, Name name, 144 KMethod(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
137 {bool isStatic, bool isExternal}) 145 {bool isStatic, bool isExternal})
138 : super(library, enclosingClass, name, 146 : super(memberIndex, library, enclosingClass, name,
139 isStatic: isStatic, isExternal: isExternal); 147 isStatic: isStatic, isExternal: isExternal);
140 148
141 @override 149 @override
142 bool get isFunction => true; 150 bool get isFunction => true;
143 151
144 String get _kind => 'method'; 152 String get _kind => 'method';
145 } 153 }
146 154
147 class KGetter extends KFunction { 155 class KGetter extends KFunction {
148 KGetter(KLibrary library, KClass enclosingClass, Name name, 156 KGetter(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
149 {bool isStatic, bool isExternal}) 157 {bool isStatic, bool isExternal})
150 : super(library, enclosingClass, name, 158 : super(memberIndex, library, enclosingClass, name,
151 isStatic: isStatic, isExternal: isExternal); 159 isStatic: isStatic, isExternal: isExternal);
152 160
153 @override 161 @override
154 bool get isGetter => true; 162 bool get isGetter => true;
155 163
156 String get _kind => 'getter'; 164 String get _kind => 'getter';
157 } 165 }
158 166
159 class KSetter extends KFunction { 167 class KSetter extends KFunction {
160 KSetter(KLibrary library, KClass enclosingClass, Name name, 168 KSetter(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
161 {bool isStatic, bool isExternal}) 169 {bool isStatic, bool isExternal})
162 : super(library, enclosingClass, name, 170 : super(memberIndex, library, enclosingClass, name,
163 isStatic: isStatic, isExternal: isExternal); 171 isStatic: isStatic, isExternal: isExternal);
164 172
165 @override 173 @override
166 bool get isAssignable => true; 174 bool get isAssignable => true;
167 175
168 @override 176 @override
169 bool get isSetter => true; 177 bool get isSetter => true;
170 178
171 String get _kind => 'setter'; 179 String get _kind => 'setter';
172 } 180 }
173 181
174 class KField extends KMember implements FieldEntity { 182 class KField extends KMember implements FieldEntity {
175 /// Field index used for fast lookup in [KernelWorldBuilder].
176 final int fieldIndex;
177 final bool isAssignable; 183 final bool isAssignable;
184 final bool isConst;
178 185
179 KField(this.fieldIndex, KLibrary library, KClass enclosingClass, Name name, 186 KField(int memberIndex, KLibrary library, KClass enclosingClass, Name name,
180 {bool isStatic, this.isAssignable}) 187 {bool isStatic, this.isAssignable, this.isConst})
181 : super(library, enclosingClass, name, isStatic: isStatic); 188 : super(memberIndex, library, enclosingClass, name, isStatic: isStatic);
182 189
183 @override 190 @override
184 bool get isField => true; 191 bool get isField => true;
185 192
186 String get _kind => 'field'; 193 String get _kind => 'field';
187 } 194 }
188 195
189 class KTypeVariable implements TypeVariableEntity { 196 class KTypeVariable implements TypeVariableEntity {
190 final Entity typeDeclaration; 197 final Entity typeDeclaration;
191 final String name; 198 final String name;
192 final int index; 199 final int index;
193 200
194 KTypeVariable(this.typeDeclaration, this.name, this.index); 201 KTypeVariable(this.typeDeclaration, this.name, this.index);
195 202
196 String toString() => 'type_variable(${typeDeclaration.name}.$name)'; 203 String toString() => 'type_variable(${typeDeclaration.name}.$name)';
197 } 204 }
198 205
199 class KLocalFunction implements Local { 206 class KLocalFunction implements Local {
200 final String name; 207 final String name;
201 final MemberEntity memberContext; 208 final MemberEntity memberContext;
202 final Entity executableContext; 209 final Entity executableContext;
203 210
204 KLocalFunction(this.name, this.memberContext, this.executableContext); 211 KLocalFunction(this.name, this.memberContext, this.executableContext);
205 212
206 String toString() => 213 String toString() =>
207 'local_function(${memberContext.name}.${name ?? '<anonymous>'})'; 214 'local_function(${memberContext.name}.${name ?? '<anonymous>'})';
208 } 215 }
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/js_backend/resolution_listener.dart ('k') | pkg/compiler/lib/src/kernel/world_builder.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698