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 // 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 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 132 // For now, all VMObjects hold a VMReference. We could consider | 132 // For now, all VMObjects hold a VMReference. We could consider |
| 133 // storing the Object reference itself here if the object is a Dart | 133 // storing the Object reference itself here if the object is a Dart |
| 134 // language objects (except for objects of type VMReference, of | 134 // language objects (except for objects of type VMReference, of |
| 135 // course). | 135 // course). |
| 136 VMReference _reference; | 136 VMReference _reference; |
| 137 } | 137 } |
| 138 | 138 |
| 139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl | 139 abstract class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl |
| 140 implements ObjectMirror { | 140 implements ObjectMirror { |
| 141 _LocalObjectMirrorImpl(ref) : super(ref) {} | 141 _LocalObjectMirrorImpl(ref) : super(ref) {} |
| 142 | 142 |
| 143 Future<InstanceMirror> invoke(String memberName, | 143 Future<InstanceMirror> invokeAsync(String memberName, |
| 144 List positionalArguments, | 144 List positionalArguments, |
| 145 [Map<String,dynamic> namedArguments]) { | 145 [Map<String,dynamic> namedArguments]) { |
| 146 if (namedArguments != null) { | 146 if (namedArguments != null) { |
| 147 throw new UnimplementedError( | 147 throw new UnimplementedError( |
| 148 'named argument support is not implemented'); | 148 'named argument support is not implemented'); |
| 149 } | 149 } |
| 150 // Walk the arguments and make sure they are legal. | 150 // Walk the arguments and make sure they are legal. |
| 151 for (int i = 0; i < positionalArguments.length; i++) { | 151 for (int i = 0; i < positionalArguments.length; i++) { |
| 152 var arg = positionalArguments[i]; | 152 var arg = positionalArguments[i]; |
| 153 _validateArgument(i, arg); | 153 _validateArgument(i, arg); |
| 154 } | 154 } |
| 155 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 155 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| 156 try { | 156 try { |
| 157 completer.complete( | 157 completer.complete( |
| 158 _invoke(this, memberName, positionalArguments)); | 158 _invoke(this, memberName, positionalArguments)); |
| 159 } catch (exception, s) { | 159 } catch (exception, s) { |
| 160 completer.completeError(exception, s); | 160 completer.completeError(exception, s); |
| 161 } | 161 } |
| 162 return completer.future; | 162 return completer.future; |
| 163 } | 163 } |
| 164 | 164 |
| 165 Future<InstanceMirror> getField(String fieldName) | 165 Future<InstanceMirror> getFieldAsync(String fieldName) |
| 166 { | 166 { |
|
ahe
2013/04/10 05:52:22
Open curly brace on previous line
| |
| 167 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 167 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| 168 try { | 168 try { |
| 169 completer.complete(_getField(this, fieldName)); | 169 completer.complete(_getField(this, fieldName)); |
| 170 } catch (exception, s) { | 170 } catch (exception, s) { |
| 171 completer.completeError(exception, s); | 171 completer.completeError(exception, s); |
| 172 } | 172 } |
| 173 return completer.future; | 173 return completer.future; |
| 174 } | 174 } |
| 175 | 175 |
| 176 Future<InstanceMirror> setField(String fieldName, Object arg) | 176 Future<InstanceMirror> setFieldAsync(String fieldName, Object arg) |
| 177 { | 177 { |
|
ahe
2013/04/10 05:52:22
Ditto.
| |
| 178 _validateArgument(0, arg); | 178 _validateArgument(0, arg); |
| 179 | 179 |
| 180 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 180 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| 181 try { | 181 try { |
| 182 completer.complete(_setField(this, fieldName, arg)); | 182 completer.complete(_setField(this, fieldName, arg)); |
| 183 } catch (exception, s) { | 183 } catch (exception, s) { |
| 184 completer.completeError(exception, s); | 184 completer.completeError(exception, s); |
| 185 } | 185 } |
| 186 return completer.future; | 186 return completer.future; |
| 187 } | 187 } |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 298 reflectee, | 298 reflectee, |
| 299 this.function) : super(ref, type, reflectee) {} | 299 this.function) : super(ref, type, reflectee) {} |
| 300 | 300 |
| 301 final MethodMirror function; | 301 final MethodMirror function; |
| 302 | 302 |
| 303 String get source { | 303 String get source { |
| 304 throw new UnimplementedError( | 304 throw new UnimplementedError( |
| 305 'ClosureMirror.source is not implemented'); | 305 'ClosureMirror.source is not implemented'); |
| 306 } | 306 } |
| 307 | 307 |
| 308 Future<InstanceMirror> apply(List<Object> positionalArguments, | 308 Future<InstanceMirror> applyAsync(List<Object> positionalArguments, |
| 309 [Map<String,Object> namedArguments]) { | 309 [Map<String,Object> namedArguments]) { |
| 310 if (namedArguments != null) { | 310 if (namedArguments != null) { |
| 311 throw new UnimplementedError( | 311 throw new UnimplementedError( |
| 312 'named argument support is not implemented'); | 312 'named argument support is not implemented'); |
| 313 } | 313 } |
| 314 // Walk the arguments and make sure they are legal. | 314 // Walk the arguments and make sure they are legal. |
| 315 for (int i = 0; i < positionalArguments.length; i++) { | 315 for (int i = 0; i < positionalArguments.length; i++) { |
| 316 var arg = positionalArguments[i]; | 316 var arg = positionalArguments[i]; |
| 317 _LocalObjectMirrorImpl._validateArgument(i, arg); | 317 _LocalObjectMirrorImpl._validateArgument(i, arg); |
| 318 } | 318 } |
| 319 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 319 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| (...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 494 'ClassMirror.isOriginalDeclaration is not implemented'); | 494 'ClassMirror.isOriginalDeclaration is not implemented'); |
| 495 } | 495 } |
| 496 | 496 |
| 497 ClassMirror get genericDeclaration { | 497 ClassMirror get genericDeclaration { |
| 498 throw new UnimplementedError( | 498 throw new UnimplementedError( |
| 499 'ClassMirror.originalDeclaration is not implemented'); | 499 'ClassMirror.originalDeclaration is not implemented'); |
| 500 } | 500 } |
| 501 | 501 |
| 502 String toString() => "ClassMirror on '$simpleName'"; | 502 String toString() => "ClassMirror on '$simpleName'"; |
| 503 | 503 |
| 504 Future<InstanceMirror> newInstance(String constructorName, | 504 Future<InstanceMirror> newInstanceAsync(String constructorName, |
| 505 List positionalArguments, | 505 List positionalArguments, |
| 506 [Map<String,dynamic> namedArguments]) { | 506 [Map<String,dynamic> namedArguments]) { |
| 507 if (namedArguments != null) { | 507 if (namedArguments != null) { |
| 508 throw new UnimplementedError( | 508 throw new UnimplementedError( |
| 509 'named argument support is not implemented'); | 509 'named argument support is not implemented'); |
| 510 } | 510 } |
| 511 // Walk the arguments and make sure they are legal. | 511 // Walk the arguments and make sure they are legal. |
| 512 for (int i = 0; i < positionalArguments.length; i++) { | 512 for (int i = 0; i < positionalArguments.length; i++) { |
| 513 var arg = positionalArguments[i]; | 513 var arg = positionalArguments[i]; |
| 514 _LocalObjectMirrorImpl._validateArgument(i, arg); | 514 _LocalObjectMirrorImpl._validateArgument(i, arg); |
| 515 } | 515 } |
| 516 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 516 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
| (...skipping 446 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 963 } | 963 } |
| 964 | 964 |
| 965 // Creates a new local InstanceMirror | 965 // Creates a new local InstanceMirror |
| 966 static InstanceMirror makeLocalInstanceMirror(Object reflectee) | 966 static InstanceMirror makeLocalInstanceMirror(Object reflectee) |
| 967 native 'Mirrors_makeLocalInstanceMirror'; | 967 native 'Mirrors_makeLocalInstanceMirror'; |
| 968 | 968 |
| 969 // Creates a new local mirror for some Object. | 969 // Creates a new local mirror for some Object. |
| 970 static InstanceMirror reflect(Object reflectee) { | 970 static InstanceMirror reflect(Object reflectee) { |
| 971 return makeLocalInstanceMirror(reflectee); | 971 return makeLocalInstanceMirror(reflectee); |
| 972 } | 972 } |
| 973 | |
| 974 static ClassMirror reflectClass(Type reflectee) { | |
| 975 throw new UnimplementedError('reflectClass is not implemented'); | |
| 976 } | |
| 977 | |
| 978 | |
|
ahe
2013/04/10 05:52:22
Delete two extra lines.
| |
| 973 } | 979 } |
| OLD | NEW |