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

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

Issue 9420038: Heartbeat implementation of dart:mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 9 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
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/lib/mirrors_sources.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // BSD-style license that can be found in the LICENSE file.
4
5 // VM-specific implementation of the dart:mirrors library.
6
7 class _IsolateMirrorImpl implements IsolateMirror {
8 _IsolateMirrorImpl(this.port, this.debugName) {}
9
10 final SendPort port;
11 final String debugName;
12
13 static buildCommand(List command) {
14 command.add('isolateMirrorOf');
15 }
16
17 static buildResponse(Map response) native "IsolateMirrorImpl_buildResponse";
18
19 static processResponse(SendPort port, Map response) {
20 if (response['ok']) {
21 return new _IsolateMirrorImpl(port, response['debugName']);
22 }
23 return null;
24 }
25 }
26
27 class _Mirrors {
28 static Future<IsolateMirror> isolateMirrorOf(SendPort port) {
29 Completer<IsolateMirror> completer = new Completer<IsolateMirror>();
30 List command = new List();
31 _IsolateMirrorImpl.buildCommand(command);
32 call(port, command).receive((message, _) {
33 completer.complete(_IsolateMirrorImpl.processResponse(port, message));
34 });
35 return completer.future;
36 }
37
38 static void processCommand(var message, SendPort replyTo) {
39 Map response = new Map();
40 if (message[0] == 'isolateMirrorOf') {
41 _IsolateMirrorImpl.buildResponse(response);
42 } else {
43 response['ok'] = false;
44 }
45 replyTo.send(response);
46 }
47
48 static ReceivePort call(SendPort port, Object message) {
49 ReceivePort rp = new ReceivePort.singleShot();
50 if (!send(port, message, rp.toSendPort())) {
51 throw new Exception("Unable to send mirror request to port $port");
52 }
53 return rp;
54 }
55
56 static bool send(SendPort port, Object message, SendPort replyTo)
57 native "Mirrors_send";
58 }
OLDNEW
« no previous file with comments | « runtime/lib/mirrors.cc ('k') | runtime/lib/mirrors_sources.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698