| 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/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
| 9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
| 10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 } | 394 } |
| 395 const Array& args = Array::Handle(Array::New(kNumArguments)); | 395 const Array& args = Array::Handle(Array::New(kNumArguments)); |
| 396 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 396 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
| 397 const Object& result = | 397 const Object& result = |
| 398 Object::Handle(DartEntry::InvokeFunction(function, args)); | 398 Object::Handle(DartEntry::InvokeFunction(function, args)); |
| 399 return result.raw(); | 399 return result.raw(); |
| 400 } | 400 } |
| 401 | 401 |
| 402 | 402 |
| 403 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, | 403 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, |
| 404 Dart_Port reply_port_id, | |
| 405 const Instance& message) { | 404 const Instance& message) { |
| 406 Isolate* isolate = Isolate::Current(); | 405 Isolate* isolate = Isolate::Current(); |
| 407 Function& function = | 406 Function& function = Function::Handle(isolate, |
| 408 Function::Handle(isolate, | 407 isolate->object_store()->handle_message_function()); |
| 409 isolate->object_store()->handle_message_function()); | 408 const int kNumArguments = 2; |
| 410 const int kNumArguments = 3; | |
| 411 if (function.IsNull()) { | 409 if (function.IsNull()) { |
| 412 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 410 Library& isolate_lib = Library::Handle(isolate, Library::IsolateLibrary()); |
| 413 ASSERT(!isolate_lib.IsNull()); | 411 ASSERT(!isolate_lib.IsNull()); |
| 414 const String& class_name = | 412 const String& class_name = String::Handle(isolate, |
| 415 String::Handle(isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); | 413 isolate_lib.PrivateName(Symbols::_RawReceivePortImpl())); |
| 416 const String& function_name = | 414 const String& function_name = String::Handle(isolate, |
| 417 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); | 415 isolate_lib.PrivateName(Symbols::_handleMessage())); |
| 418 function = Resolver::ResolveStatic(isolate_lib, | 416 function = Resolver::ResolveStatic(isolate_lib, |
| 419 class_name, | 417 class_name, |
| 420 function_name, | 418 function_name, |
| 421 kNumArguments, | 419 kNumArguments, |
| 422 Object::empty_array()); | 420 Object::empty_array()); |
| 423 ASSERT(!function.IsNull()); | 421 ASSERT(!function.IsNull()); |
| 424 isolate->object_store()->set_handle_message_function(function); | 422 isolate->object_store()->set_handle_message_function(function); |
| 425 } | 423 } |
| 426 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 424 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
| 427 args.SetAt(0, receive_port); | 425 args.SetAt(0, receive_port); |
| 428 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 426 args.SetAt(1, message); |
| 429 args.SetAt(2, message); | |
| 430 if (isolate->debugger()->IsStepping()) { | 427 if (isolate->debugger()->IsStepping()) { |
| 431 // If the isolate is being debugged and the debugger was stepping | 428 // If the isolate is being debugged and the debugger was stepping |
| 432 // through code, enable single stepping so debugger will stop | 429 // through code, enable single stepping so debugger will stop |
| 433 // at the first location the user is interested in. | 430 // at the first location the user is interested in. |
| 434 isolate->debugger()->SetSingleStep(); | 431 isolate->debugger()->SetSingleStep(); |
| 435 } | 432 } |
| 436 const Object& result = | 433 const Object& result = Object::Handle(isolate, |
| 437 Object::Handle(isolate, DartEntry::InvokeFunction(function, args)); | 434 DartEntry::InvokeFunction(function, args)); |
| 438 ASSERT(result.IsNull() || result.IsError()); | 435 ASSERT(result.IsNull() || result.IsError()); |
| 439 return result.raw(); | 436 return result.raw(); |
| 440 } | 437 } |
| 441 | 438 |
| 442 | 439 |
| 443 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { | 440 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { |
| 444 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 441 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 445 ASSERT(!isolate_lib.IsNull()); | 442 ASSERT(!isolate_lib.IsNull()); |
| 446 const String& class_name = | 443 const String& class_name = |
| 447 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); | 444 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 490 String::Handle(Field::GetterName(Symbols::_id())))); | 487 String::Handle(Field::GetterName(Symbols::_id())))); |
| 491 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 488 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
| 492 ASSERT(!func.IsNull()); | 489 ASSERT(!func.IsNull()); |
| 493 const Array& args = Array::Handle(Array::New(1)); | 490 const Array& args = Array::Handle(Array::New(1)); |
| 494 args.SetAt(0, port); | 491 args.SetAt(0, port); |
| 495 return DartEntry::InvokeFunction(func, args); | 492 return DartEntry::InvokeFunction(func, args); |
| 496 } | 493 } |
| 497 | 494 |
| 498 | 495 |
| 499 } // namespace dart | 496 } // namespace dart |
| OLD | NEW |