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 // VM-specific implementation of the dart:mirrors library. | 5 // VM-specific implementation of the dart:mirrors library. |
6 | 6 |
7 import "dart:collection"; | 7 import "dart:collection"; |
8 | 8 |
9 // These values are allowed to be passed directly over the wire. | 9 // These values are allowed to be passed directly over the wire. |
10 bool _isSimpleValue(var value) { | 10 bool _isSimpleValue(var value) { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 } else { | 92 } else { |
93 throw "positional argument $i ($arg) was not a simple value or InstanceMir
ror"; | 93 throw "positional argument $i ($arg) was not a simple value or InstanceMir
ror"; |
94 } | 94 } |
95 } | 95 } |
96 return unwrappedArgs; | 96 return unwrappedArgs; |
97 } | 97 } |
98 | 98 |
99 class _LocalMirrorSystemImpl extends MirrorSystem { | 99 class _LocalMirrorSystemImpl extends MirrorSystem { |
100 // Change parameter back to "this.libraries" when native code is changed. | 100 // Change parameter back to "this.libraries" when native code is changed. |
101 _LocalMirrorSystemImpl(List<LibraryMirror> libraries, this.isolate) | 101 _LocalMirrorSystemImpl(List<LibraryMirror> libraries, this.isolate) |
102 : this.libraries = _createLibrariesMap(libraries), | 102 : this.libraries = _createLibrariesMap(libraries); |
103 _functionTypes = new Map<String, FunctionTypeMirror>(); | |
104 | 103 |
105 final Map<Uri, LibraryMirror> libraries; | 104 final Map<Uri, LibraryMirror> libraries; |
106 final IsolateMirror isolate; | 105 final IsolateMirror isolate; |
107 | 106 |
108 TypeMirror _dynamicType = null; | 107 TypeMirror _dynamicType = null; |
109 | 108 |
110 TypeMirror get dynamicType { | 109 TypeMirror get dynamicType { |
111 if (_dynamicType == null) { | 110 if (_dynamicType == null) { |
112 _dynamicType = new _SpecialTypeMirrorImpl('dynamic'); | 111 _dynamicType = new _SpecialTypeMirrorImpl('dynamic'); |
113 } | 112 } |
114 return _dynamicType; | 113 return _dynamicType; |
115 } | 114 } |
116 | 115 |
117 TypeMirror _voidType = null; | 116 TypeMirror _voidType = null; |
118 | 117 |
119 TypeMirror get voidType { | 118 TypeMirror get voidType { |
120 if (_voidType == null) { | 119 if (_voidType == null) { |
121 _voidType = new _SpecialTypeMirrorImpl('void'); | 120 _voidType = new _SpecialTypeMirrorImpl('void'); |
122 } | 121 } |
123 return _voidType; | 122 return _voidType; |
124 } | 123 } |
125 | 124 |
126 final Map<String, FunctionTypeMirror> _functionTypes; | |
127 FunctionTypeMirror _lookupFunctionTypeMirror( | |
128 reflectee, | |
129 TypeMirror returnType, | |
130 List<ParameterMirror> parameters) { | |
131 var sigString = _makeSignatureString(returnType, parameters); | |
132 var mirror = _functionTypes[sigString]; | |
133 if (mirror == null) { | |
134 mirror = new _LocalFunctionTypeMirrorImpl(reflectee, | |
135 sigString, | |
136 returnType, | |
137 parameters); | |
138 _functionTypes[sigString] = mirror; | |
139 } | |
140 return mirror; | |
141 } | |
142 | |
143 String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; | 125 String toString() => "MirrorSystem for isolate '${isolate.debugName}'"; |
144 } | 126 } |
145 | 127 |
146 abstract class _LocalMirrorImpl implements Mirror { | 128 abstract class _LocalMirrorImpl implements Mirror { |
147 int get hashCode { | 129 int get hashCode { |
148 throw new UnimplementedError('Mirror.hashCode is not implemented'); | 130 throw new UnimplementedError('Mirror.hashCode is not implemented'); |
149 } | 131 } |
150 | 132 |
151 // Local mirrors always return the same MirrorSystem. This field | 133 // Local mirrors always return the same MirrorSystem. This field |
152 // is more interesting once we implement remote mirrors. | 134 // is more interesting once we implement remote mirrors. |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
361 | 343 |
362 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; | 344 String toString() => "ClosureMirror on '${Error.safeToString(_reflectee)}'"; |
363 | 345 |
364 static _apply(reflectee, positionalArguments) | 346 static _apply(reflectee, positionalArguments) |
365 native 'ClosureMirror_apply'; | 347 native 'ClosureMirror_apply'; |
366 | 348 |
367 static _computeFunction(reflectee) | 349 static _computeFunction(reflectee) |
368 native 'ClosureMirror_function'; | 350 native 'ClosureMirror_function'; |
369 } | 351 } |
370 | 352 |
371 class _LazyTypeMirror { | |
372 _LazyTypeMirror(String this.libraryUrl, String typeName) | |
373 : this.typeName = _s(typeName); | |
374 | |
375 TypeMirror resolve(MirrorSystem mirrors) { | |
376 if (libraryUrl == null) { | |
377 if (typeName == const Symbol('dynamic')) { | |
378 return mirrors.dynamicType; | |
379 } else if (typeName == const Symbol('void')) { | |
380 return mirrors.voidType; | |
381 } else { | |
382 throw new UnimplementedError( | |
383 "Mirror for type '$typeName' is not implemented"); | |
384 } | |
385 } | |
386 var resolved = mirrors.libraries[Uri.parse(libraryUrl)].members[typeName]; | |
387 if (resolved == null) { | |
388 throw new UnimplementedError( | |
389 "Mirror for type '$typeName' is not implemented"); | |
390 } | |
391 return resolved; | |
392 } | |
393 | |
394 final String libraryUrl; | |
395 final Symbol typeName; | |
396 } | |
397 | |
398 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl | 353 class _LocalClassMirrorImpl extends _LocalObjectMirrorImpl |
399 implements ClassMirror { | 354 implements ClassMirror { |
400 _LocalClassMirrorImpl(reflectee, | 355 _LocalClassMirrorImpl(reflectee, |
401 String simpleName) | 356 String simpleName) |
402 : this._simpleName = _s(simpleName), | 357 : this._simpleName = _s(simpleName), |
403 super(reflectee); | 358 super(reflectee); |
404 | 359 |
405 Symbol _simpleName; | 360 Symbol _simpleName; |
406 Symbol get simpleName { | 361 Symbol get simpleName { |
407 // dynamic, void and the function types have their names set eagerly in the | 362 // dynamic, void and the function types have their names set eagerly in the |
(...skipping 27 matching lines...) Expand all Loading... |
435 SourceLocation get location { | 390 SourceLocation get location { |
436 throw new UnimplementedError( | 391 throw new UnimplementedError( |
437 'ClassMirror.location is not implemented'); | 392 'ClassMirror.location is not implemented'); |
438 } | 393 } |
439 | 394 |
440 // TODO(rmacnak): Remove these left-overs from the days of separate interfaces | 395 // TODO(rmacnak): Remove these left-overs from the days of separate interfaces |
441 // once we send out a breaking change. | 396 // once we send out a breaking change. |
442 bool get isClass => true; | 397 bool get isClass => true; |
443 ClassMirror get defaultFactory => null; | 398 ClassMirror get defaultFactory => null; |
444 | 399 |
445 var _superclass; | 400 ClassMirror _superclass; |
446 ClassMirror get superclass { | 401 ClassMirror get superclass { |
447 if (_superclass == null) { | 402 if (_superclass == null) { |
448 Type supertype = _supertype(_reflectee); | 403 Type supertype = _supertype(_reflectee); |
449 if (supertype == null) { | 404 if (supertype == null) { |
450 // Object has no superclass. | 405 // Object has no superclass. |
451 return null; | 406 return null; |
452 } | 407 } |
453 _superclass = reflectClass(supertype); | 408 _superclass = reflectClass(supertype); |
454 } | 409 } |
455 if (_superclass is! Mirror) { | |
456 _superclass = _superclass.resolve(mirrors); | |
457 } | |
458 return _superclass; | 410 return _superclass; |
459 } | 411 } |
460 | 412 |
461 var _superinterfaces; | 413 var _superinterfaces; |
462 List<ClassMirror> get superinterfaces { | 414 List<ClassMirror> get superinterfaces { |
463 if (_superinterfaces == null) { | 415 if (_superinterfaces == null) { |
464 _superinterfaces = _interfaces(_reflectee) | 416 _superinterfaces = _interfaces(_reflectee) |
465 .map((i) => reflectClass(i)).toList(growable:false); | 417 .map((i) => reflectClass(i)).toList(growable:false); |
466 } | 418 } |
467 return _superinterfaces; | 419 return _superinterfaces; |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
624 _invokeSetter(reflectee, setterName, value) | 576 _invokeSetter(reflectee, setterName, value) |
625 native 'ClassMirror_invokeSetter'; | 577 native 'ClassMirror_invokeSetter'; |
626 | 578 |
627 static _invokeConstructor(reflectee, constructorName, positionalArguments) | 579 static _invokeConstructor(reflectee, constructorName, positionalArguments) |
628 native 'ClassMirror_invokeConstructor'; | 580 native 'ClassMirror_invokeConstructor'; |
629 | 581 |
630 static _ClassMirror_type_variables(reflectee) | 582 static _ClassMirror_type_variables(reflectee) |
631 native "ClassMirror_type_variables"; | 583 native "ClassMirror_type_variables"; |
632 } | 584 } |
633 | 585 |
634 class _LazyFunctionTypeMirror { | |
635 _LazyFunctionTypeMirror(this.reflectee, this.returnType, this.parameters) {} | |
636 | |
637 ClassMirror resolve(MirrorSystem mirrors) { | |
638 return mirrors._lookupFunctionTypeMirror(reflectee, | |
639 returnType.resolve(mirrors), | |
640 parameters); | |
641 } | |
642 | |
643 final reflectee; | |
644 final returnType; | |
645 final List<ParameterMirror> parameters; | |
646 } | |
647 | |
648 class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl | 586 class _LocalFunctionTypeMirrorImpl extends _LocalClassMirrorImpl |
649 implements FunctionTypeMirror { | 587 implements FunctionTypeMirror { |
650 _LocalFunctionTypeMirrorImpl(reflectee, | 588 _LocalFunctionTypeMirrorImpl(reflectee) : super(reflectee, null); |
651 simpleName, | |
652 this._returnType, | |
653 this.parameters) | |
654 : super(reflectee, | |
655 simpleName); | |
656 | 589 |
657 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); | 590 // FunctionTypeMirrors have a simpleName generated from their signature. |
658 Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); | 591 Symbol _simpleName = null; |
| 592 Symbol get simpleName { |
| 593 if (_simpleName == null) { |
| 594 _simpleName = _s(_makeSignatureString(returnType, parameters)); |
| 595 } |
| 596 return _simpleName; |
| 597 } |
659 | 598 |
660 var _returnType; | 599 TypeMirror _returnType = null; |
661 TypeMirror get returnType { | 600 TypeMirror get returnType { |
662 if (_returnType is! Mirror) { | 601 if (_returnType == null) { |
663 _returnType = _returnType.resolve(mirrors); | 602 _returnType = _FunctionTypeMirror_return_type(_reflectee); |
664 } | 603 } |
665 return _returnType; | 604 return _returnType; |
666 } | 605 } |
667 | 606 |
668 final List<ParameterMirror> parameters; | 607 List<ParameterMirror> _parameters = null; |
| 608 List<ParameterMirror> get parameters { |
| 609 if (_parameters == null) { |
| 610 _parameters = _FunctionTypeMirror_parameters(_reflectee); |
| 611 } |
| 612 return _parameters; |
| 613 } |
| 614 |
| 615 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); |
| 616 Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); |
669 final Map<Symbol, TypeVariableMirror> typeVariables = const {}; | 617 final Map<Symbol, TypeVariableMirror> typeVariables = const {}; |
670 | 618 |
671 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; | 619 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; |
| 620 |
| 621 static TypeMirror _FunctionTypeMirror_return_type(reflectee) |
| 622 native "FunctionTypeMirror_return_type"; |
| 623 |
| 624 static List<ParameterMirror> _FunctionTypeMirror_parameters(reflectee) |
| 625 native "FunctionTypeMirror_parameters"; |
672 } | 626 } |
673 | 627 |
674 abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl | 628 abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl |
675 implements DeclarationMirror { | 629 implements DeclarationMirror { |
676 _LocalDeclarationMirrorImpl(this._reflectee, this.simpleName); | 630 _LocalDeclarationMirrorImpl(this._reflectee, this.simpleName); |
677 | 631 |
678 final _reflectee; | 632 final _reflectee; |
679 | 633 |
680 final Symbol simpleName; | 634 final Symbol simpleName; |
681 | 635 |
682 Symbol _qualifiedName = null; | 636 Symbol _qualifiedName = null; |
683 Symbol get qualifiedName { | 637 Symbol get qualifiedName { |
684 if (_qualifiedName == null) { | 638 if (_qualifiedName == null) { |
685 _qualifiedName = _computeQualifiedName(owner, simpleName); | 639 _qualifiedName = _computeQualifiedName(owner, simpleName); |
686 } | 640 } |
687 return _qualifiedName; | 641 return _qualifiedName; |
688 } | 642 } |
689 | 643 |
690 List<InstanceMirror> get metadata { | 644 List<InstanceMirror> get metadata { |
691 // Get the metadata objects, convert them into InstanceMirrors using | 645 // Get the metadata objects, convert them into InstanceMirrors using |
692 // reflect() and then make them into a Dart list. | 646 // reflect() and then make them into a Dart list. |
693 return _metadata(_reflectee).map(reflect).toList(growable:false); | 647 return _metadata(_reflectee).map(reflect).toList(growable:false); |
694 } | 648 } |
695 } | 649 } |
696 | 650 |
697 class _LazyTypeVariableMirror { | |
698 _LazyTypeVariableMirror(String variableName, this._owner) | |
699 : this._variableName = _s(variableName); | |
700 | |
701 TypeVariableMirror resolve(MirrorSystem mirrors) { | |
702 ClassMirror owner = _owner.resolve(mirrors); | |
703 return owner.typeVariables[_variableName]; | |
704 } | |
705 | |
706 final Symbol _variableName; | |
707 final _LazyTypeMirror _owner; | |
708 } | |
709 | |
710 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl | 651 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl |
711 implements TypeVariableMirror { | 652 implements TypeVariableMirror { |
712 _LocalTypeVariableMirrorImpl(reflectee, | 653 _LocalTypeVariableMirrorImpl(reflectee, |
713 String simpleName, | 654 String simpleName, |
714 this._owner) | 655 this._owner) |
715 : super(reflectee, _s(simpleName)); | 656 : super(reflectee, _s(simpleName)); |
716 | 657 |
717 var _owner; | 658 DeclarationMirror _owner; |
718 DeclarationMirror get owner { | 659 DeclarationMirror get owner { |
719 if (_owner == null) { | 660 if (_owner == null) { |
720 _owner = _LocalTypeVariableMirror_owner(_reflectee); | 661 _owner = _LocalTypeVariableMirror_owner(_reflectee); |
721 } | 662 } |
722 // TODO(11897): This will go away, as soon as lazy mirrors go away. | |
723 if (_owner is! Mirror) { | |
724 _owner = _owner.resolve(mirrors); | |
725 } | |
726 return _owner; | 663 return _owner; |
727 } | 664 } |
728 | 665 |
729 bool get isPrivate => false; | 666 bool get isPrivate => false; |
730 | 667 |
731 final bool isTopLevel = false; | 668 final bool isTopLevel = false; |
732 | 669 |
733 SourceLocation get location { | 670 SourceLocation get location { |
734 throw new UnimplementedError( | 671 throw new UnimplementedError( |
735 'TypeVariableMirror.location is not implemented'); | 672 'TypeVariableMirror.location is not implemented'); |
(...skipping 19 matching lines...) Expand all Loading... |
755 | 692 |
756 static TypeMirror _LocalTypeVariableMirror_upper_bound(reflectee) | 693 static TypeMirror _LocalTypeVariableMirror_upper_bound(reflectee) |
757 native "LocalTypeVariableMirror_upper_bound"; | 694 native "LocalTypeVariableMirror_upper_bound"; |
758 } | 695 } |
759 | 696 |
760 | 697 |
761 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl | 698 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl |
762 implements TypedefMirror { | 699 implements TypedefMirror { |
763 _LocalTypedefMirrorImpl(reflectee, | 700 _LocalTypedefMirrorImpl(reflectee, |
764 String simpleName, | 701 String simpleName, |
765 this._owner, | 702 this._owner) |
766 this._referent) | |
767 : super(reflectee, _s(simpleName)); | 703 : super(reflectee, _s(simpleName)); |
768 | 704 |
769 var _owner; | 705 DeclarationMirror _owner; |
770 DeclarationMirror get owner { | 706 DeclarationMirror get owner { |
771 if (_owner == null) { | 707 if (_owner == null) { |
772 _owner = _LocalClassMirrorImpl._library(_reflectee); | 708 _owner = _LocalClassMirrorImpl._library(_reflectee); |
773 } | 709 } |
774 if (_owner is! Mirror) { | |
775 _owner = _owner.resolve(mirrors); | |
776 } | |
777 return _owner; | 710 return _owner; |
778 } | 711 } |
779 | 712 |
780 bool get isPrivate => false; | 713 bool get isPrivate => false; |
781 | 714 |
782 final bool isTopLevel = true; | 715 final bool isTopLevel = true; |
783 | 716 |
784 SourceLocation get location { | 717 SourceLocation get location { |
785 throw new UnimplementedError( | 718 throw new UnimplementedError( |
786 'TypedefMirror.location is not implemented'); | 719 'TypedefMirror.location is not implemented'); |
787 } | 720 } |
788 | 721 |
789 var _referent; | 722 TypeMirror _referent = null; |
790 TypeMirror get referent { | 723 TypeMirror get referent { |
791 if (_referent is! Mirror) { | 724 if (_referent == null) { |
792 _referent = _referent.resolve(mirrors); | 725 return new _LocalFunctionTypeMirrorImpl( |
| 726 _TypedefMirror_referent(_reflectee)); |
793 } | 727 } |
794 return _referent; | 728 return _referent; |
795 } | 729 } |
796 | 730 |
797 String toString() => "TypedefMirror on '${_n(simpleName)}'"; | 731 String toString() => "TypedefMirror on '${_n(simpleName)}'"; |
798 } | |
799 | 732 |
800 | 733 static _TypedefMirror_referent(_reflectee) |
801 class _LazyLibraryMirror { | 734 native "TypedefMirror_referent"; |
802 _LazyLibraryMirror(String this.libraryUrl); | |
803 | |
804 LibraryMirror resolve(MirrorSystem mirrors) { | |
805 return mirrors.libraries[Uri.parse(libraryUrl)]; | |
806 } | |
807 | |
808 final String libraryUrl; | |
809 } | 735 } |
810 | 736 |
811 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl | 737 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
812 implements LibraryMirror { | 738 implements LibraryMirror { |
813 _LocalLibraryMirrorImpl(reflectee, | 739 _LocalLibraryMirrorImpl(reflectee, |
814 String simpleName, | 740 String simpleName, |
815 String url) | 741 String url) |
816 : this.simpleName = _s(simpleName), | 742 : this.simpleName = _s(simpleName), |
817 this.uri = Uri.parse(url), | 743 this.uri = Uri.parse(url), |
818 super(reflectee); | 744 super(reflectee); |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
923 this.isAbstract, | 849 this.isAbstract, |
924 this.isGetter, | 850 this.isGetter, |
925 this.isSetter, | 851 this.isSetter, |
926 this.isConstructor, | 852 this.isConstructor, |
927 this.isConstConstructor, | 853 this.isConstConstructor, |
928 this.isGenerativeConstructor, | 854 this.isGenerativeConstructor, |
929 this.isRedirectingConstructor, | 855 this.isRedirectingConstructor, |
930 this.isFactoryConstructor) | 856 this.isFactoryConstructor) |
931 : super(reflectee, _s(simpleName)); | 857 : super(reflectee, _s(simpleName)); |
932 | 858 |
933 var _owner; | 859 DeclarationMirror _owner; |
934 DeclarationMirror get owner { | 860 DeclarationMirror get owner { |
935 // For nested closures it is possible, that the mirror for the owner has not | 861 // For nested closures it is possible, that the mirror for the owner has not |
936 // been created yet. | 862 // been created yet. |
937 if (_owner == null) { | 863 if (_owner == null) { |
938 _owner = _MethodMirror_owner(_reflectee); | 864 _owner = _MethodMirror_owner(_reflectee); |
939 } | 865 } |
940 // TODO(11897): This will go away, as soon as lazy mirrors go away. | |
941 if (_owner is! Mirror) { | |
942 _owner = _owner.resolve(mirrors); | |
943 } | |
944 return _owner; | 866 return _owner; |
945 } | 867 } |
946 | 868 |
947 bool get isPrivate { | 869 bool get isPrivate { |
948 return _n(simpleName).startsWith('_') || | 870 return _n(simpleName).startsWith('_') || |
949 _n(constructorName).startsWith('_'); | 871 _n(constructorName).startsWith('_'); |
950 } | 872 } |
951 | 873 |
952 bool get isTopLevel => owner is LibraryMirror; | 874 bool get isTopLevel => owner is LibraryMirror; |
953 | 875 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 native "MethodMirror_return_type"; | 947 native "MethodMirror_return_type"; |
1026 | 948 |
1027 static List<MethodMirror> _MethodMirror_parameters(reflectee) | 949 static List<MethodMirror> _MethodMirror_parameters(reflectee) |
1028 native "MethodMirror_parameters"; | 950 native "MethodMirror_parameters"; |
1029 } | 951 } |
1030 | 952 |
1031 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl | 953 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl |
1032 implements VariableMirror { | 954 implements VariableMirror { |
1033 _LocalVariableMirrorImpl(reflectee, | 955 _LocalVariableMirrorImpl(reflectee, |
1034 String simpleName, | 956 String simpleName, |
1035 this._owner, | 957 this.owner, |
1036 this._type, | 958 this._type, |
1037 this.isStatic, | 959 this.isStatic, |
1038 this.isFinal) | 960 this.isFinal) |
1039 : super(reflectee, _s(simpleName)); | 961 : super(reflectee, _s(simpleName)); |
1040 | 962 |
1041 var _owner; | 963 final DeclarationMirror owner; |
1042 DeclarationMirror get owner { | |
1043 if (_owner is! Mirror) { | |
1044 _owner = _owner.resolve(mirrors); | |
1045 } | |
1046 return _owner; | |
1047 } | |
1048 | 964 |
1049 bool get isPrivate { | 965 bool get isPrivate { |
1050 return _n(simpleName).startsWith('_'); | 966 return _n(simpleName).startsWith('_'); |
1051 } | 967 } |
1052 | 968 |
1053 bool get isTopLevel { | 969 bool get isTopLevel { |
1054 return owner is LibraryMirror; | 970 return owner is LibraryMirror; |
1055 } | 971 } |
1056 | 972 |
1057 SourceLocation get location { | 973 SourceLocation get location { |
1058 throw new UnimplementedError( | 974 throw new UnimplementedError( |
1059 'VariableMirror.location is not implemented'); | 975 'VariableMirror.location is not implemented'); |
1060 } | 976 } |
1061 | 977 |
1062 var _type; | 978 TypeMirror _type; |
1063 TypeMirror get type { | 979 TypeMirror get type { |
1064 if (_type == null) { | 980 if (_type == null) { |
1065 _type = _VariableMirror_type(_reflectee); | 981 _type = _VariableMirror_type(_reflectee); |
1066 } | 982 } |
1067 if (_type is! Mirror) { | |
1068 _type = _type.resolve(mirrors); | |
1069 } | |
1070 return _type; | 983 return _type; |
1071 } | 984 } |
1072 | 985 |
1073 final bool isStatic; | 986 final bool isStatic; |
1074 final bool isFinal; | 987 final bool isFinal; |
1075 | 988 |
1076 String toString() => "VariableMirror on '${_n(simpleName)}'"; | 989 String toString() => "VariableMirror on '${_n(simpleName)}'"; |
1077 | 990 |
1078 static _VariableMirror_type(reflectee) | 991 static _VariableMirror_type(reflectee) |
1079 native "VariableMirror_type"; | 992 native "VariableMirror_type"; |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); | 1114 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); |
1202 static ClassMirror reflectClass(Type key) { | 1115 static ClassMirror reflectClass(Type key) { |
1203 var classMirror = _classMirrorCache[key]; | 1116 var classMirror = _classMirrorCache[key]; |
1204 if (classMirror == null) { | 1117 if (classMirror == null) { |
1205 classMirror = makeLocalClassMirror(key); | 1118 classMirror = makeLocalClassMirror(key); |
1206 _classMirrorCache[key] = classMirror; | 1119 _classMirrorCache[key] = classMirror; |
1207 } | 1120 } |
1208 return classMirror; | 1121 return classMirror; |
1209 } | 1122 } |
1210 } | 1123 } |
OLD | NEW |