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

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, 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/vm/dart_entry.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 GrowableArray<const Object*> arguments(kNumArguments); 211 GrowableArray<const Object*> arguments(kNumArguments);
212 arguments.Add(&Integer::Handle(Integer::New(dest_port_id))); 212 arguments.Add(&Integer::Handle(Integer::New(dest_port_id)));
213 arguments.Add(&Integer::Handle(Integer::New(reply_port_id))); 213 arguments.Add(&Integer::Handle(Integer::New(reply_port_id)));
214 arguments.Add(&message); 214 arguments.Add(&message);
215 const Object& result = Object::Handle( 215 const Object& result = Object::Handle(
216 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); 216 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
217 ASSERT(result.IsNull() || result.IsError()); 217 ASSERT(result.IsNull() || result.IsError());
218 return result.raw(); 218 return result.raw();
219 } 219 }
220 220
221
222 RawObject* DartLibraryCalls::HandleMirrorsMessage(Dart_Port dest_port_id,
223 Dart_Port reply_port_id,
224 const Instance& message) {
225 Isolate* isolate = Isolate::Current();
226 // Create the reply port.
227 const Object& reply_port = Object::Handle(
228 DartLibraryCalls::NewSendPort(reply_port_id));
229 if (reply_port.IsError()) {
230 return reply_port.raw();
231 }
232
233 // Call _Mirrors.processCommand(message, reply_port).
234 const Library& lib =
235 Library::Handle(isolate->object_store()->mirrors_library());
236 const String& raw_class_name =
237 String::Handle(String::NewSymbol("_Mirrors"));
238 const String& private_key =
239 String::Handle(lib.private_key());
240 const String& class_name =
241 String::Handle(String::Concat(raw_class_name, private_key));
242 const String& function_name =
243 String::Handle(String::NewSymbol("processCommand"));
244 const int kNumArguments = 2;
245 const Array& kNoArgumentNames = Array::Handle();
246 const Function& function = Function::Handle(
247 Resolver::ResolveStatic(lib,
248 class_name,
249 function_name,
250 kNumArguments,
251 kNoArgumentNames,
252 Resolver::kIsQualified));
253 ASSERT(!function.IsNull());
254 GrowableArray<const Object*> arguments(kNumArguments);
255 arguments.Add(&message);
256 arguments.Add(&reply_port);
257 const Object& result = Object::Handle(
258 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames));
259 ASSERT(result.IsNull() || result.IsError());
260 return result.raw();
261 }
262
263
264 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) {
265 Library& isolate_lib = Library::Handle(Library::IsolateLibrary());
266 ASSERT(!isolate_lib.IsNull());
267 const String& class_name =
268 String::Handle(isolate_lib.PrivateName("_SendPortImpl"));
269 const String& function_name = String::Handle(String::NewSymbol("_create"));
270 const int kNumArguments = 1;
271 const Array& kNoArgumentNames = Array::Handle();
272 const Function& function = Function::Handle(
273 Resolver::ResolveStatic(isolate_lib,
274 class_name,
275 function_name,
276 kNumArguments,
277 kNoArgumentNames,
278 Resolver::kIsQualified));
279 GrowableArray<const Object*> arguments(kNumArguments);
280 arguments.Add(&Integer::Handle(Integer::New(port_id)));
281 return DartEntry::InvokeStatic(function, arguments, kNoArgumentNames);
282 }
283
284
285 RawObject* DartLibraryCalls::MapSetAt(const Instance& map,
286 const Instance& key,
287 const Instance& value) {
288 String& name = String::Handle(String::New("[]="));
289 const Function& function = Function::Handle(
290 Resolver::ResolveDynamic(map, name, 3, 0));
291 ASSERT(!function.IsNull());
292 GrowableArray<const Object*> args(2);
293 args.Add(&key);
294 args.Add(&value);
295 const Array& kNoArgumentNames = Array::Handle();
296 const Object& result = Object::Handle(
297 DartEntry::InvokeDynamic(map, function, args, kNoArgumentNames));
298 return result.raw();
299 }
300
301
302 RawObject* DartLibraryCalls::PortGetId(const Instance& port) {
303 const String& field_name = String::Handle(String::NewSymbol("_id"));
304 const Class& cls = Class::Handle(port.clazz());
305 const String& func_name = String::Handle(Field::GetterName(field_name));
306 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name));
307 ASSERT(!func.IsNull());
308 GrowableArray<const Object*> arguments;
309 const Array& kNoArgumentNames = Array::Handle();
310 return DartEntry::InvokeDynamic(port, func, arguments, kNoArgumentNames);
311 }
312
313
221 } // namespace dart 314 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/dart_entry.h ('k') | runtime/vm/isolate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698