| 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/assembler.h" | 6 #include "vm/assembler.h" |
| 7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
| 8 #include "vm/compiler.h" | 8 #include "vm/compiler.h" |
| 9 #include "vm/dart_entry.h" | 9 #include "vm/dart_entry.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 86 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
| 87 Class& cls = Class::Handle( | 87 Class& cls = Class::Handle( |
| 88 lib.LookupClass(String::Handle(String::NewSymbol("A")))); | 88 lib.LookupClass(String::Handle(String::NewSymbol("A")))); |
| 89 EXPECT(!cls.IsNull()); | 89 EXPECT(!cls.IsNull()); |
| 90 | 90 |
| 91 // Invoke the constructor. | 91 // Invoke the constructor. |
| 92 const Instance& instance = Instance::Handle(Instance::New(cls)); | 92 const Instance& instance = Instance::Handle(Instance::New(cls)); |
| 93 GrowableArray<const Object*> constructor_arguments(2); | 93 GrowableArray<const Object*> constructor_arguments(2); |
| 94 constructor_arguments.Add(&instance); | 94 constructor_arguments.Add(&instance); |
| 95 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); | 95 constructor_arguments.Add(&Smi::Handle(Smi::New(Function::kCtorPhaseAll))); |
| 96 const String& period = String::Handle(String::New(".")); | |
| 97 String& constructor_name = String::Handle(String::NewSymbol("A.")); | 96 String& constructor_name = String::Handle(String::NewSymbol("A.")); |
| 98 Function& constructor = | 97 Function& constructor = |
| 99 Function::Handle(cls.LookupConstructor(constructor_name)); | 98 Function::Handle(cls.LookupConstructor(constructor_name)); |
| 100 ASSERT(!constructor.IsNull()); | 99 ASSERT(!constructor.IsNull()); |
| 101 const Array& kNoArgumentNames = Array::Handle(); | 100 const Array& kNoArgumentNames = Array::Handle(); |
| 102 DartEntry::InvokeStatic(constructor, constructor_arguments, kNoArgumentNames); | 101 DartEntry::InvokeStatic(constructor, constructor_arguments, kNoArgumentNames); |
| 103 | 102 |
| 104 // Call foo. | 103 // Call foo. |
| 105 String& name = String::Handle(String::New("foo")); | 104 String& name = String::Handle(String::New("foo")); |
| 106 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); | 105 Function& function = Function::Handle(cls.LookupDynamicFunction(name)); |
| 107 EXPECT(!function.IsNull()); | 106 EXPECT(!function.IsNull()); |
| 108 GrowableArray<const Object*> arguments; | 107 GrowableArray<const Object*> arguments; |
| 109 const Object& retval = Object::Handle( | 108 const Object& retval = Object::Handle( |
| 110 DartEntry::InvokeDynamic( | 109 DartEntry::InvokeDynamic( |
| 111 instance, function, arguments, kNoArgumentNames)); | 110 instance, function, arguments, kNoArgumentNames)); |
| 112 EXPECT(retval.IsError()); | 111 EXPECT(retval.IsError()); |
| 113 Error& error = Error::Handle(); | 112 Error& error = Error::Handle(); |
| 114 error ^= retval.raw(); | 113 error ^= retval.raw(); |
| 115 EXPECT_SUBSTRING("++++", error.ToErrorCString()); | 114 EXPECT_SUBSTRING("++++", error.ToErrorCString()); |
| 116 } | 115 } |
| 117 | 116 |
| 118 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. | 117 #endif // TARGET_ARCH_IA32 || TARGET_ARCH_X64. |
| 119 | 118 |
| 120 } // namespace dart | 119 } // namespace dart |
| OLD | NEW |