@@ -655,16 +655,7 @@ ArObject *argon::vm::datatype::TypeNew(const TypeInfo *type, const char *name, c
655
655
((char *) ret->doc )[doc_len] = ' \0 ' ;
656
656
}
657
657
658
- if ((ret->mro = ComputeMRO (ret, bases, length)) == nullptr ) {
659
- memory::Free ((void *) ret->name );
660
- memory::Free ((void *) ret->qname );
661
- memory::Free ((void *) ret->doc );
662
-
663
- memory::Free (ret);
664
- return nullptr ;
665
- }
666
-
667
- if (!TypeInit (ret, ns))
658
+ if (!TypeInit (ret, ns, bases, length))
668
659
Release ((ArObject **) &ret);
669
660
670
661
return (ArObject *) ret;
@@ -1080,7 +1071,7 @@ bool MethodCheckOverride(TypeInfo *type) {
1080
1071
return true ;
1081
1072
}
1082
1073
1083
- bool argon::vm::datatype::TypeInit (TypeInfo *type, ArObject *auxiliary) {
1074
+ bool argon::vm::datatype::TypeInit (TypeInfo *type, ArObject *auxiliary, TypeInfo **bases, unsigned int length ) {
1084
1075
bool qname_free = false ;
1085
1076
1086
1077
if (ENUMBITMASK_ISTRUE (type->flags , TypeInfoFlags::INITIALIZED))
@@ -1089,9 +1080,14 @@ bool argon::vm::datatype::TypeInit(TypeInfo *type, ArObject *auxiliary) {
1089
1080
assert (type->tp_map == nullptr );
1090
1081
1091
1082
// Calculate MRO
1083
+ if (bases != nullptr && length > 0 ) {
1084
+ if ((type->mro = ComputeMRO (type, bases, length)) == nullptr )
1085
+ return false ;
1086
+ }
1087
+
1092
1088
if (type->object != nullptr && type->object ->traits != nullptr ) {
1093
1089
// Count base traits
1094
- unsigned int length = 0 ;
1090
+ length = 0 ;
1095
1091
for (auto **base = type->object ->traits ; *base != nullptr ; length++, base++);
1096
1092
1097
1093
if ((type->mro = ComputeMRO (type, type->object ->traits , length)) == nullptr )
@@ -1141,9 +1137,13 @@ bool argon::vm::datatype::TypeInit(TypeInfo *type, ArObject *auxiliary) {
1141
1137
return true ;
1142
1138
1143
1139
ERROR:
1140
+ Release (&type->mro );
1144
1141
Release (&type->tp_map );
1145
- if (qname_free)
1142
+
1143
+ if (qname_free) {
1146
1144
vm::memory::Free ((char *) type->qname );
1145
+ type->qname = nullptr ;
1146
+ }
1147
1147
1148
1148
return false ;
1149
1149
}
0 commit comments