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

Side by Side Diff: runtime/vm/dart_entry.cc

Issue 9420038: Heartbeat implementation of dart:mirrors. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 8 years, 10 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) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, 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 #include "vm/dart_entry.h" 5 #include "vm/dart_entry.h"
6 6
7 #include "vm/code_generator.h" 7 #include "vm/code_generator.h"
8 #include "vm/compiler.h" 8 #include "vm/compiler.h"
9 #include "vm/object_store.h" 9 #include "vm/object_store.h"
10 #include "vm/resolver.h" 10 #include "vm/resolver.h"
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 GrowableArray<const Object*> arguments(kNumArguments); 218 GrowableArray<const Object*> arguments(kNumArguments);
219 arguments.Add(&Integer::Handle(Integer::New(dest_port_id))); 219 arguments.Add(&Integer::Handle(Integer::New(dest_port_id)));
220 arguments.Add(&Integer::Handle(Integer::New(reply_port_id))); 220 arguments.Add(&Integer::Handle(Integer::New(reply_port_id)));
221 arguments.Add(&message); 221 arguments.Add(&message);
222 const Object& result = Object::Handle( 222 const Object& result = Object::Handle(
223 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 223 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
224 ASSERT(result.IsNull() || result.IsError()); 224 ASSERT(result.IsNull() || result.IsError());
225 return result.raw(); 225 return result.raw();
226 } 226 }
227 227
228
229 RawObject* DartLibraryCalls::HandleMirrorsMessage(Dart_Port dest_port_id,
230 Dart_Port reply_port_id,
231 const Instance& message) {
232 Isolate* isolate = Isolate::Current();
233 // Create the reply port.
234 const Object& reply_port = Object::Handle(
235 DartLibraryCalls::NewSendPort(reply_port_id));
236 if (reply_port.IsError()) {
237 return reply_port.raw();
238 }
239
240 // Call _Mirrors.processCommand(message, reply_port).
241 const Library& lib =
242 Library::Handle(isolate->object_store()->mirrors_library());
243 const String& raw_class_name =
244 String::Handle(String::NewSymbol("_Mirrors"));
245 const String& private_key =
246 String::Handle(lib.private_key());
247 const String& class_name =
248 String::Handle(String::Concat(raw_class_name, private_key));
249 const String& function_name =
250 String::Handle(String::NewSymbol("processCommand"));
251 const int kNumArguments = 2;
252 const Array& kNoArgumentNames = Array::Handle();
253 const Function& function = Function::Handle(
254 Resolver::ResolveStatic(lib,
255 class_name,
256 function_name,
257 kNumArguments,
258 kNoArgumentNames,
259 Resolver::kIsQualified));
260 ASSERT(!function.IsNull());
261 GrowableArray<const Object*> arguments(kNumArguments);
262 arguments.Add(&message);
263 arguments.Add(&reply_port);
264 const Object& result = Object::Handle(
265 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
266 ASSERT(result.IsNull() || result.IsError());
267 return result.raw();
268 }
269
270
271 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
272 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl"));
273 const String& function_name = String::Handle(String::NewSymbol("_create"));
274 const int kNumArguments = 1;
275 const Array& kNoArgumentNames = Array::Handle();
276 const Function& function = Function::Handle(
277 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()),
278 class_name,
279 function_name,
280 kNumArguments,
281 kNoArgumentNames,
282 Resolver::kIsQualified));
283 GrowableArray<const Object*> arguments(kNumArguments);
284 arguments.Add(&Integer::Handle(Integer::New(port_id)));
285 return DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
286 }
287
288
289 RawObject* DartLibraryCalls::MapSetAt(const Instance& map,
290 const Instance& key,
291 const Instance& value) {
292 String& name = String::Handle(String::New("[]="));
293 const Function& function = Function::Handle(
294 Resolver::ResolveDynamic(map, name, 3, 0));
295 ASSERT(!function.IsNull());
296 GrowableArray<const Object*> args(2);
297 args.Add(&key);
298 args.Add(&value);
299 const Array& kNoArgumentNames = Array::Handle();
300 const Object& result = Object::Handle(
301 DartEntry::InvokeDynamic(map, function, args, kNoArgumentNames));
302 return result.raw();
303 }
304
305
306 RawObject* DartLibraryCalls::PortGetId(const Instance& port) {
307 const String& field_name = String::Handle(String::NewSymbol("_id"));
308 const Class& cls = Class::Handle(port.clazz());
309 const String& func_name = String::Handle(Field::GetterName(field_name));
310 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
311 ASSERT(!func.IsNull());
312 GrowableArray<const Object*> arguments;
313 const Array& kNoArgumentNames = Array::Handle();
314 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
315 }
316
317
228 } // namespace dart 318 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698