Chromium Code Reviews| 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 // 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 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1070 native "VariableMirror_type"; | 1070 native "VariableMirror_type"; |
| 1071 } | 1071 } |
| 1072 | 1072 |
| 1073 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl | 1073 class _LocalParameterMirrorImpl extends _LocalVariableMirrorImpl |
| 1074 implements ParameterMirror { | 1074 implements ParameterMirror { |
| 1075 _LocalParameterMirrorImpl(reflectee, | 1075 _LocalParameterMirrorImpl(reflectee, |
| 1076 String simpleName, | 1076 String simpleName, |
| 1077 DeclarationMirror owner, | 1077 DeclarationMirror owner, |
| 1078 this._position, | 1078 this._position, |
| 1079 this.isOptional, | 1079 this.isOptional, |
| 1080 this.isNamed) | 1080 this.isNamed, |
| 1081 bool isFinal, | |
| 1082 this._defaultValueReflectee) | |
| 1081 : super(reflectee, | 1083 : super(reflectee, |
| 1082 simpleName, | 1084 simpleName, |
| 1083 owner, | 1085 owner, |
| 1084 null, // We override the type. | 1086 null, // We override the type. |
| 1085 false, // isStatic does not apply. | 1087 false, // isStatic does not apply. |
| 1086 false); // TODO(12196): Not yet implemented. | 1088 isFinal); |
| 1087 | 1089 |
| 1088 final int _position; | 1090 final int _position; |
| 1089 final bool isOptional; | 1091 final bool isOptional; |
| 1090 final bool isNamed; | 1092 final bool isNamed; |
| 1091 | 1093 |
| 1092 String get defaultValue { | 1094 Object _defaultValueReflectee; |
| 1093 throw new UnimplementedError( | 1095 InstanceMirror _defaultValue = null; |
| 1094 'ParameterMirror.defaultValue is not implemented'); | 1096 InstanceMirror get defaultValue { |
| 1097 if (_defaultValue == null && isOptional) { | |
| 1098 _defaultValue = reflect(_defaultValueReflectee); | |
| 1099 } | |
|
siva
2013/08/26 05:05:43
Maybe write as:
if (!isOptional) {
return false
Michael Lippautz (Google)
2013/08/26 19:45:57
Rewrote using this pattern, with the difference th
| |
| 1100 return _defaultValue; | |
| 1095 } | 1101 } |
| 1096 | 1102 |
| 1097 bool get hasDefaultValue { | 1103 bool get hasDefaultValue => _defaultValueReflectee != null; |
| 1098 throw new UnimplementedError( | |
| 1099 'ParameterMirror.hasDefaultValue is not implemented'); | |
| 1100 } | |
| 1101 | 1104 |
| 1102 // TODO(11418): Implement. | 1105 // TODO(11418): Implement. |
| 1103 List<InstanceMirror> get metadata { | 1106 List<InstanceMirror> get metadata { |
| 1104 throw new UnimplementedError( | 1107 throw new UnimplementedError( |
| 1105 'ParameterMirror.metadata is not implemented'); | 1108 'ParameterMirror.metadata is not implemented'); |
| 1106 } | 1109 } |
| 1107 | 1110 |
| 1108 TypeMirror _type = null; | 1111 TypeMirror _type = null; |
| 1109 TypeMirror get type { | 1112 TypeMirror get type { |
| 1110 if (_type == null) { | 1113 if (_type == null) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1219 if (typeMirror == null) { | 1222 if (typeMirror == null) { |
| 1220 typeMirror = makeLocalTypeMirror(key); | 1223 typeMirror = makeLocalTypeMirror(key); |
| 1221 _instanitationCache[key] = typeMirror; | 1224 _instanitationCache[key] = typeMirror; |
| 1222 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { | 1225 if (typeMirror is ClassMirror && !typeMirror._isGeneric) { |
| 1223 _declarationCache[key] = typeMirror; | 1226 _declarationCache[key] = typeMirror; |
| 1224 } | 1227 } |
| 1225 } | 1228 } |
| 1226 return typeMirror; | 1229 return typeMirror; |
| 1227 } | 1230 } |
| 1228 } | 1231 } |
| OLD | NEW |