OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 | 5 |
6 #include "vm/ast_printer.h" | 6 #include "vm/ast_printer.h" |
7 #include "vm/class_finalizer.h" | 7 #include "vm/class_finalizer.h" |
8 #include "vm/longjump.h" | 8 #include "vm/longjump.h" |
9 #include "vm/object.h" | 9 #include "vm/object.h" |
10 #include "vm/parser.h" | 10 #include "vm/parser.h" |
11 #include "vm/symbols.h" | 11 #include "vm/symbols.h" |
12 #include "vm/unit_test.h" | 12 #include "vm/unit_test.h" |
13 | 13 |
14 namespace dart { | 14 namespace dart { |
15 | 15 |
16 | 16 |
17 void DumpFunction(const Library& lib, const char* cname, const char* fname) { | 17 void DumpFunction(const Library& lib, const char* cname, const char* fname) { |
18 const String& classname = String::Handle(Symbols::New(cname)); | 18 const String& classname = String::Handle(Symbols::New(cname)); |
19 Class& cls = Class::Handle(lib.LookupClass(classname)); | 19 String& ambiguity_error_msg = String::Handle(); |
20 EXPECT(!cls.IsNull()); | 20 Class& cls = Class::Handle(lib.LookupClass(classname, &ambiguity_error_msg)); |
| 21 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
21 | 22 |
22 String& funcname = String::Handle(String::New(fname)); | 23 String& funcname = String::Handle(String::New(fname)); |
23 Function& function = Function::ZoneHandle(cls.LookupStaticFunction(funcname)); | 24 Function& function = Function::ZoneHandle(cls.LookupStaticFunction(funcname)); |
24 EXPECT(!function.IsNull()); | 25 EXPECT(!function.IsNull()); |
25 | 26 |
26 bool retval; | 27 bool retval; |
27 Isolate* isolate = Isolate::Current(); | 28 Isolate* isolate = Isolate::Current(); |
28 EXPECT(isolate != NULL); | 29 EXPECT(isolate != NULL); |
29 LongJump* base = isolate->long_jump_base(); | 30 LongJump* base = isolate->long_jump_base(); |
30 LongJump jump; | 31 LongJump jump; |
(...skipping 12 matching lines...) Expand all Loading... |
43 isolate->set_long_jump_base(base); | 44 isolate->set_long_jump_base(base); |
44 } | 45 } |
45 | 46 |
46 | 47 |
47 void CheckField(const Library& lib, | 48 void CheckField(const Library& lib, |
48 const char* class_name, | 49 const char* class_name, |
49 const char* field_name, | 50 const char* field_name, |
50 bool expect_static, | 51 bool expect_static, |
51 bool is_final) { | 52 bool is_final) { |
52 const String& classname = String::Handle(Symbols::New(class_name)); | 53 const String& classname = String::Handle(Symbols::New(class_name)); |
53 Class& cls = Class::Handle(lib.LookupClass(classname)); | 54 String& ambiguity_error_msg = String::Handle(); |
54 EXPECT(!cls.IsNull()); | 55 Class& cls = Class::Handle(lib.LookupClass(classname, &ambiguity_error_msg)); |
| 56 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
55 | 57 |
56 String& fieldname = String::Handle(String::New(field_name)); | 58 String& fieldname = String::Handle(String::New(field_name)); |
57 String& functionname = String::Handle(); | 59 String& functionname = String::Handle(); |
58 Function& function = Function::Handle(); | 60 Function& function = Function::Handle(); |
59 Field& field = Field::Handle(); | 61 Field& field = Field::Handle(); |
60 if (expect_static) { | 62 if (expect_static) { |
61 field ^= cls.LookupStaticField(fieldname); | 63 field ^= cls.LookupStaticField(fieldname); |
62 functionname ^= Field::GetterName(fieldname); | 64 functionname ^= Field::GetterName(fieldname); |
63 function ^= cls.LookupStaticFunction(functionname); | 65 function ^= cls.LookupStaticFunction(functionname); |
64 EXPECT(function.IsNull()); | 66 EXPECT(function.IsNull()); |
(...skipping 13 matching lines...) Expand all Loading... |
78 | 80 |
79 EXPECT_EQ(field.is_static(), expect_static); | 81 EXPECT_EQ(field.is_static(), expect_static); |
80 } | 82 } |
81 | 83 |
82 | 84 |
83 void CheckFunction(const Library& lib, | 85 void CheckFunction(const Library& lib, |
84 const char* class_name, | 86 const char* class_name, |
85 const char* function_name, | 87 const char* function_name, |
86 bool expect_static) { | 88 bool expect_static) { |
87 const String& classname = String::Handle(Symbols::New(class_name)); | 89 const String& classname = String::Handle(Symbols::New(class_name)); |
88 Class& cls = Class::Handle(lib.LookupClass(classname)); | 90 String& ambiguity_error_msg = String::Handle(); |
89 EXPECT(!cls.IsNull()); | 91 Class& cls = Class::Handle(lib.LookupClass(classname, &ambiguity_error_msg)); |
| 92 EXPECT(!cls.IsNull()); // No ambiguity error expected. |
90 | 93 |
91 String& functionname = String::Handle(String::New(function_name)); | 94 String& functionname = String::Handle(String::New(function_name)); |
92 Function& function = Function::Handle(); | 95 Function& function = Function::Handle(); |
93 if (expect_static) { | 96 if (expect_static) { |
94 function ^= cls.LookupStaticFunction(functionname); | 97 function ^= cls.LookupStaticFunction(functionname); |
95 } else { | 98 } else { |
96 function ^= cls.LookupDynamicFunction(functionname); | 99 function ^= cls.LookupDynamicFunction(functionname); |
97 } | 100 } |
98 EXPECT(!function.IsNull()); | 101 EXPECT(!function.IsNull()); |
99 } | 102 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 Parser::ParseCompilationUnit(lib, script); | 163 Parser::ParseCompilationUnit(lib, script); |
161 EXPECT(ClassFinalizer::FinalizePendingClasses()); | 164 EXPECT(ClassFinalizer::FinalizePendingClasses()); |
162 | 165 |
163 DumpFunction(lib, "A", "foo"); | 166 DumpFunction(lib, "A", "foo"); |
164 DumpFunction(lib, "A", "bar"); | 167 DumpFunction(lib, "A", "bar"); |
165 DumpFunction(lib, "A", "baz"); | 168 DumpFunction(lib, "A", "baz"); |
166 DumpFunction(lib, "B", "bam"); | 169 DumpFunction(lib, "B", "bam"); |
167 } | 170 } |
168 | 171 |
169 } // namespace dart | 172 } // namespace dart |
OLD | NEW |