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 2248 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2319 const String& class_name = String::Handle(Symbols::New("MyClass")); | 2319 const String& class_name = String::Handle(Symbols::New("MyClass")); |
2320 const Script& script = Script::Handle(); | 2320 const Script& script = Script::Handle(); |
2321 const Class& cls = | 2321 const Class& cls = |
2322 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); | 2322 Class::Handle(Class::New(class_name, script, Scanner::kDummyTokenIndex)); |
2323 const Array& functions = Array::Handle(Array::New(1)); | 2323 const Array& functions = Array::Handle(Array::New(1)); |
2324 | 2324 |
2325 const Context& context = Context::Handle(Context::New(0)); | 2325 const Context& context = Context::Handle(Context::New(0)); |
2326 Function& parent = Function::Handle(); | 2326 Function& parent = Function::Handle(); |
2327 const String& parent_name = String::Handle(Symbols::New("foo_papa")); | 2327 const String& parent_name = String::Handle(Symbols::New("foo_papa")); |
2328 parent = Function::New(parent_name, RawFunction::kRegularFunction, | 2328 parent = Function::New(parent_name, RawFunction::kRegularFunction, |
2329 false, false, 0); | 2329 false, false, false, 0); |
2330 functions.SetAt(0, parent); | 2330 functions.SetAt(0, parent); |
2331 cls.SetFunctions(functions); | 2331 cls.SetFunctions(functions); |
2332 | 2332 |
2333 Function& function = Function::Handle(); | 2333 Function& function = Function::Handle(); |
2334 const String& function_name = String::Handle(Symbols::New("foo")); | 2334 const String& function_name = String::Handle(Symbols::New("foo")); |
2335 function = Function::NewClosureFunction(function_name, parent, 0); | 2335 function = Function::NewClosureFunction(function_name, parent, 0); |
2336 const Class& signature_class = Class::Handle( | 2336 const Class& signature_class = Class::Handle( |
2337 Class::NewSignatureClass(function_name, function, script)); | 2337 Class::NewSignatureClass(function_name, function, script)); |
2338 const Closure& closure = Closure::Handle(Closure::New(function, context)); | 2338 const Closure& closure = Closure::Handle(Closure::New(function, context)); |
2339 const Class& closure_class = Class::Handle(closure.clazz()); | 2339 const Class& closure_class = Class::Handle(closure.clazz()); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2389 } | 2389 } |
2390 | 2390 |
2391 | 2391 |
2392 // only ia32 and x64 can run execution tests. | 2392 // only ia32 and x64 can run execution tests. |
2393 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) | 2393 #if defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64) |
2394 | 2394 |
2395 static Function* CreateFunction(const char* name) { | 2395 static Function* CreateFunction(const char* name) { |
2396 const String& function_name = String::ZoneHandle(Symbols::New(name)); | 2396 const String& function_name = String::ZoneHandle(Symbols::New(name)); |
2397 Function& function = Function::ZoneHandle( | 2397 Function& function = Function::ZoneHandle( |
2398 Function::New(function_name, RawFunction::kRegularFunction, | 2398 Function::New(function_name, RawFunction::kRegularFunction, |
2399 true, false, 0)); | 2399 true, false, false, 0)); |
2400 return &function; | 2400 return &function; |
2401 } | 2401 } |
2402 | 2402 |
2403 // Test for Code and Instruction object creation. | 2403 // Test for Code and Instruction object creation. |
2404 TEST_CASE(Code) { | 2404 TEST_CASE(Code) { |
2405 extern void GenerateIncrement(Assembler* assembler); | 2405 extern void GenerateIncrement(Assembler* assembler); |
2406 Assembler _assembler_; | 2406 Assembler _assembler_; |
2407 GenerateIncrement(&_assembler_); | 2407 GenerateIncrement(&_assembler_); |
2408 Code& code = Code::Handle(Code::FinalizeCode( | 2408 Code& code = Code::Handle(Code::FinalizeCode( |
2409 *CreateFunction("Test_Code"), &_assembler_)); | 2409 *CreateFunction("Test_Code"), &_assembler_)); |
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2573 count++; | 2573 count++; |
2574 } | 2574 } |
2575 ASSERT(count == 2); | 2575 ASSERT(count == 2); |
2576 } | 2576 } |
2577 | 2577 |
2578 | 2578 |
2579 static RawFunction* GetDummyTarget(const char* name) { | 2579 static RawFunction* GetDummyTarget(const char* name) { |
2580 const String& function_name = String::Handle(Symbols::New(name)); | 2580 const String& function_name = String::Handle(Symbols::New(name)); |
2581 const bool is_static = false; | 2581 const bool is_static = false; |
2582 const bool is_const = false; | 2582 const bool is_const = false; |
| 2583 const bool is_external = false; |
2583 return Function::New(function_name, | 2584 return Function::New(function_name, |
2584 RawFunction::kRegularFunction, | 2585 RawFunction::kRegularFunction, |
2585 is_static, | 2586 is_static, |
2586 is_const, | 2587 is_const, |
| 2588 is_external, |
2587 0); | 2589 0); |
2588 } | 2590 } |
2589 | 2591 |
2590 | 2592 |
2591 TEST_CASE(ICData) { | 2593 TEST_CASE(ICData) { |
2592 Function& function = Function::Handle(GetDummyTarget("Bern")); | 2594 Function& function = Function::Handle(GetDummyTarget("Bern")); |
2593 const intptr_t id = 12; | 2595 const intptr_t id = 12; |
2594 const intptr_t num_args_tested = 1; | 2596 const intptr_t num_args_tested = 1; |
2595 const String& target_name = String::Handle(String::New("Thun")); | 2597 const String& target_name = String::Handle(String::New("Thun")); |
2596 ICData& o1 = ICData::Handle(); | 2598 ICData& o1 = ICData::Handle(); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2782 // Named double-private constructor mismatch. | 2784 // Named double-private constructor mismatch. |
2783 mangled_name = OneByteString::New("foo@12345.named@12345"); | 2785 mangled_name = OneByteString::New("foo@12345.named@12345"); |
2784 bare_name = OneByteString::New("foo.name"); | 2786 bare_name = OneByteString::New("foo.name"); |
2785 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); | 2787 EXPECT(!mangled_name.EqualsIgnoringPrivateKey(bare_name)); |
2786 } | 2788 } |
2787 | 2789 |
2788 | 2790 |
2789 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). | 2791 #endif // defined(TARGET_ARCH_IA32) || defined(TARGET_ARCH_X64). |
2790 | 2792 |
2791 } // namespace dart | 2793 } // namespace dart |
OLD | NEW |