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(); |
hausner
2012/10/11 17:04:44
Please don't factor this out. If any of the expres
Lasse Reichstein Nielsen
2012/10/12 08:03:51
ACK, defactored.
| |
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 1069 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1389 } | 1392 } |
1390 // Verify that unless cls belongs to core lib, it cannot extend or implement | 1393 // Verify that unless cls belongs to core lib, it cannot extend or implement |
1391 // any of bool, num, int, double, String, Function, Dynamic. | 1394 // any of bool, num, int, double, String, Function, Dynamic. |
1392 // The exception is signature classes, which are compiler generated and | 1395 // The exception is signature classes, which are compiler generated and |
1393 // represent a function type, therefore implementing the Function interface. | 1396 // represent a function type, therefore implementing the Function interface. |
1394 if (!cls_belongs_to_core_lib) { | 1397 if (!cls_belongs_to_core_lib) { |
1395 if (interface.IsBoolType() || | 1398 if (interface.IsBoolType() || |
1396 interface.IsNumberType() || | 1399 interface.IsNumberType() || |
1397 interface.IsIntType() || | 1400 interface.IsIntType() || |
1398 interface.IsDoubleType() || | 1401 interface.IsDoubleType() || |
1399 interface.IsStringInterface() || | 1402 interface.IsStringType() || |
1400 (interface.IsFunctionType() && !cls.IsSignatureClass()) || | 1403 (interface.IsFunctionType() && !cls.IsSignatureClass()) || |
1401 interface.IsDynamicType()) { | 1404 interface.IsDynamicType()) { |
1402 const Script& script = Script::Handle(cls.script()); | 1405 const Script& script = Script::Handle(cls.script()); |
1403 ReportError(script, cls.token_pos(), | 1406 ReportError(script, cls.token_pos(), |
1404 "'%s' is not allowed to extend or implement '%s'", | 1407 "'%s' is not allowed to extend or implement '%s'", |
1405 String::Handle(cls.Name()).ToCString(), | 1408 String::Handle(cls.Name()).ToCString(), |
1406 String::Handle(interface_class.Name()).ToCString()); | 1409 String::Handle(interface_class.Name()).ToCString()); |
1407 } | 1410 } |
1408 } | 1411 } |
1409 // Now resolve the super interfaces. | 1412 // Now resolve the super interfaces. |
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1589 void ClassFinalizer::ReportError(const char* format, ...) { | 1592 void ClassFinalizer::ReportError(const char* format, ...) { |
1590 va_list args; | 1593 va_list args; |
1591 va_start(args, format); | 1594 va_start(args, format); |
1592 const Error& error = Error::Handle( | 1595 const Error& error = Error::Handle( |
1593 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1596 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
1594 va_end(args); | 1597 va_end(args); |
1595 ReportError(error); | 1598 ReportError(error); |
1596 } | 1599 } |
1597 | 1600 |
1598 } // namespace dart | 1601 } // namespace dart |
OLD | NEW |