| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 // TODO(turnidge): Move to DartLibraryCalls. | 53 // TODO(turnidge): Move to DartLibraryCalls. |
| 54 static RawObject* ReceivePortCreate(intptr_t port_id) { | 54 static RawObject* ReceivePortCreate(intptr_t port_id) { |
| 55 Isolate* isolate = Isolate::Current(); | 55 Isolate* isolate = Isolate::Current(); |
| 56 Function& func = | 56 Function& func = |
| 57 Function::Handle(isolate, | 57 Function::Handle(isolate, |
| 58 isolate->object_store()->receive_port_create_function()); | 58 isolate->object_store()->receive_port_create_function()); |
| 59 const int kNumArguments = 1; | 59 const int kNumArguments = 1; |
| 60 if (func.IsNull()) { | 60 if (func.IsNull()) { |
| 61 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 61 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 62 ASSERT(!isolate_lib.IsNull()); | 62 ASSERT(!isolate_lib.IsNull()); |
| 63 const String& public_class_name = | |
| 64 String::Handle(Symbols::New("_ReceivePortImpl")); | |
| 65 const String& class_name = | 63 const String& class_name = |
| 66 String::Handle(isolate_lib.PrivateName(public_class_name)); | 64 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
| 67 const String& function_name = | |
| 68 String::Handle(Symbols::New("_get_or_create")); | |
| 69 const Array& kNoArgumentNames = Array::Handle(); | |
| 70 func = Resolver::ResolveStatic(isolate_lib, | 65 func = Resolver::ResolveStatic(isolate_lib, |
| 71 class_name, | 66 class_name, |
| 72 function_name, | 67 Symbols::_get_or_create(), |
| 73 kNumArguments, | 68 kNumArguments, |
| 74 kNoArgumentNames, | 69 Object::empty_array(), |
| 75 Resolver::kIsQualified); | 70 Resolver::kIsQualified); |
| 76 isolate->object_store()->set_receive_port_create_function(func); | 71 isolate->object_store()->set_receive_port_create_function(func); |
| 77 } | 72 } |
| 78 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 73 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
| 79 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id))); | 74 args.SetAt(0, Integer::Handle(isolate, Integer::New(port_id))); |
| 80 const Object& result = | 75 const Object& result = |
| 81 Object::Handle(isolate, DartEntry::InvokeStatic(func, args)); | 76 Object::Handle(isolate, DartEntry::InvokeStatic(func, args)); |
| 82 if (!result.IsError()) { | 77 if (!result.IsError()) { |
| 83 PortMap::SetLive(port_id); | 78 PortMap::SetLive(port_id); |
| 84 } | 79 } |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 488 |
| 494 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { | 489 DEFINE_NATIVE_ENTRY(isolate_getPortInternal, 0) { |
| 495 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); | 490 const Object& port = Object::Handle(ReceivePortCreate(isolate->main_port())); |
| 496 if (port.IsError()) { | 491 if (port.IsError()) { |
| 497 Exceptions::PropagateError(Error::Cast(port)); | 492 Exceptions::PropagateError(Error::Cast(port)); |
| 498 } | 493 } |
| 499 return port.raw(); | 494 return port.raw(); |
| 500 } | 495 } |
| 501 | 496 |
| 502 } // namespace dart | 497 } // namespace dart |
| OLD | NEW |