| 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 // #library("mirrors"); | |
| 6 | |
| 7 // The dart:mirrors library provides reflective access for Dart program. | 5 // The dart:mirrors library provides reflective access for Dart program. |
| 8 // | 6 // |
| 9 // For the purposes of the mirrors library, we adopt a naming | 7 // For the purposes of the mirrors library, we adopt a naming |
| 10 // convention with respect to getters and setters. Specifically, for | 8 // convention with respect to getters and setters. Specifically, for |
| 11 // some variable or field... | 9 // some variable or field... |
| 12 // | 10 // |
| 13 // var myField; | 11 // var myField; |
| 14 // | 12 // |
| 15 // ...the getter is named 'myField' and the setter is named | 13 // ...the getter is named 'myField' and the setter is named |
| 16 // 'myField='. This allows us to assign unique names to getters and | 14 // 'myField='. This allows us to assign unique names to getters and |
| 17 // setters for the purposes of member lookup. | 15 // setters for the purposes of member lookup. |
| 18 // | 16 |
| 19 // TODO(turnidge): Finish implementing this api. | 17 // #library("mirrors"); |
| 20 | 18 |
| 21 /** | 19 /** |
| 22 * A [MirrorSystem] is the main interface used to reflect on a set of | 20 * A [MirrorSystem] is the main interface used to reflect on a set of |
| 23 * associated libraries. | 21 * associated libraries. |
| 24 * | 22 * |
| 25 * At runtime each running isolate has a distinct [MirrorSystem]. | 23 * At runtime each running isolate has a distinct [MirrorSystem]. |
| 26 * | 24 * |
| 27 * It is also possible to have a [MirrorSystem] which represents a set | 25 * It is also possible to have a [MirrorSystem] which represents a set |
| 28 * of libraries which are not running -- perhaps at compile-time. In | 26 * of libraries which are not running -- perhaps at compile-time. In |
| 29 * this case, all available reflective functionality would be | 27 * this case, all available reflective functionality would be |
| 30 * supported, but runtime functionality (such as invoking a function | 28 * supported, but runtime functionality (such as invoking a function |
| 31 * or inspecting the contents of a variable) would fail dynamically. | 29 * or inspecting the contents of a variable) would fail dynamically. |
| 32 */ | 30 */ |
| 33 interface MirrorSystem { | 31 interface MirrorSystem { |
| 34 /** | 32 /** |
| 35 * A mirror on the root library of the mirror system. | |
| 36 */ | |
| 37 final LibraryMirror rootLibrary; | |
| 38 | |
| 39 /** | |
| 40 * An immutable map from from library names to mirrors for all | 33 * An immutable map from from library names to mirrors for all |
| 41 * libraries known to this mirror system. | 34 * libraries known to this mirror system. |
| 42 */ | 35 */ |
| 43 Map<String, LibraryMirror> libraries(); | 36 final Map<String, LibraryMirror> libraries; |
| 44 | 37 |
| 45 /** | 38 /** |
| 46 * A mirror on the isolate associated with this [MirrorSystem]. | 39 * A mirror on the isolate associated with this [MirrorSystem]. |
| 47 * This may be null if this mirror system is not running. | 40 * This may be null if this mirror system is not running. |
| 48 */ | 41 */ |
| 49 IsolateMirror isolate; | 42 final IsolateMirror isolate; |
| 50 | 43 |
| 51 /** | 44 /** |
| 52 * Returns an [InstanceMirror] for some Dart language object. | 45 * A mirror on the [:Dynamic:] type. |
| 53 * | |
| 54 * This only works if this mirror system is associated with the | |
| 55 * current running isolate. | |
| 56 */ | 46 */ |
| 57 InstanceMirror mirrorOf(Object reflectee); | 47 final TypeMirror dynamicType; |
| 48 |
| 49 /** |
| 50 * A mirror on the [:void:] type. |
| 51 */ |
| 52 final TypeMirror voidType; |
| 58 } | 53 } |
| 59 | 54 |
| 60 /** | 55 /** |
| 61 * Returns a [MirrorSystem] for the current isolate. | 56 * Returns a [MirrorSystem] for the current isolate. |
| 62 */ | 57 */ |
| 63 MirrorSystem currentMirrorSystem() { | 58 MirrorSystem currentMirrorSystem() { |
| 64 return _Mirrors.currentMirrorSystem(); | 59 return _Mirrors.currentMirrorSystem(); |
| 65 } | 60 } |
| 66 | 61 |
| 67 /** | 62 /** |
| 68 * Creates a [MirrorSystem] for the isolate which is listening on | 63 * Creates a [MirrorSystem] for the isolate which is listening on |
| 69 * the [SendPort]. | 64 * the [SendPort]. |
| 70 */ | 65 */ |
| 71 Future<MirrorSystem> mirrorSystemOf(SendPort port) { | 66 Future<MirrorSystem> mirrorSystemOf(SendPort port) { |
| 72 return _Mirrors.mirrorSystemOf(port); | 67 return _Mirrors.mirrorSystemOf(port); |
| 73 } | 68 } |
| 74 | 69 |
| 75 /** | 70 /** |
| 71 * Returns an [InstanceMirror] for some Dart language object. |
| 72 * |
| 73 * This only works if this mirror system is associated with the |
| 74 * current running isolate. |
| 75 */ |
| 76 InstanceMirror reflect(Object reflectee) { |
| 77 return _Mirrors.reflect(reflectee); |
| 78 } |
| 79 |
| 80 /** |
| 76 * A [Mirror] reflects some Dart language entity. | 81 * A [Mirror] reflects some Dart language entity. |
| 77 * | 82 * |
| 78 * Every [Mirror] originates from some [MirrorSystem]. | 83 * Every [Mirror] originates from some [MirrorSystem]. |
| 79 */ | 84 */ |
| 80 interface Mirror { | 85 interface Mirror extends Hashable { |
| 81 /** | 86 /** |
| 82 * The originating [MirrorSystem] for this mirror. | 87 * The [MirrorSystem] that contains this mirror. |
| 83 */ | 88 */ |
| 84 final MirrorSystem mirrors; | 89 final MirrorSystem mirrors; |
| 85 } | 90 } |
| 86 | 91 |
| 87 /** | 92 /** |
| 88 * An [IsolateMirror] reflects an isolate. | 93 * An [IsolateMirror] reflects an isolate. |
| 89 */ | 94 */ |
| 90 interface IsolateMirror extends Mirror { | 95 interface IsolateMirror extends Mirror { |
| 91 /** | 96 /** |
| 92 * A unique name used to refer to an isolate in debugging messages. | 97 * A unique name used to refer to an isolate in debugging messages. |
| 93 */ | 98 */ |
| 94 final String debugName; | 99 final String debugName; |
| 95 | 100 |
| 96 /** | 101 /** |
| 97 * Does this mirror reflect the currently running isolate? | 102 * Does this mirror reflect the currently running isolate? |
| 98 */ | 103 */ |
| 99 final bool isCurrent; | 104 final bool isCurrent; |
| 105 |
| 106 /** |
| 107 * A mirror on the root library for this isolate. |
| 108 */ |
| 109 final LibraryMirror rootLibrary; |
| 100 } | 110 } |
| 101 | 111 |
| 102 | |
| 103 /** | 112 /** |
| 104 * An [ObjectMirror] is a common superinterface of [InstanceMirror], | 113 * An [ObjectMirror] is a common superinterface of [InstanceMirror], |
| 105 * [InterfaceMirror], and [LibraryMirror] that represents their shared | 114 * [ClassMirror], and [LibraryMirror] that represents their shared |
| 106 * functionality. | 115 * functionality. |
| 107 * | 116 * |
| 108 * For the purposes of the mirrors library, these types are all | 117 * For the purposes of the mirrors library, these types are all |
| 109 * object-like, in that they support method invocation and field | 118 * object-like, in that they support method invocation and field |
| 110 * access. Real Dart objects are represented by the [InstanceMirror] | 119 * access. Real Dart objects are represented by the [InstanceMirror] |
| 111 * type. | 120 * type. |
| 112 * | 121 * |
| 113 * See [InstanceMirror], [InterfaceMirror], and [LibraryMirror]. | 122 * See [InstanceMirror], [ClassMirror], and [LibraryMirror]. |
| 114 */ | 123 */ |
| 115 interface ObjectMirror extends Mirror { | 124 interface ObjectMirror extends Mirror { |
| 116 /** | 125 /** |
| 117 * Invokes the named function and returns a mirror on the result. | 126 * Invokes the named function and returns a mirror on the result. |
| 118 * | 127 * |
| 119 * TODO(turnidge): Properly document. | 128 * TODO(turnidge): Properly document. |
| 129 * TODO(turnidge): Handle ambiguous names. |
| 130 * TODO(turnidge): Handle optional & named arguments. |
| 120 */ | 131 */ |
| 121 Future<InstanceMirror> invoke(String memberName, | 132 Future<InstanceMirror> invoke(String memberName, |
| 122 List<Object> positionalArguments, | 133 List<Object> positionalArguments, |
| 123 [Map<String,Object> namedArguments]); | 134 [Map<String,Object> namedArguments]); |
| 124 | 135 |
| 125 /** | 136 /** |
| 126 * Invokes a getter and returns a mirror on the result. The getter may be | 137 * Invokes a getter and returns a mirror on the result. The getter |
| 127 * either the implicit getter for a field or a user-defined getter method. | 138 * can be the implicit getter for a field or a user-defined getter |
| 139 * method. |
| 140 * |
| 141 * TODO(turnidge): Handle ambiguous names. |
| 128 */ | 142 */ |
| 129 Future<InstanceMirror> getField(String fieldName); | 143 Future<InstanceMirror> getField(String fieldName); |
| 130 | 144 |
| 131 /** | 145 /** |
| 132 * Invokes a setter and returns a mirror on the result. The setter may be | 146 * Invokes a setter and returns a mirror on the result. The setter |
| 133 * either the implicit setter for a non-final field or a user-defined setter | 147 * may be either the implicit setter for a non-final field or a |
| 134 * method. | 148 * user-defined setter method. |
| 149 * |
| 150 * TODO(turnidge): Handle ambiguous names. |
| 135 */ | 151 */ |
| 136 Future<InstanceMirror> setField(String fieldName, Object value); | 152 Future<InstanceMirror> setField(String fieldName, Object value); |
| 137 } | 153 } |
| 138 | 154 |
| 139 /** | 155 /** |
| 140 * An [InstanceMirror] reflects an instance of a Dart language object. | 156 * An [InstanceMirror] reflects an instance of a Dart language object. |
| 141 */ | 157 */ |
| 142 interface InstanceMirror extends ObjectMirror { | 158 interface InstanceMirror extends ObjectMirror { |
| 143 /** | 159 /** |
| 144 * Returns a mirror on the class of the reflectee. | 160 * A mirror on the type of the reflectee. |
| 145 */ | 161 */ |
| 146 InterfaceMirror getClass(); | 162 final ClassMirror type; |
| 147 | 163 |
| 148 /** | 164 /** |
| 149 * Does [reflectee] contain the instance reflected by this mirror? This will | 165 * Does [reflectee] contain the instance reflected by this mirror? |
| 150 * always be true in the local case (reflecting instances in the same | 166 * This will always be true in the local case (reflecting instances |
| 151 * isolate), but only true in the remote case if this mirror reflects a | 167 * in the same isolate), but only true in the remote case if this |
| 152 * simple value. | 168 * mirror reflects a simple value. |
| 153 * | 169 * |
| 154 * A value is simple if one of the following holds: | 170 * A value is simple if one of the following holds: |
| 155 * - the value is null | 171 * - the value is null |
| 156 * - the value is of type [num] | 172 * - the value is of type [num] |
| 157 * - the value is of type [bool] | 173 * - the value is of type [bool] |
| 158 * - the value is of type [String] | 174 * - the value is of type [String] |
| 159 */ | 175 */ |
| 160 final bool hasReflectee; | 176 final bool hasReflectee; |
| 161 | 177 |
| 162 /** | 178 /** |
| 163 * If the [InstanceMirror] reflects an instance it is meaningful to have a | 179 * If the [InstanceMirror] reflects an instance it is meaningful to |
| 164 * local reference to, we provide access to the actual instance here. | 180 * have a local reference to, we provide access to the actual |
| 181 * instance here. |
| 165 * | 182 * |
| 166 * If you access [reflectee] when [hasReflectee] is false, an | 183 * If you access [reflectee] when [hasReflectee] is false, an |
| 167 * exception is thrown. | 184 * exception is thrown. |
| 168 */ | 185 */ |
| 169 final reflectee; | 186 final reflectee; |
| 170 } | 187 } |
| 171 | 188 |
| 172 /** | 189 /** |
| 173 * A [ClosureMirror] reflects a closure. Closures are special, because we do not | 190 * A [ClosureMirror] reflects a closure. |
| 174 * wish to reflect the internals of a particular closure implementation. And | 191 * |
| 175 * yet, we need access to details of the closure internals - for example, its | 192 * A [ClosureMirror] provides access to its captured variables and |
| 176 * enclosing context and its source code. | 193 * provides the ability to execute its reflectee. |
| 177 */ | 194 */ |
| 178 interface ClosureMirror extends InstanceMirror { | 195 interface ClosureMirror extends InstanceMirror { |
| 196 /** |
| 197 * A mirror on the function associated with this closure. |
| 198 */ |
| 199 final MethodMirror function; |
| 179 | 200 |
| 180 /** | 201 /** |
| 181 * Return the source code for the closure, if available. | 202 * The source code for this closure, if available. Otherwise null. |
| 182 */ | 203 * |
| 183 String source(); | 204 * TODO(turnidge): Would this just be available in function? |
| 184 | 205 */ |
| 185 /** | 206 final String source; |
| 186 * Call the closure. The arguments given in the descriptor need to be | |
| 187 * ObjectMirrors or values. Asynchronous. | |
| 188 */ | |
| 189 Future<ObjectMirror> apply(List<Object> positionalArguments, | |
| 190 [Map<String,Object> namedArguments]); | |
| 191 | 207 |
| 192 /** | 208 /** |
| 193 * Look up the value of name in the scope of the closure. The result is a | 209 * Executes the closure. The arguments given in the descriptor need to |
| 194 * mirror on that value. Asynchronous. | 210 * be InstanceMirrors or simple values. |
| 211 * |
| 212 * A value is simple if one of the following holds: |
| 213 * - the value is null |
| 214 * - the value is of type [num] |
| 215 * - the value is of type [bool] |
| 216 * - the value is of type [String] |
| 195 */ | 217 */ |
| 196 Future<ObjectMirror> findInContext(String name); | 218 Future<InstanceMirror> apply(List<Object> positionalArguments, |
| 219 [Map<String,Object> namedArguments]); |
| 197 | 220 |
| 198 /** | 221 /** |
| 199 * Return a mirror on the function of this closure. | 222 * Looks up the value of a name in the scope of the closure. The |
| 223 * result is a mirror on that value. |
| 200 */ | 224 */ |
| 201 MethodMirror function(); | 225 Future<InstanceMirror> findInContext(String name); |
| 202 } | 226 } |
| 203 | 227 |
| 204 /** | 228 /** |
| 205 * A [TypeMirror] reflects a Dart language class, interface, typedef | 229 * A [TypeMirror] reflects a Dart language class, interface, typedef |
| 206 * or type variable. | 230 * or type variable. |
| 207 */ | 231 */ |
| 208 interface TypeMirror extends Mirror { | 232 interface TypeMirror extends Mirror { |
| 209 /** | 233 /** |
| 210 * The library in which this interface is declared. | 234 * The library in which this interface is declared. |
| 211 */ | 235 */ |
| 212 final LibraryMirror library; | 236 final LibraryMirror library; |
| 213 } | 237 } |
| 214 | 238 |
| 215 /** | 239 /** |
| 216 * An [InterfaceMirror] reflects a Dart language class or interface. | 240 * A [ClassMirror] reflects a Dart language class or interface. |
| 217 */ | 241 */ |
| 218 interface InterfaceMirror extends TypeMirror, ObjectMirror { | 242 interface ClassMirror extends TypeMirror, ObjectMirror { |
| 219 /** | 243 /** |
| 220 * The name of this interface. | 244 * The name of this interface. |
| 221 */ | 245 */ |
| 222 final String simpleName; | 246 final String simpleName; |
| 223 | 247 |
| 224 /** | 248 /** |
| 225 * Does this mirror represent a class? | 249 * Does this mirror represent a class? |
| 226 */ | 250 */ |
| 227 final bool isClass; | 251 final bool isClass; |
| 228 | 252 |
| 229 /** | 253 /** |
| 230 * Returns a mirror on the superclass on the reflectee. | 254 * Returns a mirror on the superclass on the reflectee. |
| 231 * | 255 * |
| 232 * For interfaces, the superclass is Object. | 256 * For interfaces, the superclass is Object. |
| 233 */ | 257 */ |
| 234 InterfaceMirror superclass(); | 258 final ClassMirror superclass; |
| 235 | 259 |
| 236 /** | 260 /** |
| 237 * Returns a list of mirrors on the superinterfaces for the reflectee. | 261 * Returns a list of mirrors on the superinterfaces for the reflectee. |
| 238 */ | 262 */ |
| 239 List<InterfaceMirror> superinterfaces(); | 263 final List<ClassMirror> superinterfaces; |
| 240 | 264 |
| 241 /** | 265 /** |
| 242 * Returns a mirror on the default factory class or null if there is | 266 * Returns a mirror on the default factory class or null if there is |
| 243 * none. | 267 * none. |
| 244 */ | 268 */ |
| 245 InterfaceMirror defaultFactory(); | 269 final ClassMirror defaultFactory; |
| 246 | 270 |
| 247 /** | 271 /** |
| 248 * An immutable map from from names to mirrors for all members of | 272 * An immutable map from from names to mirrors for all members of |
| 249 * this type. | 273 * this type. |
| 250 * | 274 * |
| 251 * The members of an interface are its constructors, methods, | 275 * The members of an interface are its constructors, methods, |
| 252 * fields, getters, and setters. | 276 * fields, getters, and setters. |
| 253 * | 277 * |
| 254 * This does not include inherited members. | 278 * This does not include inherited members. |
| 255 */ | 279 */ |
| 256 Map<String, Mirror> members(); | 280 final Map<String, Mirror> members; |
| 257 | 281 |
| 258 /** | 282 /** |
| 259 * An immutable map from names to mirrors for all method, | 283 * An immutable map from names to mirrors for all method, |
| 260 * constructor, getter, and setter declarations in this library. | 284 * constructor, getter, and setter declarations in this library. |
| 261 */ | 285 */ |
| 262 Map<String, MethodMirror> methods(); | 286 final Map<String, MethodMirror> methods; |
| 263 | 287 |
| 264 /** | 288 /** |
| 265 * An immutable map from names to mirrors for all variable | 289 * An immutable map from names to mirrors for all variable |
| 266 * declarations in this library. | 290 * declarations in this library. |
| 267 */ | 291 */ |
| 268 Map<String, VariableMirror> variables(); | 292 final Map<String, VariableMirror> variables; |
| 269 | 293 |
| 270 /** | 294 /** |
| 271 * Invokes the named constructor and returns a mirror on the result. | 295 * Invokes the named constructor and returns a mirror on the result. |
| 272 * | 296 * |
| 273 * TODO(turnidge): Properly document. | 297 * TODO(turnidge): Properly document. |
| 274 */ | 298 */ |
| 275 Future<InstanceMirror> newInstance(String constructorName, | 299 Future<InstanceMirror> newInstance(String constructorName, |
| 276 List<Object> positionalArguments, | 300 List<Object> positionalArguments, |
| 277 [Map<String,Object> namedArguments]); | 301 [Map<String,Object> namedArguments]); |
| 278 } | 302 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 296 */ | 320 */ |
| 297 final String url; | 321 final String url; |
| 298 | 322 |
| 299 /** | 323 /** |
| 300 * An immutable map from from names to mirrors for all members in | 324 * An immutable map from from names to mirrors for all members in |
| 301 * this library. | 325 * this library. |
| 302 * | 326 * |
| 303 * The members of a library are its top-level classes, interfaces, | 327 * The members of a library are its top-level classes, interfaces, |
| 304 * functions, variables, getters, and setters. | 328 * functions, variables, getters, and setters. |
| 305 */ | 329 */ |
| 306 Map<String, Mirror> members(); | 330 final Map<String, Mirror> members; |
| 307 | 331 |
| 308 /** | 332 /** |
| 309 * An immutable map from names to mirrors for all class and | 333 * An immutable map from names to mirrors for all class and |
| 310 * interface declarations in this library. | 334 * interface declarations in this library. |
| 311 */ | 335 */ |
| 312 Map<String, InterfaceMirror> classes(); | 336 final Map<String, ClassMirror> classes; |
| 313 | 337 |
| 314 /** | 338 /** |
| 315 * An immutable map from names to mirrors for all function | 339 * An immutable map from names to mirrors for all function |
| 316 * declarations in this library. | 340 * declarations in this library. |
| 317 */ | 341 */ |
| 318 Map<String, MethodMirror> functions(); | 342 final Map<String, MethodMirror> functions; |
| 319 | 343 |
| 320 /** | 344 /** |
| 321 * An immutable map from names to mirrors for all variable | 345 * An immutable map from names to mirrors for all variable |
| 322 * declarations in this library. | 346 * declarations in this library. |
| 323 */ | 347 */ |
| 324 Map<String, VariableMirror> variables(); | 348 final Map<String, VariableMirror> variables; |
| 325 } | 349 } |
| 326 | 350 |
| 327 /** | 351 /** |
| 328 * A [MethodMirror] reflects a Dart language function, method, | 352 * A [MethodMirror] reflects a Dart language function, method, |
| 329 * constructor, getter, or setter. | 353 * constructor, getter, or setter. |
| 330 */ | 354 */ |
| 331 interface MethodMirror { | 355 interface MethodMirror { |
| 332 /** | 356 /** |
| 333 * The name of this function. | 357 * The name of this function. |
| 334 */ | 358 */ |
| 335 final String simpleName; | 359 final String simpleName; |
| 336 | 360 |
| 337 /** | 361 /** |
| 338 * A mirror on the owner of this function. This is the declaration | 362 * A mirror on the owner of this function. This is the declaration |
| 339 * immediately surrounding the reflectee. | 363 * immediately surrounding the reflectee. |
| 340 * | 364 * |
| 341 * For top-level functions, this will be a [LibraryMirror] and for | 365 * For top-level functions, this will be a [LibraryMirror] and for |
| 342 * methods, constructors, getters, and setters, this will be an | 366 * methods, constructors, getters, and setters, this will be an |
| 343 * [InterfaceMirror]. | 367 * [ClassMirror]. |
| 344 */ | 368 */ |
| 345 Mirror owner; | 369 final Mirror owner; |
| 370 |
| 371 /** |
| 372 * Returns the list of parameters for this method. |
| 373 */ |
| 374 final List<ParameterMirror> parameters; |
| 346 | 375 |
| 347 // Ownership | 376 // Ownership |
| 348 | 377 |
| 349 /** | 378 /** |
| 350 * Does this mirror reflect a top-level function? | 379 * Does this mirror reflect a top-level function? |
| 351 */ | 380 */ |
| 352 bool isTopLevel; | 381 final bool isTopLevel; |
| 353 | 382 |
| 354 /** | 383 /** |
| 355 * Does this mirror reflect a static method? | 384 * Does this mirror reflect a static method? |
| 356 * | 385 * |
| 357 * For the purposes of the mirrors library, a top-level function is | 386 * For the purposes of the mirrors library, a top-level function is |
| 358 * considered static. | 387 * considered static. |
| 359 */ | 388 */ |
| 360 bool isStatic; | 389 final bool isStatic; |
| 361 | 390 |
| 362 // Method kind | 391 // Method kind |
| 363 | 392 |
| 364 /** | 393 /** |
| 365 * Does this mirror reflect a regular function or method? | 394 * Does this mirror reflect a regular function or method? |
| 366 * | 395 * |
| 367 * A method is regular if it is not a getter, setter, or constructor. | 396 * A method is regular if it is not a getter, setter, or constructor. |
| 368 */ | 397 */ |
| 369 bool isMethod; | 398 final bool isMethod; |
| 370 | 399 |
| 371 /** | 400 /** |
| 372 * Does this mirror reflect an abstract method? | 401 * Does this mirror reflect an abstract method? |
| 373 */ | 402 */ |
| 374 bool isAbstract; | 403 final bool isAbstract; |
| 375 | 404 |
| 376 /** | 405 /** |
| 377 * Does this mirror reflect a getter? | 406 * Does this mirror reflect a getter? |
| 378 */ | 407 */ |
| 379 bool isGetter; | 408 final bool isGetter; |
| 380 | 409 |
| 381 /** | 410 /** |
| 382 * Does this mirror reflect a setter? | 411 * Does this mirror reflect a setter? |
| 383 */ | 412 */ |
| 384 bool isSetter; | 413 final bool isSetter; |
| 385 | 414 |
| 386 /** | 415 /** |
| 387 * Does this mirror reflect a constructor? | 416 * Does this mirror reflect a constructor? |
| 388 */ | 417 */ |
| 389 bool isConstructor; | 418 final bool isConstructor; |
| 390 | 419 |
| 391 // Constructor kind | 420 // Constructor kind |
| 392 | 421 |
| 393 /** | 422 /** |
| 394 * Does this mirror reflect a const constructor? | 423 * Does this mirror reflect a const constructor? |
| 395 */ | 424 */ |
| 396 bool isConstConstructor; | 425 final bool isConstConstructor; |
| 397 | 426 |
| 398 /** | 427 /** |
| 399 * Does this mirror reflect a generative constructor? | 428 * Does this mirror reflect a generative constructor? |
| 400 */ | 429 */ |
| 401 bool isGenerativeConstructor; | 430 final bool isGenerativeConstructor; |
| 402 | 431 |
| 403 /** | 432 /** |
| 404 * Does this mirror reflect a redirecting constructor? | 433 * Does this mirror reflect a redirecting constructor? |
| 405 */ | 434 */ |
| 406 bool isRedirectingConstructor; | 435 final bool isRedirectingConstructor; |
| 407 | 436 |
| 408 /** | 437 /** |
| 409 * Does this mirror reflect a factory constructor? | 438 * Does this mirror reflect a factory constructor? |
| 410 */ | 439 */ |
| 411 bool isFactoryConstructor; | 440 final bool isFactoryConstructor; |
| 412 | |
| 413 /** | |
| 414 * Returns the list of parameters for this method. | |
| 415 */ | |
| 416 List<ParameterMirror> parameters(); | |
| 417 } | 441 } |
| 418 | 442 |
| 419 /** | 443 /** |
| 420 * A [ParameterMirror] reflects a Dart formal parameter declaration. | 444 * A [ParameterMirror] reflects a Dart formal parameter declaration. |
| 421 */ | 445 */ |
| 422 interface ParameterMirror extends VariableMirror { | 446 interface ParameterMirror extends VariableMirror { |
| 423 /** | 447 /** |
| 424 * Returns the type of this parameter. | 448 * Returns the type of this parameter. |
| 425 */ | 449 */ |
| 426 TypeMirror type; | 450 final TypeMirror type; |
| 427 | 451 |
| 428 /** | 452 /** |
| 429 * Returns the default value for this parameter. | 453 * Returns the default value for this parameter. |
| 430 */ | 454 */ |
| 431 String defaultValue; | 455 final String defaultValue; |
| 432 | 456 |
| 433 /** | 457 /** |
| 434 * Returns true if this parameter has a default value. | 458 * Returns true if this parameter has a default value. |
| 435 */ | 459 */ |
| 436 bool hasDefaultValue; | 460 final bool hasDefaultValue; |
| 437 | 461 |
| 438 /** | 462 /** |
| 439 * Returns true if this parameter is optional. | 463 * Returns true if this parameter is optional. |
| 440 */ | 464 */ |
| 441 bool isOptional; | 465 final bool isOptional; |
| 442 } | 466 } |
| 443 | 467 |
| 444 /** | 468 /** |
| 445 * A [VariableMirror] reflects a Dart language variable declaration. | 469 * A [VariableMirror] reflects a Dart language variable declaration. |
| 446 */ | 470 */ |
| 447 interface VariableMirror { | 471 interface VariableMirror { |
| 448 /** | 472 /** |
| 449 * The name of this variable | 473 * The name of this variable |
| 450 */ | 474 */ |
| 451 final String simpleName; | 475 final String simpleName; |
| 452 | 476 |
| 453 /** | 477 /** |
| 454 * A mirror on the owner of this method. The owner is the | 478 * A mirror on the owner of this method. The owner is the |
| 455 * declaration immediately surrounding the reflectee. | 479 * declaration immediately surrounding the reflectee. |
| 456 * | 480 * |
| 457 * For top-level variables, this will be a [LibraryMirror] and for | 481 * For top-level variables, this will be a [LibraryMirror] and for |
| 458 * class and interface variables, this will be an [InterfaceMirror]. | 482 * class and interface variables, this will be a [ClassMirror]. |
| 459 */ | 483 */ |
| 460 Mirror owner; | 484 final Mirror owner; |
| 461 | 485 |
| 462 /** | 486 /** |
| 463 * Does this mirror reflect a top-level variable? | 487 * Does this mirror reflect a top-level variable? |
| 464 */ | 488 */ |
| 465 bool isTopLevel; | 489 final bool isTopLevel; |
| 466 | 490 |
| 467 /** | 491 /** |
| 468 * Does this mirror reflect a static variable? | 492 * Does this mirror reflect a static variable? |
| 469 * | 493 * |
| 470 * For the purposes of the mirror library, top-level variables are | 494 * For the purposes of the mirror library, top-level variables are |
| 471 * implicitly declared static. | 495 * implicitly declared static. |
| 472 */ | 496 */ |
| 473 bool isStatic; | 497 final bool isStatic; |
| 474 | 498 |
| 475 /** | 499 /** |
| 476 * Does this mirror reflect a final variable? | 500 * Does this mirror reflect a final variable? |
| 477 */ | 501 */ |
| 478 bool isFinal; | 502 final bool isFinal; |
| 479 } | 503 } |
| 480 | 504 |
| 481 | 505 |
| 482 /** | 506 /** |
| 483 * When an error occurs during the mirrored execution of code, a | 507 * When an error occurs during the mirrored execution of code, a |
| 484 * [MirroredError] is thrown. | 508 * [MirroredError] is thrown. |
| 485 * | 509 * |
| 486 * In general, there are three main classes of failure that can happen | 510 * In general, there are three main classes of failure that can happen |
| 487 * during mirrored execution of code in some isolate: | 511 * during mirrored execution of code in some isolate: |
| 488 * | 512 * |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 553 | 577 |
| 554 /** | 578 /** |
| 555 * A [MirrorException] is used to indicate errors within the mirrors | 579 * A [MirrorException] is used to indicate errors within the mirrors |
| 556 * framework. | 580 * framework. |
| 557 */ | 581 */ |
| 558 class MirrorException implements Exception { | 582 class MirrorException implements Exception { |
| 559 const MirrorException(String this._message); | 583 const MirrorException(String this._message); |
| 560 String toString() => "MirrorException: '$_message'"; | 584 String toString() => "MirrorException: '$_message'"; |
| 561 final String _message; | 585 final String _message; |
| 562 } | 586 } |
| OLD | NEW |