| OLD | NEW |
| 1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2013, 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 1197 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1208 const Script& script = Script::Handle(cls.script()); | 1208 const Script& script = Script::Handle(cls.script()); |
| 1209 ReportError(script, cls.token_pos(), | 1209 ReportError(script, cls.token_pos(), |
| 1210 "class '%s' has a cycle in its superclass relationship", | 1210 "class '%s' has a cycle in its superclass relationship", |
| 1211 name.ToCString()); | 1211 name.ToCString()); |
| 1212 } | 1212 } |
| 1213 // Finalize super class. | 1213 // Finalize super class. |
| 1214 const Class& super_class = Class::Handle(cls.SuperClass()); | 1214 const Class& super_class = Class::Handle(cls.SuperClass()); |
| 1215 if (!super_class.IsNull()) { | 1215 if (!super_class.IsNull()) { |
| 1216 FinalizeClass(super_class); | 1216 FinalizeClass(super_class); |
| 1217 } | 1217 } |
| 1218 if (cls.mixin() != Type::null()) { |
| 1219 // Copy instance methods and fields from the mixin class. |
| 1220 // This has to happen before the check whether the methods of |
| 1221 // the class conflict with inherited methods. |
| 1222 ApplyMixin(cls); |
| 1223 } |
| 1218 // Finalize type parameters before finalizing the super type. | 1224 // Finalize type parameters before finalizing the super type. |
| 1219 FinalizeTypeParameters(cls); | 1225 FinalizeTypeParameters(cls); |
| 1220 // Finalize super type. | 1226 // Finalize super type. |
| 1221 Type& super_type = Type::Handle(cls.super_type()); | 1227 Type& super_type = Type::Handle(cls.super_type()); |
| 1222 if (!super_type.IsNull()) { | 1228 if (!super_type.IsNull()) { |
| 1223 super_type ^= FinalizeType(cls, super_type, kCanonicalizeWellFormed); | 1229 super_type ^= FinalizeType(cls, super_type, kCanonicalizeWellFormed); |
| 1224 cls.set_super_type(super_type); | 1230 cls.set_super_type(super_type); |
| 1225 } | 1231 } |
| 1226 if (cls.IsSignatureClass()) { | 1232 if (cls.IsSignatureClass()) { |
| 1227 // Check for illegal self references. | 1233 // Check for illegal self references. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 1241 // Resolve and finalize the result and parameter types of the signature | 1247 // Resolve and finalize the result and parameter types of the signature |
| 1242 // function of this signature class. | 1248 // function of this signature class. |
| 1243 const Function& sig_function = Function::Handle(cls.signature_function()); | 1249 const Function& sig_function = Function::Handle(cls.signature_function()); |
| 1244 ResolveAndFinalizeSignature(cls, sig_function); | 1250 ResolveAndFinalizeSignature(cls, sig_function); |
| 1245 | 1251 |
| 1246 // Resolve and finalize the signature type of this signature class. | 1252 // Resolve and finalize the signature type of this signature class. |
| 1247 const Type& sig_type = Type::Handle(cls.SignatureType()); | 1253 const Type& sig_type = Type::Handle(cls.SignatureType()); |
| 1248 FinalizeType(cls, sig_type, kCanonicalizeWellFormed); | 1254 FinalizeType(cls, sig_type, kCanonicalizeWellFormed); |
| 1249 return; | 1255 return; |
| 1250 } | 1256 } |
| 1251 if (cls.mixin() != Type::null()) { | |
| 1252 // Copy instance methods and fields from the mixin class. | |
| 1253 // This has to happen before the check whether the methods of | |
| 1254 // the class conflict with inherited methods. | |
| 1255 ApplyMixin(cls); | |
| 1256 } | |
| 1257 // Finalize interface types (but not necessarily interface classes). | 1257 // Finalize interface types (but not necessarily interface classes). |
| 1258 Array& interface_types = Array::Handle(cls.interfaces()); | 1258 Array& interface_types = Array::Handle(cls.interfaces()); |
| 1259 AbstractType& interface_type = AbstractType::Handle(); | 1259 AbstractType& interface_type = AbstractType::Handle(); |
| 1260 for (intptr_t i = 0; i < interface_types.Length(); i++) { | 1260 for (intptr_t i = 0; i < interface_types.Length(); i++) { |
| 1261 interface_type ^= interface_types.At(i); | 1261 interface_type ^= interface_types.At(i); |
| 1262 interface_type = FinalizeType(cls, interface_type, kCanonicalizeWellFormed); | 1262 interface_type = FinalizeType(cls, interface_type, kCanonicalizeWellFormed); |
| 1263 interface_types.SetAt(i, interface_type); | 1263 interface_types.SetAt(i, interface_type); |
| 1264 } | 1264 } |
| 1265 // Mark as finalized before resolving type parameter upper bounds and member | 1265 // Mark as finalized before resolving type parameter upper bounds and member |
| 1266 // types in order to break cycles. | 1266 // types in order to break cycles. |
| (...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1692 void ClassFinalizer::ReportError(const char* format, ...) { | 1692 void ClassFinalizer::ReportError(const char* format, ...) { |
| 1693 va_list args; | 1693 va_list args; |
| 1694 va_start(args, format); | 1694 va_start(args, format); |
| 1695 const Error& error = Error::Handle( | 1695 const Error& error = Error::Handle( |
| 1696 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); | 1696 Parser::FormatError(Script::Handle(), -1, "Error", format, args)); |
| 1697 va_end(args); | 1697 va_end(args); |
| 1698 ReportError(error); | 1698 ReportError(error); |
| 1699 } | 1699 } |
| 1700 | 1700 |
| 1701 } // namespace dart | 1701 } // namespace dart |
| OLD | NEW |