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/bigint_operations.h" | 7 #include "vm/bigint_operations.h" |
8 #include "vm/isolate.h" | 8 #include "vm/isolate.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/object_store.h" | 10 #include "vm/object_store.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 // Class has no fields. | 23 // Class has no fields. |
24 const Array& no_fields = Array::Handle(Array::Empty()); | 24 const Array& no_fields = Array::Handle(Array::Empty()); |
25 cls.SetFields(no_fields); | 25 cls.SetFields(no_fields); |
26 | 26 |
27 // Create and populate the function arrays. | 27 // Create and populate the function arrays. |
28 const Array& functions = Array::Handle(Array::New(6)); | 28 const Array& functions = Array::Handle(Array::New(6)); |
29 Function& function = Function::Handle(); | 29 Function& function = Function::Handle(); |
30 String& function_name = String::Handle(); | 30 String& function_name = String::Handle(); |
31 function_name = Symbols::New("foo"); | 31 function_name = Symbols::New("foo"); |
32 function = Function::New( | 32 function = Function::New( |
33 function_name, RawFunction::kRegularFunction, false, false, 0); | 33 function_name, RawFunction::kRegularFunction, false, false, false, 0); |
34 functions.SetAt(0, function); | 34 functions.SetAt(0, function); |
35 function_name = Symbols::New("bar"); | 35 function_name = Symbols::New("bar"); |
36 function = Function::New( | 36 function = Function::New( |
37 function_name, RawFunction::kRegularFunction, false, false, 0); | 37 function_name, RawFunction::kRegularFunction, false, false, false, 0); |
38 | 38 |
39 const int kNumFixedParameters = 2; | 39 const int kNumFixedParameters = 2; |
40 const int kNumOptionalParameters = 3; | 40 const int kNumOptionalParameters = 3; |
41 function.set_num_fixed_parameters(kNumFixedParameters); | 41 function.set_num_fixed_parameters(kNumFixedParameters); |
42 function.set_num_optional_parameters(kNumOptionalParameters); | 42 function.set_num_optional_parameters(kNumOptionalParameters); |
43 functions.SetAt(1, function); | 43 functions.SetAt(1, function); |
44 | 44 |
45 function_name = Symbols::New("baz"); | 45 function_name = Symbols::New("baz"); |
46 function = Function::New( | 46 function = Function::New( |
47 function_name, RawFunction::kRegularFunction, false, false, 0); | 47 function_name, RawFunction::kRegularFunction, false, false, false, 0); |
48 functions.SetAt(2, function); | 48 functions.SetAt(2, function); |
49 | 49 |
50 function_name = Symbols::New("Foo"); | 50 function_name = Symbols::New("Foo"); |
51 function = Function::New( | 51 function = Function::New( |
52 function_name, RawFunction::kRegularFunction, true, false, 0); | 52 function_name, RawFunction::kRegularFunction, true, false, false, 0); |
53 functions.SetAt(3, function); | 53 functions.SetAt(3, function); |
54 function_name = Symbols::New("Bar"); | 54 function_name = Symbols::New("Bar"); |
55 function = Function::New( | 55 function = Function::New( |
56 function_name, RawFunction::kRegularFunction, true, false, 0); | 56 function_name, RawFunction::kRegularFunction, true, false, false, 0); |
57 functions.SetAt(4, function); | 57 functions.SetAt(4, function); |
58 function_name = Symbols::New("BaZ"); | 58 function_name = Symbols::New("BaZ"); |
59 function = Function::New( | 59 function = Function::New( |
60 function_name, RawFunction::kRegularFunction, true, false, 0); | 60 function_name, RawFunction::kRegularFunction, true, false, false, 0); |
61 functions.SetAt(5, function); | 61 functions.SetAt(5, function); |
62 | 62 |
63 // Setup the functions in the class. | 63 // Setup the functions in the class. |
64 cls.SetFunctions(functions); | 64 cls.SetFunctions(functions); |
65 | 65 |
66 function_name = String::New("Foo"); | 66 function_name = String::New("Foo"); |
67 function = cls.LookupDynamicFunction(function_name); | 67 function = cls.LookupDynamicFunction(function_name); |
68 EXPECT(function.IsNull()); | 68 EXPECT(function.IsNull()); |
69 function = cls.LookupStaticFunction(function_name); | 69 function = cls.LookupStaticFunction(function_name); |
70 EXPECT(!function.IsNull()); | 70 EXPECT(!function.IsNull()); |
(...skipping 2247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2318 const String& class_name = String::Handle(Symbols::New("MyClass")); | 2318 const String& class_name = String::Handle(Symbols::New("MyClass")); |
2319 const Script& script = Script::Handle(); | 2319 const Script& script = Script::Handle(); |
2320 const Class& cls = | 2320 const Class& cls = |
2321 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 2321 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
2322 const Array& functions = Array::Handle(Array::New(1)); | 2322 const Array& functions = Array::Handle(Array::New(1)); |
2323 | 2323 |
2324 const Context& context = Context::Handle(Context::New(0)); | 2324 const Context& context = Context::Handle(Context::New(0)); |
2325 Function& parent = Function::Handle(); | 2325 Function& parent = Function::Handle(); |
2326 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 2326 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
2327 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 2327 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
2328 false, false, 0); | 2328 false, false, false, 0); |
2329 functions.SetAt(0, parent); | 2329 functions.SetAt(0, parent); |
2330 cls.SetFunctions(functions); | 2330 cls.SetFunctions(functions); |
2331 | 2331 |
2332 Function& function = Function::Handle(); | 2332 Function& function = Function::Handle(); |
2333 const String& function_name = String::Handle(Symbols::New("foo")); | 2333 const String& function_name = String::Handle(Symbols::New("foo")); |
2334 function = Function::NewClosureFunction(function_name, parent, 0); | 2334 function = Function::NewClosureFunction(function_name, parent, 0); |
2335 const Class& signature_class = Class::Handle( | 2335 const Class& signature_class = Class::Handle( |
2336 Class::NewSignatureClass(function_name, function, script)); | 2336 Class::NewSignatureClass(function_name, function, script)); |
2337 const Closure& closure = Closure::Handle(Closure::New(function, context)); | 2337 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
2338 const Class& closure_class = Class::Handle(closure.clazz()); | 2338 const Class& closure_class = Class::Handle(closure.clazz()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2388 } | 2388 } |
2389 | 2389 |
2390 | 2390 |
2391 // only ia32 and x64 can run execution tests. | 2391 // only ia32 and x64 can run execution tests. |
2392 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 2392 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
2393 | 2393 |
2394 static Function* CreateFunction(const char* name) { | 2394 static Function* CreateFunction(const char* name) { |
2395 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 2395 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
2396 Function& function = Function::ZoneHandle( | 2396 Function& function = Function::ZoneHandle( |
2397 Function::New(function_name, RawFunction::kRegularFunction, | 2397 Function::New(function_name, RawFunction::kRegularFunction, |
2398 true, false, 0)); | 2398 true, false, false, 0)); |
2399 return &function; | 2399 return &function; |
2400 } | 2400 } |
2401 | 2401 |
2402 // Test for Code and Instruction object creation. | 2402 // Test for Code and Instruction object creation. |
2403 TEST_CASE(Code) { | 2403 TEST_CASE(Code) { |
2404 extern void GenerateIncrement(Assembler* assembler); | 2404 extern void GenerateIncrement(Assembler* assembler); |
2405 Assembler _assembler_; | 2405 Assembler _assembler_; |
2406 GenerateIncrement(&_assembler_); | 2406 GenerateIncrement(&_assembler_); |
2407 Code& code = Code::Handle(Code::FinalizeCode( | 2407 Code& code = Code::Handle(Code::FinalizeCode( |
2408 *CreateFunction("Test_Code"), &_assembler_)); | 2408 *CreateFunction("Test_Code"), &_assembler_)); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2571 count++; | 2571 count++; |
2572 } | 2572 } |
2573 ASSERT(count == 2); | 2573 ASSERT(count == 2); |
2574 } | 2574 } |
2575 | 2575 |
2576 | 2576 |
2577 static RawFunction* GetDummyTarget(const char* name) { | 2577 static RawFunction* GetDummyTarget(const char* name) { |
2578 const String& function_name = String::Handle(Symbols::New(name)); | 2578 const String& function_name = String::Handle(Symbols::New(name)); |
2579 const bool is_static = false; | 2579 const bool is_static = false; |
2580 const bool is_const = false; | 2580 const bool is_const = false; |
| 2581 const bool is_external = false; |
2581 return Function::New(function_name, | 2582 return Function::New(function_name, |
2582 RawFunction::kRegularFunction, | 2583 RawFunction::kRegularFunction, |
2583 is_static, | 2584 is_static, |
2584 is_const, | 2585 is_const, |
| 2586 is_external, |
2585 0); | 2587 0); |
2586 } | 2588 } |
2587 | 2589 |
2588 | 2590 |
2589 TEST_CASE(ICData) { | 2591 TEST_CASE(ICData) { |
2590 Function& function = Function::Handle(GetDummyTarget("Bern")); | 2592 Function& function = Function::Handle(GetDummyTarget("Bern")); |
2591 const intptr_t id = 12; | 2593 const intptr_t id = 12; |
2592 const intptr_t num_args_tested = 1; | 2594 const intptr_t num_args_tested = 1; |
2593 const String& target_name = String::Handle(String::New("Thun")); | 2595 const String& target_name = String::Handle(String::New("Thun")); |
2594 ICData& o1 = ICData::Handle(); | 2596 ICData& o1 = ICData::Handle(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2780 // Named double-private constructor mismatch. | 2782 // Named double-private constructor mismatch. |
2781 mangled_name = OneByteString::New("foo@12345.named@12345"); | 2783 mangled_name = OneByteString::New("foo@12345.named@12345"); |
2782 bare_name = OneByteString::New("foo.name"); | 2784 bare_name = OneByteString::New("foo.name"); |
2783 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); | 2785 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); |
2784 } | 2786 } |
2785 | 2787 |
2786 | 2788 |
2787 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2789 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2788 | 2790 |
2789 } // namespace dart | 2791 } // namespace dart |
OLD | NEW |