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/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/code_generator.h" | 8 #include "vm/code_generator.h" |
9 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
10 #include "vm/debugger.h" | 10 #include "vm/debugger.h" |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, | 111 RawObject* DartEntry::InvokeNoSuchMethod(const Instance& receiver, |
112 const String& target_name, | 112 const String& target_name, |
113 const Array& arguments, | 113 const Array& arguments, |
114 const Array& arguments_descriptor) { | 114 const Array& arguments_descriptor) { |
115 ASSERT(receiver.raw() == arguments.At(0)); | 115 ASSERT(receiver.raw() == arguments.At(0)); |
116 // Allocate an Invocation object. | 116 // Allocate an Invocation object. |
117 const Library& core_lib = Library::Handle(Library::CoreLibrary()); | 117 const Library& core_lib = Library::Handle(Library::CoreLibrary()); |
118 | 118 |
119 Class& invocation_mirror_class = Class::Handle( | 119 Class& invocation_mirror_class = Class::Handle( |
120 core_lib.LookupClass( | 120 core_lib.LookupClass( |
121 String::Handle(core_lib.PrivateName(Symbols::InvocationMirror())), | 121 String::Handle(core_lib.PrivateName(Symbols::InvocationMirror())))); |
122 NULL)); // No ambiguity error expected. | |
123 ASSERT(!invocation_mirror_class.IsNull()); | 122 ASSERT(!invocation_mirror_class.IsNull()); |
124 const String& function_name = | 123 const String& function_name = |
125 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror())); | 124 String::Handle(core_lib.PrivateName(Symbols::AllocateInvocationMirror())); |
126 const Function& allocation_function = Function::Handle( | 125 const Function& allocation_function = Function::Handle( |
127 Resolver::ResolveStaticByName(invocation_mirror_class, | 126 Resolver::ResolveStaticByName(invocation_mirror_class, |
128 function_name, | 127 function_name, |
129 Resolver::kIsQualified)); | 128 Resolver::kIsQualified)); |
130 ASSERT(!allocation_function.IsNull()); | 129 ASSERT(!allocation_function.IsNull()); |
131 const int kNumAllocationArgs = 3; | 130 const int kNumAllocationArgs = 3; |
132 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); | 131 const Array& allocation_args = Array::Handle(Array::New(kNumAllocationArgs)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 for (int i = 0; i < kCachedDescriptorCount; i++) { | 294 for (int i = 0; i < kCachedDescriptorCount; i++) { |
296 cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false); | 295 cached_args_descriptors_[i] = ArgumentsDescriptor::NewNonCached(i, false); |
297 } | 296 } |
298 } | 297 } |
299 | 298 |
300 | 299 |
301 RawObject* DartLibraryCalls::InstanceCreate(const Library& lib, | 300 RawObject* DartLibraryCalls::InstanceCreate(const Library& lib, |
302 const String& class_name, | 301 const String& class_name, |
303 const String& constructor_name, | 302 const String& constructor_name, |
304 const Array& arguments) { | 303 const Array& arguments) { |
305 const Class& cls = Class::Handle( | 304 const Class& cls = Class::Handle(lib.LookupClassAllowPrivate(class_name)); |
306 lib.LookupClassAllowPrivate(class_name, NULL)); // No ambiguity expected. | |
307 ASSERT(!cls.IsNull()); | 305 ASSERT(!cls.IsNull()); |
308 // For now, we only support a non-parameterized or raw type. | 306 // For now, we only support a non-parameterized or raw type. |
309 const int kNumExtraArgs = 2; // implicit rcvr and construction phase args. | 307 const int kNumExtraArgs = 2; // implicit rcvr and construction phase args. |
310 const Instance& exception_object = Instance::Handle(Instance::New(cls)); | 308 const Instance& exception_object = Instance::Handle(Instance::New(cls)); |
311 const Array& constructor_arguments = | 309 const Array& constructor_arguments = |
312 Array::Handle(Array::New(arguments.Length() + kNumExtraArgs)); | 310 Array::Handle(Array::New(arguments.Length() + kNumExtraArgs)); |
313 constructor_arguments.SetAt(0, exception_object); | 311 constructor_arguments.SetAt(0, exception_object); |
314 constructor_arguments.SetAt( | 312 constructor_arguments.SetAt( |
315 1, Smi::Handle(Smi::New(Function::kCtorPhaseAll))); | 313 1, Smi::Handle(Smi::New(Function::kCtorPhaseAll))); |
316 Object& obj = Object::Handle(); | 314 Object& obj = Object::Handle(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 ASSERT(!isolate_lib.IsNull()); | 383 ASSERT(!isolate_lib.IsNull()); |
386 const String& class_name = | 384 const String& class_name = |
387 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 385 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
388 const String& function_name = | 386 const String& function_name = |
389 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); | 387 String::Handle(isolate_lib.PrivateName(Symbols::_lookupReceivePort())); |
390 function = Resolver::ResolveStatic(isolate_lib, | 388 function = Resolver::ResolveStatic(isolate_lib, |
391 class_name, | 389 class_name, |
392 function_name, | 390 function_name, |
393 kNumArguments, | 391 kNumArguments, |
394 Object::empty_array(), | 392 Object::empty_array(), |
395 Resolver::kIsQualified, | 393 Resolver::kIsQualified); |
396 NULL); // No ambiguity error expected. | |
397 ASSERT(!function.IsNull()); | 394 ASSERT(!function.IsNull()); |
398 isolate->object_store()->set_lookup_receive_port_function(function); | 395 isolate->object_store()->set_lookup_receive_port_function(function); |
399 } | 396 } |
400 const Array& args = Array::Handle(Array::New(kNumArguments)); | 397 const Array& args = Array::Handle(Array::New(kNumArguments)); |
401 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 398 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
402 const Object& result = | 399 const Object& result = |
403 Object::Handle(DartEntry::InvokeFunction(function, args)); | 400 Object::Handle(DartEntry::InvokeFunction(function, args)); |
404 return result.raw(); | 401 return result.raw(); |
405 } | 402 } |
406 | 403 |
(...skipping 11 matching lines...) Expand all Loading... |
418 ASSERT(!isolate_lib.IsNull()); | 415 ASSERT(!isolate_lib.IsNull()); |
419 const String& class_name = | 416 const String& class_name = |
420 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); | 417 String::Handle(isolate_lib.PrivateName(Symbols::_ReceivePortImpl())); |
421 const String& function_name = | 418 const String& function_name = |
422 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); | 419 String::Handle(isolate_lib.PrivateName(Symbols::_handleMessage())); |
423 function = Resolver::ResolveStatic(isolate_lib, | 420 function = Resolver::ResolveStatic(isolate_lib, |
424 class_name, | 421 class_name, |
425 function_name, | 422 function_name, |
426 kNumArguments, | 423 kNumArguments, |
427 Object::empty_array(), | 424 Object::empty_array(), |
428 Resolver::kIsQualified, | 425 Resolver::kIsQualified); |
429 NULL); // No ambiguity error expected. | |
430 ASSERT(!function.IsNull()); | 426 ASSERT(!function.IsNull()); |
431 isolate->object_store()->set_handle_message_function(function); | 427 isolate->object_store()->set_handle_message_function(function); |
432 } | 428 } |
433 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); | 429 const Array& args = Array::Handle(isolate, Array::New(kNumArguments)); |
434 args.SetAt(0, receive_port); | 430 args.SetAt(0, receive_port); |
435 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); | 431 args.SetAt(1, Integer::Handle(isolate, Integer::New(reply_port_id))); |
436 args.SetAt(2, message); | 432 args.SetAt(2, message); |
437 if (isolate->debugger()->IsStepping()) { | 433 if (isolate->debugger()->IsStepping()) { |
438 // If the isolate is being debugged and the debugger was stepping | 434 // If the isolate is being debugged and the debugger was stepping |
439 // through code, enable single stepping so debugger will stop | 435 // through code, enable single stepping so debugger will stop |
(...skipping 14 matching lines...) Expand all Loading... |
454 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); | 450 String::Handle(isolate_lib.PrivateName(Symbols::_SendPortImpl())); |
455 const int kNumArguments = 1; | 451 const int kNumArguments = 1; |
456 const String& function_name = | 452 const String& function_name = |
457 String::Handle(isolate_lib.PrivateName(Symbols::_create())); | 453 String::Handle(isolate_lib.PrivateName(Symbols::_create())); |
458 const Function& function = Function::Handle( | 454 const Function& function = Function::Handle( |
459 Resolver::ResolveStatic(isolate_lib, | 455 Resolver::ResolveStatic(isolate_lib, |
460 class_name, | 456 class_name, |
461 function_name, | 457 function_name, |
462 kNumArguments, | 458 kNumArguments, |
463 Object::empty_array(), | 459 Object::empty_array(), |
464 Resolver::kIsQualified, | 460 Resolver::kIsQualified)); |
465 NULL)); // No ambiguity error expected. | |
466 ASSERT(!function.IsNull()); | 461 ASSERT(!function.IsNull()); |
467 const Array& args = Array::Handle(Array::New(kNumArguments)); | 462 const Array& args = Array::Handle(Array::New(kNumArguments)); |
468 args.SetAt(0, Integer::Handle(Integer::New(port_id))); | 463 args.SetAt(0, Integer::Handle(Integer::New(port_id))); |
469 return DartEntry::InvokeFunction(function, args); | 464 return DartEntry::InvokeFunction(function, args); |
470 } | 465 } |
471 | 466 |
472 | 467 |
473 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, | 468 RawObject* DartLibraryCalls::MapSetAt(const Instance& map, |
474 const Instance& key, | 469 const Instance& key, |
475 const Instance& value) { | 470 const Instance& value) { |
(...skipping 23 matching lines...) Expand all Loading... |
499 String::Handle(Field::GetterName(Symbols::_id())))); | 494 String::Handle(Field::GetterName(Symbols::_id())))); |
500 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); | 495 const Function& func = Function::Handle(cls.LookupDynamicFunction(func_name)); |
501 ASSERT(!func.IsNull()); | 496 ASSERT(!func.IsNull()); |
502 const Array& args = Array::Handle(Array::New(1)); | 497 const Array& args = Array::Handle(Array::New(1)); |
503 args.SetAt(0, port); | 498 args.SetAt(0, port); |
504 return DartEntry::InvokeFunction(func, args); | 499 return DartEntry::InvokeFunction(func, args); |
505 } | 500 } |
506 | 501 |
507 | 502 |
508 } // namespace dart | 503 } // namespace dart |
OLD | NEW |