Chromium Code Reviews| 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 access is an instance method, property, or field | 20 /// The destination of the access is an instance method, property, or field |
| 21 /// of a class, and thus must be determined dynamically. | 21 /// of a class, and thus must be determined dynamically. |
| 22 DYNAMIC_PROPERTY, | 22 DYNAMIC_PROPERTY, |
| 23 | 23 |
| 24 // TODO(johnniwinther): Split these cases into captured and non-captured | 24 // TODO(johnniwinther): Split these cases into captured and non-captured |
| 25 // local access. | 25 // local access. |
| 26 /// 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 |
| 27 /// an enclosing function or method. | 27 /// an enclosing function or method. |
| 28 LOCAL_FUNCTION, | 28 LOCAL_FUNCTION, |
| 29 | 29 |
| 30 /// The destination of the access is a variable that is defined locally within | 30 /// The destination of the access is a non-final variable that is defined |
| 31 /// an enclosing function or method. | 31 /// locally within an enclosing function or method. |
| 32 LOCAL_VARIABLE, | 32 LOCAL_VARIABLE, |
| 33 | 33 |
| 34 /// The destination of the access is a variable that is defined as a parameter | 34 /// The destination of the access is a final variable that is defined locally |
| 35 /// to an enclosing function or method. | 35 /// within an enclosing function or method. |
| 36 FINAL_LOCAL_VARIABLE, | |
| 37 | |
| 38 /// The destination of the access is a variable that is defined as a non-final | |
| 39 /// parameter to an enclosing function or method. | |
| 36 PARAMETER, | 40 PARAMETER, |
| 37 | 41 |
| 38 /// The destination of the access is a field that is defined statically within | 42 /// The destination of the access is a variable that is defined as a final |
| 39 /// a class. | 43 /// parameter to an enclosing function or method. |
| 44 FINAL_PARAMETER, | |
| 45 | |
| 46 /// The destination of the access is a non-final field that is defined | |
| 47 /// statically within a class. | |
| 40 STATIC_FIELD, | 48 STATIC_FIELD, |
| 41 | 49 |
| 50 /// The destination of the access is a final field that is defined statically | |
| 51 /// within a class. | |
| 52 STATIC_FINAL_FIELD, | |
|
karlklose
2015/05/13 07:25:59
I would use FINAL as the prefix for all of these v
Johnni Winther
2015/05/13 08:47:59
Done.
| |
| 53 | |
| 42 /// The destination of the access is a method that is defined statically | 54 /// The destination of the access is a method that is defined statically |
| 43 /// within a class. | 55 /// within a class. |
| 44 STATIC_METHOD, | 56 STATIC_METHOD, |
| 45 | 57 |
| 46 /// The destination of the access is a property getter that is defined | 58 /// The destination of the access is a property getter that is defined |
| 47 /// statically within a class. | 59 /// statically within a class. |
| 48 STATIC_GETTER, | 60 STATIC_GETTER, |
| 49 | 61 |
| 50 /// The destination of the access is a property setter that is defined | 62 /// The destination of the access is a property setter that is defined |
| 51 /// statically within a class. | 63 /// statically within a class. |
| 52 STATIC_SETTER, | 64 STATIC_SETTER, |
| 53 | 65 |
| 54 /// The destination of the access is a top level variable defined within a | 66 /// The destination of the access is a non-final top level variable defined |
| 55 /// library. | 67 /// within a library. |
| 56 TOPLEVEL_FIELD, | 68 TOPLEVEL_FIELD, |
| 57 | 69 |
| 70 /// The destination of the access is a final top level variable defined within | |
| 71 /// a library. | |
| 72 TOPLEVEL_FINAL_FIELD, | |
| 73 | |
| 58 /// The destination of the access is a top level method defined within a | 74 /// The destination of the access is a top level method defined within a |
| 59 /// library. | 75 /// library. |
| 60 TOPLEVEL_METHOD, | 76 TOPLEVEL_METHOD, |
| 61 | 77 |
| 62 /// The destination of the access is a top level property getter defined | 78 /// The destination of the access is a top level property getter defined |
| 63 /// within a library. | 79 /// within a library. |
| 64 TOPLEVEL_GETTER, | 80 TOPLEVEL_GETTER, |
| 65 | 81 |
| 66 /// The destination of the access is a top level property setter defined | 82 /// The destination of the access is a top level property setter defined |
| 67 /// within a library. | 83 /// within a library. |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 84 /// function expression `(){}` in the function expression invocation `(){}()`. | 100 /// function expression `(){}` in the function expression invocation `(){}()`. |
| 85 EXPRESSION, | 101 EXPRESSION, |
| 86 | 102 |
| 87 /// The destination of the access is `this` of the enclosing class. | 103 /// The destination of the access is `this` of the enclosing class. |
| 88 THIS, | 104 THIS, |
| 89 | 105 |
| 90 /// The destination of the access is an instance method, property, or field | 106 /// The destination of the access is an instance method, property, or field |
| 91 /// of the enclosing class. | 107 /// of the enclosing class. |
| 92 THIS_PROPERTY, | 108 THIS_PROPERTY, |
| 93 | 109 |
| 94 /// The destination of the access is a field of the super class of the | 110 /// The destination of the access is a non-final field of the super class of |
| 111 /// the enclosing class. | |
| 112 SUPER_FIELD, | |
| 113 | |
| 114 /// The destination of the access is a final field of the super class of the | |
| 95 /// enclosing class. | 115 /// enclosing class. |
| 96 SUPER_FIELD, | 116 SUPER_FINAL_FIELD, |
| 97 | 117 |
| 98 /// The destination of the access is a method of the super class of the | 118 /// The destination of the access is a method of the super class of the |
| 99 /// enclosing class. | 119 /// enclosing class. |
| 100 SUPER_METHOD, | 120 SUPER_METHOD, |
| 101 | 121 |
| 102 /// The destination of the access is a getter of the super class of the | 122 /// The destination of the access is a getter of the super class of the |
| 103 /// enclosing class. | 123 /// enclosing class. |
| 104 SUPER_GETTER, | 124 SUPER_GETTER, |
| 105 | 125 |
| 106 /// The destination of the access is a setter of the super class of the | 126 /// The destination of the access is a setter of the super class of the |
| 107 /// enclosing class. | 127 /// enclosing class. |
| 108 SUPER_SETTER, | 128 SUPER_SETTER, |
| 109 | 129 |
| 110 /// Compound access where read and write access different elements. | 130 /// Compound access where read and write access different elements. |
| 111 /// See [CompoundAccessKind]. | 131 /// See [CompoundAccessKind]. |
| 112 COMPOUND, | 132 COMPOUND, |
| 113 | 133 |
| 114 /// The destination of the access is a compile-time constant. | 134 /// The destination of the access is a compile-time constant. |
| 115 CONSTANT, | 135 CONSTANT, |
| 116 | 136 |
| 117 /// The destination of the access is unresolved in a static context. | 137 /// The destination of the access is unresolved in a static context. |
| 118 UNRESOLVED, | 138 UNRESOLVED, |
| 119 | 139 |
| 120 /// The destination of the access is unresolved super access. | 140 /// The destination of the access is unresolved super access. |
| 121 UNRESOLVED_SUPER, | 141 UNRESOLVED_SUPER, |
| 122 } | 142 } |
| 123 | 143 |
| 124 enum CompoundAccessKind { | 144 enum CompoundAccessKind { |
| 125 /// Read from a static getter and write to static setter. | 145 /// Read from a static getter and write to a static setter. |
| 126 STATIC_GETTER_SETTER, | 146 STATIC_GETTER_SETTER, |
| 127 /// Read from a static method (closurize) and write to static setter. | 147 /// Read from a static method (closurize) and write to a static setter. |
| 128 STATIC_METHOD_SETTER, | 148 STATIC_METHOD_SETTER, |
| 129 | 149 |
| 150 /// Read from an unresolved static getter and write to a static setter. | |
| 151 UNRESOLVED_STATIC_GETTER, | |
| 152 /// Read from a static getter and write to an unresolved static setter. | |
| 153 UNRESOLVED_STATIC_SETTER, | |
| 154 | |
| 130 /// Read from a top level getter and write to a top level setter. | 155 /// Read from a top level getter and write to a top level setter. |
| 131 TOPLEVEL_GETTER_SETTER, | 156 TOPLEVEL_GETTER_SETTER, |
| 132 /// Read from a top level method (closurize) and write to top level setter. | 157 /// Read from a top level method (closurize) and write to top level setter. |
| 133 TOPLEVEL_METHOD_SETTER, | 158 TOPLEVEL_METHOD_SETTER, |
| 134 | 159 |
| 160 /// Read from an unresolved top level getter and write to a top level setter. | |
| 161 UNRESOLVED_TOPLEVEL_GETTER, | |
| 162 /// Read from a top level getter and write to an unresolved top level setter. | |
| 163 UNRESOLVED_TOPLEVEL_SETTER, | |
| 164 | |
| 135 /// Read from one superclass field and write to another. | 165 /// Read from one superclass field and write to another. |
| 136 SUPER_FIELD_FIELD, | 166 SUPER_FIELD_FIELD, |
| 137 /// Read from a superclass field and write to a superclass setter. | 167 /// Read from a superclass field and write to a superclass setter. |
| 138 SUPER_FIELD_SETTER, | 168 SUPER_FIELD_SETTER, |
| 139 /// Read from a superclass getter and write to a superclass setter. | 169 /// Read from a superclass getter and write to a superclass setter. |
| 140 SUPER_GETTER_SETTER, | 170 SUPER_GETTER_SETTER, |
| 141 /// Read from a superclass method (closurize) and write to a superclass | 171 /// Read from a superclass method (closurize) and write to a superclass |
| 142 /// setter. | 172 /// setter. |
| 143 SUPER_METHOD_SETTER, | 173 SUPER_METHOD_SETTER, |
| 144 /// Read from a superclass getter and write to a superclass field. | 174 /// Read from a superclass getter and write to a superclass field. |
| (...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 251 | 281 |
| 252 StaticAccess._(AccessKind kind, this.element) | 282 StaticAccess._(AccessKind kind, this.element) |
| 253 : super._(kind); | 283 : super._(kind); |
| 254 | 284 |
| 255 StaticAccess.superSetter(MethodElement this.element) | 285 StaticAccess.superSetter(MethodElement this.element) |
| 256 : super._(AccessKind.SUPER_SETTER); | 286 : super._(AccessKind.SUPER_SETTER); |
| 257 | 287 |
| 258 StaticAccess.superField(FieldElement this.element) | 288 StaticAccess.superField(FieldElement this.element) |
| 259 : super._(AccessKind.SUPER_FIELD); | 289 : super._(AccessKind.SUPER_FIELD); |
| 260 | 290 |
| 291 StaticAccess.superFinalField(FieldElement this.element) | |
| 292 : super._(AccessKind.SUPER_FINAL_FIELD); | |
| 293 | |
| 261 StaticAccess.superMethod(MethodElement this.element) | 294 StaticAccess.superMethod(MethodElement this.element) |
| 262 : super._(AccessKind.SUPER_METHOD); | 295 : super._(AccessKind.SUPER_METHOD); |
| 263 | 296 |
| 264 StaticAccess.superGetter(MethodElement this.element) | 297 StaticAccess.superGetter(MethodElement this.element) |
| 265 : super._(AccessKind.SUPER_GETTER); | 298 : super._(AccessKind.SUPER_GETTER); |
| 266 | 299 |
| 267 StaticAccess.typeParameterTypeLiteral(TypeVariableElement this.element) | 300 StaticAccess.typeParameterTypeLiteral(TypeVariableElement this.element) |
| 268 : super._(AccessKind.TYPE_PARAMETER_TYPE_LITERAL); | 301 : super._(AccessKind.TYPE_PARAMETER_TYPE_LITERAL); |
| 269 | 302 |
| 270 StaticAccess.localFunction(LocalFunctionElement this.element) | 303 StaticAccess.localFunction(LocalFunctionElement this.element) |
| 271 : super._(AccessKind.LOCAL_FUNCTION); | 304 : super._(AccessKind.LOCAL_FUNCTION); |
| 272 | 305 |
| 273 StaticAccess.localVariable(LocalVariableElement this.element) | 306 StaticAccess.localVariable(LocalVariableElement this.element) |
| 274 : super._(AccessKind.LOCAL_VARIABLE); | 307 : super._(AccessKind.LOCAL_VARIABLE); |
| 275 | 308 |
| 309 StaticAccess.finalLocalVariable(LocalVariableElement this.element) | |
| 310 : super._(AccessKind.FINAL_LOCAL_VARIABLE); | |
| 311 | |
| 276 StaticAccess.parameter(ParameterElement this.element) | 312 StaticAccess.parameter(ParameterElement this.element) |
| 277 : super._(AccessKind.PARAMETER); | 313 : super._(AccessKind.PARAMETER); |
| 278 | 314 |
| 315 StaticAccess.finalParameter(ParameterElement this.element) | |
| 316 : super._(AccessKind.FINAL_PARAMETER); | |
| 317 | |
| 279 StaticAccess.staticField(FieldElement this.element) | 318 StaticAccess.staticField(FieldElement this.element) |
| 280 : super._(AccessKind.STATIC_FIELD); | 319 : super._(AccessKind.STATIC_FIELD); |
| 281 | 320 |
| 321 StaticAccess.staticFinalField(FieldElement this.element) | |
| 322 : super._(AccessKind.STATIC_FINAL_FIELD); | |
| 323 | |
| 282 StaticAccess.staticMethod(MethodElement this.element) | 324 StaticAccess.staticMethod(MethodElement this.element) |
| 283 : super._(AccessKind.STATIC_METHOD); | 325 : super._(AccessKind.STATIC_METHOD); |
| 284 | 326 |
| 285 StaticAccess.staticGetter(MethodElement this.element) | 327 StaticAccess.staticGetter(MethodElement this.element) |
| 286 : super._(AccessKind.STATIC_GETTER); | 328 : super._(AccessKind.STATIC_GETTER); |
| 287 | 329 |
| 288 StaticAccess.staticSetter(MethodElement this.element) | 330 StaticAccess.staticSetter(MethodElement this.element) |
| 289 : super._(AccessKind.STATIC_SETTER); | 331 : super._(AccessKind.STATIC_SETTER); |
| 290 | 332 |
| 291 StaticAccess.topLevelField(FieldElement this.element) | 333 StaticAccess.topLevelField(FieldElement this.element) |
| 292 : super._(AccessKind.TOPLEVEL_FIELD); | 334 : super._(AccessKind.TOPLEVEL_FIELD); |
| 293 | 335 |
| 336 StaticAccess.topLevelFinalField(FieldElement this.element) | |
| 337 : super._(AccessKind.TOPLEVEL_FINAL_FIELD); | |
| 338 | |
| 294 StaticAccess.topLevelMethod(MethodElement this.element) | 339 StaticAccess.topLevelMethod(MethodElement this.element) |
| 295 : super._(AccessKind.TOPLEVEL_METHOD); | 340 : super._(AccessKind.TOPLEVEL_METHOD); |
| 296 | 341 |
| 297 StaticAccess.topLevelGetter(MethodElement this.element) | 342 StaticAccess.topLevelGetter(MethodElement this.element) |
| 298 : super._(AccessKind.TOPLEVEL_GETTER); | 343 : super._(AccessKind.TOPLEVEL_GETTER); |
| 299 | 344 |
| 300 StaticAccess.topLevelSetter(MethodElement this.element) | 345 StaticAccess.topLevelSetter(MethodElement this.element) |
| 301 : super._(AccessKind.TOPLEVEL_SETTER); | 346 : super._(AccessKind.TOPLEVEL_SETTER); |
| 302 | 347 |
| 303 StaticAccess.unresolved(this.element) | 348 StaticAccess.unresolved(this.element) |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 466 | 511 |
| 467 RedirectingFactoryConstructorAccessSemantics( | 512 RedirectingFactoryConstructorAccessSemantics( |
| 468 ConstructorAccessKind kind, | 513 ConstructorAccessKind kind, |
| 469 Element element, | 514 Element element, |
| 470 DartType type, | 515 DartType type, |
| 471 this.effectiveTargetSemantics) | 516 this.effectiveTargetSemantics) |
| 472 : super(kind, element, type); | 517 : super(kind, element, type); |
| 473 } | 518 } |
| 474 | 519 |
| 475 | 520 |
| OLD | NEW |