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 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 } | 141 } |
142 | 142 |
143 | 143 |
144 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, | 144 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, |
145 const String& target_name, | 145 const String& target_name, |
146 const Array& arguments, | 146 const Array& arguments, |
147 const Array& arguments_descriptor) { | 147 const Array& arguments_descriptor) { |
148 ASSERT(receiver.raw() == arguments.At(0)); | 148 ASSERT(receiver.raw() == arguments.At(0)); |
149 // Allocate an InvocationMirror object. | 149 // Allocate an InvocationMirror object. |
150 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 150 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 151 |
151 Class& invocation_mirror_class = Class::Handle( | 152 Class& invocation_mirror_class = Class::Handle( |
152 core_lib.LookupClassAllowPrivate(Symbols::InvocationMirror())); | 153 core_lib.LookupClass( |
| 154 String::Handle(core_lib.PrivateName(Symbols::InvocationMirror())))); |
153 ASSERT(!invocation_mirror_class.IsNull()); | 155 ASSERT(!invocation_mirror_class.IsNull()); |
| 156 const String& function_name = |
| 157 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror())); |
154 const Function& allocation_function = Function::Handle( | 158 const Function& allocation_function = Function::Handle( |
155 Resolver::ResolveStaticByName(invocation_mirror_class, | 159 Resolver::ResolveStaticByName(invocation_mirror_class, |
156 Symbols::AllocateInvocationMirror(), | 160 function_name, |
157 Resolver::kIsQualified)); | 161 Resolver::kIsQualified)); |
158 ASSERT(!allocation_function.IsNull()); | 162 ASSERT(!allocation_function.IsNull()); |
159 const int kNumAllocationArgs = 3; | 163 const int kNumAllocationArgs = 3; |
160 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); | 164 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); |
161 allocation_args.SetAt(0, target_name); | 165 allocation_args.SetAt(0, target_name); |
162 allocation_args.SetAt(1, arguments_descriptor); | 166 allocation_args.SetAt(1, arguments_descriptor); |
163 allocation_args.SetAt(2, arguments); | 167 allocation_args.SetAt(2, arguments); |
164 const Object& invocation_mirror = Object::Handle( | 168 const Object& invocation_mirror = Object::Handle( |
165 InvokeStatic(allocation_function, allocation_args)); | 169 InvokeStatic(allocation_function, allocation_args)); |
166 | 170 |
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 Isolate* isolate = Isolate::Current(); | 398 Isolate* isolate = Isolate::Current(); |
395 Function& function = | 399 Function& function = |
396 Function::Handle(isolate, | 400 Function::Handle(isolate, |
397 isolate->object_store()->lookup_receive_port_function()); | 401 isolate->object_store()->lookup_receive_port_function()); |
398 const int kNumArguments = 1; | 402 const int kNumArguments = 1; |
399 if (function.IsNull()) { | 403 if (function.IsNull()) { |
400 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 404 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
401 ASSERT(!isolate_lib.IsNull()); | 405 ASSERT(!isolate_lib.IsNull()); |
402 const String& class_name = | 406 const String& class_name = |
403 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 407 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
| 408 const String& function_name = |
| 409 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); |
404 function = Resolver::ResolveStatic(isolate_lib, | 410 function = Resolver::ResolveStatic(isolate_lib, |
405 class_name, | 411 class_name, |
406 Symbols::_lookupReceivePort(), | 412 function_name, |
407 kNumArguments, | 413 kNumArguments, |
408 Object::empty_array(), | 414 Object::empty_array(), |
409 Resolver::kIsQualified); | 415 Resolver::kIsQualified); |
410 isolate->object_store()->set_lookup_receive_port_function(function); | 416 isolate->object_store()->set_lookup_receive_port_function(function); |
411 } | 417 } |
412 const Array& args = Array::Handle(Array::New(kNumArguments)); | 418 const Array& args = Array::Handle(Array::New(kNumArguments)); |
413 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 419 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
414 const Object& result = | 420 const Object& result = |
415 Object::Handle(DartEntry::InvokeStatic(function, args)); | 421 Object::Handle(DartEntry::InvokeStatic(function, args)); |
416 return result.raw(); | 422 return result.raw(); |
417 } | 423 } |
418 | 424 |
419 | 425 |
420 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, | 426 RawObject* DartLibraryCalls::HandleMessage(const Object& receive_port, |
421 Dart_Port reply_port_id, | 427 Dart_Port reply_port_id, |
422 const Instance& message) { | 428 const Instance& message) { |
423 Isolate* isolate = Isolate::Current(); | 429 Isolate* isolate = Isolate::Current(); |
424 Function& function = | 430 Function& function = |
425 Function::Handle(isolate, | 431 Function::Handle(isolate, |
426 isolate->object_store()->handle_message_function()); | 432 isolate->object_store()->handle_message_function()); |
427 const int kNumArguments = 3; | 433 const int kNumArguments = 3; |
428 if (function.IsNull()) { | 434 if (function.IsNull()) { |
429 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 435 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
430 ASSERT(!isolate_lib.IsNull()); | 436 ASSERT(!isolate_lib.IsNull()); |
431 const String& class_name = | 437 const String& class_name = |
432 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 438 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
| 439 const String& function_name = |
| 440 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); |
433 function = Resolver::ResolveStatic(isolate_lib, | 441 function = Resolver::ResolveStatic(isolate_lib, |
434 class_name, | 442 class_name, |
435 Symbols::_handleMessage(), | 443 function_name, |
436 kNumArguments, | 444 kNumArguments, |
437 Object::empty_array(), | 445 Object::empty_array(), |
438 Resolver::kIsQualified); | 446 Resolver::kIsQualified); |
439 isolate->object_store()->set_handle_message_function(function); | 447 isolate->object_store()->set_handle_message_function(function); |
440 } | 448 } |
441 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 449 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
442 args.SetAt(0, receive_port); | 450 args.SetAt(0, receive_port); |
443 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 451 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); |
444 args.SetAt(2, message); | 452 args.SetAt(2, message); |
445 const Object& result = | 453 const Object& result = |
446 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); | 454 Object::Handle(isolate, DartEntry::InvokeStatic(function, args)); |
447 ASSERT(result.IsNull() || result.IsError()); | 455 ASSERT(result.IsNull() || result.IsError()); |
448 return result.raw(); | 456 return result.raw(); |
449 } | 457 } |
450 | 458 |
451 | 459 |
452 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { | 460 RawObject* DartLibraryCalls::NewSendPort(intptr_t port_id) { |
453 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); | 461 Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
454 ASSERT(!isolate_lib.IsNull()); | 462 ASSERT(!isolate_lib.IsNull()); |
455 const String& class_name = | 463 const String& class_name = |
456 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); | 464 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); |
457 const int kNumArguments = 1; | 465 const int kNumArguments = 1; |
| 466 const String& function_name = |
| 467 String::Handle(isolate_lib.PrivateName(Symbols::_create())); |
458 const Function& function = Function::Handle( | 468 const Function& function = Function::Handle( |
459 Resolver::ResolveStatic(isolate_lib, | 469 Resolver::ResolveStatic(isolate_lib, |
460 class_name, | 470 class_name, |
461 Symbols::_create(), | 471 function_name, |
462 kNumArguments, | 472 kNumArguments, |
463 Object::empty_array(), | 473 Object::empty_array(), |
464 Resolver::kIsQualified)); | 474 Resolver::kIsQualified)); |
465 const Array& args = Array::Handle(Array::New(kNumArguments)); | 475 const Array& args = Array::Handle(Array::New(kNumArguments)); |
466 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 476 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
467 return DartEntry::InvokeStatic(function, args); | 477 return DartEntry::InvokeStatic(function, args); |
468 } | 478 } |
469 | 479 |
470 | 480 |
471 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, | 481 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, |
(...skipping 11 matching lines...) Expand all Loading... |
483 args.SetAt(1, key); | 493 args.SetAt(1, key); |
484 args.SetAt(2, value); | 494 args.SetAt(2, value); |
485 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, | 495 const Object& result = Object::Handle(DartEntry::InvokeDynamic(function, |
486 args)); | 496 args)); |
487 return result.raw(); | 497 return result.raw(); |
488 } | 498 } |
489 | 499 |
490 | 500 |
491 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { | 501 RawObject* DartLibraryCalls::PortGetId(const Instance& port) { |
492 const Class& cls = Class::Handle(port.clazz()); | 502 const Class& cls = Class::Handle(port.clazz()); |
493 const String& func_name = String::Handle(Field::GetterName(Symbols::_id())); | 503 const Library& isolate_lib = Library::Handle(Library::IsolateLibrary()); |
| 504 const String& func_name = |
| 505 String::Handle(isolate_lib.PrivateName( |
| 506 String::Handle(Field::GetterName(Symbols::_id())))); |
494 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 507 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
495 ASSERT(!func.IsNull()); | 508 ASSERT(!func.IsNull()); |
496 const Array& args = Array::Handle(Array::New(1)); | 509 const Array& args = Array::Handle(Array::New(1)); |
497 args.SetAt(0, port); | 510 args.SetAt(0, port); |
498 return DartEntry::InvokeDynamic(func, args); | 511 return DartEntry::InvokeDynamic(func, args); |
499 } | 512 } |
500 | 513 |
501 | 514 |
502 } // namespace dart | 515 } // namespace dart |
OLD | NEW |