| 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 final emptyList = new UnmodifiableListView([]); |
| 10 final emptyMap = new _UnmodifiableMapView({}); |
| 11 |
| 12 // Copied from js_mirrors, in turn copied from the package |
| 13 // "unmodifiable_collection". |
| 14 // TODO(14314): Move to dart:collection. |
| 15 class _UnmodifiableMapView<K, V> implements Map<K, V> { |
| 16 Map<K, V> _source; |
| 17 _UnmodifiableMapView(Map<K, V> source) : _source = source; |
| 18 |
| 19 static void _throw() { |
| 20 throw new UnsupportedError("Cannot modify an unmodifiable Map"); |
| 21 } |
| 22 |
| 23 int get length => _source.length; |
| 24 |
| 25 bool get isEmpty => _source.isEmpty; |
| 26 |
| 27 bool get isNotEmpty => _source.isNotEmpty; |
| 28 |
| 29 V operator [](K key) => _source[key]; |
| 30 |
| 31 bool containsKey(K key) => _source.containsKey(key); |
| 32 |
| 33 bool containsValue(V value) => _source.containsValue(value); |
| 34 |
| 35 void forEach(void f(K key, V value)) => _source.forEach(f); |
| 36 |
| 37 Iterable<K> get keys => _source.keys; |
| 38 |
| 39 Iterable<V> get values => _source.values; |
| 40 |
| 41 void operator []=(K key, V value) => _throw(); |
| 42 |
| 43 V putIfAbsent(K key, V ifAbsent()) { _throw(); } |
| 44 |
| 45 void addAll(Map<K, V> other) => _throw(); |
| 46 |
| 47 V remove(K key) { _throw(); } |
| 48 |
| 49 void clear() => _throw(); |
| 50 } |
| 51 |
| 9 // These values are allowed to be passed directly over the wire. | 52 // These values are allowed to be passed directly over the wire. |
| 10 bool _isSimpleValue(var value) { | 53 bool _isSimpleValue(var value) { |
| 11 return (value == null || value is num || value is String || value is bool); | 54 return (value == null || value is num || value is String || value is bool); |
| 12 } | 55 } |
| 13 | 56 |
| 14 Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) { | 57 Map _filterMap(Map<Symbol, dynamic> old_map, bool filter(Symbol key, value)) { |
| 15 Map new_map = new Map<Symbol, dynamic>(); | 58 Map new_map = new Map<Symbol, dynamic>(); |
| 16 old_map.forEach((key, value) { | 59 old_map.forEach((key, value) { |
| 17 if (filter(key, value)) { | 60 if (filter(key, value)) { |
| 18 new_map[key] = value; | 61 new_map[key] = value; |
| 19 } | 62 } |
| 20 }); | 63 }); |
| 21 return new_map; | 64 return new _UnmodifiableMapView(new_map); |
| 22 } | 65 } |
| 23 | 66 |
| 24 Map _makeMemberMap(List mirrors) => new Map<Symbol, dynamic>.fromIterable( | 67 Map _makeMemberMap(List mirrors) { |
| 25 mirrors, key: (e) => e.simpleName); | 68 return new _UnmodifiableMapView( |
| 69 new Map<Symbol, dynamic>.fromIterable(mirrors, key: (e) => e.simpleName)); |
| 70 } |
| 26 | 71 |
| 27 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); | 72 String _n(Symbol symbol) => _symbol_dev.Symbol.getName(symbol); |
| 28 | 73 |
| 29 Symbol _s(String name) { | 74 Symbol _s(String name) { |
| 30 if (name == null) return null; | 75 if (name == null) return null; |
| 31 return new _symbol_dev.Symbol.unvalidated(name); | 76 return new _symbol_dev.Symbol.unvalidated(name); |
| 32 } | 77 } |
| 33 | 78 |
| 34 Symbol _computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { | 79 Symbol _computeQualifiedName(DeclarationMirror owner, Symbol simpleName) { |
| 35 if (owner == null) return simpleName; | 80 if (owner == null) return simpleName; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 ClassMirror get superclass { | 548 ClassMirror get superclass { |
| 504 return _isMixinTypedef ? _trueSuperclass._trueSuperclass : _trueSuperclass; | 549 return _isMixinTypedef ? _trueSuperclass._trueSuperclass : _trueSuperclass; |
| 505 } | 550 } |
| 506 | 551 |
| 507 var _superinterfaces; | 552 var _superinterfaces; |
| 508 List<ClassMirror> get superinterfaces { | 553 List<ClassMirror> get superinterfaces { |
| 509 if (_superinterfaces == null) { | 554 if (_superinterfaces == null) { |
| 510 _superinterfaces = isOriginalDeclaration | 555 _superinterfaces = isOriginalDeclaration |
| 511 ? _nativeInterfaces(_reflectedType) | 556 ? _nativeInterfaces(_reflectedType) |
| 512 : _nativeInterfacesInstantiated(_reflectedType); | 557 : _nativeInterfacesInstantiated(_reflectedType); |
| 513 _superinterfaces = _superinterfaces | 558 _superinterfaces = |
| 514 .map((i) => reflectType(i)).toList(growable:false); | 559 new UnmodifiableListView(_superinterfaces.map(reflectType)); |
| 515 } | 560 } |
| 516 return _superinterfaces; | 561 return _superinterfaces; |
| 517 } | 562 } |
| 518 | 563 |
| 519 get _mixinApplicationName { | 564 get _mixinApplicationName { |
| 520 var mixins = new List<ClassMirror>(); | 565 var mixins = new List<ClassMirror>(); |
| 521 var klass = this; | 566 var klass = this; |
| 522 while (_nativeMixin(klass._reflectedType) != null) { | 567 while (_nativeMixin(klass._reflectedType) != null) { |
| 523 mixins.add(klass.mixin); | 568 mixins.add(klass.mixin); |
| 524 klass = klass.superclass; | 569 klass = klass.superclass; |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 614 | 659 |
| 615 bool get _isAnonymousMixinApplication { | 660 bool get _isAnonymousMixinApplication { |
| 616 if (_isMixinTypedef) return false; // Named mixin application. | 661 if (_isMixinTypedef) return false; // Named mixin application. |
| 617 if (mixin == this) return false; // Not a mixin application. | 662 if (mixin == this) return false; // Not a mixin application. |
| 618 return true; | 663 return true; |
| 619 } | 664 } |
| 620 | 665 |
| 621 List<TypeVariableMirror> _typeVariables = null; | 666 List<TypeVariableMirror> _typeVariables = null; |
| 622 List<TypeVariableMirror> get typeVariables { | 667 List<TypeVariableMirror> get typeVariables { |
| 623 if (_typeVariables == null) { | 668 if (_typeVariables == null) { |
| 669 if (_isAnonymousMixinApplication) return _typeVariables = emptyList; |
| 624 _typeVariables = new List<TypeVariableMirror>(); | 670 _typeVariables = new List<TypeVariableMirror>(); |
| 625 if (_isAnonymousMixinApplication) return _typeVariables; | |
| 626 | 671 |
| 627 List params = _ClassMirror_type_variables(_reflectee); | 672 List params = _ClassMirror_type_variables(_reflectee); |
| 628 var mirror; | 673 var mirror; |
| 629 for (var i = 0; i < params.length; i += 2) { | 674 for (var i = 0; i < params.length; i += 2) { |
| 630 mirror = new _LocalTypeVariableMirrorImpl( | 675 mirror = new _LocalTypeVariableMirrorImpl( |
| 631 params[i + 1], params[i], this); | 676 params[i + 1], params[i], this); |
| 632 _typeVariables.add(mirror); | 677 _typeVariables.add(mirror); |
| 633 } | 678 } |
| 679 _typeVariables = new UnmodifiableListView(_typeVariables); |
| 634 } | 680 } |
| 635 return _typeVariables; | 681 return _typeVariables; |
| 636 } | 682 } |
| 637 | 683 |
| 638 List<TypeMirror> _typeArguments = null; | 684 List<TypeMirror> _typeArguments = null; |
| 639 List<TypeMirror> get typeArguments { | 685 List<TypeMirror> get typeArguments { |
| 640 if(_typeArguments == null) { | 686 if(_typeArguments == null) { |
| 641 if(_isGenericDeclaration || _isAnonymousMixinApplication) { | 687 if(_isGenericDeclaration || _isAnonymousMixinApplication) { |
| 642 _typeArguments = new List<TypeMirror>(); | 688 _typeArguments = emptyList; |
| 643 } else { | 689 } else { |
| 644 _typeArguments = | 690 _typeArguments = |
| 645 new List<TypeMirror>.from(_computeTypeArguments(_reflectedType)); | 691 new UnmodifiableListView(_computeTypeArguments(_reflectedType)); |
| 646 } | 692 } |
| 647 } | 693 } |
| 648 return _typeArguments; | 694 return _typeArguments; |
| 649 } | 695 } |
| 650 | 696 |
| 651 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; | 697 bool get isOriginalDeclaration => !_isGeneric || _isGenericDeclaration; |
| 652 | 698 |
| 653 ClassMirror get originalDeclaration { | 699 ClassMirror get originalDeclaration { |
| 654 if (isOriginalDeclaration) { | 700 if (isOriginalDeclaration) { |
| 655 return this; | 701 return this; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 693 return new Future(() { | 739 return new Future(() { |
| 694 return this.newInstance(constructorName, | 740 return this.newInstance(constructorName, |
| 695 _unwrapAsyncPositionals(positionalArguments), | 741 _unwrapAsyncPositionals(positionalArguments), |
| 696 _unwrapAsyncNamed(namedArguments)); | 742 _unwrapAsyncNamed(namedArguments)); |
| 697 }); | 743 }); |
| 698 } | 744 } |
| 699 | 745 |
| 700 List<InstanceMirror> get metadata { | 746 List<InstanceMirror> get metadata { |
| 701 // Get the metadata objects, convert them into InstanceMirrors using | 747 // Get the metadata objects, convert them into InstanceMirrors using |
| 702 // reflect() and then make them into a Dart list. | 748 // reflect() and then make them into a Dart list. |
| 703 return _metadata(_reflectee).map(reflect).toList(growable:false); | 749 return new UnmodifiableListView(_metadata(_reflectee).map(reflect)); |
| 704 } | 750 } |
| 705 | 751 |
| 706 bool operator ==(other) { | 752 bool operator ==(other) { |
| 707 return this.runtimeType == other.runtimeType && | 753 return this.runtimeType == other.runtimeType && |
| 708 this._reflectee == other._reflectee && | 754 this._reflectee == other._reflectee && |
| 709 this._reflectedType == other._reflectedType && | 755 this._reflectedType == other._reflectedType && |
| 710 this._isGenericDeclaration == other._isGenericDeclaration; | 756 this._isGenericDeclaration == other._isGenericDeclaration; |
| 711 } | 757 } |
| 712 | 758 |
| 713 int get hashCode => simpleName.hashCode; | 759 int get hashCode => simpleName.hashCode; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 791 return _returnType; | 837 return _returnType; |
| 792 } | 838 } |
| 793 | 839 |
| 794 List<ParameterMirror> _parameters = null; | 840 List<ParameterMirror> _parameters = null; |
| 795 List<ParameterMirror> get parameters { | 841 List<ParameterMirror> get parameters { |
| 796 if (_parameters == null) { | 842 if (_parameters == null) { |
| 797 _parameters = _FunctionTypeMirror_parameters(_reflectee); | 843 _parameters = _FunctionTypeMirror_parameters(_reflectee); |
| 798 _parameters.forEach((p) { | 844 _parameters.forEach((p) { |
| 799 p._type = p.type._instantiateInContextOf(reflectType(_instantiator)); | 845 p._type = p.type._instantiateInContextOf(reflectType(_instantiator)); |
| 800 }); | 846 }); |
| 847 _parameters = new UnmodifiableListView(_parameters); |
| 801 } | 848 } |
| 802 return _parameters; | 849 return _parameters; |
| 803 } | 850 } |
| 804 | 851 |
| 805 bool get isOriginalDeclaration => true; | 852 bool get isOriginalDeclaration => true; |
| 806 get originalDeclaration => this; | 853 get originalDeclaration => this; |
| 807 get typeVariables => []; | 854 get typeVariables => emptyList; |
| 808 get typeArguments => []; | 855 get typeArguments => emptyList; |
| 809 get metadata => []; | 856 get metadata => emptyList; |
| 810 | 857 Map<Symbol, Mirror> get members => emptyMap; |
| 811 Map<Symbol, Mirror> get members => new Map<Symbol,Mirror>(); | 858 Map<Symbol, MethodMirror> get constructors => emptyMap; |
| 812 Map<Symbol, MethodMirror> get constructors => new Map<Symbol,MethodMirror>(); | |
| 813 | 859 |
| 814 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; | 860 String toString() => "FunctionTypeMirror on '${_n(simpleName)}'"; |
| 815 | 861 |
| 816 MethodMirror _FunctionTypeMirror_call_method(reflectee) | 862 MethodMirror _FunctionTypeMirror_call_method(reflectee) |
| 817 native "FunctionTypeMirror_call_method"; | 863 native "FunctionTypeMirror_call_method"; |
| 818 | 864 |
| 819 static Type _FunctionTypeMirror_return_type(reflectee) | 865 static Type _FunctionTypeMirror_return_type(reflectee) |
| 820 native "FunctionTypeMirror_return_type"; | 866 native "FunctionTypeMirror_return_type"; |
| 821 | 867 |
| 822 List<ParameterMirror> _FunctionTypeMirror_parameters(reflectee) | 868 List<ParameterMirror> _FunctionTypeMirror_parameters(reflectee) |
| (...skipping 13 matching lines...) Expand all Loading... |
| 836 Symbol get qualifiedName { | 882 Symbol get qualifiedName { |
| 837 if (_qualifiedName == null) { | 883 if (_qualifiedName == null) { |
| 838 _qualifiedName = _computeQualifiedName(owner, simpleName); | 884 _qualifiedName = _computeQualifiedName(owner, simpleName); |
| 839 } | 885 } |
| 840 return _qualifiedName; | 886 return _qualifiedName; |
| 841 } | 887 } |
| 842 | 888 |
| 843 List<InstanceMirror> get metadata { | 889 List<InstanceMirror> get metadata { |
| 844 // Get the metadata objects, convert them into InstanceMirrors using | 890 // Get the metadata objects, convert them into InstanceMirrors using |
| 845 // reflect() and then make them into a Dart list. | 891 // reflect() and then make them into a Dart list. |
| 846 return _metadata(_reflectee).map(reflect).toList(growable:false); | 892 return new UnmodifiableListView(_metadata(_reflectee).map(reflect)); |
| 847 } | 893 } |
| 848 | 894 |
| 849 bool operator ==(other) { | 895 bool operator ==(other) { |
| 850 return this.runtimeType == other.runtimeType && | 896 return this.runtimeType == other.runtimeType && |
| 851 this._reflectee == other._reflectee; | 897 this._reflectee == other._reflectee; |
| 852 } | 898 } |
| 853 | 899 |
| 854 int get hashCode => simpleName.hashCode; | 900 int get hashCode => simpleName.hashCode; |
| 855 } | 901 } |
| 856 | 902 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 882 TypeMirror get upperBound { | 928 TypeMirror get upperBound { |
| 883 if (_upperBound == null) { | 929 if (_upperBound == null) { |
| 884 _upperBound = reflectType(_TypeVariableMirror_upper_bound(_reflectee)); | 930 _upperBound = reflectType(_TypeVariableMirror_upper_bound(_reflectee)); |
| 885 } | 931 } |
| 886 return _upperBound; | 932 return _upperBound; |
| 887 } | 933 } |
| 888 | 934 |
| 889 bool get hasReflectedType => false; | 935 bool get hasReflectedType => false; |
| 890 Type get reflectedType => throw new UnsupportedError() ; | 936 Type get reflectedType => throw new UnsupportedError() ; |
| 891 | 937 |
| 892 List<TypeVariableMirror> get typeVariables => new UnmodifiableListView<TypeVar
iableMirror>(); | 938 List<TypeVariableMirror> get typeVariables => emptyList; |
| 893 List<TypeMirror> get typeArguments => new UnmodifiableListView<TypeMirror>(); | 939 List<TypeMirror> get typeArguments => emptyList; |
| 894 | 940 |
| 895 bool get isOriginalDeclaration => true; | 941 bool get isOriginalDeclaration => true; |
| 896 TypeMirror get originalDeclaration => this; | 942 TypeMirror get originalDeclaration => this; |
| 897 | 943 |
| 898 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; | 944 String toString() => "TypeVariableMirror on '${_n(simpleName)}'"; |
| 899 | 945 |
| 900 operator ==(other) { | 946 operator ==(other) { |
| 901 return other is TypeVariableMirror | 947 return other is TypeVariableMirror |
| 902 && simpleName == other.simpleName | 948 && simpleName == other.simpleName |
| 903 && owner == other.owner; | 949 && owner == other.owner; |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 988 _typeVariables.add(mirror); | 1034 _typeVariables.add(mirror); |
| 989 } | 1035 } |
| 990 } | 1036 } |
| 991 return _typeVariables; | 1037 return _typeVariables; |
| 992 } | 1038 } |
| 993 | 1039 |
| 994 List<TypeMirror> _typeArguments = null; | 1040 List<TypeMirror> _typeArguments = null; |
| 995 List<TypeMirror> get typeArguments { | 1041 List<TypeMirror> get typeArguments { |
| 996 if(_typeArguments == null) { | 1042 if(_typeArguments == null) { |
| 997 if(_isGenericDeclaration) { | 1043 if(_isGenericDeclaration) { |
| 998 _typeArguments = new List<TypeMirror>(); | 1044 _typeArguments = emptyList; |
| 999 } else { | 1045 } else { |
| 1000 _typeArguments = | 1046 _typeArguments = new UnmodifiableListView( |
| 1001 new List<TypeMirror>.from(_LocalClassMirrorImpl._computeTypeArgument
s(_reflectedType)); | 1047 _LocalClassMirrorImpl._computeTypeArguments(_reflectedType)); |
| 1002 } | 1048 } |
| 1003 } | 1049 } |
| 1004 return _typeArguments; | 1050 return _typeArguments; |
| 1005 } | 1051 } |
| 1006 | 1052 |
| 1007 TypeMirror _instantiateInContextOf(declaration) { | 1053 TypeMirror _instantiateInContextOf(declaration) { |
| 1008 var instantiator = declaration; | 1054 var instantiator = declaration; |
| 1009 while (instantiator is MethodMirror) instantiator = instantiator.owner; | 1055 while (instantiator is MethodMirror) instantiator = instantiator.owner; |
| 1010 if (instantiator is LibraryMirror) return this; | 1056 if (instantiator is LibraryMirror) return this; |
| 1011 if (!(instantiator is ClassMirror || instantiator is TypedefMirror)) | 1057 if (!(instantiator is ClassMirror || instantiator is TypedefMirror)) |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1068 Map<Symbol, TypeMirror> get types { | 1114 Map<Symbol, TypeMirror> get types { |
| 1069 if (_types == null) { | 1115 if (_types == null) { |
| 1070 _types = _filterMap(members, (key, value) => (value is TypeMirror)); | 1116 _types = _filterMap(members, (key, value) => (value is TypeMirror)); |
| 1071 } | 1117 } |
| 1072 return _types; | 1118 return _types; |
| 1073 } | 1119 } |
| 1074 | 1120 |
| 1075 Map<Symbol, ClassMirror> _classes; | 1121 Map<Symbol, ClassMirror> _classes; |
| 1076 Map<Symbol, ClassMirror> get classes { | 1122 Map<Symbol, ClassMirror> get classes { |
| 1077 if (_classes == null) { | 1123 if (_classes == null) { |
| 1078 _classes = _filterMap(members, | 1124 _classes = _filterMap(members, (key, value) => (value is ClassMirror)); |
| 1079 (key, value) => (value is ClassMirror)); | |
| 1080 } | 1125 } |
| 1081 return _classes; | 1126 return _classes; |
| 1082 } | 1127 } |
| 1083 | 1128 |
| 1084 Map<Symbol, MethodMirror> _functions; | 1129 Map<Symbol, MethodMirror> _functions; |
| 1085 Map<Symbol, MethodMirror> get functions { | 1130 Map<Symbol, MethodMirror> get functions { |
| 1086 if (_functions == null) { | 1131 if (_functions == null) { |
| 1087 _functions = _filterMap(members, (key, value) => (value is MethodMirror)); | 1132 _functions = _filterMap(members, (key, value) => (value is MethodMirror)); |
| 1088 } | 1133 } |
| 1089 return _functions; | 1134 return _functions; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1110 if (_variables == null) { | 1155 if (_variables == null) { |
| 1111 _variables = _filterMap(members, | 1156 _variables = _filterMap(members, |
| 1112 (key, value) => (value is VariableMirror)); | 1157 (key, value) => (value is VariableMirror)); |
| 1113 } | 1158 } |
| 1114 return _variables; | 1159 return _variables; |
| 1115 } | 1160 } |
| 1116 | 1161 |
| 1117 List<InstanceMirror> get metadata { | 1162 List<InstanceMirror> get metadata { |
| 1118 // Get the metadata objects, convert them into InstanceMirrors using | 1163 // Get the metadata objects, convert them into InstanceMirrors using |
| 1119 // reflect() and then make them into a Dart list. | 1164 // reflect() and then make them into a Dart list. |
| 1120 return _metadata(_reflectee).map(reflect).toList(growable:false); | 1165 return new UnmodifiableListView(_metadata(_reflectee).map(reflect)); |
| 1121 } | 1166 } |
| 1122 | 1167 |
| 1123 bool operator ==(other) { | 1168 bool operator ==(other) { |
| 1124 return this.runtimeType == other.runtimeType && | 1169 return this.runtimeType == other.runtimeType && |
| 1125 this._reflectee == other._reflectee; | 1170 this._reflectee == other._reflectee; |
| 1126 } | 1171 } |
| 1127 | 1172 |
| 1128 int get hashCode => simpleName.hashCode; | 1173 int get hashCode => simpleName.hashCode; |
| 1129 | 1174 |
| 1130 String toString() => "LibraryMirror on '${_n(simpleName)}'"; | 1175 String toString() => "LibraryMirror on '${_n(simpleName)}'"; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 } | 1247 } |
| 1203 _returnType = _returnType._instantiateInContextOf(owner); | 1248 _returnType = _returnType._instantiateInContextOf(owner); |
| 1204 } | 1249 } |
| 1205 return _returnType; | 1250 return _returnType; |
| 1206 } | 1251 } |
| 1207 | 1252 |
| 1208 List<ParameterMirror> _parameters = null; | 1253 List<ParameterMirror> _parameters = null; |
| 1209 List<ParameterMirror> get parameters { | 1254 List<ParameterMirror> get parameters { |
| 1210 if (_parameters == null) { | 1255 if (_parameters == null) { |
| 1211 _parameters = _MethodMirror_parameters(_reflectee); | 1256 _parameters = _MethodMirror_parameters(_reflectee); |
| 1257 _parameters = new UnmodifiableListView(_parameters); |
| 1212 } | 1258 } |
| 1213 return _parameters; | 1259 return _parameters; |
| 1214 } | 1260 } |
| 1215 | 1261 |
| 1216 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; | 1262 bool get isRegularMethod => !isGetter && !isSetter && !isConstructor; |
| 1217 | 1263 |
| 1218 Symbol _constructorName = null; | 1264 Symbol _constructorName = null; |
| 1219 Symbol get constructorName { | 1265 Symbol get constructorName { |
| 1220 if (_constructorName == null) { | 1266 if (_constructorName == null) { |
| 1221 if (!isConstructor) { | 1267 if (!isConstructor) { |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 } | 1383 } |
| 1338 if (_defaultValue == null) { | 1384 if (_defaultValue == null) { |
| 1339 _defaultValue = reflect(_defaultValueReflectee); | 1385 _defaultValue = reflect(_defaultValueReflectee); |
| 1340 } | 1386 } |
| 1341 return _defaultValue; | 1387 return _defaultValue; |
| 1342 } | 1388 } |
| 1343 | 1389 |
| 1344 bool get hasDefaultValue => _defaultValueReflectee != null; | 1390 bool get hasDefaultValue => _defaultValueReflectee != null; |
| 1345 | 1391 |
| 1346 List<InstanceMirror> get metadata { | 1392 List<InstanceMirror> get metadata { |
| 1347 if ( _unmirroredMetadata == null) return const []; | 1393 if ( _unmirroredMetadata == null) return emptyList; |
| 1348 return _unmirroredMetadata.map(reflect).toList(growable:false); | 1394 return new UnmodifiableListView(_unmirroredMetadata.map(reflect)); |
| 1349 } | 1395 } |
| 1350 | 1396 |
| 1351 TypeMirror _type = null; | 1397 TypeMirror _type = null; |
| 1352 TypeMirror get type { | 1398 TypeMirror get type { |
| 1353 if (_type == null) { | 1399 if (_type == null) { |
| 1354 _type = reflectType(_ParameterMirror_type(_reflectee, _position)); | 1400 _type = reflectType(_ParameterMirror_type(_reflectee, _position)); |
| 1355 _type = _type._instantiateInContextOf(owner); | 1401 _type = _type._instantiateInContextOf(owner); |
| 1356 } | 1402 } |
| 1357 return _type; | 1403 return _type; |
| 1358 } | 1404 } |
| 1359 | 1405 |
| 1360 String toString() => "ParameterMirror on '${_n(simpleName)}'"; | 1406 String toString() => "ParameterMirror on '${_n(simpleName)}'"; |
| 1361 | 1407 |
| 1362 static Type _ParameterMirror_type(_reflectee, _position) | 1408 static Type _ParameterMirror_type(_reflectee, _position) |
| 1363 native "ParameterMirror_type"; | 1409 native "ParameterMirror_type"; |
| 1364 } | 1410 } |
| 1365 | 1411 |
| 1366 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl | 1412 class _SpecialTypeMirrorImpl extends _LocalMirrorImpl |
| 1367 implements TypeMirror, DeclarationMirror { | 1413 implements TypeMirror, DeclarationMirror { |
| 1368 _SpecialTypeMirrorImpl(String name) : simpleName = _s(name); | 1414 _SpecialTypeMirrorImpl(String name) : simpleName = _s(name); |
| 1369 | 1415 |
| 1370 final bool isPrivate = false; | 1416 final bool isPrivate = false; |
| 1371 final DeclarationMirror owner = null; | 1417 final DeclarationMirror owner = null; |
| 1372 final Symbol simpleName; | 1418 final Symbol simpleName; |
| 1373 final bool isTopLevel = true; | 1419 final bool isTopLevel = true; |
| 1374 // Fixed length 0, therefore immutable. | 1420 // Fixed length 0, therefore immutable. |
| 1375 final List<InstanceMirror> metadata = new List(0); | 1421 final List<InstanceMirror> metadata = emptyList; |
| 1376 | 1422 |
| 1377 SourceLocation get location { | 1423 SourceLocation get location { |
| 1378 throw new UnimplementedError('TypeMirror.location is not implemented'); | 1424 throw new UnimplementedError('TypeMirror.location is not implemented'); |
| 1379 } | 1425 } |
| 1380 | 1426 |
| 1381 Symbol get qualifiedName => simpleName; | 1427 Symbol get qualifiedName => simpleName; |
| 1382 | 1428 |
| 1383 // TODO(11955): Remove once dynamicType and voidType are canonical objects in | 1429 // TODO(11955): Remove once dynamicType and voidType are canonical objects in |
| 1384 // the object store. | 1430 // the object store. |
| 1385 bool operator ==(other) { | 1431 bool operator ==(other) { |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1461 if (typeMirror == null) { | 1507 if (typeMirror == null) { |
| 1462 typeMirror = makeLocalTypeMirror(key); | 1508 typeMirror = makeLocalTypeMirror(key); |
| 1463 _instanitationCache[key] = typeMirror; | 1509 _instanitationCache[key] = typeMirror; |
| 1464 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1510 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1465 _declarationCache[key] = typeMirror; | 1511 _declarationCache[key] = typeMirror; |
| 1466 } | 1512 } |
| 1467 } | 1513 } |
| 1468 return typeMirror; | 1514 return typeMirror; |
| 1469 } | 1515 } |
| 1470 } | 1516 } |
| OLD | NEW |