OLD | NEW |
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
364 const Array& args = Array::Handle(Array::New(kNumArguments)); | 364 const Array& args = Array::Handle(Array::New(kNumArguments)); |
365 args.SetAt(0, left); | 365 args.SetAt(0, left); |
366 args.SetAt(1, right); | 366 args.SetAt(1, right); |
367 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, | 367 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, |
368 args)); | 368 args)); |
369 ASSERT(result.IsInstance() || result.IsError()); | 369 ASSERT(result.IsInstance() || result.IsError()); |
370 return result.raw(); | 370 return result.raw(); |
371 } | 371 } |
372 | 372 |
373 | 373 |
374 RawObject* DartLibraryCalls::HandleMessage(Dart_Port dest_port_id, | 374 RawObject* DartLibraryCalls::LookupReceivePort(Dart_Port port_id) { |
| 375 Isolate* isolate = Isolate::Current(); |
| 376 Function& function = |
| 377 Function::Handle(isolate, |
| 378 isolate->object_store()->lookup_receive_port_function()); |
| 379 const int kNumArguments = 1; |
| 380 if (function.IsNull()) { |
| 381 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 382 ASSERT(!isolate_lib.IsNull()); |
| 383 const String& public_class_name = |
| 384 String::Handle(Symbols::New("_ReceivePortImpl")); |
| 385 const String& class_name = |
| 386 String::Handle(isolate_lib.PrivateName(public_class_name)); |
| 387 const String& function_name = |
| 388 String::Handle(Symbols::New("_lookupReceivePort")); |
| 389 const Array& kNoArgumentNames = Array::Handle(); |
| 390 function = Resolver::ResolveStatic(isolate_lib, |
| 391 class_name, |
| 392 function_name, |
| 393 kNumArguments, |
| 394 kNoArgumentNames, |
| 395 Resolver::kIsQualified); |
| 396 isolate->object_store()->set_lookup_receive_port_function(function); |
| 397 } |
| 398 const Array& args = Array::Handle(Array::New(kNumArguments)); |
| 399 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
| 400 const Object& result = |
| 401 Object::Handle(DartEntry::InvokeStatic(function, args)); |
| 402 return result.raw(); |
| 403 } |
| 404 |
| 405 |
| 406 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, |
375 Dart_Port reply_port_id, | 407 Dart_Port reply_port_id, |
376 const Instance& message) { | 408 const Instance& message) { |
377 Isolate* isolate = Isolate::Current(); | 409 Isolate* isolate = Isolate::Current(); |
378 Function& function = | 410 Function& function = |
379 Function::Handle(isolate, | 411 Function::Handle(isolate, |
380 isolate->object_store()->handle_message_function()); | 412 isolate->object_store()->handle_message_function()); |
381 const int kNumArguments = 3; | 413 const int kNumArguments = 3; |
382 if (function.IsNull()) { | 414 if (function.IsNull()) { |
383 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 415 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
384 ASSERT(!isolate_lib.IsNull()); | 416 ASSERT(!isolate_lib.IsNull()); |
385 const String& public_class_name = | 417 const String& public_class_name = |
386 String::Handle(Symbols::New("_ReceivePortImpl")); | 418 String::Handle(Symbols::New("_ReceivePortImpl")); |
387 const String& class_name = | 419 const String& class_name = |
388 String::Handle(isolate_lib.PrivateName(public_class_name)); | 420 String::Handle(isolate_lib.PrivateName(public_class_name)); |
389 const String& function_name = | 421 const String& function_name = |
390 String::Handle(Symbols::New("_handleMessage")); | 422 String::Handle(Symbols::New("_handleMessage")); |
391 const Array& kNoArgumentNames = Array::Handle(); | 423 const Array& kNoArgumentNames = Array::Handle(); |
392 function = Resolver::ResolveStatic(isolate_lib, | 424 function = Resolver::ResolveStatic(isolate_lib, |
393 class_name, | 425 class_name, |
394 function_name, | 426 function_name, |
395 kNumArguments, | 427 kNumArguments, |
396 kNoArgumentNames, | 428 kNoArgumentNames, |
397 Resolver::kIsQualified); | 429 Resolver::kIsQualified); |
398 isolate->object_store()->set_handle_message_function(function); | 430 isolate->object_store()->set_handle_message_function(function); |
399 } | 431 } |
400 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 432 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
401 args.SetAt(0, Integer::Handle(isolate, Integer::New(dest_port_id))); | 433 args.SetAt(0, receive_port); |
402 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 434 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); |
403 args.SetAt(2, message); | 435 args.SetAt(2, message); |
404 const Object& result = | 436 const Object& result = |
405 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); | 437 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); |
406 ASSERT(result.IsNull() || result.IsError()); | 438 ASSERT(result.IsNull() || result.IsError()); |
407 return result.raw(); | 439 return result.raw(); |
408 } | 440 } |
409 | 441 |
410 | 442 |
411 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { | 443 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 const String& func_name = String::Handle(Field::GetterName(field_name)); | 487 const String& func_name = String::Handle(Field::GetterName(field_name)); |
456 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 488 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
457 ASSERT(!func.IsNull()); | 489 ASSERT(!func.IsNull()); |
458 const Array& args = Array::Handle(Array::New(1)); | 490 const Array& args = Array::Handle(Array::New(1)); |
459 args.SetAt(0, port); | 491 args.SetAt(0, port); |
460 return DartEntry::InvokeDynamic(func, args); | 492 return DartEntry::InvokeDynamic(func, args); |
461 } | 493 } |
462 | 494 |
463 | 495 |
464 } // namespace dart | 496 } // namespace dart |
OLD | NEW |