| 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 // 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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 return mirrors.libraries[Uri.parse(libraryUrl)]; | 786 return mirrors.libraries[Uri.parse(libraryUrl)]; |
| 787 } | 787 } |
| 788 | 788 |
| 789 final String libraryUrl; | 789 final String libraryUrl; |
| 790 } | 790 } |
| 791 | 791 |
| 792 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl | 792 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl |
| 793 implements LibraryMirror { | 793 implements LibraryMirror { |
| 794 _LocalLibraryMirrorImpl(reflectee, | 794 _LocalLibraryMirrorImpl(reflectee, |
| 795 String simpleName, | 795 String simpleName, |
| 796 String url, | 796 String url) |
| 797 Map<String, Mirror> members) | |
| 798 : this.simpleName = _s(simpleName), | 797 : this.simpleName = _s(simpleName), |
| 799 this.members = _convertStringToSymbolMap(members), | |
| 800 this.uri = Uri.parse(url), | 798 this.uri = Uri.parse(url), |
| 801 super(reflectee); | 799 super(reflectee); |
| 802 | 800 |
| 803 final Symbol simpleName; | 801 final Symbol simpleName; |
| 804 | 802 |
| 805 // The simple name and the qualified name are the same for a library. | 803 // The simple name and the qualified name are the same for a library. |
| 806 Symbol get qualifiedName => simpleName; | 804 Symbol get qualifiedName => simpleName; |
| 807 | 805 |
| 808 // Always null for libraries. | 806 // Always null for libraries. |
| 809 final DeclarationMirror owner = null; | 807 final DeclarationMirror owner = null; |
| 810 | 808 |
| 811 // Always false for libraries. | 809 // Always false for libraries. |
| 812 final bool isPrivate = false; | 810 final bool isPrivate = false; |
| 813 | 811 |
| 814 // Always false for libraries. | 812 // Always false for libraries. |
| 815 final bool isTopLevel = false; | 813 final bool isTopLevel = false; |
| 816 | 814 |
| 817 SourceLocation get location { | 815 SourceLocation get location { |
| 818 throw new UnimplementedError( | 816 throw new UnimplementedError( |
| 819 'LibraryMirror.location is not implemented'); | 817 'LibraryMirror.location is not implemented'); |
| 820 } | 818 } |
| 821 | 819 |
| 822 final Uri uri; | 820 final Uri uri; |
| 823 final Map<Symbol, Mirror> members; | 821 |
| 822 Map<Symbol, Mirror> _members; |
| 823 |
| 824 Map<Symbol, Mirror> get members { |
| 825 if (_members == null) { |
| 826 _members = _makeMemberMap(_computeMembers(_reflectee)); |
| 827 } |
| 828 return _members; |
| 829 } |
| 824 | 830 |
| 825 Map<Symbol, ClassMirror> _classes = null; | 831 Map<Symbol, ClassMirror> _classes = null; |
| 826 Map<Symbol, MethodMirror> _functions = null; | 832 Map<Symbol, MethodMirror> _functions = null; |
| 827 Map<Symbol, MethodMirror> _getters = null; | 833 Map<Symbol, MethodMirror> _getters = null; |
| 828 Map<Symbol, MethodMirror> _setters = null; | 834 Map<Symbol, MethodMirror> _setters = null; |
| 829 Map<Symbol, VariableMirror> _variables = null; | 835 Map<Symbol, VariableMirror> _variables = null; |
| 830 | 836 |
| 831 Map<Symbol, ClassMirror> get classes { | 837 Map<Symbol, ClassMirror> get classes { |
| 832 if (_classes == null) { | 838 if (_classes == null) { |
| 833 _classes = _filterMap(members, | 839 _classes = _filterMap(members, |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 877 String toString() => "LibraryMirror on '${_n(simpleName)}'"; | 883 String toString() => "LibraryMirror on '${_n(simpleName)}'"; |
| 878 | 884 |
| 879 _invoke(reflectee, memberName, positionalArguments) | 885 _invoke(reflectee, memberName, positionalArguments) |
| 880 native 'LibraryMirror_invoke'; | 886 native 'LibraryMirror_invoke'; |
| 881 | 887 |
| 882 _invokeGetter(reflectee, getterName) | 888 _invokeGetter(reflectee, getterName) |
| 883 native 'LibraryMirror_invokeGetter'; | 889 native 'LibraryMirror_invokeGetter'; |
| 884 | 890 |
| 885 _invokeSetter(reflectee, setterName, value) | 891 _invokeSetter(reflectee, setterName, value) |
| 886 native 'LibraryMirror_invokeSetter'; | 892 native 'LibraryMirror_invokeSetter'; |
| 893 |
| 894 _computeMembers(reflectee) |
| 895 native "LibraryMirror_members"; |
| 887 } | 896 } |
| 888 | 897 |
| 889 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl | 898 class _LocalMethodMirrorImpl extends _LocalDeclarationMirrorImpl |
| 890 implements MethodMirror { | 899 implements MethodMirror { |
| 891 _LocalMethodMirrorImpl(reflectee, | 900 _LocalMethodMirrorImpl(reflectee, |
| 892 this._owner, | 901 this._owner, |
| 893 this.parameters, | 902 this.parameters, |
| 894 this.isStatic, | 903 this.isStatic, |
| 895 this.isAbstract, | 904 this.isAbstract, |
| 896 this.isGetter, | 905 this.isGetter, |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1193 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); | 1202 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); |
| 1194 static ClassMirror reflectClass(Type key) { | 1203 static ClassMirror reflectClass(Type key) { |
| 1195 var classMirror = _classMirrorCache[key]; | 1204 var classMirror = _classMirrorCache[key]; |
| 1196 if (classMirror == null) { | 1205 if (classMirror == null) { |
| 1197 classMirror = makeLocalClassMirror(key); | 1206 classMirror = makeLocalClassMirror(key); |
| 1198 _classMirrorCache[key] = classMirror; | 1207 _classMirrorCache[key] = classMirror; |
| 1199 } | 1208 } |
| 1200 return classMirror; | 1209 return classMirror; |
| 1201 } | 1210 } |
| 1202 } | 1211 } |
| OLD | NEW |