| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 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 | 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 "platform/assert.h" | 5 #include "platform/assert.h" |
| 6 #include "vm/bootstrap_natives.h" | 6 #include "vm/bootstrap_natives.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/dart.h" | 8 #include "vm/dart.h" |
| 9 #include "vm/dart_api_impl.h" | 9 #include "vm/dart_api_impl.h" |
| 10 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 76 name ^= String::NewSymbol(class_name); | 76 name ^= String::NewSymbol(class_name); |
| 77 str ^= String::Concat(str, name); | 77 str ^= String::Concat(str, name); |
| 78 GrowableArray<const Object*> arguments(1); | 78 GrowableArray<const Object*> arguments(1); |
| 79 arguments.Add(&str); | 79 arguments.Add(&str); |
| 80 Exceptions::ThrowByType(type, arguments); | 80 Exceptions::ThrowByType(type, arguments); |
| 81 } | 81 } |
| 82 | 82 |
| 83 | 83 |
| 84 // TODO(turnidge): Move to DartLibraryCalls. | 84 // TODO(turnidge): Move to DartLibraryCalls. |
| 85 RawObject* ReceivePortCreate(intptr_t port_id) { | 85 RawObject* ReceivePortCreate(intptr_t port_id) { |
| 86 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 87 ASSERT(!isolate_lib.IsNull()); |
| 86 const String& class_name = | 88 const String& class_name = |
| 87 String::Handle(String::NewSymbol("ReceivePortImpl")); | 89 String::Handle(isolate_lib.PrivateName("_ReceivePortImpl")); |
| 88 const String& function_name = | 90 const String& function_name = |
| 89 String::Handle(String::NewSymbol("_get_or_create")); | 91 String::Handle(String::NewSymbol("_get_or_create")); |
| 90 const int kNumArguments = 1; | 92 const int kNumArguments = 1; |
| 91 const Array& kNoArgumentNames = Array::Handle(); | 93 const Array& kNoArgumentNames = Array::Handle(); |
| 92 const Function& function = Function::Handle( | 94 const Function& function = Function::Handle( |
| 93 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), | 95 Resolver::ResolveStatic(isolate_lib, |
| 94 class_name, | 96 class_name, |
| 95 function_name, | 97 function_name, |
| 96 kNumArguments, | 98 kNumArguments, |
| 97 kNoArgumentNames, | 99 kNoArgumentNames, |
| 98 Resolver::kIsQualified)); | 100 Resolver::kIsQualified)); |
| 99 GrowableArray<const Object*> arguments(kNumArguments); | 101 GrowableArray<const Object*> arguments(kNumArguments); |
| 100 arguments.Add(&Integer::Handle(Integer::New(port_id))); | 102 arguments.Add(&Integer::Handle(Integer::New(port_id))); |
| 101 const Object& result = Object::Handle( | 103 const Object& result = Object::Handle( |
| 102 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); | 104 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); |
| 103 if (!result.IsError()) { | 105 if (!result.IsError()) { |
| 104 PortMap::SetLive(port_id); | 106 PortMap::SetLive(port_id); |
| 105 } | 107 } |
| 106 return result.raw(); | 108 return result.raw(); |
| 107 } | 109 } |
| 108 | 110 |
| 109 | 111 |
| 110 // TODO(turnidge): Move to DartLibraryCalls. | 112 // TODO(turnidge): Move to DartLibraryCalls. |
| 111 static RawObject* SendPortCreate(intptr_t port_id) { | 113 static RawObject* SendPortCreate(intptr_t port_id) { |
| 112 const String& class_name = String::Handle(String::NewSymbol("SendPortImpl")); | 114 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 115 ASSERT(!isolate_lib.IsNull()); |
| 116 const String& class_name = |
| 117 String::Handle(isolate_lib.PrivateName("_SendPortImpl")); |
| 113 const String& function_name = String::Handle(String::NewSymbol("_create")); | 118 const String& function_name = String::Handle(String::NewSymbol("_create")); |
| 114 const int kNumArguments = 1; | 119 const int kNumArguments = 1; |
| 115 const Array& kNoArgumentNames = Array::Handle(); | 120 const Array& kNoArgumentNames = Array::Handle(); |
| 116 const Function& function = Function::Handle( | 121 const Function& function = Function::Handle( |
| 117 Resolver::ResolveStatic(Library::Handle(Library::CoreLibrary()), | 122 Resolver::ResolveStatic(isolate_lib, |
| 118 class_name, | 123 class_name, |
| 119 function_name, | 124 function_name, |
| 120 kNumArguments, | 125 kNumArguments, |
| 121 kNoArgumentNames, | 126 kNoArgumentNames, |
| 122 Resolver::kIsQualified)); | 127 Resolver::kIsQualified)); |
| 123 GrowableArray<const Object*> arguments(kNumArguments); | 128 GrowableArray<const Object*> arguments(kNumArguments); |
| 124 arguments.Add(&Integer::Handle(Integer::New(port_id))); | 129 arguments.Add(&Integer::Handle(Integer::New(port_id))); |
| 125 const Object& result = Object::Handle( | 130 const Object& result = Object::Handle( |
| 126 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); | 131 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); |
| 127 return result.raw(); | 132 return result.raw(); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 373 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 369 // TODO(iposva): Allow for arbitrary messages to be sent. | 374 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 370 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 375 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); |
| 371 | 376 |
| 372 // TODO(turnidge): Throw an exception when the return value is false? | 377 // TODO(turnidge): Throw an exception when the return value is false? |
| 373 PortMap::PostMessage(new Message( | 378 PortMap::PostMessage(new Message( |
| 374 send_id, reply_id, data, Message::kNormalPriority)); | 379 send_id, reply_id, data, Message::kNormalPriority)); |
| 375 } | 380 } |
| 376 | 381 |
| 377 } // namespace dart | 382 } // namespace dart |
| OLD | NEW |