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

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

Issue 23224016: Implement ParameterMirror.metadata. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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
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 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 1073 matching lines...) Expand 10 before | Expand all | Expand 10 after
1084 1084
1085 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl 1085 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl
1086 implements ParameterMirror { 1086 implements ParameterMirror {
1087 _LocalParameterMirrorImpl(reflectee, 1087 _LocalParameterMirrorImpl(reflectee,
1088 String simpleName, 1088 String simpleName,
1089 DeclarationMirror owner, 1089 DeclarationMirror owner,
1090 this._position, 1090 this._position,
1091 this.isOptional, 1091 this.isOptional,
1092 this.isNamed, 1092 this.isNamed,
1093 bool isFinal, 1093 bool isFinal,
1094 this._defaultValueReflectee) 1094 this._defaultValueReflectee,
1095 this._unmirroredMetadata)
1095 : super(reflectee, 1096 : super(reflectee,
1096 simpleName, 1097 simpleName,
1097 owner, 1098 owner,
1098 null, // We override the type. 1099 null, // We override the type.
1099 false, // isStatic does not apply. 1100 false, // isStatic does not apply.
1100 isFinal); 1101 isFinal);
1101 1102
1102 final int _position; 1103 final int _position;
1103 final bool isOptional; 1104 final bool isOptional;
1104 final bool isNamed; 1105 final bool isNamed;
1106 final List _unmirroredMetadata;
1105 1107
1106 Object _defaultValueReflectee; 1108 Object _defaultValueReflectee;
1107 InstanceMirror _defaultValue; 1109 InstanceMirror _defaultValue;
1108 InstanceMirror get defaultValue { 1110 InstanceMirror get defaultValue {
1109 if (!isOptional) { 1111 if (!isOptional) {
1110 return null; 1112 return null;
1111 } 1113 }
1112 if (_defaultValue == null) { 1114 if (_defaultValue == null) {
1113 _defaultValue = reflect(_defaultValueReflectee); 1115 _defaultValue = reflect(_defaultValueReflectee);
1114 } 1116 }
1115 return _defaultValue; 1117 return _defaultValue;
1116 } 1118 }
1117 1119
1118 bool get hasDefaultValue => _defaultValueReflectee != null; 1120 bool get hasDefaultValue => _defaultValueReflectee != null;
1119 1121
1120 // TODO(11418): Implement.
1121 List<InstanceMirror> get metadata { 1122 List<InstanceMirror> get metadata {
1122 throw new UnimplementedError( 1123 if ( _unmirroredMetadata == null) return const [];
1123 'ParameterMirror.metadata is not implemented'); 1124 return _unmirroredMetadata.map(reflect).toList(growable:false);
1124 } 1125 }
1125 1126
1126 TypeMirror _type = null; 1127 TypeMirror _type = null;
1127 TypeMirror get type { 1128 TypeMirror get type {
1128 if (_type == null) { 1129 if (_type == null) {
1129 _type = 1130 _type =
1130 _Mirrors._reflectType(_ParameterMirror_type(_reflectee, _position)); 1131 _Mirrors._reflectType(_ParameterMirror_type(_reflectee, _position));
1131 } 1132 }
1132 return _type; 1133 return _type;
1133 } 1134 }
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
1237 if (typeMirror == null) { 1238 if (typeMirror == null) {
1238 typeMirror = makeLocalTypeMirror(key); 1239 typeMirror = makeLocalTypeMirror(key);
1239 _instanitationCache[key] = typeMirror; 1240 _instanitationCache[key] = typeMirror;
1240 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { 1241 if (typeMirror is ClassMirror && !typeMirror._isGeneric) {
1241 _declarationCache[key] = typeMirror; 1242 _declarationCache[key] = typeMirror;
1242 } 1243 }
1243 } 1244 }
1244 return typeMirror; 1245 return typeMirror;
1245 } 1246 }
1246 } 1247 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698