Chromium Code Reviews| 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 // For the purposes of the mirrors library, we adopt a naming | 5 // For the purposes of the mirrors library, we adopt a naming |
| 6 // convention with respect to getters and setters. Specifically, for | 6 // convention with respect to getters and setters. Specifically, for |
| 7 // some variable or field... | 7 // some variable or field... |
| 8 // | 8 // |
| 9 // var myField; | 9 // var myField; |
| 10 // | 10 // |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 64 * or inspecting the contents of a variable) would fail dynamically. | 64 * or inspecting the contents of a variable) would fail dynamically. |
| 65 */ | 65 */ |
| 66 abstract class MirrorSystem { | 66 abstract class MirrorSystem { |
| 67 /** | 67 /** |
| 68 * Returns an immutable map from URIs to mirrors for all | 68 * Returns an immutable map from URIs to mirrors for all |
| 69 * libraries known to this mirror system. | 69 * libraries known to this mirror system. |
| 70 */ | 70 */ |
| 71 Map<Uri, LibraryMirror> get libraries; | 71 Map<Uri, LibraryMirror> get libraries; |
| 72 | 72 |
| 73 /** | 73 /** |
| 74 * Returns an iterable of all libraries in the mirror system whose library | 74 * Returns the unique library named [libraryName] if it exists. |
| 75 * name is [libraryName]. | 75 * |
| 76 * If no unique library exists, an error is thrown. | |
| 76 */ | 77 */ |
| 77 Iterable<LibraryMirror> findLibrary(Symbol libraryName) { | 78 LibraryMirror findLibrary(Symbol libraryName) { |
| 78 return libraries.values.where( | 79 return libraries.values.singleWhere( |
| 79 (library) => library.simpleName == libraryName); | 80 (library) => library.simpleName == libraryName); |
| 80 } | 81 } |
| 81 | 82 |
| 82 /** | 83 /** |
| 83 * A mirror on the isolate associated with this [MirrorSystem]. | 84 * A mirror on the isolate associated with this [MirrorSystem]. |
| 84 * This may be null if this mirror system is not running. | 85 * This may be null if this mirror system is not running. |
| 85 */ | 86 */ |
| 86 IsolateMirror get isolate; | 87 IsolateMirror get isolate; |
| 87 | 88 |
| 88 /** | 89 /** |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 /** | 123 /** |
| 123 * Returns a [MirrorSystem] for the current isolate. | 124 * Returns a [MirrorSystem] for the current isolate. |
| 124 */ | 125 */ |
| 125 external MirrorSystem currentMirrorSystem(); | 126 external MirrorSystem currentMirrorSystem(); |
| 126 | 127 |
| 127 /** | 128 /** |
| 128 * Reflects an instance. | 129 * Reflects an instance. |
| 129 * Returns an [InstanceMirror] reflecting [reflectee]. | 130 * Returns an [InstanceMirror] reflecting [reflectee]. |
| 130 * If [reflectee] is a function or an instance of a class | 131 * If [reflectee] is a function or an instance of a class |
| 131 * that has a [:call:] method, the returned instance mirror | 132 * that has a [:call:] method, the returned instance mirror |
| 132 * will be a [ClosureMirror]. | 133 * will be a [ClosureMirror]. |
| 133 * | 134 * |
| 134 * Note that since one cannot obtain an object from | 135 * Note that since one cannot obtain an object from |
| 135 * another isolate, this function can only be used to | 136 * another isolate, this function can only be used to |
| 136 * obtain mirrors on objects of the current isolate. | 137 * obtain mirrors on objects of the current isolate. |
| 137 */ | 138 */ |
| 138 external InstanceMirror reflect(Object reflectee); | 139 external InstanceMirror reflect(Object reflectee); |
| 139 | 140 |
| 140 /** | 141 /** |
| 141 * Reflects a class declaration. | 142 * Reflects a class declaration. |
| 142 * Let *C* be the original class declaration of the class | 143 * Let *C* be the original class declaration of the class |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 275 /** | 276 /** |
| 276 * Is this declaration top-level? | 277 * Is this declaration top-level? |
| 277 * | 278 * |
| 278 * This is defined to be equivalent to: | 279 * This is defined to be equivalent to: |
| 279 * [:mirror.owner != null && mirror.owner is LibraryMirror:] | 280 * [:mirror.owner != null && mirror.owner is LibraryMirror:] |
| 280 */ | 281 */ |
| 281 bool get isTopLevel; | 282 bool get isTopLevel; |
| 282 | 283 |
| 283 /** | 284 /** |
| 284 * The source location of this Dart language entity. | 285 * The source location of this Dart language entity. |
| 286 * | |
| 287 * This operation is optional and may return [:null:]. | |
| 285 */ | 288 */ |
| 286 SourceLocation get location; | 289 SourceLocation get location; |
| 287 | 290 |
| 288 /** | 291 /** |
| 289 * A list of the metadata associated with this declaration. | 292 * A list of the metadata associated with this declaration. |
| 290 * | 293 * |
| 291 * Let *D* be the declaration this mirror reflects. | 294 * Let *D* be the declaration this mirror reflects. |
| 292 * If *D* is decorated with annotations *A1, ..., An* | 295 * If *D* is decorated with annotations *A1, ..., An* |
| 293 * where *n > 0*, then for each annotation *Ai* associated | 296 * where *n > 0*, then for each annotation *Ai* associated |
| 294 * with *D, 1 <= i <= n*, let *ci* be the constant object | 297 * with *D, 1 <= i <= n*, let *ci* be the constant object |
| 295 * specified by *Ai*. Then this method returns a list whose | 298 * specified by *Ai*. Then this method returns a list whose |
| 296 * members are instance mirrors on *c1, ..., cn*. | 299 * members are instance mirrors on *c1, ..., cn*. |
| 297 * If no annotations are associated with *D*, then | 300 * If no annotations are associated with *D*, then |
| 298 * an empty list is returned. | 301 * an empty list is returned. |
| 299 * | 302 * |
| 300 * If evaluating any of *c1, ..., cn* would cause a | 303 * If evaluating any of *c1, ..., cn* would cause a |
| 301 * compilation error | 304 * compilation error |
| 302 * the effect is the same as if a non-reflective compilation error | 305 * the effect is the same as if a non-reflective compilation error |
| 303 * had been encountered. | 306 * had been encountered. |
| 304 */ | 307 */ |
| 305 List<InstanceMirror> get metadata; | 308 List<InstanceMirror> get metadata; |
| 306 } | 309 } |
| 307 | 310 |
| 308 /** | 311 /** |
| 309 * An [ObjectMirror] is a common superinterface of [InstanceMirror], | 312 * An [ObjectMirror] is a common superinterface of [InstanceMirror], |
| 310 * [ClassMirror], and [LibraryMirror] that represents their shared | 313 * [ClassMirror], and [LibraryMirror] that represents their shared |
| 311 * functionality. | 314 * functionality. |
| 312 * | 315 * |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 329 * [namedArguments.keys] | 332 * [namedArguments.keys] |
| 330 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 333 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
| 331 * Then this method will perform the method invocation | 334 * Then this method will perform the method invocation |
| 332 * *o.f(a1, ..., an, k1: v1, ..., km: vm)* | 335 * *o.f(a1, ..., an, k1: v1, ..., km: vm)* |
| 333 * in a scope that has access to the private members | 336 * in a scope that has access to the private members |
| 334 * of *o* (if *o* is a class or library) or the private members of the | 337 * of *o* (if *o* is a class or library) or the private members of the |
| 335 * class of *o* (otherwise). | 338 * class of *o* (otherwise). |
| 336 * If the invocation returns a result *r*, this method returns | 339 * If the invocation returns a result *r*, this method returns |
| 337 * the result of calling [reflect](*r*). | 340 * the result of calling [reflect](*r*). |
| 338 * If the invocation causes a compilation error | 341 * If the invocation causes a compilation error |
| 339 * the effect is the same as if a non-reflective compilation error | 342 * the effect is the same as if a non-reflective compilation error |
| 340 * had been encountered. | 343 * had been encountered. |
| 341 * If the invocation throws an exception *e* (that it does not catch) | 344 * If the invocation throws an exception *e* (that it does not catch) |
| 342 * this method throws *e*. | 345 * this method throws *e*. |
| 343 */ | 346 */ |
| 344 /* | 347 /* |
| 345 * TODO(turnidge): Handle ambiguous names. | 348 * TODO(turnidge): Handle ambiguous names. |
| 346 * TODO(turnidge): Handle optional & named arguments. | 349 * TODO(turnidge): Handle optional & named arguments. |
| 347 */ | 350 */ |
| 348 InstanceMirror invoke(Symbol memberName, | 351 InstanceMirror invoke(Symbol memberName, |
| 349 List positionalArguments, | 352 List positionalArguments, |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 370 * method in the corresponding library, the result of the invocation is an | 373 * method in the corresponding library, the result of the invocation is an |
| 371 * instance mirror on a closure corresponding to that method. | 374 * instance mirror on a closure corresponding to that method. |
| 372 * | 375 * |
| 373 * If this mirror is a [ClassMirror], and [fieldName] denotes a static method | 376 * If this mirror is a [ClassMirror], and [fieldName] denotes a static method |
| 374 * in the corresponding class, the result of the invocation is an instance | 377 * in the corresponding class, the result of the invocation is an instance |
| 375 * mirror on a closure corresponding to that method. | 378 * mirror on a closure corresponding to that method. |
| 376 * | 379 * |
| 377 * If the invocation returns a result *r*, this method returns | 380 * If the invocation returns a result *r*, this method returns |
| 378 * the result of calling [reflect](*r*). | 381 * the result of calling [reflect](*r*). |
| 379 * If the invocation causes a compilation error | 382 * If the invocation causes a compilation error |
| 380 * the effect is the same as if a non-reflective compilation error | 383 * the effect is the same as if a non-reflective compilation error |
| 381 * had been encountered. | 384 * had been encountered. |
| 382 * If the invocation throws an exception *e* (that it does not catch) | 385 * If the invocation throws an exception *e* (that it does not catch) |
| 383 * this method throws *e*. | 386 * this method throws *e*. |
| 384 */ | 387 */ |
| 385 /* TODO(turnidge): Handle ambiguous names.*/ | 388 // TODO(ahe): Remove stuff about scope and private members. [fieldName] is a |
| 389 // capability giving access to private members. | |
| 386 InstanceMirror getField(Symbol fieldName); | 390 InstanceMirror getField(Symbol fieldName); |
| 387 | 391 |
| 388 /** | 392 /** |
| 389 * Invokes a setter and returns a mirror on the result. The setter | 393 * Invokes a setter and returns a mirror on the result. The setter |
| 390 * may be either the implicit setter for a non-final field or a | 394 * may be either the implicit setter for a non-final field or a |
| 391 * user-defined setter method. | 395 * user-defined setter method. |
| 392 * | 396 * |
| 393 * Let *o* be the object reflected by this mirror, let | 397 * Let *o* be the object reflected by this mirror, let |
| 394 * *f* be the simple name of the getter denoted by [fieldName], | 398 * *f* be the simple name of the getter denoted by [fieldName], |
| 395 * and let *a* be the object bound to [value]. | 399 * and let *a* be the object bound to [value]. |
| 396 * Then this method will perform the setter invocation | 400 * Then this method will perform the setter invocation |
| 397 * *o.f = a* | 401 * *o.f = a* |
| 398 * in a scope that has access to the private members | 402 * in a scope that has access to the private members |
| 399 * of *o* (if *o* is a class or library) or the private members of the | 403 * of *o* (if *o* is a class or library) or the private members of the |
| 400 * class of *o* (otherwise). | 404 * class of *o* (otherwise). |
| 401 * If the invocation returns a result *r*, this method returns | 405 * If the invocation returns a result *r*, this method returns |
| 402 * the result of calling [reflect]([value]). | 406 * the result of calling [reflect]([value]). |
| 403 * If the invocation causes a compilation error | 407 * If the invocation causes a compilation error |
| 404 * the effect is the same as if a non-reflective compilation error | 408 * the effect is the same as if a non-reflective compilation error |
| 405 * had been encountered. | 409 * had been encountered. |
| 406 * If the invocation throws an exception *e* (that it does not catch) | 410 * If the invocation throws an exception *e* (that it does not catch) |
| 407 * this method throws *e*. | 411 * this method throws *e*. |
| 408 */ | 412 */ |
| 409 /* TODO(turnidge): Handle ambiguous names.*/ | 413 /* TODO(turnidge): Handle ambiguous names.*/ |
| 410 InstanceMirror setField(Symbol fieldName, Object value); | 414 InstanceMirror setField(Symbol fieldName, Object value); |
| 411 } | 415 } |
| 412 | 416 |
| 413 /** | 417 /** |
| 414 * An [InstanceMirror] reflects an instance of a Dart language object. | 418 * An [InstanceMirror] reflects an instance of a Dart language object. |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 475 | 479 |
| 476 /** | 480 /** |
| 477 * A [ClosureMirror] reflects a closure. | 481 * A [ClosureMirror] reflects a closure. |
| 478 * | 482 * |
| 479 * A [ClosureMirror] provides access to its captured variables and | 483 * A [ClosureMirror] provides access to its captured variables and |
| 480 * provides the ability to execute its reflectee. | 484 * provides the ability to execute its reflectee. |
| 481 */ | 485 */ |
| 482 abstract class ClosureMirror implements InstanceMirror { | 486 abstract class ClosureMirror implements InstanceMirror { |
| 483 /** | 487 /** |
| 484 * A mirror on the function associated with this closure. | 488 * A mirror on the function associated with this closure. |
| 489 * | |
| 490 * The function associated with an implicit closure of a function is that | |
| 491 * function. | |
| 492 * | |
| 493 * The function associated with an instance of a class that has a [:call:] | |
| 494 * method is that [:call:] method. | |
| 485 */ | 495 */ |
| 486 MethodMirror get function; | 496 MethodMirror get function; |
| 487 | 497 |
| 488 /** | 498 /** |
| 489 * Executes the closure and returns a mirror on the result. | 499 * Executes the closure and returns a mirror on the result. |
| 490 * Let *f* be the closure reflected by this mirror, | 500 * Let *f* be the closure reflected by this mirror, |
| 491 * let *a1, ..., an* be the elements of [positionalArguments] | 501 * let *a1, ..., an* be the elements of [positionalArguments] |
| 492 * let *k1, ..., km* be the identifiers denoted by the elements of | 502 * let *k1, ..., km* be the identifiers denoted by the elements of |
| 493 * [namedArguments.keys] | 503 * [namedArguments.keys] |
| 494 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 504 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 529 * library. | 539 * library. |
| 530 */ | 540 */ |
| 531 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { | 541 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { |
| 532 /** | 542 /** |
| 533 * The absolute uri of the library. | 543 * The absolute uri of the library. |
| 534 */ | 544 */ |
| 535 Uri get uri; | 545 Uri get uri; |
| 536 | 546 |
| 537 /** | 547 /** |
| 538 * Returns an immutable map of the declarations actually given in the library. | 548 * Returns an immutable map of the declarations actually given in the library. |
| 539 * | 549 * |
| 540 * This map includes all regular methods, getters, setters, fields, classes | 550 * This map includes all regular methods, getters, setters, fields, classes |
| 541 * and typedefs actually declared in the library. The map is keyed by the | 551 * and typedefs actually declared in the library. The map is keyed by the |
| 542 * simple names of the declarations. | 552 * simple names of the declarations. |
| 543 */ | 553 */ |
| 544 Map<Symbol, DeclarationMirror> get declarations; | 554 Map<Symbol, DeclarationMirror> get declarations; |
| 545 | 555 |
| 546 /** | 556 /** |
| 547 * An immutable map from from names to mirrors for all members in | 557 * An immutable map from from names to mirrors for all members in |
| 548 * this library. | 558 * this library. |
| 549 * | 559 * |
| 550 * The members of a library are its top-level classes, | 560 * The members of a library are its top-level classes, |
| 551 * functions, variables, getters, and setters. | 561 * functions, variables, getters, and setters. |
| 552 */ | 562 */ |
| 553 Map<Symbol, Mirror> get members; | 563 Map<Symbol, Mirror> get members; |
| 554 | 564 |
| 555 /** | 565 /** |
| 556 * An immutable map from names to mirrors for all class | |
| 557 * declarations in this library. | |
| 558 */ | |
| 559 Map<Symbol, ClassMirror> get classes; | |
| 560 | |
| 561 /** | |
| 562 * An immutable map from names to mirrors for all type | |
| 563 * declarations in this library. | |
| 564 */ | |
| 565 Map<Symbol, TypeMirror> get types; | |
| 566 | |
| 567 /** | |
| 568 * An immutable map from names to mirrors for all function, getter, | |
| 569 * and setter declarations in this library. | |
| 570 */ | |
| 571 Map<Symbol, MethodMirror> get functions; | |
| 572 | |
| 573 /** | |
| 574 * An immutable map from names to mirrors for all getter | |
| 575 * declarations in this library. | |
| 576 */ | |
| 577 Map<Symbol, MethodMirror> get getters; | |
| 578 | |
| 579 /** | |
| 580 * An immutable map from names to mirrors for all setter | |
| 581 * declarations in this library. | |
| 582 */ | |
| 583 Map<Symbol, MethodMirror> get setters; | |
| 584 | |
| 585 /** | |
| 586 * An immutable map from names to mirrors for all variable | |
| 587 * declarations in this library. | |
| 588 */ | |
| 589 Map<Symbol, VariableMirror> get variables; | |
| 590 | |
| 591 /** | |
| 592 * Returns [:true:] if this mirror is equal to [other]. | 566 * Returns [:true:] if this mirror is equal to [other]. |
| 593 * Otherwise returns [:false:]. | 567 * Otherwise returns [:false:]. |
| 594 * | 568 * |
| 595 * The equality holds if and only if | 569 * The equality holds if and only if |
| 596 * (1) [other] is a mirror of the same kind | 570 * (1) [other] is a mirror of the same kind |
| 597 * and | 571 * and |
| 598 * (2) The library being reflected by this mirror | 572 * (2) The library being reflected by this mirror |
| 599 * and the library being reflected by [other] | 573 * and the library being reflected by [other] |
| 600 * are | 574 * are |
| 601 * the same library in the same isolate. | 575 * the same library in the same isolate. |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 679 * | 653 * |
| 680 * If this type is [:Object:], the superclass will be null. | 654 * If this type is [:Object:], the superclass will be null. |
| 681 */ | 655 */ |
| 682 ClassMirror get superclass; | 656 ClassMirror get superclass; |
| 683 | 657 |
| 684 /** | 658 /** |
| 685 * A list of mirrors on the superinterfaces of the reflectee. | 659 * A list of mirrors on the superinterfaces of the reflectee. |
| 686 */ | 660 */ |
| 687 List<ClassMirror> get superinterfaces; | 661 List<ClassMirror> get superinterfaces; |
| 688 | 662 |
| 689 /** | 663 /** |
| 690 * Returns an immutable map of the declarations actually given in the class | 664 * Returns an immutable map of the declarations actually given in the class |
| 691 * declaration. | 665 * declaration. |
| 692 * | 666 * |
| 693 * This map includes all regular methods, getters, setters, fields, | 667 * This map includes all regular methods, getters, setters, fields, |
| 694 * constructors and type variables actually declared in the class. Both | 668 * constructors and type variables actually declared in the class. Both |
| 695 * static and instance members are included, but no inherited members are | 669 * static and instance members are included, but no inherited members are |
| 696 * included. The map is keyed by the simple names of the declarations. | 670 * included. The map is keyed by the simple names of the declarations. |
| 697 */ | 671 */ |
| 698 Map<Symbol, DeclarationMirror> get declarations; | 672 Map<Symbol, DeclarationMirror> get declarations; |
| 699 | 673 |
| 700 /** | 674 /** |
| 701 * The mixin of this class. | 675 * The mixin of this class. |
| 702 * If this class is the result of a mixin application of the | 676 * If this class is the result of a mixin application of the |
| 703 * form S with M, returns a class mirror on M. | 677 * form S with M, returns a class mirror on M. |
| 704 * Otherwise returns a class mirror on [reflectee]. | 678 * Otherwise returns a class mirror on [reflectee]. |
| 705 */ | 679 */ |
| 706 ClassMirror get mixin; | 680 ClassMirror get mixin; |
| 707 | 681 |
| 708 /** | 682 /** |
| 709 * An immutable map from names to mirrors for all members of | 683 * An immutable map from names to mirrors for all members of |
| 710 * this type. | 684 * this type. |
| 711 * | 685 * |
| 712 * The members of a type are its methods, fields, getters, and | 686 * The members of a type are its methods, fields, getters, and |
| 713 * setters. Note that constructors and type variables are not | 687 * setters. Note that constructors and type variables are not |
| 714 * considered to be members of a type. | 688 * considered to be members of a type. |
| 715 * | 689 * |
| 716 * This does not include inherited members. | 690 * This does not include inherited members. |
| 717 */ | 691 */ |
| 692 // TODO(ahe): Should include inherited members? | |
|
Johnni Winther
2013/10/30 08:02:26
Probably, since we now have [declarations] and [me
ahe
2013/10/30 13:22:30
This is a bad merge. It was replaced by declaratio
| |
| 718 Map<Symbol, Mirror> get members; | 693 Map<Symbol, Mirror> get members; |
| 719 | 694 |
| 720 /** | 695 // TODO(ahe): What about: |
| 721 * An immutable map from names to mirrors for all method, | 696 // /// Finds the instance member named [name] declared or inherited in the |
| 722 * declarations for this type. This does not include getters and | 697 // /// reflected class. |
| 723 * setters. | 698 // DeclarationMirror instanceLookup(Symbol name); |
|
Johnni Winther
2013/10/30 08:02:26
This is not needed if [members] include inherited
| |
| 724 */ | |
| 725 Map<Symbol, MethodMirror> get methods; | |
| 726 | |
| 727 /** | |
| 728 * An immutable map from names to mirrors for all getter | |
| 729 * declarations for this type. | |
| 730 */ | |
| 731 Map<Symbol, MethodMirror> get getters; | |
| 732 | |
| 733 /** | |
| 734 * An immutable map from names to mirrors for all setter | |
| 735 * declarations for this type. | |
| 736 */ | |
| 737 Map<Symbol, MethodMirror> get setters; | |
| 738 | |
| 739 /** | |
| 740 * An immutable map from names to mirrors for all variable | |
| 741 * declarations for this type. | |
| 742 */ | |
| 743 Map<Symbol, VariableMirror> get variables; | |
| 744 | |
| 745 /** | |
| 746 * An immutable map from names to mirrors for all constructor | |
| 747 * declarations for this type. | |
| 748 */ | |
| 749 Map<Symbol, MethodMirror> get constructors; | |
| 750 | 699 |
| 751 /** | 700 /** |
| 752 * Invokes the named constructor and returns a mirror on the result. | 701 * Invokes the named constructor and returns a mirror on the result. |
| 753 * | 702 * |
| 754 * Let *c* be the class reflected by this mirror | 703 * Let *c* be the class reflected by this mirror |
| 755 * let *a1, ..., an* be the elements of [positionalArguments] | 704 * let *a1, ..., an* be the elements of [positionalArguments] |
| 756 * let *k1, ..., km* be the identifiers denoted by the elements of | 705 * let *k1, ..., km* be the identifiers denoted by the elements of |
| 757 * [namedArguments.keys] | 706 * [namedArguments.keys] |
| 758 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 707 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
| 759 * If [constructorName] was created from the empty string | 708 * If [constructorName] was created from the empty string |
| 760 * Then this method will execute the instance creation expression | 709 * Then this method will execute the instance creation expression |
| 761 * *new c(a1, ..., an, k1: v1, ..., km: vm)* | 710 * *new c(a1, ..., an, k1: v1, ..., km: vm)* |
| 762 * in a scope that has access to the private members | 711 * in a scope that has access to the private members |
| 763 * of *c*. Otherwise, let | 712 * of *c*. Otherwise, let |
| 764 * *f* be the simple name of the constructor denoted by [constructorName] | 713 * *f* be the simple name of the constructor denoted by [constructorName] |
| 765 * Then this method will execute the instance creation expression | 714 * Then this method will execute the instance creation expression |
| 766 * *new c.f(a1, ..., an, k1: v1, ..., km: vm)* | 715 * *new c.f(a1, ..., an, k1: v1, ..., km: vm)* |
| 767 * in a scope that has access to the private members | 716 * in a scope that has access to the private members |
| 768 * of *c*. | 717 * of *c*. |
| 769 * In either case: | 718 * In either case: |
| 770 * If the expression evaluates to a result *r*, this method returns | 719 * If the expression evaluates to a result *r*, this method returns |
| 771 * the result of calling [reflect](*r*). | 720 * the result of calling [reflect](*r*). |
| 772 * If evaluating the expression causes a compilation error | 721 * If evaluating the expression causes a compilation error |
| 773 * the effect is the same as if a non-reflective compilation error | 722 * the effect is the same as if a non-reflective compilation error |
| 774 * had been encountered. | 723 * had been encountered. |
| 775 * If evaluating the expression throws an exception *e* | 724 * If evaluating the expression throws an exception *e* |
| 776 * (that it does not catch) | 725 * (that it does not catch) |
| 777 * this method throws *e*. | 726 * this method throws *e*. |
| 778 */ | 727 */ |
| 779 InstanceMirror newInstance(Symbol constructorName, | 728 InstanceMirror newInstance(Symbol constructorName, |
| 780 List positionalArguments, | 729 List positionalArguments, |
| 781 [Map<Symbol,dynamic> namedArguments]); | 730 [Map<Symbol,dynamic> namedArguments]); |
| 782 | 731 |
| 783 /** | 732 /** |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1035 InstanceMirror get defaultValue; | 984 InstanceMirror get defaultValue; |
| 1036 } | 985 } |
| 1037 | 986 |
| 1038 /** | 987 /** |
| 1039 * A [SourceLocation] describes the span of an entity in Dart source code. | 988 * A [SourceLocation] describes the span of an entity in Dart source code. |
| 1040 */ | 989 */ |
| 1041 abstract class SourceLocation { | 990 abstract class SourceLocation { |
| 1042 } | 991 } |
| 1043 | 992 |
| 1044 /** | 993 /** |
| 1045 * When an error occurs during the mirrored execution of code, a | |
| 1046 * [MirroredError] is thrown. | |
| 1047 * | |
| 1048 * In general, there are three main classes of failure that can happen | |
| 1049 * during mirrored execution of code in some isolate: | |
| 1050 * | |
| 1051 * - An exception is thrown but not caught. This is caught by the | |
| 1052 * mirrors framework and a [MirroredUncaughtExceptionError] is | |
| 1053 * created and thrown. | |
| 1054 * | |
| 1055 * - A compile-time error occurs, such as a syntax error. This is | |
| 1056 * suppressed by the mirrors framework and a | |
| 1057 * [MirroredCompilationError] is created and thrown. | |
| 1058 * | |
| 1059 * - A truly fatal error occurs, causing the isolate to be exited. If | |
| 1060 * the reflector and reflectee share the same isolate, then they | |
| 1061 * will both suffer. If the reflector and reflectee are in distinct | |
| 1062 * isolates, then we hope to provide some information about the | |
| 1063 * isolate death, but this has yet to be implemented. | |
| 1064 * | |
| 1065 * TODO(turnidge): Specify the behavior for remote fatal errors. | |
| 1066 */ | |
| 1067 abstract class MirroredError implements Exception { | |
| 1068 } | |
| 1069 | |
| 1070 /** | |
| 1071 * When an uncaught exception occurs during the mirrored execution | |
| 1072 * of code, a [MirroredUncaughtExceptionError] is thrown. | |
| 1073 * | |
| 1074 * This exception contains a mirror on the original exception object. | |
| 1075 * It also contains an object which can be used to recover the | |
| 1076 * stacktrace. | |
| 1077 */ | |
| 1078 class MirroredUncaughtExceptionError extends MirroredError { | |
| 1079 MirroredUncaughtExceptionError(this.exception_mirror, | |
| 1080 this.exception_string, | |
| 1081 this.stacktrace) {} | |
| 1082 | |
| 1083 /** A mirror on the exception object. */ | |
| 1084 final InstanceMirror exception_mirror; | |
| 1085 | |
| 1086 /** The result of toString() for the exception object. */ | |
| 1087 final String exception_string; | |
| 1088 | |
| 1089 /** A stacktrace object for the uncaught exception. */ | |
| 1090 final Object stacktrace; | |
| 1091 | |
| 1092 String toString() { | |
| 1093 return | |
| 1094 "Uncaught exception during mirrored execution: <${exception_string}>"; | |
| 1095 } | |
| 1096 } | |
| 1097 | |
| 1098 /** | |
| 1099 * When a compile-time error occurs during the mirrored execution | |
| 1100 * of code, a [MirroredCompilationError] is thrown. | |
| 1101 * | |
| 1102 * This exception includes the compile-time error message that would | |
| 1103 * have been displayed to the user, if the function had not been | |
| 1104 * invoked via mirror. | |
| 1105 */ | |
| 1106 class MirroredCompilationError extends MirroredError { | |
| 1107 MirroredCompilationError(this.message) {} | |
| 1108 | |
| 1109 final String message; | |
| 1110 | |
| 1111 String toString() { | |
| 1112 return "Compile-time error during mirrored execution: <$message>"; | |
| 1113 } | |
| 1114 } | |
| 1115 | |
| 1116 /** | |
| 1117 * A [MirrorException] is used to indicate errors within the mirrors | |
| 1118 * framework. | |
| 1119 */ | |
| 1120 class MirrorException implements Exception { | |
| 1121 const MirrorException(String this._message); | |
| 1122 String toString() => "MirrorException: '$_message'"; | |
| 1123 final String _message; | |
| 1124 } | |
| 1125 | |
| 1126 /** | |
| 1127 * Class used for encoding comments as metadata annotations. | 994 * Class used for encoding comments as metadata annotations. |
| 1128 */ | 995 */ |
| 1129 class Comment { | 996 class Comment { |
| 1130 /** | 997 /** |
| 1131 * The comment text as written in the source text. | 998 * The comment text as written in the source text. |
| 1132 */ | 999 */ |
| 1133 final String text; | 1000 final String text; |
| 1134 | 1001 |
| 1135 /** | 1002 /** |
| 1136 * The comment text without the start, end, and padding text. | 1003 * The comment text without the start, end, and padding text. |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1242 * | 1109 * |
| 1243 * When used as metadata on an import of "dart:mirrors", this metadata does | 1110 * When used as metadata on an import of "dart:mirrors", this metadata does |
| 1244 * not apply to the library in which the annotation is used, but instead | 1111 * not apply to the library in which the annotation is used, but instead |
| 1245 * applies to the other libraries (all libraries if "*" is used). | 1112 * applies to the other libraries (all libraries if "*" is used). |
| 1246 */ | 1113 */ |
| 1247 final override; | 1114 final override; |
| 1248 | 1115 |
| 1249 const MirrorsUsed( | 1116 const MirrorsUsed( |
| 1250 {this.symbols, this.targets, this.metaTargets, this.override}); | 1117 {this.symbols, this.targets, this.metaTargets, this.override}); |
| 1251 } | 1118 } |
| OLD | NEW |