Chromium Code Reviews| Index: runtime/lib/mirrors_impl.dart |
| =================================================================== |
| --- runtime/lib/mirrors_impl.dart (revision 9728) |
| +++ runtime/lib/mirrors_impl.dart (working copy) |
| @@ -125,8 +125,48 @@ |
| return completer.future; |
| } |
| + Future<InstanceMirror> getField(String fieldName) |
| + { |
| + Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| + try { |
| + completer.complete( |
|
turnidge
2012/07/17 23:59:33
Can this fit on one line?
|
| + _getField(this, fieldName)); |
| + } catch (var exception) { |
| + completer.completeException(exception); |
| + } |
| + return completer.future; |
| + } |
| + |
| + Future<InstanceMirror> setField(String fieldName, Object arg) |
| + { |
| + if (arg is Mirror) { |
| + if (arg is! InstanceMirror) { |
| + throw new MirrorException( |
| + 'argument ($arg) was not an InstanceMirror'); |
| + } |
| + } else if (!isSimpleValue(arg)) { |
| + throw new MirrorException( |
| + 'argument ($arg) was not a simple value'); |
|
turnidge
2012/07/17 23:59:33
Maybe make a helper function for arg checking to a
|
| + } |
| + |
| + Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| + try { |
| + completer.complete( |
|
turnidge
2012/07/17 23:59:33
Can this fit on one line?
|
| + _setField(this, fieldName, arg)); |
| + } catch (var exception) { |
| + completer.completeException(exception); |
| + } |
| + return completer.future; |
| + } |
| + |
| static _invoke(ref, memberName, positionalArguments) |
| native 'LocalObjectMirrorImpl_invoke'; |
| + |
| + static _getField(ref, fieldName) |
| + native 'LocalObjectMirrorImpl_getField'; |
| + |
| + static _setField(ref, fieldName, value) |
| + native 'LocalObjectMirrorImpl_setField'; |
| } |
| // Prints a string as it might appear in dart program text. |