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 #include "vm/class_finalizer.h" | 5 #include "vm/class_finalizer.h" |
6 | 6 |
7 #include "vm/flags.h" | 7 #include "vm/flags.h" |
8 #include "vm/heap.h" | 8 #include "vm/heap.h" |
9 #include "vm/isolate.h" | 9 #include "vm/isolate.h" |
10 #include "vm/longjump.h" | 10 #include "vm/longjump.h" |
(...skipping 981 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
992 } | 992 } |
993 // Mark as finalized before resolving type parameter upper bounds and member | 993 // Mark as finalized before resolving type parameter upper bounds and member |
994 // types in order to break cycles. | 994 // types in order to break cycles. |
995 cls.Finalize(); | 995 cls.Finalize(); |
996 ResolveAndFinalizeUpperBounds(cls); | 996 ResolveAndFinalizeUpperBounds(cls); |
997 ResolveAndFinalizeMemberTypes(cls); | 997 ResolveAndFinalizeMemberTypes(cls); |
998 // Run additional checks after all types are finalized. | 998 // Run additional checks after all types are finalized. |
999 if (cls.is_const()) { | 999 if (cls.is_const()) { |
1000 CheckForLegalConstClass(cls); | 1000 CheckForLegalConstClass(cls); |
1001 } | 1001 } |
| 1002 // Check to ensure we don't have classes with native fields in libraries |
| 1003 // which do not have a native resolver. |
| 1004 if (cls.num_native_fields() != 0) { |
| 1005 const Library& lib = Library::Handle(cls.library()); |
| 1006 if (lib.native_entry_resolver() == NULL) { |
| 1007 const String& cls_name = String::Handle(cls.Name()); |
| 1008 const String& lib_name = String::Handle(lib.url()); |
| 1009 ReportError("class '%s' is trying to extend a native fields class," |
| 1010 "but library '%s' has no native resolvers", |
| 1011 cls_name.ToCString(), lib_name.ToCString()); |
| 1012 } |
| 1013 } |
1002 } | 1014 } |
1003 | 1015 |
1004 | 1016 |
1005 bool ClassFinalizer::IsSuperCycleFree(const Class& cls) { | 1017 bool ClassFinalizer::IsSuperCycleFree(const Class& cls) { |
1006 Class& test1 = Class::Handle(cls.raw()); | 1018 Class& test1 = Class::Handle(cls.raw()); |
1007 Class& test2 = Class::Handle(cls.SuperClass()); | 1019 Class& test2 = Class::Handle(cls.SuperClass()); |
1008 // A finalized class has been checked for cycles. | 1020 // A finalized class has been checked for cycles. |
1009 // Using the hare and tortoise algorithm for locating cycles. | 1021 // Using the hare and tortoise algorithm for locating cycles. |
1010 while (!test1.is_finalized() && | 1022 while (!test1.is_finalized() && |
1011 !test2.IsNull() && !test2.is_finalized()) { | 1023 !test2.IsNull() && !test2.is_finalized()) { |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 va_end(args); | 1274 va_end(args); |
1263 if (FLAG_warning_as_error) { | 1275 if (FLAG_warning_as_error) { |
1264 isolate->long_jump_base()->Jump(1, msg_buffer); | 1276 isolate->long_jump_base()->Jump(1, msg_buffer); |
1265 UNREACHABLE(); | 1277 UNREACHABLE(); |
1266 } else { | 1278 } else { |
1267 OS::Print(msg_buffer); | 1279 OS::Print(msg_buffer); |
1268 } | 1280 } |
1269 } | 1281 } |
1270 | 1282 |
1271 } // namespace dart | 1283 } // namespace dart |
OLD | NEW |