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/globals.h" | 6 #include "vm/globals.h" |
7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 7 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
8 | 8 |
9 #include "vm/ast.h" | 9 #include "vm/ast.h" |
10 #include "vm/assembler.h" | 10 #include "vm/assembler.h" |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
334 | 334 |
335 String& constructor_name = String::Handle(String::New("A.")); | 335 String& constructor_name = String::Handle(String::New("A.")); |
336 Function& constructor = | 336 Function& constructor = |
337 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 337 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
338 EXPECT(!constructor.IsNull()); | 338 EXPECT(!constructor.IsNull()); |
339 | 339 |
340 // The unit test creates an instance of class A and calls function 'bar'. | 340 // The unit test creates an instance of class A and calls function 'bar'. |
341 String& function_bar_name = String::ZoneHandle(String::NewSymbol("bar")); | 341 String& function_bar_name = String::ZoneHandle(String::NewSymbol("bar")); |
342 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); | 342 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); |
343 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); | 343 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); |
| 344 const LocalVariable& allocated = *test->CreateTempConstVariable("alloc"); |
344 InstanceCallNode* call_bar = new InstanceCallNode( | 345 InstanceCallNode* call_bar = new InstanceCallNode( |
345 kPos, | 346 kPos, |
346 new ConstructorCallNode( | 347 new ConstructorCallNode( |
347 kPos, no_type_arguments, constructor, no_arguments), | 348 kPos, no_type_arguments, constructor, no_arguments, allocated), |
348 function_bar_name, | 349 function_bar_name, |
349 no_arguments); | 350 no_arguments); |
350 | 351 |
351 test->node_sequence()->Add(new ReturnNode(kPos, call_bar)); | 352 test->node_sequence()->Add(new ReturnNode(kPos, call_bar)); |
352 } | 353 } |
353 CODEGEN_TEST_RUN(InstanceCallCodegen, Smi::New(42)) | 354 CODEGEN_TEST_RUN(InstanceCallCodegen, Smi::New(42)) |
354 | 355 |
355 | 356 |
356 // Tested Dart code: | 357 // Tested Dart code: |
357 // int sum(int a, int b, | 358 // int sum(int a, int b, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
468 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); | 469 Class& cls = Class::ZoneHandle(LookupClass(lib, "A")); |
469 EXPECT(!cls.IsNull()); | 470 EXPECT(!cls.IsNull()); |
470 | 471 |
471 String& constructor_name = String::Handle(String::New("A.")); | 472 String& constructor_name = String::Handle(String::New("A.")); |
472 Function& constructor = | 473 Function& constructor = |
473 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); | 474 Function::ZoneHandle(cls.LookupConstructor(constructor_name)); |
474 EXPECT(!constructor.IsNull()); | 475 EXPECT(!constructor.IsNull()); |
475 | 476 |
476 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); | 477 const TypeArguments& no_type_arguments = TypeArguments::ZoneHandle(); |
477 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); | 478 ArgumentListNode* no_arguments = new ArgumentListNode(kPos); |
| 479 const LocalVariable& allocated = *test->CreateTempConstVariable("alloc"); |
478 test->node_sequence()->Add(new ReturnNode(kPos, new ConstructorCallNode( | 480 test->node_sequence()->Add(new ReturnNode(kPos, new ConstructorCallNode( |
479 kPos, no_type_arguments, constructor, no_arguments))); | 481 kPos, no_type_arguments, constructor, no_arguments, allocated))); |
480 } | 482 } |
481 | 483 |
482 | 484 |
483 CODEGEN_TEST_RAW_RUN(AllocateNewObjectCodegen, function) { | 485 CODEGEN_TEST_RAW_RUN(AllocateNewObjectCodegen, function) { |
484 GrowableArray<const Object*> arguments; | 486 GrowableArray<const Object*> arguments; |
485 const Array& kNoArgumentNames = Array::Handle(); | 487 const Array& kNoArgumentNames = Array::Handle(); |
486 Object& result = Object::Handle(); | 488 Object& result = Object::Handle(); |
487 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); | 489 result = DartEntry::InvokeStatic(function, arguments, kNoArgumentNames); |
488 EXPECT(!result.IsError()); | 490 EXPECT(!result.IsError()); |
489 const Library& app_lib = Library::Handle( | 491 const Library& app_lib = Library::Handle( |
490 Isolate::Current()->object_store()->registered_libraries()); | 492 Isolate::Current()->object_store()->registered_libraries()); |
491 const Class& cls = Class::Handle( | 493 const Class& cls = Class::Handle( |
492 app_lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 494 app_lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
493 EXPECT_EQ(cls.raw(), result.clazz()); | 495 EXPECT_EQ(cls.raw(), result.clazz()); |
494 } | 496 } |
495 | 497 |
496 } // namespace dart | 498 } // namespace dart |
497 | 499 |
498 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) | 500 #endif // defined TARGET_ARCH_IA32 || defined(TARGET_ARCH_X64) |
OLD | NEW |