| 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 */ |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 232 ConstantExpression get constant => null; | 232 ConstantExpression get constant => null; |
| 233 | 233 |
| 234 /// The element for the getter in case of a compound access, | 234 /// The element for the getter in case of a compound access, |
| 235 /// [element] otherwise. | 235 /// [element] otherwise. |
| 236 Element get getter => element; | 236 Element get getter => element; |
| 237 | 237 |
| 238 /// The element for the setter in case of a compound access, | 238 /// The element for the setter in case of a compound access, |
| 239 /// [element] otherwise. | 239 /// [element] otherwise. |
| 240 Element get setter => element; | 240 Element get setter => element; |
| 241 | 241 |
| 242 // TODO(johnniwinther): Make access semantics getter/setter specific. |
| 243 /// `true` if the [element] of this access is accessed statically. |
| 244 bool get isAccessedStatically => false; |
| 245 |
| 242 AccessSemantics.expression() | 246 AccessSemantics.expression() |
| 243 : kind = AccessKind.EXPRESSION; | 247 : kind = AccessKind.EXPRESSION; |
| 244 | 248 |
| 245 AccessSemantics.thisAccess() | 249 AccessSemantics.thisAccess() |
| 246 : kind = AccessKind.THIS; | 250 : kind = AccessKind.THIS; |
| 247 | 251 |
| 248 AccessSemantics.thisProperty() | 252 AccessSemantics.thisProperty() |
| 249 : kind = AccessKind.THIS_PROPERTY; | 253 : kind = AccessKind.THIS_PROPERTY; |
| 250 | 254 |
| 251 AccessSemantics._(this.kind); | 255 AccessSemantics._(this.kind); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 268 | 272 |
| 269 | 273 |
| 270 class DynamicAccess extends AccessSemantics { | 274 class DynamicAccess extends AccessSemantics { |
| 271 final target; | 275 final target; |
| 272 | 276 |
| 273 DynamicAccess.dynamicProperty(this.target) | 277 DynamicAccess.dynamicProperty(this.target) |
| 274 : super._(AccessKind.DYNAMIC_PROPERTY); | 278 : super._(AccessKind.DYNAMIC_PROPERTY); |
| 275 | 279 |
| 276 DynamicAccess.ifNotNullProperty(this.target) | 280 DynamicAccess.ifNotNullProperty(this.target) |
| 277 : super._(AccessKind.CONDITIONAL_DYNAMIC_PROPERTY); | 281 : super._(AccessKind.CONDITIONAL_DYNAMIC_PROPERTY); |
| 282 |
| 283 bool get isAccessedStatically => false; |
| 278 } | 284 } |
| 279 | 285 |
| 280 class ConstantAccess extends AccessSemantics { | 286 class ConstantAccess extends AccessSemantics { |
| 281 final ConstantExpression constant; | 287 final ConstantExpression constant; |
| 282 | 288 |
| 283 ConstantAccess(AccessKind kind, this.constant) | 289 ConstantAccess(AccessKind kind, this.constant) |
| 284 : super._(kind); | 290 : super._(kind); |
| 285 | 291 |
| 286 ConstantAccess.classTypeLiteral(this.constant) | 292 ConstantAccess.classTypeLiteral(this.constant) |
| 287 : super._(AccessKind.CLASS_TYPE_LITERAL); | 293 : super._(AccessKind.CLASS_TYPE_LITERAL); |
| 288 | 294 |
| 289 ConstantAccess.typedefTypeLiteral(this.constant) | 295 ConstantAccess.typedefTypeLiteral(this.constant) |
| 290 : super._(AccessKind.TYPEDEF_TYPE_LITERAL); | 296 : super._(AccessKind.TYPEDEF_TYPE_LITERAL); |
| 291 | 297 |
| 292 ConstantAccess.dynamicTypeLiteral(this.constant) | 298 ConstantAccess.dynamicTypeLiteral(this.constant) |
| 293 : super._(AccessKind.DYNAMIC_TYPE_LITERAL); | 299 : super._(AccessKind.DYNAMIC_TYPE_LITERAL); |
| 300 |
| 301 bool get isAccessedStatically => false; |
| 294 } | 302 } |
| 295 | 303 |
| 296 class StaticAccess extends AccessSemantics { | 304 class StaticAccess extends AccessSemantics { |
| 297 final Element element; | 305 final Element element; |
| 298 | 306 |
| 299 ClassElement get classElement => element.enclosingClass; | 307 ClassElement get classElement => element.enclosingClass; |
| 300 | 308 |
| 301 StaticAccess._(AccessKind kind, this.element) | 309 StaticAccess._(AccessKind kind, this.element) |
| 302 : super._(kind); | 310 : super._(kind); |
| 303 | 311 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 : super._(AccessKind.TOPLEVEL_SETTER); | 373 : super._(AccessKind.TOPLEVEL_SETTER); |
| 366 | 374 |
| 367 StaticAccess.unresolved(this.element) | 375 StaticAccess.unresolved(this.element) |
| 368 : super._(AccessKind.UNRESOLVED); | 376 : super._(AccessKind.UNRESOLVED); |
| 369 | 377 |
| 370 StaticAccess.unresolvedSuper(this.element) | 378 StaticAccess.unresolvedSuper(this.element) |
| 371 : super._(AccessKind.UNRESOLVED_SUPER); | 379 : super._(AccessKind.UNRESOLVED_SUPER); |
| 372 | 380 |
| 373 StaticAccess.invalid(this.element) | 381 StaticAccess.invalid(this.element) |
| 374 : super._(AccessKind.INVALID); | 382 : super._(AccessKind.INVALID); |
| 383 |
| 384 bool get isAccessedStatically { |
| 385 switch (kind) { |
| 386 case AccessKind.UNRESOLVED: |
| 387 case AccessKind.UNRESOLVED_SUPER: |
| 388 case AccessKind.INVALID: |
| 389 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: |
| 390 return false; |
| 391 default: |
| 392 return true; |
| 393 } |
| 394 } |
| 375 } | 395 } |
| 376 | 396 |
| 377 class CompoundAccessSemantics extends AccessSemantics { | 397 class CompoundAccessSemantics extends AccessSemantics { |
| 378 final CompoundAccessKind compoundAccessKind; | 398 final CompoundAccessKind compoundAccessKind; |
| 379 final Element getter; | 399 final Element getter; |
| 380 final Element setter; | 400 final Element setter; |
| 381 | 401 |
| 382 CompoundAccessSemantics(this.compoundAccessKind, | 402 CompoundAccessSemantics(this.compoundAccessKind, |
| 383 this.getter, | 403 this.getter, |
| 384 this.setter) | 404 this.setter) |
| 385 : super._(AccessKind.COMPOUND); | 405 : super._(AccessKind.COMPOUND); |
| 386 | 406 |
| 387 Element get element => setter; | 407 Element get element => setter; |
| 388 | 408 |
| 409 // TODO(johnniwinther): Discriminate between access of the getter and setter. |
| 410 bool get isAccessedStatically => true; |
| 411 |
| 389 String toString() { | 412 String toString() { |
| 390 StringBuffer sb = new StringBuffer(); | 413 StringBuffer sb = new StringBuffer(); |
| 391 sb.write('CompoundAccessSemantics['); | 414 sb.write('CompoundAccessSemantics['); |
| 392 sb.write('kind=$compoundAccessKind'); | 415 sb.write('kind=$compoundAccessKind'); |
| 393 if (getter != null) { | 416 if (getter != null) { |
| 394 sb.write(',getter='); | 417 sb.write(',getter='); |
| 395 sb.write('${getter}'); | 418 sb.write('${getter}'); |
| 396 } | 419 } |
| 397 if (setter != null) { | 420 if (setter != null) { |
| 398 sb.write(',setter='); | 421 sb.write(',setter='); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 547 | 570 |
| 548 RedirectingFactoryConstructorAccessSemantics( | 571 RedirectingFactoryConstructorAccessSemantics( |
| 549 ConstructorAccessKind kind, | 572 ConstructorAccessKind kind, |
| 550 Element element, | 573 Element element, |
| 551 DartType type, | 574 DartType type, |
| 552 this.effectiveTargetSemantics) | 575 this.effectiveTargetSemantics) |
| 553 : super(kind, element, type); | 576 : super(kind, element, type); |
| 554 } | 577 } |
| 555 | 578 |
| 556 | 579 |
| OLD | NEW |