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

Side by Side Diff: pkg/compiler/lib/src/resolution/member_impl.dart

Issue 1859343004: dartfmt pkg/compiler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 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) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, 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 part of dart2js.resolution.compute_members; 5 part of dart2js.resolution.compute_members;
6 6
7 class DeclaredMember implements Member { 7 class DeclaredMember implements Member {
8 final Name name; 8 final Name name;
9 final Element element; 9 final Element element;
10 final InterfaceType declarer; 10 final InterfaceType declarer;
11 final DartType type; 11 final DartType type;
12 final FunctionType functionType; 12 final FunctionType functionType;
13 13
14 DeclaredMember(this.name, this.element, 14 DeclaredMember(
15 this.declarer, 15 this.name, this.element, this.declarer, this.type, this.functionType);
16 this.type, this.functionType);
17 16
18 bool get isStatic => !element.isInstanceMember; 17 bool get isStatic => !element.isInstanceMember;
19 18
20 bool get isGetter => element.isGetter || (!isSetter && element.isField); 19 bool get isGetter => element.isGetter || (!isSetter && element.isField);
21 20
22 bool get isSetter => name.isSetter; 21 bool get isSetter => name.isSetter;
23 22
24 bool get isMethod => element.isFunction; 23 bool get isMethod => element.isFunction;
25 24
26 bool get isDeclaredByField => element.isField; 25 bool get isDeclaredByField => element.isField;
(...skipping 21 matching lines...) Expand all
48 InheritedMember _newInheritedMember(InterfaceType instance) { 47 InheritedMember _newInheritedMember(InterfaceType instance) {
49 return new InheritedMember(this, instance); 48 return new InheritedMember(this, instance);
50 } 49 }
51 50
52 Iterable<Member> get declarations => <Member>[this]; 51 Iterable<Member> get declarations => <Member>[this];
53 52
54 int get hashCode => element.hashCode + 13 * isSetter.hashCode; 53 int get hashCode => element.hashCode + 13 * isSetter.hashCode;
55 54
56 bool operator ==(other) { 55 bool operator ==(other) {
57 if (other is! Member) return false; 56 if (other is! Member) return false;
58 return element == other.element && 57 return element == other.element && isSetter == other.isSetter;
59 isSetter == other.isSetter;
60 } 58 }
61 59
62 String toString() { 60 String toString() {
63 StringBuffer sb = new StringBuffer(); 61 StringBuffer sb = new StringBuffer();
64 printOn(sb, type); 62 printOn(sb, type);
65 return sb.toString(); 63 return sb.toString();
66 } 64 }
67 65
68 void printOn(StringBuffer sb, DartType type) { 66 void printOn(StringBuffer sb, DartType type) {
69 if (isStatic) { 67 if (isStatic) {
(...skipping 14 matching lines...) Expand all
84 sb.write(' _)'); 82 sb.write(' _)');
85 } else { 83 } else {
86 sb.write(type.getStringAsDeclared('$name')); 84 sb.write(type.getStringAsDeclared('$name'));
87 } 85 }
88 } 86 }
89 } 87 }
90 88
91 class DeclaredAbstractMember extends DeclaredMember { 89 class DeclaredAbstractMember extends DeclaredMember {
92 final DeclaredMember implementation; 90 final DeclaredMember implementation;
93 91
94 DeclaredAbstractMember(Name name, Element element, 92 DeclaredAbstractMember(Name name, Element element, InterfaceType declarer,
95 InterfaceType declarer, 93 DartType type, FunctionType functionType, this.implementation)
96 DartType type, FunctionType functionType,
97 this.implementation)
98 : super(name, element, declarer, type, functionType); 94 : super(name, element, declarer, type, functionType);
99 95
100 bool get isAbstract => true; 96 bool get isAbstract => true;
101 97
102 InheritedMember _newInheritedMember(InterfaceType instance) { 98 InheritedMember _newInheritedMember(InterfaceType instance) {
103 return new InheritedAbstractMember(this, instance, 99 return new InheritedAbstractMember(this, instance,
104 implementation != null ? implementation.inheritFrom(instance) : null); 100 implementation != null ? implementation.inheritFrom(instance) : null);
105 } 101 }
106 } 102 }
107 103
108 class InheritedMember implements DeclaredMember { 104 class InheritedMember implements DeclaredMember {
109 final DeclaredMember declaration; 105 final DeclaredMember declaration;
110 final InterfaceType instance; 106 final InterfaceType instance;
111 107
112 InheritedMember(DeclaredMember this.declaration, 108 InheritedMember(
113 InterfaceType this.instance) { 109 DeclaredMember this.declaration, InterfaceType this.instance) {
114 assert(instance.isGeneric); 110 assert(instance.isGeneric);
115 assert(!declaration.isStatic); 111 assert(!declaration.isStatic);
116 } 112 }
117 113
118 Element get element => declaration.element; 114 Element get element => declaration.element;
119 115
120 Name get name => declaration.name; 116 Name get name => declaration.name;
121 117
122 InterfaceType get declarer => instance; 118 InterfaceType get declarer => instance;
123 119
(...skipping 22 matching lines...) Expand all
146 // Assert that if [instance] contains type variables, then these are 142 // Assert that if [instance] contains type variables, then these are
147 // defined in the declaration of [newInstance] and will therefore be 143 // defined in the declaration of [newInstance] and will therefore be
148 // substituted into the context of [newInstance] in the created member. 144 // substituted into the context of [newInstance] in the created member.
149 ClassElement contextClass = Types.getClassContext(instance); 145 ClassElement contextClass = Types.getClassContext(instance);
150 return contextClass == null || contextClass == newInstance.element; 146 return contextClass == null || contextClass == newInstance.element;
151 }); 147 });
152 return _newInheritedMember(newInstance); 148 return _newInheritedMember(newInstance);
153 } 149 }
154 150
155 InheritedMember _newInheritedMember(InterfaceType newInstance) { 151 InheritedMember _newInheritedMember(InterfaceType newInstance) {
156 return new InheritedMember(declaration, 152 return new InheritedMember(
157 instance.substByContext(newInstance)); 153 declaration, instance.substByContext(newInstance));
158 } 154 }
159 155
160 Iterable<Member> get declarations => <Member>[this]; 156 Iterable<Member> get declarations => <Member>[this];
161 157
162 int get hashCode => declaration.hashCode + 17 * instance.hashCode; 158 int get hashCode => declaration.hashCode + 17 * instance.hashCode;
163 159
164 bool operator ==(other) { 160 bool operator ==(other) {
165 if (other is! InheritedMember) return false; 161 if (other is! InheritedMember) return false;
166 return declaration == other.declaration && 162 return declaration == other.declaration && instance == other.instance;
167 instance == other.instance;
168 } 163 }
169 164
170 void printOn(StringBuffer sb, DartType type) { 165 void printOn(StringBuffer sb, DartType type) {
171 declaration.printOn(sb, type); 166 declaration.printOn(sb, type);
172 sb.write(' inherited from $instance'); 167 sb.write(' inherited from $instance');
173 } 168 }
174 169
175 String toString() { 170 String toString() {
176 StringBuffer sb = new StringBuffer(); 171 StringBuffer sb = new StringBuffer();
177 printOn(sb, instance); 172 printOn(sb, instance);
178 return sb.toString(); 173 return sb.toString();
179 } 174 }
180 } 175 }
181 176
182 class InheritedAbstractMember extends InheritedMember { 177 class InheritedAbstractMember extends InheritedMember {
183 final DeclaredMember implementation; 178 final DeclaredMember implementation;
184 179
185 InheritedAbstractMember(DeclaredMember declaration, 180 InheritedAbstractMember(
186 InterfaceType instance, 181 DeclaredMember declaration, InterfaceType instance, this.implementation)
187 this.implementation)
188 : super(declaration, instance); 182 : super(declaration, instance);
189 183
190 bool get isAbstract => true; 184 bool get isAbstract => true;
191 185
192 InheritedMember _newInheritedMember(InterfaceType newInstance) { 186 InheritedMember _newInheritedMember(InterfaceType newInstance) {
193 return new InheritedAbstractMember( 187 return new InheritedAbstractMember(
194 declaration, 188 declaration,
195 instance.substByContext(newInstance), 189 instance.substByContext(newInstance),
196 implementation != null 190 implementation != null
197 ? implementation.inheritFrom(newInstance) : null); 191 ? implementation.inheritFrom(newInstance)
192 : null);
198 } 193 }
199 } 194 }
200 195
201
202 abstract class AbstractSyntheticMember implements MemberSignature { 196 abstract class AbstractSyntheticMember implements MemberSignature {
203 final Setlet<Member> inheritedMembers; 197 final Setlet<Member> inheritedMembers;
204 198
205 AbstractSyntheticMember(this.inheritedMembers); 199 AbstractSyntheticMember(this.inheritedMembers);
206 200
207 Member get member => inheritedMembers.first; 201 Member get member => inheritedMembers.first;
208 202
209 Iterable<Member> get declarations => inheritedMembers; 203 Iterable<Member> get declarations => inheritedMembers;
210 204
211 Name get name => member.name; 205 Name get name => member.name;
212 } 206 }
213 207
214
215 class SyntheticMember extends AbstractSyntheticMember { 208 class SyntheticMember extends AbstractSyntheticMember {
216 final DartType type; 209 final DartType type;
217 final FunctionType functionType; 210 final FunctionType functionType;
218 211
219 SyntheticMember(Setlet<Member> inheritedMembers, 212 SyntheticMember(Setlet<Member> inheritedMembers, this.type, this.functionType)
220 this.type,
221 this.functionType)
222 : super(inheritedMembers); 213 : super(inheritedMembers);
223 214
224 bool get isSetter => member.isSetter; 215 bool get isSetter => member.isSetter;
225 216
226 bool get isGetter => member.isGetter; 217 bool get isGetter => member.isGetter;
227 218
228 bool get isMethod => member.isMethod; 219 bool get isMethod => member.isMethod;
229 220
230 bool get isMalformed => false; 221 bool get isMalformed => false;
231 222
232 String toString() => '${type.getStringAsDeclared('$name')} synthesized ' 223 String toString() => '${type.getStringAsDeclared('$name')} synthesized '
233 'from ${inheritedMembers}'; 224 'from ${inheritedMembers}';
234 } 225 }
235 226
236 class ErroneousMember extends AbstractSyntheticMember { 227 class ErroneousMember extends AbstractSyntheticMember {
237 ErroneousMember(Setlet<Member> inheritedMembers) : super(inheritedMembers); 228 ErroneousMember(Setlet<Member> inheritedMembers) : super(inheritedMembers);
238 229
239 DartType get type => functionType; 230 DartType get type => functionType;
240 231
241 FunctionType get functionType { 232 FunctionType get functionType {
242 throw new UnsupportedError('Erroneous members have no type.'); 233 throw new UnsupportedError('Erroneous members have no type.');
243 } 234 }
244 235
245 bool get isSetter => false; 236 bool get isSetter => false;
246 237
247 bool get isGetter => false; 238 bool get isGetter => false;
248 239
249 bool get isMethod => false; 240 bool get isMethod => false;
250 241
251 bool get isMalformed => true; 242 bool get isMalformed => true;
252 243
253 String toString() => "erroneous member '$name' synthesized " 244 String toString() => "erroneous member '$name' synthesized "
254 "from ${inheritedMembers}"; 245 "from ${inheritedMembers}";
255 } 246 }
256
OLDNEW
« no previous file with comments | « pkg/compiler/lib/src/resolution/label_scope.dart ('k') | pkg/compiler/lib/src/resolution/members.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698