| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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()); | 86 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 87 ASSERT(!isolate_lib.IsNull()); | 87 ASSERT(!isolate_lib.IsNull()); |
| 88 const String& public_class_name = |
| 89 String::Handle(String::NewSymbol("_ReceivePortImpl")); |
| 88 const String& class_name = | 90 const String& class_name = |
| 89 String::Handle(isolate_lib.PrivateName("_ReceivePortImpl")); | 91 String::Handle(isolate_lib.PrivateName(public_class_name)); |
| 90 const String& function_name = | 92 const String& function_name = |
| 91 String::Handle(String::NewSymbol("_get_or_create")); | 93 String::Handle(String::NewSymbol("_get_or_create")); |
| 92 const int kNumArguments = 1; | 94 const int kNumArguments = 1; |
| 93 const Array& kNoArgumentNames = Array::Handle(); | 95 const Array& kNoArgumentNames = Array::Handle(); |
| 94 const Function& function = Function::Handle( | 96 const Function& function = Function::Handle( |
| 95 Resolver::ResolveStatic(isolate_lib, | 97 Resolver::ResolveStatic(isolate_lib, |
| 96 class_name, | 98 class_name, |
| 97 function_name, | 99 function_name, |
| 98 kNumArguments, | 100 kNumArguments, |
| 99 kNoArgumentNames, | 101 kNoArgumentNames, |
| 100 Resolver::kIsQualified)); | 102 Resolver::kIsQualified)); |
| 101 GrowableArray<const Object*> arguments(kNumArguments); | 103 GrowableArray<const Object*> arguments(kNumArguments); |
| 102 arguments.Add(&Integer::Handle(Integer::New(port_id))); | 104 arguments.Add(&Integer::Handle(Integer::New(port_id))); |
| 103 const Object& result = Object::Handle( | 105 const Object& result = Object::Handle( |
| 104 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); | 106 DartEntry::InvokeStatic(function, arguments, kNoArgumentNames)); |
| 105 if (!result.IsError()) { | 107 if (!result.IsError()) { |
| 106 PortMap::SetLive(port_id); | 108 PortMap::SetLive(port_id); |
| 107 } | 109 } |
| 108 return result.raw(); | 110 return result.raw(); |
| 109 } | 111 } |
| 110 | 112 |
| 111 | 113 |
| 112 // TODO(turnidge): Move to DartLibraryCalls. | 114 // TODO(turnidge): Move to DartLibraryCalls. |
| 113 static RawObject* SendPortCreate(intptr_t port_id) { | 115 static RawObject* SendPortCreate(intptr_t port_id) { |
| 114 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 116 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 115 ASSERT(!isolate_lib.IsNull()); | 117 ASSERT(!isolate_lib.IsNull()); |
| 118 const String& public_class_name = |
| 119 String::Handle(String::NewSymbol("_ReceivePortImpl")); |
| 116 const String& class_name = | 120 const String& class_name = |
| 117 String::Handle(isolate_lib.PrivateName("_SendPortImpl")); | 121 String::Handle(isolate_lib.PrivateName(public_class_name)); |
| 118 const String& function_name = String::Handle(String::NewSymbol("_create")); | 122 const String& function_name = String::Handle(String::NewSymbol("_create")); |
| 119 const int kNumArguments = 1; | 123 const int kNumArguments = 1; |
| 120 const Array& kNoArgumentNames = Array::Handle(); | 124 const Array& kNoArgumentNames = Array::Handle(); |
| 121 const Function& function = Function::Handle( | 125 const Function& function = Function::Handle( |
| 122 Resolver::ResolveStatic(isolate_lib, | 126 Resolver::ResolveStatic(isolate_lib, |
| 123 class_name, | 127 class_name, |
| 124 function_name, | 128 function_name, |
| 125 kNumArguments, | 129 kNumArguments, |
| 126 kNoArgumentNames, | 130 kNoArgumentNames, |
| 127 Resolver::kIsQualified)); | 131 Resolver::kIsQualified)); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); | 377 intptr_t reply_id = Smi::CheckedHandle(arguments->At(1)).Value(); |
| 374 // TODO(iposva): Allow for arbitrary messages to be sent. | 378 // TODO(iposva): Allow for arbitrary messages to be sent. |
| 375 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); | 379 uint8_t* data = SerializeObject(Instance::CheckedHandle(arguments->At(2))); |
| 376 | 380 |
| 377 // TODO(turnidge): Throw an exception when the return value is false? | 381 // TODO(turnidge): Throw an exception when the return value is false? |
| 378 PortMap::PostMessage(new Message( | 382 PortMap::PostMessage(new Message( |
| 379 send_id, reply_id, data, Message::kNormalPriority)); | 383 send_id, reply_id, data, Message::kNormalPriority)); |
| 380 } | 384 } |
| 381 | 385 |
| 382 } // namespace dart | 386 } // namespace dart |
| OLD | NEW |