| 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/debugger.h" | 9 #include "vm/debugger.h" |
| 10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, | 112 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, |
| 113 const String& target_name, | 113 const String& target_name, |
| 114 const Array& arguments, | 114 const Array& arguments, |
| 115 const Array& arguments_descriptor) { | 115 const Array& arguments_descriptor) { |
| 116 ASSERT(receiver.raw() == arguments.At(0)); | 116 ASSERT(receiver.raw() == arguments.At(0)); |
| 117 // Allocate an Invocation object. | 117 // Allocate an Invocation object. |
| 118 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 118 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
| 119 | 119 |
| 120 Class& invocation_mirror_class = Class::Handle( | 120 Class& invocation_mirror_class = Class::Handle( |
| 121 core_lib.LookupClass( | 121 core_lib.LookupClass( |
| 122 String::Handle(core_lib.PrivateName(Symbols::InvocationMirror())))); | 122 String::Handle(core_lib.PrivateName(Symbols::InvocationMirror())), |
| 123 NULL)); // No ambiguity error expected. |
| 123 ASSERT(!invocation_mirror_class.IsNull()); | 124 ASSERT(!invocation_mirror_class.IsNull()); |
| 124 const String& function_name = | 125 const String& function_name = |
| 125 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror())); | 126 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror())); |
| 126 const Function& allocation_function = Function::Handle( | 127 const Function& allocation_function = Function::Handle( |
| 127 Resolver::ResolveStaticByName(invocation_mirror_class, | 128 Resolver::ResolveStaticByName(invocation_mirror_class, |
| 128 function_name, | 129 function_name, |
| 129 Resolver::kIsQualified)); | 130 Resolver::kIsQualified)); |
| 130 ASSERT(!allocation_function.IsNull()); | 131 ASSERT(!allocation_function.IsNull()); |
| 131 const int kNumAllocationArgs = 3; | 132 const int kNumAllocationArgs = 3; |
| 132 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); | 133 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 348 for (int i = 0; i < kCachedDescriptorCount; i++) { | 349 for (int i = 0; i < kCachedDescriptorCount; i++) { |
| 349 cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false); | 350 cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false); |
| 350 } | 351 } |
| 351 } | 352 } |
| 352 | 353 |
| 353 | 354 |
| 354 RawObject* DartLibraryCalls::InstanceCreate(const Library& lib, | 355 RawObject* DartLibraryCalls::InstanceCreate(const Library& lib, |
| 355 const String& class_name, | 356 const String& class_name, |
| 356 const String& constructor_name, | 357 const String& constructor_name, |
| 357 const Array& arguments) { | 358 const Array& arguments) { |
| 358 const Class& cls = Class::Handle(lib.LookupClassAllowPrivate(class_name)); | 359 const Class& cls = Class::Handle( |
| 360 lib.LookupClassAllowPrivate(class_name, NULL)); // No ambiguity expected. |
| 359 ASSERT(!cls.IsNull()); | 361 ASSERT(!cls.IsNull()); |
| 360 // For now, we only support a non-parameterized or raw type. | 362 // For now, we only support a non-parameterized or raw type. |
| 361 const int kNumExtraArgs = 2; // implicit rcvr and construction phase args. | 363 const int kNumExtraArgs = 2; // implicit rcvr and construction phase args. |
| 362 const Instance& exception_object = Instance::Handle(Instance::New(cls)); | 364 const Instance& exception_object = Instance::Handle(Instance::New(cls)); |
| 363 const Array& constructor_arguments = | 365 const Array& constructor_arguments = |
| 364 Array::Handle(Array::New(arguments.Length() + kNumExtraArgs)); | 366 Array::Handle(Array::New(arguments.Length() + kNumExtraArgs)); |
| 365 constructor_arguments.SetAt(0, exception_object); | 367 constructor_arguments.SetAt(0, exception_object); |
| 366 constructor_arguments.SetAt( | 368 constructor_arguments.SetAt( |
| 367 1, Smi::Handle(Smi::New(Function::kCtorPhaseAll))); | 369 1, Smi::Handle(Smi::New(Function::kCtorPhaseAll))); |
| 368 Object& obj = Object::Handle(); | 370 Object& obj = Object::Handle(); |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 437 ASSERT(!isolate_lib.IsNull()); | 439 ASSERT(!isolate_lib.IsNull()); |
| 438 const String& class_name = | 440 const String& class_name = |
| 439 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 441 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
| 440 const String& function_name = | 442 const String& function_name = |
| 441 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); | 443 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); |
| 442 function = Resolver::ResolveStatic(isolate_lib, | 444 function = Resolver::ResolveStatic(isolate_lib, |
| 443 class_name, | 445 class_name, |
| 444 function_name, | 446 function_name, |
| 445 kNumArguments, | 447 kNumArguments, |
| 446 Object::empty_array(), | 448 Object::empty_array(), |
| 447 Resolver::kIsQualified); | 449 Resolver::kIsQualified, |
| 450 NULL); // No ambiguity error expected. |
| 451 ASSERT(!function.IsNull()); |
| 448 isolate->object_store()->set_lookup_receive_port_function(function); | 452 isolate->object_store()->set_lookup_receive_port_function(function); |
| 449 } | 453 } |
| 450 const Array& args = Array::Handle(Array::New(kNumArguments)); | 454 const Array& args = Array::Handle(Array::New(kNumArguments)); |
| 451 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 455 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
| 452 const Object& result = | 456 const Object& result = |
| 453 Object::Handle(DartEntry::InvokeFunction(function, args)); | 457 Object::Handle(DartEntry::InvokeFunction(function, args)); |
| 454 return result.raw(); | 458 return result.raw(); |
| 455 } | 459 } |
| 456 | 460 |
| 457 | 461 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 468 ASSERT(!isolate_lib.IsNull()); | 472 ASSERT(!isolate_lib.IsNull()); |
| 469 const String& class_name = | 473 const String& class_name = |
| 470 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 474 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
| 471 const String& function_name = | 475 const String& function_name = |
| 472 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); | 476 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); |
| 473 function = Resolver::ResolveStatic(isolate_lib, | 477 function = Resolver::ResolveStatic(isolate_lib, |
| 474 class_name, | 478 class_name, |
| 475 function_name, | 479 function_name, |
| 476 kNumArguments, | 480 kNumArguments, |
| 477 Object::empty_array(), | 481 Object::empty_array(), |
| 478 Resolver::kIsQualified); | 482 Resolver::kIsQualified, |
| 483 NULL); // No ambiguity error expected. |
| 484 ASSERT(!function.IsNull()); |
| 479 isolate->object_store()->set_handle_message_function(function); | 485 isolate->object_store()->set_handle_message_function(function); |
| 480 } | 486 } |
| 481 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 487 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
| 482 args.SetAt(0, receive_port); | 488 args.SetAt(0, receive_port); |
| 483 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 489 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); |
| 484 args.SetAt(2, message); | 490 args.SetAt(2, message); |
| 485 if (isolate->debugger()->IsStepping()) { | 491 if (isolate->debugger()->IsStepping()) { |
| 486 // If the isolate is being debugged and the debugger was stepping | 492 // If the isolate is being debugged and the debugger was stepping |
| 487 // through code, enable single stepping so debugger will stop | 493 // through code, enable single stepping so debugger will stop |
| 488 // at the first location the user is interested in. | 494 // at the first location the user is interested in. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 502 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); | 508 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); |
| 503 const int kNumArguments = 1; | 509 const int kNumArguments = 1; |
| 504 const String& function_name = | 510 const String& function_name = |
| 505 String::Handle(isolate_lib.PrivateName(Symbols::_create())); | 511 String::Handle(isolate_lib.PrivateName(Symbols::_create())); |
| 506 const Function& function = Function::Handle( | 512 const Function& function = Function::Handle( |
| 507 Resolver::ResolveStatic(isolate_lib, | 513 Resolver::ResolveStatic(isolate_lib, |
| 508 class_name, | 514 class_name, |
| 509 function_name, | 515 function_name, |
| 510 kNumArguments, | 516 kNumArguments, |
| 511 Object::empty_array(), | 517 Object::empty_array(), |
| 512 Resolver::kIsQualified)); | 518 Resolver::kIsQualified, |
| 519 NULL)); // No ambiguity error expected. |
| 520 ASSERT(!function.IsNull()); |
| 513 const Array& args = Array::Handle(Array::New(kNumArguments)); | 521 const Array& args = Array::Handle(Array::New(kNumArguments)); |
| 514 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 522 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
| 515 return DartEntry::InvokeFunction(function, args); | 523 return DartEntry::InvokeFunction(function, args); |
| 516 } | 524 } |
| 517 | 525 |
| 518 | 526 |
| 519 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, | 527 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, |
| 520 const Instance& key, | 528 const Instance& key, |
| 521 const Instance& value) { | 529 const Instance& value) { |
| 522 const int kNumArguments = 3; | 530 const int kNumArguments = 3; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 545 String::Handle(Field::GetterName(Symbols::_id())))); | 553 String::Handle(Field::GetterName(Symbols::_id())))); |
| 546 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 554 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
| 547 ASSERT(!func.IsNull()); | 555 ASSERT(!func.IsNull()); |
| 548 const Array& args = Array::Handle(Array::New(1)); | 556 const Array& args = Array::Handle(Array::New(1)); |
| 549 args.SetAt(0, port); | 557 args.SetAt(0, port); |
| 550 return DartEntry::InvokeFunction(func, args); | 558 return DartEntry::InvokeFunction(func, args); |
| 551 } | 559 } |
| 552 | 560 |
| 553 | 561 |
| 554 } // namespace dart | 562 } // namespace dart |
| OLD | NEW |