| 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 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 292 case kUint64ArrayCid: | 292 case kUint64ArrayCid: |
| 293 case kExternalUint64ArrayCid: | 293 case kExternalUint64ArrayCid: |
| 294 case kFloat32ArrayCid: | 294 case kFloat32ArrayCid: |
| 295 case kExternalFloat32ArrayCid: | 295 case kExternalFloat32ArrayCid: |
| 296 case kFloat64ArrayCid: | 296 case kFloat64ArrayCid: |
| 297 case kExternalFloat64ArrayCid: | 297 case kExternalFloat64ArrayCid: |
| 298 case kDartFunctionCid: | 298 case kDartFunctionCid: |
| 299 case kWeakPropertyCid: | 299 case kWeakPropertyCid: |
| 300 is_error = true; | 300 is_error = true; |
| 301 break; | 301 break; |
| 302 default: | 302 default: { |
| 303 // Special case: classes for which we don't have a known class id. | 303 // Special case: classes for which we don't have a known class id. |
| 304 // TODO(regis): Why isn't comparing to kIntegerCid enough? | 304 // TODO(regis): Why isn't comparing to kIntegerCid enough? |
| 305 if (Type::Handle(Type::Double()).type_class() == super_class.raw() || | 305 RawClass* super_raw = super_class.raw(); |
| 306 Type::Handle(Type::IntType()).type_class() == super_class.raw()) { | 306 if (Type::Handle(Type::Double()).type_class() == super_raw || |
| 307 Type::Handle(Type::IntType()).type_class() == super_raw || |
| 308 Type::Handle(Type::StringType()).type_class() == super_raw) { |
| 307 is_error = true; | 309 is_error = true; |
| 308 } | 310 } |
| 309 break; | 311 break; |
| 312 } |
| 310 } | 313 } |
| 311 if (is_error) { | 314 if (is_error) { |
| 312 const Script& script = Script::Handle(cls.script()); | 315 const Script& script = Script::Handle(cls.script()); |
| 313 ReportError(script, cls.token_pos(), | 316 ReportError(script, cls.token_pos(), |
| 314 "'%s' is not allowed to extend '%s'", | 317 "'%s' is not allowed to extend '%s'", |
| 315 String::Handle(cls.Name()).ToCString(), | 318 String::Handle(cls.Name()).ToCString(), |
| 316 String::Handle(super_class.Name()).ToCString()); | 319 String::Handle(super_class.Name()).ToCString()); |
| 317 } | 320 } |
| 318 } | 321 } |
| 319 return; | 322 return; |
| (...skipping 1051 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1371 } | 1374 } |
| 1372 // Verify that unless cls belongs to core lib, it cannot extend or implement | 1375 // Verify that unless cls belongs to core lib, it cannot extend or implement |
| 1373 // any of bool, num, int, double, String, Function, Dynamic. | 1376 // any of bool, num, int, double, String, Function, Dynamic. |
| 1374 // The exception is signature classes, which are compiler generated and | 1377 // The exception is signature classes, which are compiler generated and |
| 1375 // represent a function type, therefore implementing the Function interface. | 1378 // represent a function type, therefore implementing the Function interface. |
| 1376 if (!cls_belongs_to_core_lib) { | 1379 if (!cls_belongs_to_core_lib) { |
| 1377 if (interface.IsBoolType() || | 1380 if (interface.IsBoolType() || |
| 1378 interface.IsNumberType() || | 1381 interface.IsNumberType() || |
| 1379 interface.IsIntType() || | 1382 interface.IsIntType() || |
| 1380 interface.IsDoubleType() || | 1383 interface.IsDoubleType() || |
| 1381 interface.IsStringInterface() || | 1384 interface.IsStringType() || |
| 1382 (interface.IsFunctionType() && !cls.IsSignatureClass()) || | 1385 (interface.IsFunctionType() && !cls.IsSignatureClass()) || |
| 1383 interface.IsDynamicType()) { | 1386 interface.IsDynamicType()) { |
| 1384 const Script& script = Script::Handle(cls.script()); | 1387 const Script& script = Script::Handle(cls.script()); |
| 1385 ReportError(script, cls.token_pos(), | 1388 ReportError(script, cls.token_pos(), |
| 1386 "'%s' is not allowed to extend or implement '%s'", | 1389 "'%s' is not allowed to extend or implement '%s'", |
| 1387 String::Handle(cls.Name()).ToCString(), | 1390 String::Handle(cls.Name()).ToCString(), |
| 1388 String::Handle(interface_class.Name()).ToCString()); | 1391 String::Handle(interface_class.Name()).ToCString()); |
| 1389 } | 1392 } |
| 1390 } | 1393 } |
| 1391 // Now resolve the super interfaces. | 1394 // Now resolve the super interfaces. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1571 void ClassFinalizer::ReportError(const char* format, ...) { | 1574 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1572 va_list args; | 1575 va_list args; |
| 1573 va_start(args, format); | 1576 va_start(args, format); |
| 1574 const Error& error = Error::Handle( | 1577 const Error& error = Error::Handle( |
| 1575 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1578 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1576 va_end(args); | 1579 va_end(args); |
| 1577 ReportError(error); | 1580 ReportError(error); |
| 1578 } | 1581 } |
| 1579 | 1582 |
| 1580 } // namespace dart | 1583 } // namespace dart |
| OLD | NEW |