| 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 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 251 "both classes or both interfaces", | 251 "both classes or both interfaces", |
| 252 class_name.ToCString(), | 252 class_name.ToCString(), |
| 253 super_class_name.ToCString()); | 253 super_class_name.ToCString()); |
| 254 } | 254 } |
| 255 // If cls belongs to core lib or to core lib's implementation, restrictions | 255 // If cls belongs to core lib or to core lib's implementation, restrictions |
| 256 // about allowed interfaces are lifted. | 256 // about allowed interfaces are lifted. |
| 257 if ((cls.library() != Library::CoreLibrary()) && | 257 if ((cls.library() != Library::CoreLibrary()) && |
| 258 (cls.library() != Library::CoreImplLibrary())) { | 258 (cls.library() != Library::CoreImplLibrary())) { |
| 259 // Prevent extending core implementation classes. | 259 // Prevent extending core implementation classes. |
| 260 switch (super_class.id()) { | 260 switch (super_class.id()) { |
| 261 case kNumberCid: |
| 261 case kIntegerCid: | 262 case kIntegerCid: |
| 262 case kSmiCid: | 263 case kSmiCid: |
| 263 case kMintCid: | 264 case kMintCid: |
| 264 case kBigintCid: | 265 case kBigintCid: |
| 265 case kDoubleCid: | 266 case kDoubleCid: |
| 266 case kOneByteStringCid: | 267 case kOneByteStringCid: |
| 267 case kTwoByteStringCid: | 268 case kTwoByteStringCid: |
| 268 case kFourByteStringCid: | 269 case kFourByteStringCid: |
| 269 case kExternalOneByteStringCid: | 270 case kExternalOneByteStringCid: |
| 270 case kExternalTwoByteStringCid: | 271 case kExternalTwoByteStringCid: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 286 case kUint32ArrayCid: | 287 case kUint32ArrayCid: |
| 287 case kExternalUint32ArrayCid: | 288 case kExternalUint32ArrayCid: |
| 288 case kInt64ArrayCid: | 289 case kInt64ArrayCid: |
| 289 case kExternalInt64ArrayCid: | 290 case kExternalInt64ArrayCid: |
| 290 case kUint64ArrayCid: | 291 case kUint64ArrayCid: |
| 291 case kExternalUint64ArrayCid: | 292 case kExternalUint64ArrayCid: |
| 292 case kFloat32ArrayCid: | 293 case kFloat32ArrayCid: |
| 293 case kExternalFloat32ArrayCid: | 294 case kExternalFloat32ArrayCid: |
| 294 case kFloat64ArrayCid: | 295 case kFloat64ArrayCid: |
| 295 case kExternalFloat64ArrayCid: | 296 case kExternalFloat64ArrayCid: |
| 297 case kDartFunctionCid: |
| 296 case kWeakPropertyCid: { | 298 case kWeakPropertyCid: { |
| 297 const Script& script = Script::Handle(cls.script()); | 299 const Script& script = Script::Handle(cls.script()); |
| 298 ReportError(script, cls.token_pos(), | 300 ReportError(script, cls.token_pos(), |
| 299 "'%s' is not allowed to extend '%s'", | 301 "'%s' is not allowed to extend '%s'", |
| 300 String::Handle(cls.Name()).ToCString(), | 302 String::Handle(cls.Name()).ToCString(), |
| 301 String::Handle(super_class.Name()).ToCString()); | 303 String::Handle(super_class.Name()).ToCString()); |
| 302 break; | 304 break; |
| 303 } | 305 } |
| 304 default: break; | 306 default: break; |
| 305 } | 307 } |
| (...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1216 ReportError(script, cls.token_pos(), | 1218 ReportError(script, cls.token_pos(), |
| 1217 "'%s' is used where an interface or class name is expected", | 1219 "'%s' is used where an interface or class name is expected", |
| 1218 String::Handle(interface_class.Name()).ToCString()); | 1220 String::Handle(interface_class.Name()).ToCString()); |
| 1219 } | 1221 } |
| 1220 // Verify that unless cls belongs to core lib, it cannot extend or implement | 1222 // Verify that unless cls belongs to core lib, it cannot extend or implement |
| 1221 // any of bool, num, int, double, String, Function, Dynamic. | 1223 // any of bool, num, int, double, String, Function, Dynamic. |
| 1222 // The exception is signature classes, which are compiler generated and | 1224 // The exception is signature classes, which are compiler generated and |
| 1223 // represent a function type, therefore implementing the Function interface. | 1225 // represent a function type, therefore implementing the Function interface. |
| 1224 if (!cls_belongs_to_core_lib) { | 1226 if (!cls_belongs_to_core_lib) { |
| 1225 if (interface.IsBoolInterface() || | 1227 if (interface.IsBoolInterface() || |
| 1226 interface.IsNumberInterface() || | 1228 interface.IsNumberType() || |
| 1227 interface.IsIntInterface() || | 1229 interface.IsIntInterface() || |
| 1228 interface.IsDoubleInterface() || | 1230 interface.IsDoubleInterface() || |
| 1229 interface.IsStringInterface() || | 1231 interface.IsStringInterface() || |
| 1230 (interface.IsFunctionInterface() && !cls.IsSignatureClass()) || | 1232 (interface.IsFunctionType() && !cls.IsSignatureClass()) || |
| 1231 interface.IsDynamicType()) { | 1233 interface.IsDynamicType()) { |
| 1232 const Script& script = Script::Handle(cls.script()); | 1234 const Script& script = Script::Handle(cls.script()); |
| 1233 ReportError(script, cls.token_pos(), | 1235 ReportError(script, cls.token_pos(), |
| 1234 "'%s' is not allowed to extend or implement '%s'", | 1236 "'%s' is not allowed to extend or implement '%s'", |
| 1235 String::Handle(cls.Name()).ToCString(), | 1237 String::Handle(cls.Name()).ToCString(), |
| 1236 String::Handle(interface_class.Name()).ToCString()); | 1238 String::Handle(interface_class.Name()).ToCString()); |
| 1237 } | 1239 } |
| 1238 } | 1240 } |
| 1239 // Now resolve the super interfaces. | 1241 // Now resolve the super interfaces. |
| 1240 ResolveInterfaces(interface_class, visited); | 1242 ResolveInterfaces(interface_class, visited); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1390 void ClassFinalizer::ReportError(const char* format, ...) { | 1392 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1391 va_list args; | 1393 va_list args; |
| 1392 va_start(args, format); | 1394 va_start(args, format); |
| 1393 const Error& error = Error::Handle( | 1395 const Error& error = Error::Handle( |
| 1394 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1396 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1395 va_end(args); | 1397 va_end(args); |
| 1396 ReportError(error); | 1398 ReportError(error); |
| 1397 } | 1399 } |
| 1398 | 1400 |
| 1399 } // namespace dart | 1401 } // namespace dart |
| OLD | NEW |