diff options
author | Ash Wolf <ninji@wuffs.org> | 2023-01-20 00:39:43 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2023-01-20 00:39:43 +0000 |
commit | 7d986adf37220e1981a707745b784b078de4e3bc (patch) | |
tree | 831dea5f470c0c6b3c373f38d3a5f0354bc22600 /compiler_and_linker/unsorted/CABI.c | |
parent | 4d670146b4054e11e90227f96a3a1c66410e8d0b (diff) | |
download | MWCC-7d986adf37220e1981a707745b784b078de4e3bc.tar.gz MWCC-7d986adf37220e1981a707745b784b078de4e3bc.zip |
fix various inaccuracies exposed by the mach ppc plugin
Diffstat (limited to 'compiler_and_linker/unsorted/CABI.c')
-rw-r--r-- | compiler_and_linker/unsorted/CABI.c | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/compiler_and_linker/unsorted/CABI.c b/compiler_and_linker/unsorted/CABI.c index d5bf287..0b898c2 100644 --- a/compiler_and_linker/unsorted/CABI.c +++ b/compiler_and_linker/unsorted/CABI.c @@ -33,11 +33,11 @@ short CABI_GetStructResultArgumentIndex(TypeFunc *tfunc) { } Type *CABI_GetSizeTType(void) { - return (Type *) &stunsignedlong; + return TYPE(&stunsignedlong); } Type *CABI_GetPtrDiffTType(void) { - return (Type *) &stsignedlong; + return TYPE(&stsignedlong); } SInt16 CABI_StructSizeAlignValue(Type *type, SInt32 size) { @@ -331,11 +331,11 @@ static SInt32 CABI_GetBaseVTableSize(TypeClass *tclass) { static void CABI_ApplyClassFlags(Object *obj, UInt8 flags, Boolean unused) { if (flags & CLASS_EFLAGS_INTERNAL) - obj->flags |= OBJECT_FLAGS_10; + obj->flags = obj->flags | OBJECT_FLAGS_10; if (flags & CLASS_EFLAGS_IMPORT) - obj->flags |= OBJECT_FLAGS_20; + obj->flags = obj->flags | OBJECT_FLAGS_20; if (flags & CLASS_EFLAGS_EXPORT) - obj->flags |= OBJECT_FLAGS_40; + obj->flags = obj->flags | OBJECT_FLAGS_40; } static void CABI_AllocateVTable(DeclE *decle, TypeClass *tclass) { @@ -472,12 +472,12 @@ void CABI_LayoutClass(DeclE *decle, TypeClass *tclass) { tclass->align = CMach_GetClassAlign(tclass); if (tclass->size == 0) { tclass->size = 1; - tclass->flags |= CLASS_FLAGS_1000; + tclass->flags = tclass->flags | CLASS_FLAGS_1000; } else { tclass->size += CABI_StructSizeAlignValue(TYPE(tclass), tclass->size); } - tclass->flags |= CLASS_FLAGS_2; + tclass->flags = tclass->flags | CLASS_FLAGS_2; copts.structalignment = saveAlignMode; } @@ -486,8 +486,8 @@ void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func) { DefArgCtorInfo *info; Boolean saveDebugInfo; ENodeList *copied; - FuncArg *args; ENodeList *argexprs; + FuncArg *args; CScopeSave savedScope; Statement firstStmt; Statement returnStmt; @@ -1449,7 +1449,7 @@ static Statement *CABI_CopyConAssignCB(Statement *stmt, TypeClass *tclass, TypeC expr, CABI_ClassInitLoopCallBack); } else { - for (i = 0, offset = regions->start; i < count; offset += type->size, i++) { + for (i = 0, offset = regions->start; i < count; i++, offset += type->size) { expr = CABI_MakeCopyConArgExpr(tclass, flag); expr->rtype = type; @@ -1647,7 +1647,7 @@ static Statement *CABI_DestroyMembers(Statement *stmt, ObjMemberVar *ivars, Type dtor = CABI_GetDestructorObject(dtor, 1); stmt = CABI_DestroyMembers(stmt, ivars->next, tclass); expr = create_objectrefnode(dtor); - expr->flags |= ENODE_FLAG_80; + expr->flags = expr->flags | ENODE_FLAG_80; stmt = CFunc_InsertStatement(ST_EXPRESSION, stmt); stmt->expr = funccallexpr( @@ -1685,12 +1685,17 @@ static Statement *CABI_DestroyBases(Statement *stmt, ClassList *bases) { SInt32 count; SInt32 i; - for (base = bases, count = 0; base; base = base->next) + base = bases; + count = 0; + while (base) { + base = base->next; count++; + } while (count > 0) { base = bases; - for (i = 1; i < count; i++) + i = count; + while (i-- > 1) base = base->next; if (!base->is_virtual && (dtor = CClass_Destructor(base->base))) { @@ -2011,9 +2016,9 @@ ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, CABIDestroyMode mode, Bo expr->rtype = &stvoid; expr->data.funccall.funcref = create_objectrefnode(dtor); if (flag1) - expr->data.funccall.funcref->flags |= ENODE_FLAG_80; + expr->data.funccall.funcref->flags = expr->data.funccall.funcref->flags | ENODE_FLAG_80; expr->data.funccall.functype = TYPE_FUNC(dtor->type); - dtor->flags |= OBJECT_FLAGS_1; + dtor->flags = dtor->flags | OBJECT_FLAGS_1; list = lalloc(sizeof(ENodeList)); list->node = objexpr; |