Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(202)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 21281002: Hoist .simpleName and .qualifiedName up to _LocalDeclarationMirrorImpl. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 // These values are allowed to be passed directly over the wire. 7 // These values are allowed to be passed directly over the wire.
8 bool _isSimpleValue(var value) { 8 bool _isSimpleValue(var value) {
9 return (value == null || value is num || value is String || value is bool); 9 return (value == null || value is num || value is String || value is bool);
10 } 10 }
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after
649 return _returnType; 649 return _returnType;
650 } 650 }
651 651
652 final List<ParameterMirror> parameters; 652 final List<ParameterMirror> parameters;
653 653
654 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; 654 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'";
655 } 655 }
656 656
657 abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl 657 abstract class _LocalDeclarationMirrorImpl extends _LocalMirrorImpl
658 implements DeclarationMirror { 658 implements DeclarationMirror {
659 _LocalDeclarationMirrorImpl(this._reflectee); 659 _LocalDeclarationMirrorImpl(this._reflectee, this.simpleName);
660 final _MirrorReference _reflectee;
661 660
662 List<InstanceMirror> get metadata { 661 final _MirrorReference _reflectee;
663 // Get the metadata objects, convert them into InstanceMirrors using 662
664 // reflect() and then make them into a Dart list. 663 final Symbol simpleName;
665 return _metadata(_reflectee).map(reflect).toList(growable:false); 664
665 Symbol _qualifiedName = null;
666 Symbol get qualifiedName {
667 if (_qualifiedName == null) {
668 _qualifiedName = _computeQualifiedName(owner, simpleName);
666 } 669 }
670 return _qualifiedName;
671 }
672
673 List<InstanceMirror> get metadata {
674 // Get the metadata objects, convert them into InstanceMirrors using
675 // reflect() and then make them into a Dart list.
676 return _metadata(_reflectee).map(reflect).toList(growable:false);
677 }
667 } 678 }
668 679
669 class _LazyTypeVariableMirror { 680 class _LazyTypeVariableMirror {
670 _LazyTypeVariableMirror(String variableName, this._owner) 681 _LazyTypeVariableMirror(String variableName, this._owner)
671 : this._variableName = _s(variableName); 682 : this._variableName = _s(variableName);
672 683
673 TypeVariableMirror resolve(MirrorSystem mirrors) { 684 TypeVariableMirror resolve(MirrorSystem mirrors) {
674 ClassMirror owner = _owner.resolve(mirrors); 685 ClassMirror owner = _owner.resolve(mirrors);
675 return owner.typeVariables[_variableName]; 686 return owner.typeVariables[_variableName];
676 } 687 }
677 688
678 final Symbol _variableName; 689 final Symbol _variableName;
679 final _LazyTypeMirror _owner; 690 final _LazyTypeMirror _owner;
680 } 691 }
681 692
682 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl 693 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl
683 implements TypeVariableMirror { 694 implements TypeVariableMirror {
684 _LocalTypeVariableMirrorImpl(reflectee, 695 _LocalTypeVariableMirrorImpl(reflectee,
685 String simpleName, 696 String simpleName,
686 this._owner, 697 this._owner,
687 this._upperBound) 698 this._upperBound)
688 : this.simpleName = _s(simpleName), 699 : super(reflectee, _s(simpleName));
689 super(reflectee);
690
691 final Symbol simpleName;
692
693 Symbol _qualifiedName = null;
694 Symbol get qualifiedName {
695 if (_qualifiedName == null) {
696 _qualifiedName = _computeQualifiedName(owner, simpleName);
697 }
698 return _qualifiedName;
699 }
700 700
701 var _owner; 701 var _owner;
702 DeclarationMirror get owner { 702 DeclarationMirror get owner {
703 if (_owner is! Mirror) { 703 if (_owner is! Mirror) {
704 _owner = _owner.resolve(mirrors); 704 _owner = _owner.resolve(mirrors);
705 } 705 }
706 return _owner; 706 return _owner;
707 } 707 }
708 708
709 bool get isPrivate => false; 709 bool get isPrivate => false;
(...skipping 21 matching lines...) Expand all
731 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; 731 String toString() => "TypeVariableMirror on '${_n(simpleName)}'";
732 } 732 }
733 733
734 734
735 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl 735 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl
736 implements TypedefMirror { 736 implements TypedefMirror {
737 _LocalTypedefMirrorImpl(reflectee, 737 _LocalTypedefMirrorImpl(reflectee,
738 String simpleName, 738 String simpleName,
739 this._owner, 739 this._owner,
740 this._referent) 740 this._referent)
741 : this.simpleName = _s(simpleName), 741 : super(reflectee, _s(simpleName));
742 super(reflectee);
743
744 final Symbol simpleName;
745
746 Symbol _qualifiedName = null;
747 Symbol get qualifiedName {
748 if (_qualifiedName == null) {
749 _qualifiedName = _computeQualifiedName(owner, simpleName);
750 }
751 return _qualifiedName;
752 }
753 742
754 var _owner; 743 var _owner;
755 DeclarationMirror get owner { 744 DeclarationMirror get owner {
756 if (_owner == null) { 745 if (_owner == null) {
757 _owner = _LocalClassMirrorImpl._library(_reflectee); 746 _owner = _LocalClassMirrorImpl._library(_reflectee);
758 } 747 }
759 if (_owner is! Mirror) { 748 if (_owner is! Mirror) {
760 _owner = _owner.resolve(mirrors); 749 _owner = _owner.resolve(mirrors);
761 } 750 }
762 return _owner; 751 return _owner;
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 _invokeSetter(reflectee, setterName, value) 884 _invokeSetter(reflectee, setterName, value)
896 native 'LibraryMirror_invokeSetter'; 885 native 'LibraryMirror_invokeSetter';
897 886
898 _computeMembers(reflectee) 887 _computeMembers(reflectee)
899 native "LibraryMirror_members"; 888 native "LibraryMirror_members";
900 } 889 }
901 890
902 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl 891 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl
903 implements MethodMirror { 892 implements MethodMirror {
904 _LocalMethodMirrorImpl(reflectee, 893 _LocalMethodMirrorImpl(reflectee,
894 String simpleName,
905 this._owner, 895 this._owner,
906 this.isStatic, 896 this.isStatic,
907 this.isAbstract, 897 this.isAbstract,
908 this.isGetter, 898 this.isGetter,
909 this.isSetter, 899 this.isSetter,
910 this.isConstructor, 900 this.isConstructor,
911 this.isConstConstructor, 901 this.isConstConstructor,
912 this.isGenerativeConstructor, 902 this.isGenerativeConstructor,
913 this.isRedirectingConstructor, 903 this.isRedirectingConstructor,
914 this.isFactoryConstructor) : super(reflectee); 904 this.isFactoryConstructor)
915 905 : super(reflectee, _s(simpleName));
916 Symbol _simpleName = null;
917 Symbol get simpleName {
918 if (_simpleName == null) {
919 _simpleName = _s(_MethodMirror_name(_reflectee));
920 }
921 return _simpleName;
922 }
923
924 Symbol _qualifiedName = null;
925 Symbol get qualifiedName {
926 if (_qualifiedName == null) {
927 _qualifiedName = _computeQualifiedName(owner, simpleName);
928 }
929 return _qualifiedName;
930 }
931 906
932 var _owner; 907 var _owner;
933 DeclarationMirror get owner { 908 DeclarationMirror get owner {
934 // For nested closures it is possible, that the mirror for the owner has not 909 // For nested closures it is possible, that the mirror for the owner has not
935 // been created yet. 910 // been created yet.
936 if (_owner == null) { 911 if (_owner == null) {
937 _owner = _MethodMirror_owner(_reflectee); 912 _owner = _MethodMirror_owner(_reflectee);
938 } 913 }
939 // TODO(11897): This will go away, as soon as lazy mirrors go away. 914 // TODO(11897): This will go away, as soon as lazy mirrors go away.
940 if (_owner is! Mirror) { 915 if (_owner is! Mirror) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return _constructorName; 985 return _constructorName;
1011 } 986 }
1012 987
1013 final bool isConstConstructor; 988 final bool isConstConstructor;
1014 final bool isGenerativeConstructor; 989 final bool isGenerativeConstructor;
1015 final bool isRedirectingConstructor; 990 final bool isRedirectingConstructor;
1016 final bool isFactoryConstructor; 991 final bool isFactoryConstructor;
1017 992
1018 String toString() => "MethodMirror on '${_n(simpleName)}'"; 993 String toString() => "MethodMirror on '${_n(simpleName)}'";
1019 994
1020 static String _MethodMirror_name(reflectee)
1021 native "MethodMirror_name";
1022
1023 static dynamic _MethodMirror_owner(reflectee) 995 static dynamic _MethodMirror_owner(reflectee)
1024 native "MethodMirror_owner"; 996 native "MethodMirror_owner";
1025 997
1026 static dynamic _MethodMirror_return_type(reflectee) 998 static dynamic _MethodMirror_return_type(reflectee)
1027 native "MethodMirror_return_type"; 999 native "MethodMirror_return_type";
1028 1000
1029 static List<MethodMirror> _MethodMirror_parameters(reflectee) 1001 static List<MethodMirror> _MethodMirror_parameters(reflectee)
1030 native "MethodMirror_parameters"; 1002 native "MethodMirror_parameters";
1031 } 1003 }
1032 1004
1033 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl 1005 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl
1034 implements VariableMirror { 1006 implements VariableMirror {
1035 _LocalVariableMirrorImpl(reflectee, 1007 _LocalVariableMirrorImpl(reflectee,
1036 String simpleName, 1008 String simpleName,
1037 this._owner, 1009 this._owner,
1038 this._type, 1010 this._type,
1039 this.isStatic, 1011 this.isStatic,
1040 this.isFinal) 1012 this.isFinal)
1041 : this.simpleName = _s(simpleName), 1013 : super(reflectee, _s(simpleName));
1042 super(reflectee);
1043
1044 final Symbol simpleName;
1045
1046 Symbol _qualifiedName = null;
1047 Symbol get qualifiedName {
1048 if (_qualifiedName == null) {
1049 _qualifiedName = _computeQualifiedName(owner, simpleName);
1050 }
1051 return _qualifiedName;
1052 }
1053 1014
1054 var _owner; 1015 var _owner;
1055 DeclarationMirror get owner { 1016 DeclarationMirror get owner {
1056 if (_owner is! Mirror) { 1017 if (_owner is! Mirror) {
1057 _owner = _owner.resolve(mirrors); 1018 _owner = _owner.resolve(mirrors);
1058 } 1019 }
1059 return _owner; 1020 return _owner;
1060 } 1021 }
1061 1022
1062 bool get isPrivate { 1023 bool get isPrivate {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1175 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1215 static ClassMirror reflectClass(Type key) { 1176 static ClassMirror reflectClass(Type key) {
1216 var classMirror = _classMirrorCache[key]; 1177 var classMirror = _classMirrorCache[key];
1217 if (classMirror == null) { 1178 if (classMirror == null) {
1218 classMirror = makeLocalClassMirror(key); 1179 classMirror = makeLocalClassMirror(key);
1219 _classMirrorCache[key] = classMirror; 1180 _classMirrorCache[key] = classMirror;
1220 } 1181 }
1221 return classMirror; 1182 return classMirror;
1222 } 1183 }
1223 } 1184 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/vm/bootstrap_natives.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698