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 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 // Walk the arguments and make sure they are legal. | 313 // Walk the arguments and make sure they are legal. |
314 for (int i = 0; i < positionalArguments.length; i++) { | 314 for (int i = 0; i < positionalArguments.length; i++) { |
315 var arg = positionalArguments[i]; | 315 var arg = positionalArguments[i]; |
316 _LocalObjectMirrorImpl._validateArgument(i, arg); | 316 _LocalObjectMirrorImpl._validateArgument(i, arg); |
317 } | 317 } |
318 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); | 318 Completer<InstanceMirror> completer = new Completer<InstanceMirror>(); |
319 try { | 319 try { |
320 completer.complete( | 320 completer.complete( |
321 _apply(this, positionalArguments)); | 321 _apply(this, positionalArguments)); |
322 } catch (exception) { | 322 } catch (exception) { |
323 completer.completeException(exception); | 323 completer.completeError(exception); |
324 } | 324 } |
325 return completer.future; | 325 return completer.future; |
326 } | 326 } |
327 | 327 |
328 Future<InstanceMirror> findInContext(String name) { | 328 Future<InstanceMirror> findInContext(String name) { |
329 throw new UnimplementedError( | 329 throw new UnimplementedError( |
330 'ClosureMirror.findInContext() is not implemented'); | 330 'ClosureMirror.findInContext() is not implemented'); |
331 } | 331 } |
332 | 332 |
333 static _apply(ref, positionalArguments) | 333 static _apply(ref, positionalArguments) |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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>(); |
517 try { | 517 try { |
518 completer.complete( | 518 completer.complete( |
519 _invokeConstructor(this, constructorName, positionalArguments)); | 519 _invokeConstructor(this, constructorName, positionalArguments)); |
520 } catch (exception) { | 520 } catch (exception) { |
521 completer.completeException(exception); | 521 completer.completeError(exception); |
522 } | 522 } |
523 return completer.future; | 523 return completer.future; |
524 } | 524 } |
525 | 525 |
526 static _invokeConstructor(ref, constructorName, positionalArguments) | 526 static _invokeConstructor(ref, constructorName, positionalArguments) |
527 native 'LocalClassMirrorImpl_invokeConstructor'; | 527 native 'LocalClassMirrorImpl_invokeConstructor'; |
528 } | 528 } |
529 | 529 |
530 class _LazyFunctionTypeMirror { | 530 class _LazyFunctionTypeMirror { |
531 _LazyFunctionTypeMirror(this.returnType, this.parameters) {} | 531 _LazyFunctionTypeMirror(this.returnType, this.parameters) {} |
(...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
945 return _currentMirrorSystem; | 945 return _currentMirrorSystem; |
946 } | 946 } |
947 | 947 |
948 static Future<MirrorSystem> mirrorSystemOf(SendPort port) { | 948 static Future<MirrorSystem> mirrorSystemOf(SendPort port) { |
949 Completer<MirrorSystem> completer = new Completer<MirrorSystem>(); | 949 Completer<MirrorSystem> completer = new Completer<MirrorSystem>(); |
950 if (isLocalPort(port)) { | 950 if (isLocalPort(port)) { |
951 // Make a local mirror system. | 951 // Make a local mirror system. |
952 try { | 952 try { |
953 completer.complete(currentMirrorSystem()); | 953 completer.complete(currentMirrorSystem()); |
954 } catch (exception) { | 954 } catch (exception) { |
955 completer.completeException(exception); | 955 completer.completeError(exception); |
956 } | 956 } |
957 } else { | 957 } else { |
958 // Make a remote mirror system | 958 // Make a remote mirror system |
959 throw new UnimplementedError( | 959 throw new UnimplementedError( |
960 'Remote mirror support is not implemented'); | 960 'Remote mirror support is not implemented'); |
961 } | 961 } |
962 return completer.future; | 962 return completer.future; |
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 } | 973 } |
OLD | NEW |