| 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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 _n(memberName), | 187 _n(memberName), |
| 188 positionalArguments.toList(growable:false))); | 188 positionalArguments.toList(growable:false))); |
| 189 } | 189 } |
| 190 | 190 |
| 191 InstanceMirror getField(Symbol memberName) { | 191 InstanceMirror getField(Symbol memberName) { |
| 192 return reflect(this._invokeGetter(_reflectee, | 192 return reflect(this._invokeGetter(_reflectee, |
| 193 _n(memberName))); | 193 _n(memberName))); |
| 194 } | 194 } |
| 195 | 195 |
| 196 InstanceMirror setField(Symbol memberName, Object value) { | 196 InstanceMirror setField(Symbol memberName, Object value) { |
| 197 return reflect(this._invokeSetter(_reflectee, | 197 this._invokeSetter(_reflectee, |
| 198 _n(memberName), | 198 _n(memberName), |
| 199 value)); | 199 value); |
| 200 return reflect(value); |
| 200 } | 201 } |
| 201 | 202 |
| 202 Future<InstanceMirror> invokeAsync(Symbol memberName, | 203 Future<InstanceMirror> invokeAsync(Symbol memberName, |
| 203 List positionalArguments, | 204 List positionalArguments, |
| 204 [Map<Symbol, dynamic> namedArguments]) { | 205 [Map<Symbol, dynamic> namedArguments]) { |
| 205 if (namedArguments != null) { | 206 if (namedArguments != null) { |
| 206 throw new UnimplementedError( | 207 throw new UnimplementedError( |
| 207 'named argument support is not implemented'); | 208 'named argument support is not implemented'); |
| 208 } | 209 } |
| 209 | 210 |
| (...skipping 22 matching lines...) Expand all Loading... |
| 232 var unwrappedValue; | 233 var unwrappedValue; |
| 233 if(_isSimpleValue(value)) { | 234 if(_isSimpleValue(value)) { |
| 234 unwrappedValue = value; | 235 unwrappedValue = value; |
| 235 } else if(value is InstanceMirror) { | 236 } else if(value is InstanceMirror) { |
| 236 unwrappedValue = value._reflectee; | 237 unwrappedValue = value._reflectee; |
| 237 } else { | 238 } else { |
| 238 throw "setter argument ($value) must be" | 239 throw "setter argument ($value) must be" |
| 239 "a simple value or InstanceMirror"; | 240 "a simple value or InstanceMirror"; |
| 240 } | 241 } |
| 241 | 242 |
| 242 var result = this._invokeSetter(_reflectee, | 243 this._invokeSetter(_reflectee, |
| 243 _n(memberName), | 244 _n(memberName), |
| 244 unwrappedValue); | 245 unwrappedValue); |
| 245 return new Future.value(reflect(result)); | 246 return new Future.value(reflect(unwrappedValue)); |
| 246 } catch(e) { | 247 } catch(e) { |
| 247 return new Future.error(e); | 248 return new Future.error(e); |
| 248 } | 249 } |
| 249 } | 250 } |
| 250 | 251 |
| 251 static _validateArgument(int i, Object arg) | 252 static _validateArgument(int i, Object arg) |
| 252 { | 253 { |
| 253 if (arg is Mirror) { | 254 if (arg is Mirror) { |
| 254 if (arg is! InstanceMirror) { | 255 if (arg is! InstanceMirror) { |
| 255 throw new MirrorException( | 256 throw new MirrorException( |
| (...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); | 1203 static Expando<ClassMirror> _classMirrorCache = new Expando("ClassMirror"); |
| 1203 static ClassMirror reflectClass(Type key) { | 1204 static ClassMirror reflectClass(Type key) { |
| 1204 var classMirror = _classMirrorCache[key]; | 1205 var classMirror = _classMirrorCache[key]; |
| 1205 if (classMirror == null) { | 1206 if (classMirror == null) { |
| 1206 classMirror = makeLocalClassMirror(key); | 1207 classMirror = makeLocalClassMirror(key); |
| 1207 _classMirrorCache[key] = classMirror; | 1208 _classMirrorCache[key] = classMirror; |
| 1208 } | 1209 } |
| 1209 return classMirror; | 1210 return classMirror; |
| 1210 } | 1211 } |
| 1211 } | 1212 } |
| OLD | NEW |