OLD | NEW |
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 /// This library defines individual world impacts. | 5 /// This library defines individual world impacts. |
6 /// | 6 /// |
7 /// We call these building blocks `uses`. Each `use` is a single impact of the | 7 /// We call these building blocks `uses`. Each `use` is a single impact of the |
8 /// world. Some example uses are: | 8 /// world. Some example uses are: |
9 /// | 9 /// |
10 /// * an invocation of a top level function | 10 /// * an invocation of a top level function |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 } | 200 } |
201 | 201 |
202 /// Invocation of a constructor (body) [element] through a this or super | 202 /// Invocation of a constructor (body) [element] through a this or super |
203 /// constructor call with the given [callStructure]. | 203 /// constructor call with the given [callStructure]. |
204 factory StaticUse.constructorBodyInvoke( | 204 factory StaticUse.constructorBodyInvoke( |
205 ConstructorBodyElement element, CallStructure callStructure) { | 205 ConstructorBodyElement element, CallStructure callStructure) { |
206 // TODO(johnniwinther): Use the [callStructure]. | 206 // TODO(johnniwinther): Use the [callStructure]. |
207 return new StaticUse.internal(element, StaticUseKind.GENERAL); | 207 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
208 } | 208 } |
209 | 209 |
| 210 /// Direct invocation of a method [element] with the given [callStructure]. |
| 211 factory StaticUse.directInvoke( |
| 212 MethodElement element, CallStructure callStructure) { |
| 213 // TODO(johnniwinther): Use the [callStructure]. |
| 214 assert(invariant(element, element.isInstanceMember, |
| 215 message: "Direct invoke element $element must be an instance method.")); |
| 216 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
| 217 } |
| 218 |
| 219 /// Direct read access of a field or getter [element]. |
| 220 factory StaticUse.directGet(MemberElement element) { |
| 221 assert(invariant(element, element.isInstanceMember, |
| 222 message: "Direct get element $element must be an instance method.")); |
| 223 assert(invariant(element, element.isField || element.isGetter, |
| 224 message: "Direct get element $element must be a field or a getter.")); |
| 225 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
| 226 } |
| 227 |
| 228 /// Direct write access of a field [element]. |
| 229 factory StaticUse.directSet(FieldElement element) { |
| 230 assert(invariant(element, element.isInstanceMember, |
| 231 message: "Direct set element $element must be an instance method.")); |
| 232 assert(invariant(element, element.isField, |
| 233 message: "Direct set element $element must be a field.")); |
| 234 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
| 235 } |
| 236 |
210 /// Constructor invocation of [element] with the given [callStructure]. | 237 /// Constructor invocation of [element] with the given [callStructure]. |
211 factory StaticUse.constructorInvoke( | 238 factory StaticUse.constructorInvoke( |
212 ConstructorElement element, CallStructure callStructure) { | 239 ConstructorElement element, CallStructure callStructure) { |
213 // TODO(johnniwinther): Use the [callStructure]. | 240 // TODO(johnniwinther): Use the [callStructure]. |
214 return new StaticUse.internal(element, StaticUseKind.GENERAL); | 241 return new StaticUse.internal(element, StaticUseKind.GENERAL); |
215 } | 242 } |
216 | 243 |
217 /// Constructor invocation of [element] with the given [callStructure] on | 244 /// Constructor invocation of [element] with the given [callStructure] on |
218 /// [type]. | 245 /// [type]. |
219 factory StaticUse.typedConstructorInvoke( | 246 factory StaticUse.typedConstructorInvoke( |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
337 } | 364 } |
338 | 365 |
339 bool operator ==(other) { | 366 bool operator ==(other) { |
340 if (identical(this, other)) return true; | 367 if (identical(this, other)) return true; |
341 if (other is! TypeUse) return false; | 368 if (other is! TypeUse) return false; |
342 return type == other.type && kind == other.kind; | 369 return type == other.type && kind == other.kind; |
343 } | 370 } |
344 | 371 |
345 String toString() => 'TypeUse($type,$kind)'; | 372 String toString() => 'TypeUse($type,$kind)'; |
346 } | 373 } |
OLD | NEW |