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 "vm/resolver.h" |
5 #include "platform/assert.h" | 6 #include "platform/assert.h" |
6 #include "vm/assembler.h" | 7 #include "vm/assembler.h" |
7 #include "vm/class_finalizer.h" | 8 #include "vm/class_finalizer.h" |
8 #include "vm/compiler.h" | 9 #include "vm/compiler.h" |
9 #include "vm/dart_entry.h" | 10 #include "vm/dart_entry.h" |
10 #include "vm/object.h" | 11 #include "vm/object.h" |
11 #include "vm/resolver.h" | |
12 #include "vm/symbols.h" | 12 #include "vm/symbols.h" |
13 #include "vm/unit_test.h" | 13 #include "vm/unit_test.h" |
14 | 14 |
15 namespace dart { | 15 namespace dart { |
16 | 16 |
17 // Setup function for invocation. | 17 // Setup function for invocation. |
18 static void SetupFunction(const char* test_library_name, | 18 static void SetupFunction(const char* test_library_name, |
19 const char* test_class_name, | 19 const char* test_class_name, |
20 const char* test_static_function_name, | 20 const char* test_static_function_name, |
21 bool is_static) { | 21 bool is_static) { |
(...skipping 20 matching lines...) Expand all Loading... |
42 String& source = String::Handle(zone, String::New(script_chars)); | 42 String& source = String::Handle(zone, String::New(script_chars)); |
43 Script& script = | 43 Script& script = |
44 Script::Handle(zone, Script::New(url, source, RawScript::kScriptTag)); | 44 Script::Handle(zone, Script::New(url, source, RawScript::kScriptTag)); |
45 const String& lib_name = String::Handle(zone, String::New(test_library_name)); | 45 const String& lib_name = String::Handle(zone, String::New(test_library_name)); |
46 Library& lib = Library::Handle(zone, Library::New(lib_name)); | 46 Library& lib = Library::Handle(zone, Library::New(lib_name)); |
47 lib.Register(thread); | 47 lib.Register(thread); |
48 EXPECT(CompilerTest::TestCompileScript(lib, script)); | 48 EXPECT(CompilerTest::TestCompileScript(lib, script)); |
49 EXPECT(ClassFinalizer::ProcessPendingClasses()); | 49 EXPECT(ClassFinalizer::ProcessPendingClasses()); |
50 } | 50 } |
51 | 51 |
52 | |
53 // Setup a static function for invocation. | 52 // Setup a static function for invocation. |
54 static void SetupStaticFunction(const char* test_library_name, | 53 static void SetupStaticFunction(const char* test_library_name, |
55 const char* test_class_name, | 54 const char* test_class_name, |
56 const char* test_static_function_name) { | 55 const char* test_static_function_name) { |
57 // Setup a static dart class and function. | 56 // Setup a static dart class and function. |
58 SetupFunction(test_library_name, test_class_name, test_static_function_name, | 57 SetupFunction(test_library_name, test_class_name, test_static_function_name, |
59 true); | 58 true); |
60 } | 59 } |
61 | 60 |
62 | |
63 // Setup an instance function for invocation. | 61 // Setup an instance function for invocation. |
64 static void SetupInstanceFunction(const char* test_library_name, | 62 static void SetupInstanceFunction(const char* test_library_name, |
65 const char* test_class_name, | 63 const char* test_class_name, |
66 const char* test_function_name) { | 64 const char* test_function_name) { |
67 // Setup a static dart class and function. | 65 // Setup a static dart class and function. |
68 SetupFunction(test_library_name, test_class_name, test_function_name, false); | 66 SetupFunction(test_library_name, test_class_name, test_function_name, false); |
69 } | 67 } |
70 | 68 |
71 | |
72 TEST_CASE(DartStaticResolve) { | 69 TEST_CASE(DartStaticResolve) { |
73 const char* test_library_name = "ResolverApp"; | 70 const char* test_library_name = "ResolverApp"; |
74 const char* test_class_name = "A"; | 71 const char* test_class_name = "A"; |
75 const char* test_static_function_name = "static_foo"; | 72 const char* test_static_function_name = "static_foo"; |
76 const int kTestValue = 42; | 73 const int kTestValue = 42; |
77 | 74 |
78 // Setup a static function which can be invoked. | 75 // Setup a static function which can be invoked. |
79 SetupStaticFunction(test_library_name, test_class_name, | 76 SetupStaticFunction(test_library_name, test_class_name, |
80 test_static_function_name); | 77 test_static_function_name); |
81 | 78 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 const String& super_class_name = String::Handle(String::New("Base")); | 118 const String& super_class_name = String::Handle(String::New("Base")); |
122 const int kTypeArgsLen = 0; | 119 const int kTypeArgsLen = 0; |
123 const int kNumArguments = 0; | 120 const int kNumArguments = 0; |
124 const Function& super_function = Function::Handle(Resolver::ResolveStatic( | 121 const Function& super_function = Function::Handle(Resolver::ResolveStatic( |
125 library, super_class_name, super_static_function_name, kTypeArgsLen, | 122 library, super_class_name, super_static_function_name, kTypeArgsLen, |
126 kNumArguments, Object::empty_array())); | 123 kNumArguments, Object::empty_array())); |
127 EXPECT(!super_function.IsNull()); // No ambiguity error expected. | 124 EXPECT(!super_function.IsNull()); // No ambiguity error expected. |
128 } | 125 } |
129 } | 126 } |
130 | 127 |
131 | |
132 TEST_CASE(DartDynamicResolve) { | 128 TEST_CASE(DartDynamicResolve) { |
133 const char* test_library_name = "ResolverApp"; | 129 const char* test_library_name = "ResolverApp"; |
134 const char* test_class_name = "A"; | 130 const char* test_class_name = "A"; |
135 const char* test_function_name = "foo"; | 131 const char* test_function_name = "foo"; |
136 const int kTestValue = 42; | 132 const int kTestValue = 42; |
137 | 133 |
138 // Setup a function which can be invoked. | 134 // Setup a function which can be invoked. |
139 SetupInstanceFunction(test_library_name, test_class_name, test_function_name); | 135 SetupInstanceFunction(test_library_name, test_class_name, test_function_name); |
140 | 136 |
141 // Now create an instance object of the class and try to | 137 // Now create an instance object of the class and try to |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
189 ArgumentsDescriptor args_desc( | 185 ArgumentsDescriptor args_desc( |
190 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments))); | 186 Array::Handle(ArgumentsDescriptor::New(kTypeArgsLen, kNumArguments))); |
191 const String& super_function_name = String::Handle(String::New("dynCall")); | 187 const String& super_function_name = String::Handle(String::New("dynCall")); |
192 const Function& super_function = Function::Handle( | 188 const Function& super_function = Function::Handle( |
193 Resolver::ResolveDynamic(receiver, super_function_name, args_desc)); | 189 Resolver::ResolveDynamic(receiver, super_function_name, args_desc)); |
194 EXPECT(!super_function.IsNull()); | 190 EXPECT(!super_function.IsNull()); |
195 } | 191 } |
196 } | 192 } |
197 | 193 |
198 } // namespace dart | 194 } // namespace dart |
OLD | NEW |