Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(41)

Side by Side Diff: runtime/lib/mirrors_impl.dart

Issue 10416050: Remove the partially completed code for remote IsolateMirrors and (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 //
7 // TODO(turnidge): Make Impl classes private when Dart_GetClass can
8 // handle private classes.
Ivan Posva 2012/05/29 22:13:45 Is this still valid?
turnidge 2012/05/29 23:13:47 Removed.
6 9
7 class _IsolateMirrorImpl implements IsolateMirror { 10 // These values are allowed to be passed directly over the wire.
8 _IsolateMirrorImpl(this.port, this.debugName) {} 11 bool isSimpleValue(var value) {
12 return (value === null || value is num || value is String || value is bool);
13 }
9 14
10 final SendPort port; 15 class _LocalMirrorImpl implements Mirror {
Ivan Posva 2012/05/29 22:13:45 abstract class maybe?
turnidge 2012/05/29 23:13:47 Done.
16 // Local mirrors always return the same IsolateMirror. This field
17 // is more interesting once we implement remote mirrors.
18 IsolateMirror get isolate() { return Mirrors.localIsolateMirror(); }
19 }
20
21 class _LocalIsolateMirrorImpl extends _LocalMirrorImpl
22 implements IsolateMirror {
23 _LocalIsolateMirrorImpl(this.debugName, this.rootLibrary, this.libraries) {}
24
11 final String debugName; 25 final String debugName;
26 final LibraryMirror rootLibrary;
27 final Map<String, LibraryMirror> libraries;
28 }
12 29
13 static _make(SendPort port, String debugName) { 30 // A VMReference is used to hold a reference to a VM-internal object,
14 return new _IsolateMirrorImpl(port, debugName); 31 // which can include things like libraries, classes, etc.
32 class VMReference extends NativeFieldWrapperClass1 {
33 }
34
35 class _LocalVMObjectMirrorImpl extends _LocalMirrorImpl {
Ivan Posva 2012/05/29 22:13:45 abstract class?
turnidge 2012/05/29 23:13:47 Done.
36 _LocalVMObjectMirrorImpl(this._reference) {}
37
38 // For now, all VMObjects hold a VMReference. We could consider
39 // storing the Object reference itself here if the object is a Dart
40 // language objects (except for objects of type VMReference, of
41 // course).
42 VMReference _reference;
43 }
44
45 class _LocalObjectMirrorImpl extends _LocalVMObjectMirrorImpl
Ivan Posva 2012/05/29 22:13:45 abstract class?
turnidge 2012/05/29 23:13:47 Done.
46 implements ObjectMirror {
47 _LocalObjectMirrorImpl(ref) : super(ref) {}
48
49 Future<InstanceMirror> invoke(String memberName,
50 List<Object> positionalArguments,
51 [Map<String,Object> namedArguments]) {
52 if (namedArguments !== null) {
53 throw new NotImplementedException('named arguments not implemented');
54 }
55 // Walk the arguments and make sure they are legal.
56 for (int i = 0; i < positionalArguments.length; i++) {
57 var arg = positionalArguments[i];
58 if (arg is Mirror) {
59 throw new MirrorException(
60 'positional argument $i ($arg) was not an InstanceMirror');
61 }
62 if (!isSimpleValue(arg)) {
63 throw new MirrorException(
64 'positional argument $i ($arg) was not a simple value');
65 }
66 }
67 Completer<InstanceMirror> completer = new Completer<InstanceMirror>();
68 completer.complete(
69 _invoke(this, memberName, positionalArguments));
70 return completer.future;
15 } 71 }
72
73 static _invoke(ref, memberName, positionalArguments)
74 native 'LocalObjectMirrorImpl_invoke';
75 }
76
77 class _LocalInstanceMirrorImpl extends _LocalObjectMirrorImpl
78 implements InstanceMirror {
79 _LocalInstanceMirrorImpl(ref, this.simpleValue) : super(ref) {}
80
81 final simpleValue;
82 }
83
84 class _LocalLibraryMirrorImpl extends _LocalObjectMirrorImpl
85 implements LibraryMirror {
86 _LocalLibraryMirrorImpl(ref, this.simpleName, this.url) : super(ref) {}
87
88 final String simpleName;
89 final String url;
16 } 90 }
17 91
18 class _Mirrors { 92 class _Mirrors {
93 // Does a port refer to our local isolate?
94 static bool isLocalPort(SendPort port) native 'Mirrors_isLocalPort';
95
96 static IsolateMirror _localIsolateMirror;
97
98 // The IsolateMirror for the current isolate.
99 static IsolateMirror localIsolateMirror() {
100 if (_localIsolateMirror === null) {
101 _localIsolateMirror = makeLocalIsolateMirror();
102 }
103 return _localIsolateMirror;
104 }
105
106 // Creates a new local IsolateMirror.
107 static bool makeLocalIsolateMirror()
108 native 'Mirrors_makeLocalIsolateMirror';
109
19 static Future<IsolateMirror> isolateMirrorOf(SendPort port) { 110 static Future<IsolateMirror> isolateMirrorOf(SendPort port) {
20 Completer<IsolateMirror> completer = new Completer<IsolateMirror>(); 111 Completer<IsolateMirror> completer = new Completer<IsolateMirror>();
21 String request = '{ "command": "isolateMirrorOf" }'; 112 if (isLocalPort(port)) {
22 ReceivePort rp = new ReceivePort(); 113 // Make a local isolate mirror.
23 if (!send(port, request, rp.toSendPort())) { 114 completer.complete(localIsolateMirror());
24 throw new Exception("Unable to send mirror request to port $port"); 115 } else {
116 // Make a remote isolate mirror.
117 throw new NotImplementedException('Remote mirrors not yet implemented');
25 } 118 }
26 rp.receive((message, _) {
27 rp.close();
28 completer.complete(_Mirrors.processResponse(
29 port, "isolateMirrorOf", message));
30 });
31 return completer.future; 119 return completer.future;
32 } 120 }
33
34 static bool send(SendPort port, String request, SendPort replyTo)
35 native "Mirrors_send";
36
37 static processResponse(SendPort port, String command, String response)
38 native "Mirrors_processResponse";
39 } 121 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698