| 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 // The dart:mirrors library provides reflective access for Dart program. | 5 // The dart:mirrors library provides reflective access for Dart program. |
| 6 // | 6 // |
| 7 // For the purposes of the mirrors library, we adopt a naming | 7 // For the purposes of the mirrors library, we adopt a naming |
| 8 // convention with respect to getters and setters. Specifically, for | 8 // convention with respect to getters and setters. Specifically, for |
| 9 // some variable or field... | 9 // some variable or field... |
| 10 // | 10 // |
| (...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 [Map<String,Object> namedArguments]); | 219 [Map<String,Object> namedArguments]); |
| 220 | 220 |
| 221 /** | 221 /** |
| 222 * Looks up the value of a name in the scope of the closure. The | 222 * Looks up the value of a name in the scope of the closure. The |
| 223 * result is a mirror on that value. | 223 * result is a mirror on that value. |
| 224 */ | 224 */ |
| 225 Future<InstanceMirror> findInContext(String name); | 225 Future<InstanceMirror> findInContext(String name); |
| 226 } | 226 } |
| 227 | 227 |
| 228 /** | 228 /** |
| 229 * A [LibraryMirror] reflects a Dart language library, providing |
| 230 * access to the variables, functions, classes, and interfaces of the |
| 231 * library. |
| 232 */ |
| 233 interface LibraryMirror extends ObjectMirror { |
| 234 /** |
| 235 * The name of this library, as provided in the [#library] declaration. |
| 236 */ |
| 237 final String simpleName; |
| 238 |
| 239 /** |
| 240 * The url of the library. |
| 241 * |
| 242 * TODO(turnidge): Document where this url comes from. Will this |
| 243 * value be sensible? |
| 244 */ |
| 245 final String url; |
| 246 |
| 247 /** |
| 248 * An immutable map from from names to mirrors for all members in |
| 249 * this library. |
| 250 * |
| 251 * The members of a library are its top-level classes, interfaces, |
| 252 * functions, variables, getters, and setters. |
| 253 */ |
| 254 final Map<String, Mirror> members; |
| 255 |
| 256 /** |
| 257 * An immutable map from names to mirrors for all class and |
| 258 * interface declarations in this library. |
| 259 */ |
| 260 final Map<String, ClassMirror> classes; |
| 261 |
| 262 /** |
| 263 * An immutable map from names to mirrors for all function |
| 264 * declarations in this library. |
| 265 */ |
| 266 final Map<String, MethodMirror> functions; |
| 267 |
| 268 /** |
| 269 * An immutable map from names to mirrors for all variable |
| 270 * declarations in this library. |
| 271 */ |
| 272 final Map<String, VariableMirror> variables; |
| 273 } |
| 274 |
| 275 /** |
| 229 * A [TypeMirror] reflects a Dart language class, interface, typedef | 276 * A [TypeMirror] reflects a Dart language class, interface, typedef |
| 230 * or type variable. | 277 * or type variable. |
| 231 */ | 278 */ |
| 232 interface TypeMirror extends Mirror { | 279 interface TypeMirror extends Mirror { |
| 233 /** | 280 /** |
| 234 * The library in which this interface is declared. | 281 * The library in which this interface is declared. |
| 235 */ | 282 */ |
| 236 final LibraryMirror library; | 283 final LibraryMirror library; |
| 237 } | 284 } |
| 238 | 285 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 * Invokes the named constructor and returns a mirror on the result. | 342 * Invokes the named constructor and returns a mirror on the result. |
| 296 * | 343 * |
| 297 * TODO(turnidge): Properly document. | 344 * TODO(turnidge): Properly document. |
| 298 */ | 345 */ |
| 299 Future<InstanceMirror> newInstance(String constructorName, | 346 Future<InstanceMirror> newInstance(String constructorName, |
| 300 List<Object> positionalArguments, | 347 List<Object> positionalArguments, |
| 301 [Map<String,Object> namedArguments]); | 348 [Map<String,Object> namedArguments]); |
| 302 } | 349 } |
| 303 | 350 |
| 304 /** | 351 /** |
| 305 * A [LibraryMirror] reflects a Dart language library, providing | |
| 306 * access to the variables, functions, classes, and interfaces of the | |
| 307 * library. | |
| 308 */ | |
| 309 interface LibraryMirror extends ObjectMirror { | |
| 310 /** | |
| 311 * The name of this library, as provided in the [#library] declaration. | |
| 312 */ | |
| 313 final String simpleName; | |
| 314 | |
| 315 /** | |
| 316 * The url of the library. | |
| 317 * | |
| 318 * TODO(turnidge): Document where this url comes from. Will this | |
| 319 * value be sensible? | |
| 320 */ | |
| 321 final String url; | |
| 322 | |
| 323 /** | |
| 324 * An immutable map from from names to mirrors for all members in | |
| 325 * this library. | |
| 326 * | |
| 327 * The members of a library are its top-level classes, interfaces, | |
| 328 * functions, variables, getters, and setters. | |
| 329 */ | |
| 330 final Map<String, Mirror> members; | |
| 331 | |
| 332 /** | |
| 333 * An immutable map from names to mirrors for all class and | |
| 334 * interface declarations in this library. | |
| 335 */ | |
| 336 final Map<String, ClassMirror> classes; | |
| 337 | |
| 338 /** | |
| 339 * An immutable map from names to mirrors for all function | |
| 340 * declarations in this library. | |
| 341 */ | |
| 342 final Map<String, MethodMirror> functions; | |
| 343 | |
| 344 /** | |
| 345 * An immutable map from names to mirrors for all variable | |
| 346 * declarations in this library. | |
| 347 */ | |
| 348 final Map<String, VariableMirror> variables; | |
| 349 } | |
| 350 | |
| 351 /** | |
| 352 * A [MethodMirror] reflects a Dart language function, method, | 352 * A [MethodMirror] reflects a Dart language function, method, |
| 353 * constructor, getter, or setter. | 353 * constructor, getter, or setter. |
| 354 */ | 354 */ |
| 355 interface MethodMirror { | 355 interface MethodMirror { |
| 356 /** | 356 /** |
| 357 * The name of this function. | 357 * The name of this function. |
| 358 */ | 358 */ |
| 359 final String simpleName; | 359 final String simpleName; |
| 360 | 360 |
| 361 /** | 361 /** |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 */ | 434 */ |
| 435 final bool isRedirectingConstructor; | 435 final bool isRedirectingConstructor; |
| 436 | 436 |
| 437 /** | 437 /** |
| 438 * Does this mirror reflect a factory constructor? | 438 * Does this mirror reflect a factory constructor? |
| 439 */ | 439 */ |
| 440 final bool isFactoryConstructor; | 440 final bool isFactoryConstructor; |
| 441 } | 441 } |
| 442 | 442 |
| 443 /** | 443 /** |
| 444 * A [ParameterMirror] reflects a Dart formal parameter declaration. | |
| 445 */ | |
| 446 interface ParameterMirror extends VariableMirror { | |
| 447 /** | |
| 448 * Returns the type of this parameter. | |
| 449 */ | |
| 450 final TypeMirror type; | |
| 451 | |
| 452 /** | |
| 453 * Returns the default value for this parameter. | |
| 454 */ | |
| 455 final String defaultValue; | |
| 456 | |
| 457 /** | |
| 458 * Returns true if this parameter has a default value. | |
| 459 */ | |
| 460 final bool hasDefaultValue; | |
| 461 | |
| 462 /** | |
| 463 * Returns true if this parameter is optional. | |
| 464 */ | |
| 465 final bool isOptional; | |
| 466 } | |
| 467 | |
| 468 /** | |
| 469 * A [VariableMirror] reflects a Dart language variable declaration. | 444 * A [VariableMirror] reflects a Dart language variable declaration. |
| 470 */ | 445 */ |
| 471 interface VariableMirror { | 446 interface VariableMirror { |
| 472 /** | 447 /** |
| 473 * The name of this variable | 448 * The name of this variable |
| 474 */ | 449 */ |
| 475 final String simpleName; | 450 final String simpleName; |
| 476 | 451 |
| 477 /** | 452 /** |
| 478 * A mirror on the owner of this method. The owner is the | 453 * A mirror on the owner of this method. The owner is the |
| (...skipping 16 matching lines...) Expand all Loading... |
| 495 * implicitly declared static. | 470 * implicitly declared static. |
| 496 */ | 471 */ |
| 497 final bool isStatic; | 472 final bool isStatic; |
| 498 | 473 |
| 499 /** | 474 /** |
| 500 * Does this mirror reflect a final variable? | 475 * Does this mirror reflect a final variable? |
| 501 */ | 476 */ |
| 502 final bool isFinal; | 477 final bool isFinal; |
| 503 } | 478 } |
| 504 | 479 |
| 480 /** |
| 481 * A [ParameterMirror] reflects a Dart formal parameter declaration. |
| 482 */ |
| 483 interface ParameterMirror extends VariableMirror { |
| 484 /** |
| 485 * Returns the type of this parameter. |
| 486 */ |
| 487 final TypeMirror type; |
| 488 |
| 489 /** |
| 490 * Returns the default value for this parameter. |
| 491 */ |
| 492 final String defaultValue; |
| 493 |
| 494 /** |
| 495 * Returns true if this parameter has a default value. |
| 496 */ |
| 497 final bool hasDefaultValue; |
| 498 |
| 499 /** |
| 500 * Returns true if this parameter is optional. |
| 501 */ |
| 502 final bool isOptional; |
| 503 } |
| 505 | 504 |
| 506 /** | 505 /** |
| 507 * When an error occurs during the mirrored execution of code, a | 506 * When an error occurs during the mirrored execution of code, a |
| 508 * [MirroredError] is thrown. | 507 * [MirroredError] is thrown. |
| 509 * | 508 * |
| 510 * In general, there are three main classes of failure that can happen | 509 * In general, there are three main classes of failure that can happen |
| 511 * during mirrored execution of code in some isolate: | 510 * during mirrored execution of code in some isolate: |
| 512 * | 511 * |
| 513 * - An exception is thrown but not caught. This is caught by the | 512 * - An exception is thrown but not caught. This is caught by the |
| 514 * mirrors framework and a [MirroredUncaughtExceptionError] is | 513 * mirrors framework and a [MirroredUncaughtExceptionError] is |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 | 576 |
| 578 /** | 577 /** |
| 579 * A [MirrorException] is used to indicate errors within the mirrors | 578 * A [MirrorException] is used to indicate errors within the mirrors |
| 580 * framework. | 579 * framework. |
| 581 */ | 580 */ |
| 582 class MirrorException implements Exception { | 581 class MirrorException implements Exception { |
| 583 const MirrorException(String this._message); | 582 const MirrorException(String this._message); |
| 584 String toString() => "MirrorException: '$_message'"; | 583 String toString() => "MirrorException: '$_message'"; |
| 585 final String _message; | 584 final String _message; |
| 586 } | 585 } |
| OLD | NEW |