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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 * let *a1, ..., an* be the elements of [positionalArguments] | 364 * let *a1, ..., an* be the elements of [positionalArguments] |
365 * let *k1, ..., km* be the identifiers denoted by the elements of | 365 * let *k1, ..., km* be the identifiers denoted by the elements of |
366 * [namedArguments.keys] | 366 * [namedArguments.keys] |
367 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 367 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
368 * Then this method will perform the method invocation | 368 * Then this method will perform the method invocation |
369 * *o.f(a1, ..., an, k1: v1, ..., km: vm)* | 369 * *o.f(a1, ..., an, k1: v1, ..., km: vm)* |
370 * in a scope that has access to the private members | 370 * in a scope that has access to the private members |
371 * of *o* (if *o* is a class or library) or the private members of the | 371 * of *o* (if *o* is a class or library) or the private members of the |
372 * class of *o* (otherwise). | 372 * class of *o* (otherwise). |
373 * If the invocation returns a result *r*, this method returns | 373 * If the invocation returns a result *r*, this method returns |
374 * the result of calling [reflect](*r*). | 374 * the result of calling [reflect]\(*r*\). |
375 * If the invocation causes a compilation error | 375 * If the invocation causes a compilation error |
376 * the effect is the same as if a non-reflective compilation error | 376 * the effect is the same as if a non-reflective compilation error |
377 * had been encountered. | 377 * had been encountered. |
378 * If the invocation throws an exception *e* (that it does not catch) | 378 * If the invocation throws an exception *e* (that it does not catch) |
379 * this method throws *e*. | 379 * this method throws *e*. |
380 */ | 380 */ |
381 /* | 381 /* |
382 * TODO(turnidge): Handle ambiguous names. | 382 * TODO(turnidge): Handle ambiguous names. |
383 * TODO(turnidge): Handle optional & named arguments. | 383 * TODO(turnidge): Handle optional & named arguments. |
384 */ | 384 */ |
(...skipping 20 matching lines...) Expand all Loading... |
405 * | 405 * |
406 * If this mirror is a [LibraryMirror], and [fieldName] denotes a top-level | 406 * If this mirror is a [LibraryMirror], and [fieldName] denotes a top-level |
407 * method in the corresponding library, the result of the invocation is an | 407 * method in the corresponding library, the result of the invocation is an |
408 * instance mirror on a closure corresponding to that method. | 408 * instance mirror on a closure corresponding to that method. |
409 * | 409 * |
410 * If this mirror is a [ClassMirror], and [fieldName] denotes a static method | 410 * If this mirror is a [ClassMirror], and [fieldName] denotes a static method |
411 * in the corresponding class, the result of the invocation is an instance | 411 * in the corresponding class, the result of the invocation is an instance |
412 * mirror on a closure corresponding to that method. | 412 * mirror on a closure corresponding to that method. |
413 * | 413 * |
414 * If the invocation returns a result *r*, this method returns | 414 * If the invocation returns a result *r*, this method returns |
415 * the result of calling [reflect](*r*). | 415 * the result of calling [reflect]\(*r*\). |
416 * If the invocation causes a compilation error | 416 * If the invocation causes a compilation error |
417 * the effect is the same as if a non-reflective compilation error | 417 * the effect is the same as if a non-reflective compilation error |
418 * had been encountered. | 418 * had been encountered. |
419 * If the invocation throws an exception *e* (that it does not catch) | 419 * If the invocation throws an exception *e* (that it does not catch) |
420 * this method throws *e*. | 420 * this method throws *e*. |
421 */ | 421 */ |
422 // TODO(ahe): Remove stuff about scope and private members. [fieldName] is a | 422 // TODO(ahe): Remove stuff about scope and private members. [fieldName] is a |
423 // capability giving access to private members. | 423 // capability giving access to private members. |
424 InstanceMirror getField(Symbol fieldName); | 424 InstanceMirror getField(Symbol fieldName); |
425 | 425 |
426 /** | 426 /** |
427 * Invokes a setter and returns a mirror on the result. The setter | 427 * Invokes a setter and returns a mirror on the result. The setter |
428 * may be either the implicit setter for a non-final field or a | 428 * may be either the implicit setter for a non-final field or a |
429 * user-defined setter method. | 429 * user-defined setter method. |
430 * | 430 * |
431 * Let *o* be the object reflected by this mirror, let | 431 * Let *o* be the object reflected by this mirror, let |
432 * *f* be the simple name of the getter denoted by [fieldName], | 432 * *f* be the simple name of the getter denoted by [fieldName], |
433 * and let *a* be the object bound to [value]. | 433 * and let *a* be the object bound to [value]. |
434 * Then this method will perform the setter invocation | 434 * Then this method will perform the setter invocation |
435 * *o.f = a* | 435 * *o.f = a* |
436 * in a scope that has access to the private members | 436 * in a scope that has access to the private members |
437 * of *o* (if *o* is a class or library) or the private members of the | 437 * of *o* (if *o* is a class or library) or the private members of the |
438 * class of *o* (otherwise). | 438 * class of *o* (otherwise). |
439 * If the invocation returns a result *r*, this method returns | 439 * If the invocation returns a result *r*, this method returns |
440 * the result of calling [reflect]([value]). | 440 * the result of calling [reflect]\([value]\). |
441 * If the invocation causes a compilation error | 441 * If the invocation causes a compilation error |
442 * the effect is the same as if a non-reflective compilation error | 442 * the effect is the same as if a non-reflective compilation error |
443 * had been encountered. | 443 * had been encountered. |
444 * If the invocation throws an exception *e* (that it does not catch) | 444 * If the invocation throws an exception *e* (that it does not catch) |
445 * this method throws *e*. | 445 * this method throws *e*. |
446 */ | 446 */ |
447 /* TODO(turnidge): Handle ambiguous names.*/ | 447 /* TODO(turnidge): Handle ambiguous names.*/ |
448 InstanceMirror setField(Symbol fieldName, Object value); | 448 InstanceMirror setField(Symbol fieldName, Object value); |
449 } | 449 } |
450 | 450 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 * if (invocation.isGetter) { | 507 * if (invocation.isGetter) { |
508 * return this.getField(invocation.memberName).reflectee; | 508 * return this.getField(invocation.memberName).reflectee; |
509 * } else if (invocation.isSetter) { | 509 * } else if (invocation.isSetter) { |
510 * return this.setField(invocation.memberName, | 510 * return this.setField(invocation.memberName, |
511 * invocation.positionArguments[0]).reflectee; | 511 * invocation.positionArguments[0]).reflectee; |
512 * } else { | 512 * } else { |
513 * return this.invoke(invocation.memberName, | 513 * return this.invoke(invocation.memberName, |
514 * invocation.positionalArguments, | 514 * invocation.positionalArguments, |
515 * invocation.namedArguments).reflectee; | 515 * invocation.namedArguments).reflectee; |
516 * } | 516 * } |
517 */ | 517 */ |
518 delegate(Invocation invocation); | 518 delegate(Invocation invocation); |
(...skipping 30 matching lines...) Expand all Loading... |
549 /** | 549 /** |
550 * Executes the closure and returns a mirror on the result. | 550 * Executes the closure and returns a mirror on the result. |
551 * Let *f* be the closure reflected by this mirror, | 551 * Let *f* be the closure reflected by this mirror, |
552 * let *a1, ..., an* be the elements of [positionalArguments] | 552 * let *a1, ..., an* be the elements of [positionalArguments] |
553 * let *k1, ..., km* be the identifiers denoted by the elements of | 553 * let *k1, ..., km* be the identifiers denoted by the elements of |
554 * [namedArguments.keys] | 554 * [namedArguments.keys] |
555 * and let *v1, ..., vm* be the elements of [namedArguments.values]. | 555 * and let *v1, ..., vm* be the elements of [namedArguments.values]. |
556 * Then this method will perform the method invocation | 556 * Then this method will perform the method invocation |
557 * *f(a1, ..., an, k1: v1, ..., km: vm)* | 557 * *f(a1, ..., an, k1: v1, ..., km: vm)* |
558 * If the invocation returns a result *r*, this method returns | 558 * If the invocation returns a result *r*, this method returns |
559 * the result of calling [reflect](*r*). | 559 * the result of calling [reflect]\(*r*\). |
560 * If the invocation causes a compilation error | 560 * If the invocation causes a compilation error |
561 * the effect is the same as if a non-reflective compilation error | 561 * the effect is the same as if a non-reflective compilation error |
562 * had been encountered. | 562 * had been encountered. |
563 * If the invocation throws an exception *e* (that it does not catch) | 563 * If the invocation throws an exception *e* (that it does not catch) |
564 * this method throws *e*. | 564 * this method throws *e*. |
565 */ | 565 */ |
566 InstanceMirror apply(List positionalArguments, | 566 InstanceMirror apply(List positionalArguments, |
567 [Map<Symbol, dynamic> namedArguments]); | 567 [Map<Symbol, dynamic> namedArguments]); |
568 } | 568 } |
569 | 569 |
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
830 * *new c(a1, ..., an, k1: v1, ..., km: vm)* | 830 * *new c(a1, ..., an, k1: v1, ..., km: vm)* |
831 * in a scope that has access to the private members | 831 * in a scope that has access to the private members |
832 * of *c*. Otherwise, let | 832 * of *c*. Otherwise, let |
833 * *f* be the simple name of the constructor denoted by [constructorName] | 833 * *f* be the simple name of the constructor denoted by [constructorName] |
834 * Then this method will execute the instance creation expression | 834 * Then this method will execute the instance creation expression |
835 * *new c.f(a1, ..., an, k1: v1, ..., km: vm)* | 835 * *new c.f(a1, ..., an, k1: v1, ..., km: vm)* |
836 * in a scope that has access to the private members | 836 * in a scope that has access to the private members |
837 * of *c*. | 837 * of *c*. |
838 * In either case: | 838 * In either case: |
839 * If the expression evaluates to a result *r*, this method returns | 839 * If the expression evaluates to a result *r*, this method returns |
840 * the result of calling [reflect](*r*). | 840 * the result of calling [reflect]\(*r*\). |
841 * If evaluating the expression causes a compilation error | 841 * If evaluating the expression causes a compilation error |
842 * the effect is the same as if a non-reflective compilation error | 842 * the effect is the same as if a non-reflective compilation error |
843 * had been encountered. | 843 * had been encountered. |
844 * If evaluating the expression throws an exception *e* | 844 * If evaluating the expression throws an exception *e* |
845 * (that it does not catch) | 845 * (that it does not catch) |
846 * this method throws *e*. | 846 * this method throws *e*. |
847 */ | 847 */ |
848 InstanceMirror newInstance(Symbol constructorName, | 848 InstanceMirror newInstance(Symbol constructorName, |
849 List positionalArguments, | 849 List positionalArguments, |
850 [Map<Symbol,dynamic> namedArguments]); | 850 [Map<Symbol,dynamic> namedArguments]); |
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1430 final override; | 1430 final override; |
1431 | 1431 |
1432 /** | 1432 /** |
1433 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], | 1433 * See the documentation for [MirrorsUsed.symbols], [MirrorsUsed.targets], |
1434 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation | 1434 * [MirrorsUsed.metaTargets] and [MirrorsUsed.override] for documentation |
1435 * of the parameters. | 1435 * of the parameters. |
1436 */ | 1436 */ |
1437 const MirrorsUsed( | 1437 const MirrorsUsed( |
1438 {this.symbols, this.targets, this.metaTargets, this.override}); | 1438 {this.symbols, this.targets, this.metaTargets, this.override}); |
1439 } | 1439 } |
OLD | NEW |