| 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/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 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 String& super_class_name = String::Handle(super_class.Name()); | 245 String& super_class_name = String::Handle(super_class.Name()); |
| 246 const Script& script = Script::Handle(cls.script()); | 246 const Script& script = Script::Handle(cls.script()); |
| 247 ReportError(script, cls.token_pos(), | 247 ReportError(script, cls.token_pos(), |
| 248 "class '%s' and superclass '%s' are not " | 248 "class '%s' and superclass '%s' are not " |
| 249 "both classes or both interfaces", | 249 "both classes or both interfaces", |
| 250 class_name.ToCString(), | 250 class_name.ToCString(), |
| 251 super_class_name.ToCString()); | 251 super_class_name.ToCString()); |
| 252 } | 252 } |
| 253 // If cls belongs to core lib or to core lib's implementation, restrictions | 253 // If cls belongs to core lib or to core lib's implementation, restrictions |
| 254 // about allowed interfaces are lifted. | 254 // about allowed interfaces are lifted. |
| 255 if ((cls.library() != Library::CoreLibrary()) && | 255 if (cls.library() != Library::CoreLibrary()) { |
| 256 (cls.library() != Library::CoreImplLibrary())) { | |
| 257 // Prevent extending core implementation classes. | 256 // Prevent extending core implementation classes. |
| 258 bool is_error = false; | 257 bool is_error = false; |
| 259 switch (super_class.id()) { | 258 switch (super_class.id()) { |
| 260 case kNumberCid: | 259 case kNumberCid: |
| 261 case kIntegerCid: | 260 case kIntegerCid: |
| 262 case kSmiCid: | 261 case kSmiCid: |
| 263 case kMintCid: | 262 case kMintCid: |
| 264 case kBigintCid: | 263 case kBigintCid: |
| 265 case kDoubleCid: | 264 case kDoubleCid: |
| 266 case kOneByteStringCid: | 265 case kOneByteStringCid: |
| (...skipping 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1382 } | 1381 } |
| 1383 | 1382 |
| 1384 // If the class/interface has no explicit interfaces, we are done. | 1383 // If the class/interface has no explicit interfaces, we are done. |
| 1385 Array& super_interfaces = Array::Handle(cls.interfaces()); | 1384 Array& super_interfaces = Array::Handle(cls.interfaces()); |
| 1386 if (super_interfaces.Length() == 0) { | 1385 if (super_interfaces.Length() == 0) { |
| 1387 return; | 1386 return; |
| 1388 } | 1387 } |
| 1389 | 1388 |
| 1390 // If cls belongs to core lib or to core lib's implementation, restrictions | 1389 // If cls belongs to core lib or to core lib's implementation, restrictions |
| 1391 // about allowed interfaces are lifted. | 1390 // about allowed interfaces are lifted. |
| 1392 const bool cls_belongs_to_core_lib = | 1391 const bool cls_belongs_to_core_lib = cls.library() == Library::CoreLibrary(); |
| 1393 (cls.library() == Library::CoreLibrary()) || | |
| 1394 (cls.library() == Library::CoreImplLibrary()); | |
| 1395 | 1392 |
| 1396 // Resolve and check the interfaces of cls. | 1393 // Resolve and check the interfaces of cls. |
| 1397 visited->Add(cls_index); | 1394 visited->Add(cls_index); |
| 1398 AbstractType& interface = AbstractType::Handle(); | 1395 AbstractType& interface = AbstractType::Handle(); |
| 1399 Class& interface_class = Class::Handle(); | 1396 Class& interface_class = Class::Handle(); |
| 1400 for (intptr_t i = 0; i < super_interfaces.Length(); i++) { | 1397 for (intptr_t i = 0; i < super_interfaces.Length(); i++) { |
| 1401 interface ^= super_interfaces.At(i); | 1398 interface ^= super_interfaces.At(i); |
| 1402 ResolveType(cls, interface, kCanonicalizeWellFormed); | 1399 ResolveType(cls, interface, kCanonicalizeWellFormed); |
| 1403 if (interface.IsTypeParameter()) { | 1400 if (interface.IsTypeParameter()) { |
| 1404 const Script& script = Script::Handle(cls.script()); | 1401 const Script& script = Script::Handle(cls.script()); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1618 void ClassFinalizer::ReportError(const char* format, ...) { | 1615 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1619 va_list args; | 1616 va_list args; |
| 1620 va_start(args, format); | 1617 va_start(args, format); |
| 1621 const Error& error = Error::Handle( | 1618 const Error& error = Error::Handle( |
| 1622 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1619 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1623 va_end(args); | 1620 va_end(args); |
| 1624 ReportError(error); | 1621 ReportError(error); |
| 1625 } | 1622 } |
| 1626 | 1623 |
| 1627 } // namespace dart | 1624 } // namespace dart |
| OLD | NEW |