OLD | NEW |
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
210 | 210 |
211 /** | 211 /** |
212 * Whether [other] is an [IsolateMirror] on the same isolate as this mirror. | 212 * Whether [other] is an [IsolateMirror] on the same isolate as this mirror. |
213 * | 213 * |
214 * The equality holds if and only if | 214 * The equality holds if and only if |
215 * | 215 * |
216 * 1. [other] is a mirror of the same kind, and | 216 * 1. [other] is a mirror of the same kind, and |
217 * 2. the isolate being reflected by this mirror is the same isolate being | 217 * 2. the isolate being reflected by this mirror is the same isolate being |
218 * reflected by [other]. | 218 * reflected by [other]. |
219 */ | 219 */ |
220 bool operator == (other); | 220 bool operator ==(other); |
221 } | 221 } |
222 | 222 |
223 /** | 223 /** |
224 * A [DeclarationMirror] reflects some entity declared in a Dart program. | 224 * A [DeclarationMirror] reflects some entity declared in a Dart program. |
225 */ | 225 */ |
226 abstract class DeclarationMirror implements Mirror { | 226 abstract class DeclarationMirror implements Mirror { |
227 /** | 227 /** |
228 * The simple name for this Dart language entity. | 228 * The simple name for this Dart language entity. |
229 * | 229 * |
230 * The simple name is in most cases the identifier name of the entity, | 230 * The simple name is in most cases the identifier name of the entity, |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 * functionality. | 352 * functionality. |
353 * | 353 * |
354 * For the purposes of the mirrors library, these types are all | 354 * For the purposes of the mirrors library, these types are all |
355 * object-like, in that they support method invocation and field | 355 * object-like, in that they support method invocation and field |
356 * access. Real Dart objects are represented by the [InstanceMirror] | 356 * access. Real Dart objects are represented by the [InstanceMirror] |
357 * type. | 357 * type. |
358 * | 358 * |
359 * See [InstanceMirror], [ClassMirror], and [LibraryMirror]. | 359 * See [InstanceMirror], [ClassMirror], and [LibraryMirror]. |
360 */ | 360 */ |
361 abstract class ObjectMirror implements Mirror { | 361 abstract class ObjectMirror implements Mirror { |
362 | |
363 /** | 362 /** |
364 * Invokes the named function and returns a mirror on the result. | 363 * Invokes the named function and returns a mirror on the result. |
365 * | 364 * |
366 * Let *o* be the object reflected by this mirror, let *f* be the simple name | 365 * Let *o* be the object reflected by this mirror, let *f* be the simple name |
367 * of the member denoted by [memberName], let *a1, ..., an* be the elements | 366 * of the member denoted by [memberName], let *a1, ..., an* be the elements |
368 * of [positionalArguments], let *k1, ..., km* be the identifiers denoted by | 367 * of [positionalArguments], let *k1, ..., km* be the identifiers denoted by |
369 * the elements of [namedArguments.keys], and let *v1, ..., vm* be the | 368 * the elements of [namedArguments.keys], and let *v1, ..., vm* be the |
370 * elements of [namedArguments.values]. Then this method will perform the | 369 * elements of [namedArguments.values]. Then this method will perform the |
371 * method invocation *o.f(a1, ..., an, k1: v1, ..., km: vm)* in a scope that | 370 * method invocation *o.f(a1, ..., an, k1: v1, ..., km: vm)* in a scope that |
372 * has access to the private members of *o* (if *o* is a class or library) or | 371 * has access to the private members of *o* (if *o* is a class or library) or |
373 * the private members of the class of *o* (otherwise). | 372 * the private members of the class of *o* (otherwise). |
374 * | 373 * |
375 * If the invocation returns a result *r*, this method returns the result of | 374 * If the invocation returns a result *r*, this method returns the result of |
376 * calling [reflect]\(*r*\). | 375 * calling [reflect]\(*r*\). |
377 * | 376 * |
378 * If the invocation causes a compilation error the effect is the same as if | 377 * If the invocation causes a compilation error the effect is the same as if |
379 * a non-reflective compilation error had been encountered. | 378 * a non-reflective compilation error had been encountered. |
380 * | 379 * |
381 * If the invocation throws an exception *e* (that it does not catch), this | 380 * If the invocation throws an exception *e* (that it does not catch), this |
382 * method throws *e*. | 381 * method throws *e*. |
383 */ | 382 */ |
384 /* | 383 /* |
385 * TODO(turnidge): Handle ambiguous names. | 384 * TODO(turnidge): Handle ambiguous names. |
386 * TODO(turnidge): Handle optional & named arguments. | 385 * TODO(turnidge): Handle optional & named arguments. |
387 */ | 386 */ |
388 InstanceMirror invoke(Symbol memberName, | 387 InstanceMirror invoke(Symbol memberName, List positionalArguments, |
389 List positionalArguments, | 388 [Map<Symbol, dynamic> namedArguments]); |
390 [Map<Symbol,dynamic> namedArguments]); | |
391 | 389 |
392 /** | 390 /** |
393 * Invokes a getter and returns a mirror on the result. | 391 * Invokes a getter and returns a mirror on the result. |
394 * | 392 * |
395 * The getter can be the implicit getter for a field or a user-defined getter | 393 * The getter can be the implicit getter for a field or a user-defined getter |
396 * method. | 394 * method. |
397 * | 395 * |
398 * Let *o* be the object reflected by this mirror, | 396 * Let *o* be the object reflected by this mirror, |
399 * let *f* be the simple name of the getter denoted by [fieldName]. | 397 * let *f* be the simple name of the getter denoted by [fieldName]. |
400 * | 398 * |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 * | 517 * |
520 * 1. [other] is a mirror of the same kind, and | 518 * 1. [other] is a mirror of the same kind, and |
521 * 2. either | 519 * 2. either |
522 * | 520 * |
523 * a. [hasReflectee] is true and so is | 521 * a. [hasReflectee] is true and so is |
524 * [:identical(reflectee, other.reflectee):], or | 522 * [:identical(reflectee, other.reflectee):], or |
525 * | 523 * |
526 * b. the remote objects reflected by this mirror and by [other] are | 524 * b. the remote objects reflected by this mirror and by [other] are |
527 * identical. | 525 * identical. |
528 */ | 526 */ |
529 bool operator == (other); | 527 bool operator ==(other); |
530 } | 528 } |
531 | 529 |
532 /** | 530 /** |
533 * A [ClosureMirror] reflects a closure. | 531 * A [ClosureMirror] reflects a closure. |
534 * | 532 * |
535 * A [ClosureMirror] provides the ability to execute its reflectee and | 533 * A [ClosureMirror] provides the ability to execute its reflectee and |
536 * introspect its function. | 534 * introspect its function. |
537 */ | 535 */ |
538 abstract class ClosureMirror implements InstanceMirror { | 536 abstract class ClosureMirror implements InstanceMirror { |
539 /** | 537 /** |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 * If the invocation returns a result *r*, this method returns the result of | 570 * If the invocation returns a result *r*, this method returns the result of |
573 * calling [reflect]\(*r*\). | 571 * calling [reflect]\(*r*\). |
574 * | 572 * |
575 * If the invocation causes a compilation error, the effect is the same as if | 573 * If the invocation causes a compilation error, the effect is the same as if |
576 * a non-reflective compilation error had been encountered. | 574 * a non-reflective compilation error had been encountered. |
577 * | 575 * |
578 * If the invocation throws an exception *e* (that it does not catch), this | 576 * If the invocation throws an exception *e* (that it does not catch), this |
579 * method throws *e*. | 577 * method throws *e*. |
580 */ | 578 */ |
581 InstanceMirror apply(List positionalArguments, | 579 InstanceMirror apply(List positionalArguments, |
582 [Map<Symbol, dynamic> namedArguments]); | 580 [Map<Symbol, dynamic> namedArguments]); |
583 } | 581 } |
584 | 582 |
585 /** | 583 /** |
586 * A [LibraryMirror] reflects a Dart language library, providing | 584 * A [LibraryMirror] reflects a Dart language library, providing |
587 * access to the variables, functions, and classes of the | 585 * access to the variables, functions, and classes of the |
588 * library. | 586 * library. |
589 */ | 587 */ |
590 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { | 588 abstract class LibraryMirror implements DeclarationMirror, ObjectMirror { |
591 /** | 589 /** |
592 * The absolute uri of the library. | 590 * The absolute uri of the library. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 * A mirror on the original declaration of this type. | 727 * A mirror on the original declaration of this type. |
730 * | 728 * |
731 * For most classes, they are their own original declaration. For | 729 * For most classes, they are their own original declaration. For |
732 * generic classes, however, there is a distinction between the | 730 * generic classes, however, there is a distinction between the |
733 * original class declaration, which has unbound type variables, and | 731 * original class declaration, which has unbound type variables, and |
734 * the instantiations of generic classes, which have bound type | 732 * the instantiations of generic classes, which have bound type |
735 * variables. | 733 * variables. |
736 */ | 734 */ |
737 TypeMirror get originalDeclaration; | 735 TypeMirror get originalDeclaration; |
738 | 736 |
739 | |
740 /** | 737 /** |
741 * Checks the subtype relationship, denoted by `<:` in the language | 738 * Checks the subtype relationship, denoted by `<:` in the language |
742 * specification. | 739 * specification. |
743 * | 740 * |
744 * This is the type relationship used in `is` test checks. | 741 * This is the type relationship used in `is` test checks. |
745 */ | 742 */ |
746 bool isSubtypeOf(TypeMirror other); | 743 bool isSubtypeOf(TypeMirror other); |
747 | 744 |
748 /** | 745 /** |
749 * Checks the assignability relationship, denoted by `<=>` in the language | 746 * Checks the assignability relationship, denoted by `<=>` in the language |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
811 * Returns a map of the static methods, getters and setters of the class. | 808 * Returns a map of the static methods, getters and setters of the class. |
812 * | 809 * |
813 * The intent is to capture those members that constitute the API of a class. | 810 * The intent is to capture those members that constitute the API of a class. |
814 * Hence fields are not included, but the getters and setters implicitly | 811 * Hence fields are not included, but the getters and setters implicitly |
815 * introduced by fields are included. | 812 * introduced by fields are included. |
816 * | 813 * |
817 * The map is keyed by the simple names of the members. | 814 * The map is keyed by the simple names of the members. |
818 */ | 815 */ |
819 Map<Symbol, MethodMirror> get staticMembers; | 816 Map<Symbol, MethodMirror> get staticMembers; |
820 | 817 |
821 | |
822 /** | 818 /** |
823 * The mixin of this class. | 819 * The mixin of this class. |
824 * | 820 * |
825 * If this class is the result of a mixin application of the form S with M, | 821 * If this class is the result of a mixin application of the form S with M, |
826 * returns a class mirror on M. Otherwise returns a class mirror on | 822 * returns a class mirror on M. Otherwise returns a class mirror on |
827 * [reflectee]. | 823 * [reflectee]. |
828 */ | 824 */ |
829 ClassMirror get mixin; | 825 ClassMirror get mixin; |
830 | 826 |
831 // TODO(ahe): What about: | 827 // TODO(ahe): What about: |
(...skipping 22 matching lines...) Expand all Loading... |
854 * | 850 * |
855 * In either case: | 851 * In either case: |
856 * | 852 * |
857 * * If the expression evaluates to a result *r*, this method returns the | 853 * * If the expression evaluates to a result *r*, this method returns the |
858 * result of calling [reflect]\(*r*\). | 854 * result of calling [reflect]\(*r*\). |
859 * * If evaluating the expression causes a compilation error, the effect is | 855 * * If evaluating the expression causes a compilation error, the effect is |
860 * the same as if a non-reflective compilation error had been encountered. | 856 * the same as if a non-reflective compilation error had been encountered. |
861 * * If evaluating the expression throws an exception *e* (that it does not | 857 * * If evaluating the expression throws an exception *e* (that it does not |
862 * catch), this method throws *e*. | 858 * catch), this method throws *e*. |
863 */ | 859 */ |
864 InstanceMirror newInstance(Symbol constructorName, | 860 InstanceMirror newInstance(Symbol constructorName, List positionalArguments, |
865 List positionalArguments, | 861 [Map<Symbol, dynamic> namedArguments]); |
866 [Map<Symbol,dynamic> namedArguments]); | |
867 | 862 |
868 /** | 863 /** |
869 * Whether this mirror is equal to [other]. | 864 * Whether this mirror is equal to [other]. |
870 * | 865 * |
871 * The equality holds if and only if | 866 * The equality holds if and only if |
872 * | 867 * |
873 * 1. [other] is a mirror of the same kind, and | 868 * 1. [other] is a mirror of the same kind, and |
874 * 2. This mirror and [other] reflect the same class. | 869 * 2. This mirror and [other] reflect the same class. |
875 * | 870 * |
876 * Note that if the reflected class is an invocation of a generic class, 2. | 871 * Note that if the reflected class is an invocation of a generic class, 2. |
877 * implies that the reflected class and [other] have equal type arguments. | 872 * implies that the reflected class and [other] have equal type arguments. |
878 */ | 873 */ |
879 bool operator == (other); | 874 bool operator ==(other); |
880 | 875 |
881 /** | 876 /** |
882 * Returns whether the class denoted by the receiver is a subclass of the | 877 * Returns whether the class denoted by the receiver is a subclass of the |
883 * class denoted by the argument. | 878 * class denoted by the argument. |
884 * | 879 * |
885 * Note that the subclass relationship is reflexive. | 880 * Note that the subclass relationship is reflexive. |
886 */ | 881 */ |
887 bool isSubclassOf(ClassMirror other); | 882 bool isSubclassOf(ClassMirror other); |
888 } | 883 } |
889 | 884 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 | 924 |
930 /** | 925 /** |
931 * Whether [other] is a [TypeVariableMirror] on the same type variable as this | 926 * Whether [other] is a [TypeVariableMirror] on the same type variable as this |
932 * mirror. | 927 * mirror. |
933 * | 928 * |
934 * The equality holds if and only if | 929 * The equality holds if and only if |
935 * | 930 * |
936 * 1. [other] is a mirror of the same kind, and | 931 * 1. [other] is a mirror of the same kind, and |
937 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. | 932 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. |
938 */ | 933 */ |
939 bool operator == (other); | 934 bool operator ==(other); |
940 } | 935 } |
941 | 936 |
942 /** | 937 /** |
943 * A [TypedefMirror] represents a typedef in a Dart language program. | 938 * A [TypedefMirror] represents a typedef in a Dart language program. |
944 */ | 939 */ |
945 abstract class TypedefMirror implements TypeMirror { | 940 abstract class TypedefMirror implements TypeMirror { |
946 /** | 941 /** |
947 * The defining type for this typedef. | 942 * The defining type for this typedef. |
948 * | 943 * |
949 * If the type referred to by the reflectee is a function type *F*, the | 944 * If the type referred to by the reflectee is a function type *F*, the |
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1057 bool get isFactoryConstructor; | 1052 bool get isFactoryConstructor; |
1058 | 1053 |
1059 /** | 1054 /** |
1060 * Whether this mirror is equal to [other]. | 1055 * Whether this mirror is equal to [other]. |
1061 * | 1056 * |
1062 * The equality holds if and only if | 1057 * The equality holds if and only if |
1063 * | 1058 * |
1064 * 1. [other] is a mirror of the same kind, and | 1059 * 1. [other] is a mirror of the same kind, and |
1065 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. | 1060 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. |
1066 */ | 1061 */ |
1067 bool operator == (other); | 1062 bool operator ==(other); |
1068 } | 1063 } |
1069 | 1064 |
1070 /** | 1065 /** |
1071 * A [VariableMirror] reflects a Dart language variable declaration. | 1066 * A [VariableMirror] reflects a Dart language variable declaration. |
1072 */ | 1067 */ |
1073 abstract class VariableMirror implements DeclarationMirror { | 1068 abstract class VariableMirror implements DeclarationMirror { |
1074 /** | 1069 /** |
1075 * Returns a mirror on the type of the reflectee. | 1070 * Returns a mirror on the type of the reflectee. |
1076 */ | 1071 */ |
1077 TypeMirror get type; | 1072 TypeMirror get type; |
(...skipping 20 matching lines...) Expand all Loading... |
1098 bool get isConst; | 1093 bool get isConst; |
1099 | 1094 |
1100 /** | 1095 /** |
1101 * Whether this mirror is equal to [other]. | 1096 * Whether this mirror is equal to [other]. |
1102 * | 1097 * |
1103 * The equality holds if and only if | 1098 * The equality holds if and only if |
1104 * | 1099 * |
1105 * 1. [other] is a mirror of the same kind, and | 1100 * 1. [other] is a mirror of the same kind, and |
1106 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. | 1101 * 2. [:simpleName == other.simpleName:] and [:owner == other.owner:]. |
1107 */ | 1102 */ |
1108 bool operator == (other); | 1103 bool operator ==(other); |
1109 } | 1104 } |
1110 | 1105 |
1111 /** | 1106 /** |
1112 * A [ParameterMirror] reflects a Dart formal parameter declaration. | 1107 * A [ParameterMirror] reflects a Dart formal parameter declaration. |
1113 */ | 1108 */ |
1114 abstract class ParameterMirror implements VariableMirror { | 1109 abstract class ParameterMirror implements VariableMirror { |
1115 /** | 1110 /** |
1116 * A mirror on the type of this parameter. | 1111 * A mirror on the type of this parameter. |
1117 */ | 1112 */ |
1118 TypeMirror get type; | 1113 TypeMirror get type; |
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1443 final override; | 1438 final override; |
1444 | 1439 |
1445 /** | 1440 /** |
1446 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], | 1441 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], |
1447 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation | 1442 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation |
1448 * of the parameters. | 1443 * of the parameters. |
1449 */ | 1444 */ |
1450 const MirrorsUsed( | 1445 const MirrorsUsed( |
1451 {this.symbols, this.targets, this.metaTargets, this.override}); | 1446 {this.symbols, this.targets, this.metaTargets, this.override}); |
1452 } | 1447 } |
OLD | NEW |