| 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 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 cls.set_super_type(super_type); | 256 cls.set_super_type(super_type); |
| 257 const Class& super_class = Class::Handle(super_type.type_class()); | 257 const Class& super_class = Class::Handle(super_type.type_class()); |
| 258 if (cls.is_interface() != super_class.is_interface()) { | 258 if (cls.is_interface() != super_class.is_interface()) { |
| 259 String& class_name = String::Handle(cls.Name()); | 259 String& class_name = String::Handle(cls.Name()); |
| 260 String& super_class_name = String::Handle(super_class.Name()); | 260 String& super_class_name = String::Handle(super_class.Name()); |
| 261 ReportError("class '%s' and superclass '%s' are not " | 261 ReportError("class '%s' and superclass '%s' are not " |
| 262 "both classes or both interfaces.\n", | 262 "both classes or both interfaces.\n", |
| 263 class_name.ToCString(), | 263 class_name.ToCString(), |
| 264 super_class_name.ToCString()); | 264 super_class_name.ToCString()); |
| 265 } | 265 } |
| 266 // If cls belongs to core lib or to core lib's implementation, restrictions |
| 267 // about allowed interfaces are lifted. |
| 268 if ((cls.library() != Library::CoreLibrary()) && |
| 269 (cls.library() != Library::CoreImplLibrary())) { |
| 270 // Prevent extending core implementation classes Bool, Double, ObjectArray, |
| 271 // ImmutableArray, GrowableObjectArray, IntegerImplementation, Smi, Mint, |
| 272 // BigInt, OneByteString, TwoByteString, FourByteString. |
| 273 ObjectStore* object_store = Isolate::Current()->object_store(); |
| 274 const Library& core_impl_lib = Library::Handle(Library::CoreImplLibrary()); |
| 275 const String& integer_implementation_name = |
| 276 String::Handle(String::NewSymbol("IntegerImplementation")); |
| 277 const Class& integer_implementation_class = |
| 278 Class::Handle(core_impl_lib.LookupClass(integer_implementation_name)); |
| 279 const String& growable_object_array_name = |
| 280 String::Handle(String::NewSymbol("GrowableObjectArray")); |
| 281 const Class& growable_object_array_class = |
| 282 Class::Handle(core_impl_lib.LookupClass(growable_object_array_name)); |
| 283 if ((super_class.raw() == object_store->bool_class()) || |
| 284 (super_class.raw() == object_store->double_class()) || |
| 285 (super_class.raw() == object_store->array_class()) || |
| 286 (super_class.raw() == object_store->immutable_array_class()) || |
| 287 (super_class.raw() == growable_object_array_class.raw()) || |
| 288 (super_class.raw() == integer_implementation_class.raw()) || |
| 289 (super_class.raw() == object_store->smi_class()) || |
| 290 (super_class.raw() == object_store->mint_class()) || |
| 291 (super_class.raw() == object_store->bigint_class()) || |
| 292 (super_class.raw() == object_store->one_byte_string_class()) || |
| 293 (super_class.raw() == object_store->two_byte_string_class()) || |
| 294 (super_class.raw() == object_store->four_byte_string_class())) { |
| 295 ReportError("'%s' is not allowed to extend '%s'\n", |
| 296 String::Handle(cls.Name()).ToCString(), |
| 297 String::Handle(super_class.Name()).ToCString()); |
| 298 } |
| 299 } |
| 266 return; | 300 return; |
| 267 } | 301 } |
| 268 | 302 |
| 269 | 303 |
| 270 void ClassFinalizer::ResolveDefaultClass(const Class& interface) { | 304 void ClassFinalizer::ResolveDefaultClass(const Class& interface) { |
| 271 ASSERT(interface.is_interface()); | 305 ASSERT(interface.is_interface()); |
| 272 if (interface.is_finalized()) { | 306 if (interface.is_finalized()) { |
| 273 return; | 307 return; |
| 274 } | 308 } |
| 275 Type& factory_type = Type::Handle(interface.factory_type()); | 309 Type& factory_type = Type::Handle(interface.factory_type()); |
| (...skipping 759 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1035 ASSERT(msg_buffer != NULL); | 1069 ASSERT(msg_buffer != NULL); |
| 1036 va_list args; | 1070 va_list args; |
| 1037 va_start(args, format); | 1071 va_start(args, format); |
| 1038 OS::VSNPrint(msg_buffer, kBufferLength, format, args); | 1072 OS::VSNPrint(msg_buffer, kBufferLength, format, args); |
| 1039 va_end(args); | 1073 va_end(args); |
| 1040 isolate->long_jump_base()->Jump(1, msg_buffer); | 1074 isolate->long_jump_base()->Jump(1, msg_buffer); |
| 1041 UNREACHABLE(); | 1075 UNREACHABLE(); |
| 1042 } | 1076 } |
| 1043 | 1077 |
| 1044 } // namespace dart | 1078 } // namespace dart |
| OLD | NEW |