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 // |
11 // ...the getter is named 'myField' and the setter is named | 11 // ...the getter is named 'myField' and the setter is named |
12 // 'myField='. This allows us to assign unique names to getters and | 12 // 'myField='. This allows us to assign unique names to getters and |
13 // setters for the purposes of member lookup. | 13 // setters for the purposes of member lookup. |
14 | 14 |
15 /** | 15 /** |
16 * Basic reflection in Dart, | 16 * Basic reflection in Dart, |
17 * with support for introspection and dynamic evaluation. | 17 * with support for introspection and dynamic invocation. |
18 * | 18 * |
19 * *Introspection* is that subset of reflection by which a running | 19 * *Introspection* is that subset of reflection by which a running |
20 * program can examine its own structure. For example, a function | 20 * program can examine its own structure. For example, a function |
21 * that prints out the names of all the members of an arbitrary object. | 21 * that prints out the names of all the members of an arbitrary object. |
22 * | 22 * |
23 * *Dynamic evaluation* refers the ability to evaluate code that | 23 * *Dynamic invocation* refers the ability to evaluate code that |
24 * has not been literally specified at compile time, such as calling a method | 24 * has not been literally specified at compile time, such as calling a method |
25 * whose name is provided as an argument (because it is looked up | 25 * whose name is provided as an argument (because it is looked up |
26 * in a database, or provided interactively by the user). | 26 * in a database, or provided interactively by the user). |
27 * | 27 * |
28 * ## How to interpret this library's documentation | 28 * ## How to interpret this library's documentation |
29 * | 29 * |
30 * As a rule, the names of Dart declarations are represented using | 30 * As a rule, the names of Dart declarations are represented using |
31 * instances of class [Symbol]. Whenever the doc speaks of an object *s* | 31 * instances of class [Symbol]. Whenever the doc speaks of an object *s* |
32 * of class [Symbol] denoting a name, it means the string that | 32 * of class [Symbol] denoting a name, it means the string that |
33 * was used to construct *s*. | 33 * was used to construct *s*. |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 * or | 497 * or |
498 * (b) the remote objects reflected by this mirror and | 498 * (b) the remote objects reflected by this mirror and |
499 * by [other] are identical. | 499 * by [other] are identical. |
500 */ | 500 */ |
501 bool operator == (other); | 501 bool operator == (other); |
502 | 502 |
503 /** | 503 /** |
504 * Perform [invocation] on [reflectee]. | 504 * Perform [invocation] on [reflectee]. |
505 * Equivalent to | 505 * Equivalent to |
506 * | 506 * |
507 * this.invoke(invocation.memberName, | 507 * if (invocation.isGetter) { |
508 * invocation.positionalArguments, | 508 * return this.getField(invocation.memberName).reflectee; |
509 * invocation.namedArguments); | 509 * } else if (invocation.isSetter) { |
510 * return this.setField(invocation.memberName, | |
511 * invocation.positionArguments[0]).reflectee; | |
512 * } else { | |
513 * return this.invoke(invocation.memberName, | |
514 * invocation.positionalArguments, | |
515 * invocation.namedArguments).reflectee; | |
516 * } | |
510 */ | 517 */ |
511 delegate(Invocation invocation); | 518 delegate(Invocation invocation); |
512 } | 519 } |
513 | 520 |
514 /** | 521 /** |
515 * A [ClosureMirror] reflects a closure. | 522 * A [ClosureMirror] reflects a closure. |
516 * | 523 * |
517 * A [ClosureMirror] provides access to its captured variables and | 524 * A [ClosureMirror] provides the ability to execute its reflectee and |
518 * provides the ability to execute its reflectee. | 525 * introspect its function. |
gbracha
2015/06/09 00:27:41
Sigh. What is the point of a closure mirror? We ca
rmacnak
2015/06/09 00:40:10
closureMirror.function isn't the same as closureMi
| |
519 */ | 526 */ |
520 abstract class ClosureMirror implements InstanceMirror { | 527 abstract class ClosureMirror implements InstanceMirror { |
521 /** | 528 /** |
522 * A mirror on the function associated with this closure. | 529 * A mirror on the function associated with this closure. |
523 * | 530 * |
524 * The function associated with an implicit closure of a function is that | 531 * The function associated with an implicit closure of a function is that |
525 * function. | 532 * function. |
526 * | 533 * |
527 * The function associated with an instance of a class that has a [:call:] | 534 * The function associated with an instance of a class that has a [:call:] |
528 * method is that [:call:] method. | 535 * method is that [:call:] method. |
(...skipping 894 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1423 final override; | 1430 final override; |
1424 | 1431 |
1425 /** | 1432 /** |
1426 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], | 1433 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], |
1427 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation | 1434 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation |
1428 * of the parameters. | 1435 * of the parameters. |
1429 */ | 1436 */ |
1430 const MirrorsUsed( | 1437 const MirrorsUsed( |
1431 {this.symbols, this.targets, this.metaTargets, this.override}); | 1438 {this.symbols, this.targets, this.metaTargets, this.override}); |
1432 } | 1439 } |
OLD | NEW |