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