| 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 197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 ConstantExpression get constant => null; | 208 ConstantExpression get constant => null; |
| 209 | 209 |
| 210 /// The element for the getter in case of a compound access, | 210 /// The element for the getter in case of a compound access, |
| 211 /// [element] otherwise. | 211 /// [element] otherwise. |
| 212 Element get getter => element; | 212 Element get getter => element; |
| 213 | 213 |
| 214 /// The element for the setter in case of a compound access, | 214 /// The element for the setter in case of a compound access, |
| 215 /// [element] otherwise. | 215 /// [element] otherwise. |
| 216 Element get setter => element; | 216 Element get setter => element; |
| 217 | 217 |
| 218 // TODO(johnniwinther): Make access semantics getter/setter specific. | |
| 219 /// `true` if the [element] of this access is accessed statically. | |
| 220 bool get isAccessedStatically => false; | |
| 221 | |
| 222 const AccessSemantics._(this.kind); | 218 const AccessSemantics._(this.kind); |
| 223 | 219 |
| 224 String toString() { | 220 String toString() { |
| 225 StringBuffer sb = new StringBuffer(); | 221 StringBuffer sb = new StringBuffer(); |
| 226 sb.write('AccessSemantics['); | 222 sb.write('AccessSemantics['); |
| 227 sb.write('kind=$kind,'); | 223 sb.write('kind=$kind,'); |
| 228 if (element != null) { | 224 if (element != null) { |
| 229 sb.write('element='); | 225 sb.write('element='); |
| 230 if (element.enclosingClass != null) { | 226 if (element.enclosingClass != null) { |
| 231 sb.write('${element.enclosingClass.name}.'); | 227 sb.write('${element.enclosingClass.name}.'); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 246 : super._(AccessKind.THIS); | 242 : super._(AccessKind.THIS); |
| 247 | 243 |
| 248 const DynamicAccess.thisProperty() | 244 const DynamicAccess.thisProperty() |
| 249 : super._(AccessKind.THIS_PROPERTY); | 245 : super._(AccessKind.THIS_PROPERTY); |
| 250 | 246 |
| 251 const DynamicAccess.dynamicProperty() | 247 const DynamicAccess.dynamicProperty() |
| 252 : super._(AccessKind.DYNAMIC_PROPERTY); | 248 : super._(AccessKind.DYNAMIC_PROPERTY); |
| 253 | 249 |
| 254 const DynamicAccess.ifNotNullProperty() | 250 const DynamicAccess.ifNotNullProperty() |
| 255 : super._(AccessKind.CONDITIONAL_DYNAMIC_PROPERTY); | 251 : super._(AccessKind.CONDITIONAL_DYNAMIC_PROPERTY); |
| 256 | |
| 257 bool get isAccessedStatically => false; | |
| 258 } | 252 } |
| 259 | 253 |
| 260 class ConstantAccess extends AccessSemantics { | 254 class ConstantAccess extends AccessSemantics { |
| 261 final ConstantExpression constant; | 255 final ConstantExpression constant; |
| 262 | 256 |
| 263 ConstantAccess(AccessKind kind, this.constant) | 257 ConstantAccess(AccessKind kind, this.constant) |
| 264 : super._(kind); | 258 : super._(kind); |
| 265 | 259 |
| 266 ConstantAccess.classTypeLiteral(this.constant) | 260 ConstantAccess.classTypeLiteral(this.constant) |
| 267 : super._(AccessKind.CLASS_TYPE_LITERAL); | 261 : super._(AccessKind.CLASS_TYPE_LITERAL); |
| 268 | 262 |
| 269 ConstantAccess.typedefTypeLiteral(this.constant) | 263 ConstantAccess.typedefTypeLiteral(this.constant) |
| 270 : super._(AccessKind.TYPEDEF_TYPE_LITERAL); | 264 : super._(AccessKind.TYPEDEF_TYPE_LITERAL); |
| 271 | 265 |
| 272 ConstantAccess.dynamicTypeLiteral(this.constant) | 266 ConstantAccess.dynamicTypeLiteral(this.constant) |
| 273 : super._(AccessKind.DYNAMIC_TYPE_LITERAL); | 267 : super._(AccessKind.DYNAMIC_TYPE_LITERAL); |
| 274 | |
| 275 bool get isAccessedStatically => false; | |
| 276 } | 268 } |
| 277 | 269 |
| 278 class StaticAccess extends AccessSemantics { | 270 class StaticAccess extends AccessSemantics { |
| 279 final Element element; | 271 final Element element; |
| 280 | 272 |
| 281 StaticAccess._(AccessKind kind, this.element) | 273 StaticAccess._(AccessKind kind, this.element) |
| 282 : super._(kind); | 274 : super._(kind); |
| 283 | 275 |
| 284 StaticAccess.superSetter(MethodElement this.element) | 276 StaticAccess.superSetter(MethodElement this.element) |
| 285 : super._(AccessKind.SUPER_SETTER); | 277 : super._(AccessKind.SUPER_SETTER); |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 : super._(AccessKind.TOPLEVEL_SETTER); | 337 : super._(AccessKind.TOPLEVEL_SETTER); |
| 346 | 338 |
| 347 StaticAccess.unresolved(this.element) | 339 StaticAccess.unresolved(this.element) |
| 348 : super._(AccessKind.UNRESOLVED); | 340 : super._(AccessKind.UNRESOLVED); |
| 349 | 341 |
| 350 StaticAccess.unresolvedSuper(this.element) | 342 StaticAccess.unresolvedSuper(this.element) |
| 351 : super._(AccessKind.UNRESOLVED_SUPER); | 343 : super._(AccessKind.UNRESOLVED_SUPER); |
| 352 | 344 |
| 353 StaticAccess.invalid(this.element) | 345 StaticAccess.invalid(this.element) |
| 354 : super._(AccessKind.INVALID); | 346 : super._(AccessKind.INVALID); |
| 355 | |
| 356 bool get isAccessedStatically { | |
| 357 switch (kind) { | |
| 358 case AccessKind.UNRESOLVED: | |
| 359 case AccessKind.UNRESOLVED_SUPER: | |
| 360 case AccessKind.INVALID: | |
| 361 case AccessKind.TYPE_PARAMETER_TYPE_LITERAL: | |
| 362 return false; | |
| 363 default: | |
| 364 return true; | |
| 365 } | |
| 366 } | |
| 367 } | 347 } |
| 368 | 348 |
| 369 class CompoundAccessSemantics extends AccessSemantics { | 349 class CompoundAccessSemantics extends AccessSemantics { |
| 370 final CompoundAccessKind compoundAccessKind; | 350 final CompoundAccessKind compoundAccessKind; |
| 371 final Element getter; | 351 final Element getter; |
| 372 final Element setter; | 352 final Element setter; |
| 373 | 353 |
| 374 CompoundAccessSemantics(this.compoundAccessKind, | 354 CompoundAccessSemantics(this.compoundAccessKind, |
| 375 this.getter, | 355 this.getter, |
| 376 this.setter) | 356 this.setter) |
| 377 : super._(AccessKind.COMPOUND); | 357 : super._(AccessKind.COMPOUND); |
| 378 | 358 |
| 379 Element get element => setter; | 359 Element get element => setter; |
| 380 | 360 |
| 381 // TODO(johnniwinther): Discriminate between access of the getter and setter. | |
| 382 bool get isAccessedStatically => true; | |
| 383 | |
| 384 String toString() { | 361 String toString() { |
| 385 StringBuffer sb = new StringBuffer(); | 362 StringBuffer sb = new StringBuffer(); |
| 386 sb.write('CompoundAccessSemantics['); | 363 sb.write('CompoundAccessSemantics['); |
| 387 sb.write('kind=$compoundAccessKind'); | 364 sb.write('kind=$compoundAccessKind'); |
| 388 if (getter != null) { | 365 if (getter != null) { |
| 389 sb.write(',getter='); | 366 sb.write(',getter='); |
| 390 sb.write('${getter}'); | 367 sb.write('${getter}'); |
| 391 } | 368 } |
| 392 if (setter != null) { | 369 if (setter != null) { |
| 393 sb.write(',setter='); | 370 sb.write(',setter='); |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 542 | 519 |
| 543 RedirectingFactoryConstructorAccessSemantics( | 520 RedirectingFactoryConstructorAccessSemantics( |
| 544 ConstructorAccessKind kind, | 521 ConstructorAccessKind kind, |
| 545 Element element, | 522 Element element, |
| 546 DartType type, | 523 DartType type, |
| 547 this.effectiveTargetSemantics) | 524 this.effectiveTargetSemantics) |
| 548 : super(kind, element, type); | 525 : super(kind, element, type); |
| 549 } | 526 } |
| 550 | 527 |
| 551 | 528 |
| OLD | NEW |