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

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 Symbol get simpleName => _simpleName;
rmacnak 2013/07/30 19:48:37 If the getter just answers the field, we can just
Michael Lippautz (Google) 2013/07/30 19:58:18 Done.
665
666 Symbol _qualifiedName = null;
667 Symbol get qualifiedName {
668 if (_qualifiedName == null) {
669 _qualifiedName = _computeQualifiedName(owner, simpleName);
666 } 670 }
671 return _qualifiedName;
672 }
673
674 List<InstanceMirror> get metadata {
675 // Get the metadata objects, convert them into InstanceMirrors using
676 // reflect() and then make them into a Dart list.
677 return _metadata(_reflectee).map(reflect).toList(growable:false);
678 }
667 } 679 }
668 680
669 class _LazyTypeVariableMirror { 681 class _LazyTypeVariableMirror {
670 _LazyTypeVariableMirror(String variableName, this._owner) 682 _LazyTypeVariableMirror(String variableName, this._owner)
671 : this._variableName = _s(variableName); 683 : this._variableName = _s(variableName);
672 684
673 TypeVariableMirror resolve(MirrorSystem mirrors) { 685 TypeVariableMirror resolve(MirrorSystem mirrors) {
674 ClassMirror owner = _owner.resolve(mirrors); 686 ClassMirror owner = _owner.resolve(mirrors);
675 return owner.typeVariables[_variableName]; 687 return owner.typeVariables[_variableName];
676 } 688 }
677 689
678 final Symbol _variableName; 690 final Symbol _variableName;
679 final _LazyTypeMirror _owner; 691 final _LazyTypeMirror _owner;
680 } 692 }
681 693
682 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl 694 class _LocalTypeVariableMirrorImpl extends _LocalDeclarationMirrorImpl
683 implements TypeVariableMirror { 695 implements TypeVariableMirror {
684 _LocalTypeVariableMirrorImpl(reflectee, 696 _LocalTypeVariableMirrorImpl(reflectee,
685 String simpleName, 697 String simpleName,
686 this._owner, 698 this._owner,
687 this._upperBound) 699 this._upperBound)
688 : this.simpleName = _s(simpleName), 700 : 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 701
701 var _owner; 702 var _owner;
702 DeclarationMirror get owner { 703 DeclarationMirror get owner {
703 if (_owner is! Mirror) { 704 if (_owner is! Mirror) {
704 _owner = _owner.resolve(mirrors); 705 _owner = _owner.resolve(mirrors);
705 } 706 }
706 return _owner; 707 return _owner;
707 } 708 }
708 709
709 bool get isPrivate => false; 710 bool get isPrivate => false;
(...skipping 21 matching lines...) Expand all
731 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; 732 String toString() => "TypeVariableMirror on '${_n(simpleName)}'";
732 } 733 }
733 734
734 735
735 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl 736 class _LocalTypedefMirrorImpl extends _LocalDeclarationMirrorImpl
736 implements TypedefMirror { 737 implements TypedefMirror {
737 _LocalTypedefMirrorImpl(reflectee, 738 _LocalTypedefMirrorImpl(reflectee,
738 String simpleName, 739 String simpleName,
739 this._owner, 740 this._owner,
740 this._referent) 741 this._referent)
741 : this.simpleName = _s(simpleName), 742 : super(reflectee, _s(simpleName));
742 super(reflectee);
743
744 final Symbol simpleName;
745 743
746 Symbol _qualifiedName = null; 744 Symbol _qualifiedName = null;
747 Symbol get qualifiedName { 745 Symbol get qualifiedName {
rmacnak 2013/07/30 19:48:37 Isn't this inherited now?
Michael Lippautz (Google) 2013/07/30 19:58:18 Yep, did miss this one.
748 if (_qualifiedName == null) { 746 if (_qualifiedName == null) {
749 _qualifiedName = _computeQualifiedName(owner, simpleName); 747 _qualifiedName = _computeQualifiedName(owner, simpleName);
750 } 748 }
751 return _qualifiedName; 749 return _qualifiedName;
752 } 750 }
753 751
754 var _owner; 752 var _owner;
755 DeclarationMirror get owner { 753 DeclarationMirror get owner {
756 if (_owner == null) { 754 if (_owner == null) {
757 _owner = _LocalClassMirrorImpl._library(_reflectee); 755 _owner = _LocalClassMirrorImpl._library(_reflectee);
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 _invokeSetter(reflectee, setterName, value) 893 _invokeSetter(reflectee, setterName, value)
896 native 'LibraryMirror_invokeSetter'; 894 native 'LibraryMirror_invokeSetter';
897 895
898 _computeMembers(reflectee) 896 _computeMembers(reflectee)
899 native "LibraryMirror_members"; 897 native "LibraryMirror_members";
900 } 898 }
901 899
902 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl 900 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl
903 implements MethodMirror { 901 implements MethodMirror {
904 _LocalMethodMirrorImpl(reflectee, 902 _LocalMethodMirrorImpl(reflectee,
903 String simpleName,
905 this._owner, 904 this._owner,
906 this.isStatic, 905 this.isStatic,
907 this.isAbstract, 906 this.isAbstract,
908 this.isGetter, 907 this.isGetter,
909 this.isSetter, 908 this.isSetter,
910 this.isConstructor, 909 this.isConstructor,
911 this.isConstConstructor, 910 this.isConstConstructor,
912 this.isGenerativeConstructor, 911 this.isGenerativeConstructor,
913 this.isRedirectingConstructor, 912 this.isRedirectingConstructor,
914 this.isFactoryConstructor) : super(reflectee); 913 this.isFactoryConstructor)
915 914 : 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 915
932 var _owner; 916 var _owner;
933 DeclarationMirror get owner { 917 DeclarationMirror get owner {
934 // For nested closures it is possible, that the mirror for the owner has not 918 // For nested closures it is possible, that the mirror for the owner has not
935 // been created yet. 919 // been created yet.
936 if (_owner == null) { 920 if (_owner == null) {
937 _owner = _MethodMirror_owner(_reflectee); 921 _owner = _MethodMirror_owner(_reflectee);
938 } 922 }
939 // TODO(11897): This will go away, as soon as lazy mirrors go away. 923 // TODO(11897): This will go away, as soon as lazy mirrors go away.
940 if (_owner is! Mirror) { 924 if (_owner is! Mirror) {
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1010 return _constructorName; 994 return _constructorName;
1011 } 995 }
1012 996
1013 final bool isConstConstructor; 997 final bool isConstConstructor;
1014 final bool isGenerativeConstructor; 998 final bool isGenerativeConstructor;
1015 final bool isRedirectingConstructor; 999 final bool isRedirectingConstructor;
1016 final bool isFactoryConstructor; 1000 final bool isFactoryConstructor;
1017 1001
1018 String toString() => "MethodMirror on '${_n(simpleName)}'"; 1002 String toString() => "MethodMirror on '${_n(simpleName)}'";
1019 1003
1020 static String _MethodMirror_name(reflectee)
1021 native "MethodMirror_name";
1022
1023 static dynamic _MethodMirror_owner(reflectee) 1004 static dynamic _MethodMirror_owner(reflectee)
1024 native "MethodMirror_owner"; 1005 native "MethodMirror_owner";
1025 1006
1026 static dynamic _MethodMirror_return_type(reflectee) 1007 static dynamic _MethodMirror_return_type(reflectee)
1027 native "MethodMirror_return_type"; 1008 native "MethodMirror_return_type";
1028 1009
1029 static List<MethodMirror> _MethodMirror_parameters(reflectee) 1010 static List<MethodMirror> _MethodMirror_parameters(reflectee)
1030 native "MethodMirror_parameters"; 1011 native "MethodMirror_parameters";
1031 } 1012 }
1032 1013
1033 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl 1014 class _LocalVariableMirrorImpl extends _LocalDeclarationMirrorImpl
1034 implements VariableMirror { 1015 implements VariableMirror {
1035 _LocalVariableMirrorImpl(reflectee, 1016 _LocalVariableMirrorImpl(reflectee,
1036 String simpleName, 1017 String simpleName,
1037 this._owner, 1018 this._owner,
1038 this._type, 1019 this._type,
1039 this.isStatic, 1020 this.isStatic,
1040 this.isFinal) 1021 this.isFinal)
1041 : this.simpleName = _s(simpleName), 1022 : 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 1023
1054 var _owner; 1024 var _owner;
1055 DeclarationMirror get owner { 1025 DeclarationMirror get owner {
1056 if (_owner is! Mirror) { 1026 if (_owner is! Mirror) {
1057 _owner = _owner.resolve(mirrors); 1027 _owner = _owner.resolve(mirrors);
1058 } 1028 }
1059 return _owner; 1029 return _owner;
1060 } 1030 }
1061 1031
1062 bool get isPrivate { 1032 bool get isPrivate {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
1214 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); 1184 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror");
1215 static ClassMirror reflectClass(Type key) { 1185 static ClassMirror reflectClass(Type key) {
1216 var classMirror = _classMirrorCache[key]; 1186 var classMirror = _classMirrorCache[key];
1217 if (classMirror == null) { 1187 if (classMirror == null) {
1218 classMirror = makeLocalClassMirror(key); 1188 classMirror = makeLocalClassMirror(key);
1219 _classMirrorCache[key] = classMirror; 1189 _classMirrorCache[key] = classMirror;
1220 } 1190 }
1221 return classMirror; 1191 return classMirror;
1222 } 1192 }
1223 } 1193 }
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