OLD | NEW |
1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 // TODO(johnniwinther): Temporarily copied from analyzer2dart. Merge when | 5 // TODO(johnniwinther): Temporarily copied from analyzer2dart. Merge when |
6 // we shared code with the analyzer and this semantic visitor is complete. | 6 // we shared code with the analyzer and this semantic visitor is complete. |
7 | 7 |
8 /** | 8 /** |
9 * Code for classifying the semantics of identifiers appearing in a Dart file. | 9 * Code for classifying the semantics of identifiers appearing in a Dart file. |
10 */ | 10 */ |
11 library dart2js.access_semantics; | 11 library dart2js.access_semantics; |
12 | 12 |
13 import '../constants/expressions.dart'; | 13 import '../constants/expressions.dart'; |
14 import '../elements/elements.dart'; | 14 import '../elements/elements.dart'; |
15 import '../dart_types.dart'; | 15 import '../dart_types.dart'; |
16 | 16 |
17 /// Enum representing the different kinds of destinations which a property | 17 /// Enum representing the different kinds of destinations which a property |
18 /// access or method or function invocation might refer to. | 18 /// access or method or function invocation might refer to. |
19 enum AccessKind { | 19 enum AccessKind { |
20 /// The destination of the conditional access is an instance method, property, | |
21 /// or field of a class, and thus must be determined dynamically. | |
22 CONDITIONAL_DYNAMIC_PROPERTY, | |
23 | |
24 /// The destination of the access is an instance method, property, or field | 20 /// The destination of the access is an instance method, property, or field |
25 /// of a class, and thus must be determined dynamically. | 21 /// of a class, and thus must be determined dynamically. |
26 DYNAMIC_PROPERTY, | 22 DYNAMIC_PROPERTY, |
27 | 23 |
28 // TODO(johnniwinther): Split these cases into captured and non-captured | 24 // TODO(johnniwinther): Split these cases into captured and non-captured |
29 // local access. | 25 // local access. |
30 /// The destination of the access is a function that is defined locally within | 26 /// The destination of the access is a function that is defined locally within |
31 /// an enclosing function or method. | 27 /// an enclosing function or method. |
32 LOCAL_FUNCTION, | 28 LOCAL_FUNCTION, |
33 | 29 |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
253 return sb.toString(); | 249 return sb.toString(); |
254 } | 250 } |
255 } | 251 } |
256 | 252 |
257 | 253 |
258 class DynamicAccess extends AccessSemantics { | 254 class DynamicAccess extends AccessSemantics { |
259 final target; | 255 final target; |
260 | 256 |
261 DynamicAccess.dynamicProperty(this.target) | 257 DynamicAccess.dynamicProperty(this.target) |
262 : super._(AccessKind.DYNAMIC_PROPERTY); | 258 : super._(AccessKind.DYNAMIC_PROPERTY); |
263 | |
264 DynamicAccess.ifNotNullProperty(this.target) | |
265 : super._(AccessKind.CONDITIONAL_DYNAMIC_PROPERTY); | |
266 } | 259 } |
267 | 260 |
268 class ConstantAccess extends AccessSemantics { | 261 class ConstantAccess extends AccessSemantics { |
269 final ConstantExpression constant; | 262 final ConstantExpression constant; |
270 | 263 |
271 ConstantAccess(AccessKind kind, this.constant) | 264 ConstantAccess(AccessKind kind, this.constant) |
272 : super._(kind); | 265 : super._(kind); |
273 | 266 |
274 ConstantAccess.classTypeLiteral(this.constant) | 267 ConstantAccess.classTypeLiteral(this.constant) |
275 : super._(AccessKind.CLASS_TYPE_LITERAL); | 268 : super._(AccessKind.CLASS_TYPE_LITERAL); |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 | 525 |
533 RedirectingFactoryConstructorAccessSemantics( | 526 RedirectingFactoryConstructorAccessSemantics( |
534 ConstructorAccessKind kind, | 527 ConstructorAccessKind kind, |
535 Element element, | 528 Element element, |
536 DartType type, | 529 DartType type, |
537 this.effectiveTargetSemantics) | 530 this.effectiveTargetSemantics) |
538 : super(kind, element, type); | 531 : super(kind, element, type); |
539 } | 532 } |
540 | 533 |
541 | 534 |
OLD | NEW |