diff options
Diffstat (limited to 'compiler_and_linker/unsorted')
-rw-r--r-- | compiler_and_linker/unsorted/CABI.c | 33 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CDecl.c | 144 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CError.c | 58 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CExpr.c | 14 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CFunc.c | 6 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CInit.c | 21 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CInt64.c | 35 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/COptimizer.c | 6 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CSOM.c | 39 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CTemplateNew.c | 11 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/CodeGen.c | 19 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/IrOptimizer.c | 15 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/ObjGenMachO.c | 45 | ||||
-rw-r--r-- | compiler_and_linker/unsorted/Operands.c | 14 |
14 files changed, 230 insertions, 230 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; diff --git a/compiler_and_linker/unsorted/CDecl.c b/compiler_and_linker/unsorted/CDecl.c index 8ad16a8..bc30347 100644 --- a/compiler_and_linker/unsorted/CDecl.c +++ b/compiler_and_linker/unsorted/CDecl.c @@ -606,20 +606,12 @@ static Boolean CDecl_IsEnumClassTypeOrRef(Type *type) { return IS_TYPE_CLASS(type) || IS_TYPE_ENUM(type); } -typedef enum OpMysteryValue { - OpMysteryValue0 = 0, - OpMysteryValue1 = 1, - OpMysteryValue2 = 2, - OpMysteryValue3 = 3, - OpMysteryValue4 = 4 -} OpMysteryValue; - static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { FuncArg *args; FuncArg *secondarg; Type *functype; - short r27; - Boolean r6; + short argCount; + Boolean isMethod; if (!IS_TYPE_FUNC(declinfo->thetype)) { CError_Error(CErrorStr193); @@ -630,7 +622,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { args = TYPE_FUNC(declinfo->thetype)->args; if (args) { if (args != &elipsis && args != &oldstyle) { - r27 = OpMysteryValue1; + argCount = 1; if (args->dexpr) { switch (declinfo->x3E) { case TK_NEW: @@ -645,11 +637,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { secondarg = args->next; if (secondarg) { - //r27 = ((secondarg != &elipsis && !secondarg->next) != 0) ? OpMysteryValue2 : OpMysteryValue3; - if ((secondarg != &elipsis && !secondarg->next) != 0) - r27 = OpMysteryValue2; - else - r27 = OpMysteryValue3; + argCount = ((secondarg != &elipsis && !secondarg->next) != 0) ? 2 : 3; if (secondarg->dexpr) { switch (declinfo->x3E) { case '(': @@ -664,63 +652,66 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { } } } else { - r27 = OpMysteryValue3; + argCount = 3; } } else { CError_Error(CErrorStr193); return 0; } - r6 = flag && IS_TYPEFUNC_METHOD(TYPE_FUNC(declinfo->thetype)) && !TYPE_METHOD(declinfo->thetype)->x26; + isMethod = flag && + IS_TYPEFUNC_METHOD(TYPE_FUNC(declinfo->thetype)) && + !TYPE_METHOD(declinfo->thetype)->x26; + switch (declinfo->x3E) { case TK_NEW: case TK_NEW_ARRAY: - if (r6 || !is_typesame(functype, (Type *) &void_ptr) || r27 < OpMysteryValue1 || args->type != CABI_GetSizeTType()) { + if (isMethod || !is_typesame(functype, TYPE(&void_ptr)) || argCount < 1 || args->type != CABI_GetSizeTType()) { CError_Error(CErrorStr193); return 0; } return 1; case TK_DELETE: case TK_DELETE_ARRAY: - if (r6 || !IS_TYPE_VOID(functype) || r27 < OpMysteryValue1 || !is_typesame(args->type, (Type *) &void_ptr)) { + if (isMethod || !IS_TYPE_VOID(functype) || argCount < 1 || !is_typesame(args->type, TYPE(&void_ptr))) { CError_Error(CErrorStr193); return 0; } return 1; case '=': - if (!r6) { + if (!isMethod) { CError_Error(CErrorStr193); return 0; } break; case '(': - if (!r6) { + if (!isMethod) { CError_Error(CErrorStr193); return 0; } return 1; case '[': - if (!r6) { + if (!isMethod) { CError_Error(CErrorStr193); return 0; } break; case TK_ARROW: - if (r27 != OpMysteryValue1 || r6 == 0) { + if (argCount != 1 || isMethod == 0) { CError_Error(CErrorStr193); return 0; } return 1; case TK_INCREMENT: case TK_DECREMENT: - if (r27 == OpMysteryValue2 && secondarg->type != (Type *) &stsignedint) { + if (argCount == 2 && secondarg->type != TYPE(&stsignedint)) { CError_Error(CErrorStr193); return 0; } break; } - if (flag && !r6) { + if (flag && !isMethod) { CError_Error(CErrorStr193); return 0; } @@ -732,11 +723,11 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { case '-': case TK_INCREMENT: case TK_DECREMENT: - if (r27 != OpMysteryValue1) + if (argCount != 1) goto whatever; case '!': case '~': - if (r27 == OpMysteryValue1) { + if (argCount == 1) { if (flag || CDecl_IsEnumClassTypeOrRef(args->type)) return 1; } @@ -772,7 +763,7 @@ static Boolean CDecl_CheckOperatorType(DeclInfo *declinfo, Boolean flag) { case TK_DOT_STAR: case TK_ARROW_STAR: whatever: - if (r27 == OpMysteryValue2) { + if (argCount == 2) { if (flag || CDecl_IsEnumClassTypeOrRef(args->type) || CDecl_IsEnumClassTypeOrRef(secondarg->type)) return 1; } @@ -1408,12 +1399,12 @@ static void CDecl_FuncRedeclCheck(Object *obj, DeclInfo *declinfo, Boolean flag) } Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean *pflag, Boolean someotherflag) { - Boolean r27; - Object *obj; - Type *type; NameSpace *nspace2; + Type *type; + Object *obj; NameSpaceObjectList *list; TypeMemberFunc tmp; + Boolean r27; Boolean outflag; r27 = 0; @@ -1429,14 +1420,14 @@ Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean * case TYPEFUNC: case TYPEARRAY: CError_Error(CErrorStr128); - TYPE_FUNC(declinfo->thetype)->functype = (Type *) &stsignedint; + TYPE_FUNC(declinfo->thetype)->functype = TYPE(&stsignedint); break; } if (nspace2->theclass) { CError_ASSERT(1969, declinfo->name); if (!nspace2->theclass->size) - CDecl_CompleteType((Type *) nspace2->theclass); + CDecl_CompleteType(TYPE(nspace2->theclass)); if (!(list = CScope_GetLocalObject(nspace2, declinfo->name))) { CError_Error(CErrorStr140, declinfo->name->name); return NULL; @@ -1630,7 +1621,7 @@ void CDecl_TypedefDeclarator(DeclInfo *declinfo) { CBrowse_NewTypedef(nspace, declinfo->name, declinfo->file, declinfo->file2, declinfo->x60, CPrep_BrowserFileOffset()); } -static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) { +static void CDecl_DataDeclarator(DeclInfo *declinfo, AccessType access, Boolean flag) { NameSpaceObjectList *list; Object *obj; NameSpace *nspace; @@ -1732,7 +1723,7 @@ static void CDecl_DataDeclarator(DeclInfo *declinfo, short access, Boolean flag) if (IS_TYPE_CLASS(declinfo->thetype) && TYPE_CLASS(declinfo->thetype)->sominfo) CError_Error(CErrorStr288); if (!CanCreateObject(declinfo->thetype)) - declinfo->thetype = (Type *) &stsignedint; + declinfo->thetype = TYPE(&stsignedint); obj = CParser_NewGlobalDataObject(declinfo); obj->access = access; @@ -3131,11 +3122,11 @@ static void InlineFunctionObject(Object *obj, TypeClass *tclass) { void CDecl_ExtractClassExportFlags(DeclInfo *declinfo, UInt8 flags) { if (flags & CLASS_EFLAGS_INTERNAL) - declinfo->exportflags |= EXPORT_FLAGS_INTERNAL; + declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_INTERNAL; if (flags & CLASS_EFLAGS_IMPORT) - declinfo->exportflags |= EXPORT_FLAGS_IMPORT; + declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_IMPORT; if (flags & CLASS_EFLAGS_EXPORT) - declinfo->exportflags |= EXPORT_FLAGS_EXPORT; + declinfo->exportflags = declinfo->exportflags | EXPORT_FLAGS_EXPORT; } TypeMemberFunc *CDecl_MakeTypeMemberFunc(TypeFunc *tfunc, TypeClass *tclass, Boolean flag) { @@ -3164,7 +3155,7 @@ static void CDecl_MakeFunctionVirtual(TypeClass *tclass, Object *func) { func->datatype = DVFUNC; } -static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *declinfo, short access, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4) { +static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *declinfo, AccessType access, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4) { NameSpaceObjectList *list; // r20 Object *obj; // also r20 TypeMemberFunc *tfunc; // r19 @@ -3228,7 +3219,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d if (flag2) { tfunc->flags |= FUNC_FLAGS_40; - tclass->flags |= CLASS_FLAGS_40; + tclass->flags = tclass->flags | CLASS_FLAGS_40; } if (r31) { @@ -3241,7 +3232,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d if (!CInt64_IsZero(&tkintconst)) CError_Error(CErrorStr121); tfunc->flags |= FUNC_FLAGS_8; - tclass->flags |= CLASS_FLAGS_ABSTRACT; + tclass->flags = tclass->flags | CLASS_FLAGS_ABSTRACT; tk = lex(); } else { CError_Error(CErrorStr121); @@ -3258,7 +3249,7 @@ static void CDecl_AddFunctionMember(DeclE *decle, TypeClass *tclass, DeclInfo *d CBrowse_AddClassMemberFunction(obj, CPrep_BrowserTokenOffset(&member_fileoffset) + 1, CPrep_BrowserFileOffset()); } -static Boolean CDecl_IsAccessDeclaration(TypeClass *tclass, short access) { +static Boolean CDecl_IsAccessDeclaration(TypeClass *tclass, AccessType access) { SInt32 state; Boolean flag; @@ -3383,7 +3374,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { Object *obj; NameSpace *nspace; - is_templ = (tclass->flags & CLASS_FLAGS_100) ? 1 : 0; + is_templ = (tclass->flags & CLASS_FLAGS_100) != 0; r27 = (tk == TK_CLASS || tk == TK_STRUCT || tk == TK_UNION); memclrw(&declinfo, sizeof(DeclInfo)); @@ -3469,7 +3460,7 @@ static void CDecl_ParseFriendDecl(TypeClass *tclass) { CError_Error(CErrorStr123); } -static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclass, Type *type, UInt32 qual, HashNameNode *name, short access) { +static ObjMemberVar *CDecl_InstanceDataDeclarator(DeclE *decle, TypeClass *tclass, Type *type, UInt32 qual, HashNameNode *name, AccessType access) { NameSpaceObjectList *list; ObjMemberVar *ivar; ObjMemberVar *scan; @@ -3533,12 +3524,7 @@ void CDecl_CheckCtorIntegrity(FuncArg *args, TypeClass *tclass) { } static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) { - short access; - UInt32 r22; - UInt32 r21; - UInt8 r20; - Boolean r19; - UInt8 r18; + AccessType access; Boolean r17; BigDeclInfo bde; DeclInfo declinfo; @@ -3546,18 +3532,18 @@ static void CDecl_ParseClassMembers(DeclE *decle, TypeClass *tclass, short mode) ObjMemberVar *ivar; ObjMemberVar *scanivar; Type *tmptype; + UInt32 r22; + UInt32 r21; + UInt8 r20; + UInt8 r18; + Boolean r19; short t; r17 = (tclass->flags & CLASS_FLAGS_100) && TEMPL_CLASS(tclass)->pspec_owner; memclrw(&bde, sizeof(BigDeclInfo)); - if (mode == CLASS_MODE_2) - access = ACCESSPRIVATE; - else - access = ACCESSPUBLIC; + access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC; global_access = access; - //global_access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC; - //access = (mode == CLASS_MODE_2) ? ACCESSPRIVATE : ACCESSPUBLIC; restart: while (tk != '}') { @@ -3967,7 +3953,7 @@ void CDecl_MakeVBaseList(TypeClass *tclass) { SInt32 offset; if (copts.vbase_ctor_offset) - tclass->flags |= CLASS_FLAGS_8000; + tclass->flags = tclass->flags | CLASS_FLAGS_8000; for (base = tclass->bases, offset = tclass->size; base; base = base->next) { for (vbase = base->base->vbases; vbase; vbase = vbase->next) { @@ -4002,7 +3988,7 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v CError_Error(CErrorStr191); return 0; } - tclass->flags |= CLASS_FLAGS_10; + tclass->flags = tclass->flags | CLASS_FLAGS_10; } if (baseclass->flags & CLASS_FLAGS_1) { @@ -4010,7 +3996,7 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v CError_Error(CErrorStr191); return 0; } - tclass->flags |= CLASS_FLAGS_1; + tclass->flags = tclass->flags | CLASS_FLAGS_1; } if (baseclass->sominfo) { @@ -4039,21 +4025,21 @@ Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_v } if (baseclass->flags & CLASS_FLAGS_2000) - tclass->flags |= CLASS_FLAGS_2000; + tclass->flags = tclass->flags | CLASS_FLAGS_2000; if (baseclass->flags & CLASS_FLAGS_40) - tclass->flags |= CLASS_FLAGS_40; + tclass->flags = tclass->flags | CLASS_FLAGS_40; if (baseclass->flags & CLASS_FLAGS_20) - tclass->flags |= CLASS_FLAGS_20; + tclass->flags = tclass->flags | CLASS_FLAGS_20; if (is_virtual) - tclass->flags |= CLASS_FLAGS_20; + tclass->flags = tclass->flags | CLASS_FLAGS_20; return 1; } static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_templ) { Boolean is_virtual; - short access; + AccessType access; CScopeParseResult pr; ObjType *inherited_type; ClassList *base; @@ -4113,7 +4099,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t CParser_CheckTemplateClassUsage(TEMPL_CLASS(pr.x8), 1)) { CTemplClass_RegisterBaseClass(TEMPL_CLASS(tclass), pr.x8, access, is_virtual); if (is_virtual) - tclass->flags |= CLASS_FLAGS_20; + tclass->flags = tclass->flags | CLASS_FLAGS_20; } continue; } @@ -4135,12 +4121,12 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t if (!strcmp(tkidentifier->name, "SingleObject") || !strcmp(tkidentifier->name, "SingleInheritance")) { if (tclass->bases) CError_Error(CErrorStr191); - tclass->flags |= CLASS_FLAGS_10; + tclass->flags = tclass->flags | CLASS_FLAGS_10; tk = lex(); break; } if (!strcmp(tkidentifier->name, "__comobject")) { - tclass->flags |= CLASS_FLAGS_2000; + tclass->flags = tclass->flags | CLASS_FLAGS_2000; tk = lex(); break; } @@ -4190,7 +4176,7 @@ static void CDecl_ParseBaseClassList(TypeClass *tclass, short mode, Boolean is_t } } -static short getaccesstype(AccessType a, AccessType b, AccessType c) { +static AccessType getaccesstype(AccessType a, AccessType b, AccessType c) { if (a == ACCESSNONE || b == ACCESSNONE || b == ACCESSPRIVATE) return ACCESSNONE; @@ -4220,14 +4206,14 @@ static void CDecl_AddDefArgConstructor(TypeClass *tclass) { // empty } -static void CDecl_AddMemberFunctionObject(TypeClass *tclass, HashNameNode *name, TypeMemberFunc *tmeth, short access) { +static void CDecl_AddMemberFunctionObject(TypeClass *tclass, HashNameNode *name, TypeMemberFunc *tmeth, AccessType access) { Object *obj = CParser_NewCompilerDefFunctionObject(); obj->name = name; obj->type = TYPE(tmeth); obj->qual = Q_80000; obj->access = access; obj->nspace = tclass->nspace; - obj->qual |= Q_INLINE; + obj->qual = obj->qual | Q_INLINE; CScope_AddObject(tclass->nspace, obj->name, OBJ_BASE(obj)); } @@ -4299,7 +4285,7 @@ static void CDecl_AddDefaultCopyConstructor(DeclE *decle, TypeClass *tclass) { ClassList *base; ObjMemberVar *ivar; Object *obj; - short access; + AccessType access; Boolean has_copyctor; Boolean is_const; FuncArg *arg; @@ -4377,7 +4363,7 @@ static void CDecl_AddDefaultAssignmentOperator(DeclE *decle, TypeClass *tclass) ClassList *base; ObjMemberVar *ivar; Object *obj; - short access; + AccessType access; Boolean is_const; Boolean has_ass; DeclInfo declinfo; @@ -4442,7 +4428,7 @@ static void CDecl_AddDefaultDestructor(DeclE *decle, TypeClass *tclass) { ClassList *base; ObjMemberVar *ivar; Object *obj; - short access; + AccessType access; Boolean has_dtor; Boolean is_virtual; DeclInfo declinfo; @@ -4662,11 +4648,11 @@ void CDecl_ParseClassDeclSpec(UInt8 *declspec) { memclrw(&declinfo, sizeof(DeclInfo)); CParser_ParseDeclSpec(&declinfo, 1); if (declinfo.exportflags & EXPORT_FLAGS_INTERNAL) - *declspec |= CLASS_EFLAGS_INTERNAL; + *declspec = *declspec | CLASS_EFLAGS_INTERNAL; if (declinfo.exportflags & EXPORT_FLAGS_IMPORT) - *declspec |= CLASS_EFLAGS_IMPORT; + *declspec = *declspec | CLASS_EFLAGS_IMPORT; if (declinfo.exportflags & EXPORT_FLAGS_EXPORT) - *declspec |= CLASS_EFLAGS_EXPORT; + *declspec = *declspec | CLASS_EFLAGS_EXPORT; if ((tk = lex()) != ')') CError_Error(CErrorStr115); else @@ -4802,7 +4788,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class } } - is_templ = (tclass->flags & CLASS_FLAGS_100) ? 1 : 0; + is_templ = (tclass->flags & CLASS_FLAGS_100) != 0; if (tclass->flags & CLASS_FLAGS_800) { TEMPL_CLASS_INST(tclass)->is_instantiated = 1; if (!declinfo->x28) @@ -4811,7 +4797,7 @@ void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class CError_ASSERT(6853, copts.structalignment >= 0 && copts.structalignment <= 14); - tclass->eflags |= (UInt8) ((copts.structalignment + 1) << 4); + tclass->eflags = tclass->eflags | (((copts.structalignment + 1) << 4) & 0xF0); if (tk == ':') CDecl_ParseBaseClassList(tclass, mode, is_templ); diff --git a/compiler_and_linker/unsorted/CError.c b/compiler_and_linker/unsorted/CError.c index 985e46d..1fe6814 100644 --- a/compiler_and_linker/unsorted/CError.c +++ b/compiler_and_linker/unsorted/CError.c @@ -26,6 +26,10 @@ char cerror_synchdata[32]; short cerror_synchoffset; int CError_BreakPointcount; +// forward decls +static void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual); +static void CError_AppendObjectName(CErrorBuffer *eb, Object *obj); + void CError_Init(void) { cerror_errorcount = 0; cerror_lasterrorline = -1; @@ -56,17 +60,17 @@ void CError_ResetErrorSkip(void) { cerror_lasterrorline = -1; } -void CError_GetErrorString(char *buf, short code) { +static void CError_GetErrorString(char *buf, short code) { CError_ASSERT(142, code >= CErrorStr100 && code < CErrorStrMAX); COS_GetString(buf, 10000, code - 99); } -void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize) { +static void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize) { eb->start = eb->end = buf; eb->size = eb->remaining = bufSize - 1; } -void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) { +static void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) { char *newBuf; newBuf = lalloc(eb->size + amount); @@ -77,7 +81,7 @@ void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount) { eb->remaining += amount; } -void CError_BufferAppendChar(CErrorBuffer *eb, char ch) { +static void CError_BufferAppendChar(CErrorBuffer *eb, char ch) { if (eb) { if (!eb->remaining) CError_BufferGrow(eb, 256); @@ -86,7 +90,7 @@ void CError_BufferAppendChar(CErrorBuffer *eb, char ch) { } } -void CError_BufferAppendString(CErrorBuffer *eb, const char *str) { +static void CError_BufferAppendString(CErrorBuffer *eb, const char *str) { size_t len; if (eb) { @@ -99,14 +103,14 @@ void CError_BufferAppendString(CErrorBuffer *eb, const char *str) { } } -void CError_BufferTerminate(CErrorBuffer *eb) { +static void CError_BufferTerminate(CErrorBuffer *eb) { if (eb->remaining == 0) CError_BufferGrow(eb, 1); *eb->end = 0; eb->remaining = 0; } -void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) { +static void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) { if (qual & Q_PASCAL) CError_BufferAppendString(eb, "pascal "); if (qual & Q_CONST) @@ -119,7 +123,7 @@ void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual) { CError_BufferAppendString(eb, "restrict "); } -void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) { +static void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) { char buf[32]; if (node) { @@ -138,7 +142,7 @@ void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node) { CError_BufferAppendString(eb, "{targ_expr}"); } -void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) { +static void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) { switch (targ->pid.type) { case TPT_TYPE: CError_BufferAppendType(eb, targ->data.typeparam.type, targ->data.typeparam.qual); @@ -154,7 +158,7 @@ void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ) { } } -void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) { +static void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) { if (targs) { CError_BufferAppendChar(eb, '<'); while (targs) { @@ -167,7 +171,7 @@ void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs) { } } -void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) { +static void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) { while (nspace) { if (nspace->name) { CError_BufferAppendNameSpace(eb, nspace->parent); @@ -188,7 +192,7 @@ void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace) { } } -void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) { +static void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) { switch (ty->type) { case TYPEPOINTER: CError_BufferAppendPType(eb, TYPE_POINTER(ty)->target); @@ -207,12 +211,12 @@ void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty) { } } -void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) { +static void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) { char buf[64]; switch (type->dtype) { case TEMPLDEP_ARGUMENT: if (type->u.pid.nindex) - sprintf(buf, "T%" PRId32 "%" PRId32, type->u.pid.nindex, type->u.pid.index); + sprintf(buf, "T%" PRId32 "_%" PRId32, type->u.pid.nindex, type->u.pid.index); else sprintf(buf, "T%" PRId32, type->u.pid.index); CError_BufferAppendString(eb, buf); @@ -248,7 +252,7 @@ void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type) { } } -void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod) { +static void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod) { FuncArg *arg; UInt32 qual; @@ -288,7 +292,7 @@ void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMe CError_BufferAppendQualifier(eb, qual); } -void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) { +static void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual) { // not matching - register issues Type *scan; Type *scan2; @@ -505,7 +509,7 @@ char *CError_GetTypeName(Type *ty, UInt32 qual, Boolean useGlobalHeap) { return strcpy(ptr, eb.start); } -void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc) { +static void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc) { Boolean flag = 0; char *opname; @@ -535,7 +539,7 @@ void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNa } } -void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc) { +static void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc) { while (nspace->is_templ && nspace->parent) nspace = nspace->parent; @@ -551,7 +555,7 @@ void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode } } -void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) { +static void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) { if (obj->type->type == TYPEFUNC) { CError_AppendFunctionName(eb, obj->nspace, obj->name, obj->u.func.inst ? obj->u.func.inst->args : NULL, TYPE_FUNC(obj->type)); } else { @@ -560,7 +564,7 @@ void CError_AppendObjectName(CErrorBuffer *eb, Object *obj) { } } -void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth) { +static void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth) { ObjCMethodArg *arg; CError_BufferAppendChar(eb, meth->is_class_method ? '+' : '-'); @@ -648,8 +652,8 @@ void CError_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2) TStreamElement *token; short tokensize; CPrepFileInfo *tokenfile; - char buf[128]; CWMessageRef myref; + char buf[128]; CWMessageRef *ref; unsigned char messagetype; @@ -703,7 +707,7 @@ void CError_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2) cerror_token = NULL; } -void CError_BufferAppendTemplateStack(CErrorBuffer *eb) { +static void CError_BufferAppendTemplateStack(CErrorBuffer *eb) { TemplStack *stack[64]; TemplStack *scan; int index; @@ -717,7 +721,7 @@ void CError_BufferAppendTemplateStack(CErrorBuffer *eb) { } for (index = count - 1; index >= 0; index--) { - CError_BufferAppendChar(eb, '\n'); + CError_BufferAppendChar(eb, LF); for (indent = index; indent < count; indent++) CError_BufferAppendChar(eb, ' '); CError_BufferAppendString(eb, "(instantiating: '"); @@ -800,7 +804,7 @@ void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean f CError_ErrorMessage(code, eb.start, flag1, flag2); } -void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2) { +static void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2) { char buf[256]; CError_GetErrorString(buf, code); @@ -898,7 +902,7 @@ void CError_ErrorFuncCall(short code, NameSpaceObjectList *args, ENodeList *argN exit_main_loop: while (args) { if (args->object->otype == OT_OBJECT) { - CError_BufferAppendChar(&eb, '\n'); + CError_BufferAppendChar(&eb, LF); CError_BufferAppendChar(&eb, '\''); CError_AppendObjectName(&eb, (Object *) args->object); CError_BufferAppendChar(&eb, '\''); @@ -941,13 +945,13 @@ void CError_OverloadedFunctionError(Object *obj, ObjectList *olst) { CError_BufferAppendString(&eb, string); if (obj) { - CError_BufferAppendChar(&eb, '\n'); + CError_BufferAppendChar(&eb, LF); CError_BufferAppendChar(&eb, '\''); CError_AppendObjectName(&eb, obj); CError_BufferAppendChar(&eb, '\''); } while (olst) { - CError_BufferAppendChar(&eb, '\n'); + CError_BufferAppendChar(&eb, LF); CError_BufferAppendChar(&eb, '\''); CError_AppendObjectName(&eb, olst->object); CError_BufferAppendChar(&eb, '\''); diff --git a/compiler_and_linker/unsorted/CExpr.c b/compiler_and_linker/unsorted/CExpr.c index 992fc09..500ae57 100644 --- a/compiler_and_linker/unsorted/CExpr.c +++ b/compiler_and_linker/unsorted/CExpr.c @@ -1649,7 +1649,7 @@ static ENode *primary_expression(Boolean flag) { else tk = lex(); if (ENODE_IS(expr, EASS)) - expr->flags |= ENODE_FLAG_80; + expr->flags = expr->flags | ENODE_FLAG_80; return expr; case '[': if (copts.objective_c) @@ -2227,7 +2227,7 @@ restart: } if (obj->datatype == DINLINEFUNC) CError_Error(CErrorStr175); - obj->flags |= OBJECT_FLAGS_2; + obj->flags = obj->flags | OBJECT_FLAGS_2; if (flag && !copts.cplusplus && obj->sclass == TK_REGISTER) CError_Error(CErrorStr163); break; @@ -2806,7 +2806,7 @@ static ENode *CExpr_MemberPointerCast(ENode *expr, TypeMemberPointer *type, UInt ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { TypePointer *tptr; ENode *tmp; - UInt32 flags; + short flags; if (!copts.old_argmatch) return CExpr_Convert(expr, type, qual, 1, 0); @@ -2830,7 +2830,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { flags = qual & ENODE_FLAG_QUALS; if (ENODE_IS(expr, EOBJLIST)) - return CExpr_AssignmentPromotion(expr, type, flags, 1); + return CExpr_AssignmentPromotion(expr, type, qual & ENODE_FLAG_QUALS, 1); if (ENODE_IS(expr, EOBJREF) && IS_TYPE_NONSTATIC_METHOD(expr->data.objref->type)) { CError_Error(CErrorStr221); @@ -2898,7 +2898,7 @@ ENode *do_typecast(ENode *expr, Type *type, UInt32 qual) { if (ENODE_IS(expr, ETYPCON) && expr->rtype->type == type->type && expr->rtype->size == type->size) { if (is_unsigned(expr->rtype) == is_unsigned(type) && ENODE_QUALS(expr) == qual) { expr->rtype = type; - expr->flags |= ENODE_FLAG_80; + expr->flags = expr->flags | ENODE_FLAG_80; return expr; } } @@ -4153,14 +4153,14 @@ ENode *CExpr_New_ECOND_Node(ENode *cond, ENode *expr1, ENode *expr2) { result->rtype = expr1->rtype; result->flags = expr1->flags | expr2->flags; result->data.cond.cond = cond; - if (ENODE_IS(expr1, EFUNCCALL) && expr1->rtype == &stvoid && (expr1->flags & ENODE_FLAG_VOLATILE)) { + if (ENODE_IS(expr1, EFUNCCALL) && expr1->rtype == &stvoid && (expr1->flags & ENODE_FLAG_VOLATILE) != 0) { result->rtype = expr2->rtype; result->flags = expr2->flags; result->data.cond.expr1 = expr1; result->data.cond.expr2 = expr2; return result; } - if (ENODE_IS(expr2, EFUNCCALL) && expr2->rtype == &stvoid && (expr2->flags & ENODE_FLAG_VOLATILE)) { + if (ENODE_IS(expr2, EFUNCCALL) && expr2->rtype == &stvoid && (expr2->flags & ENODE_FLAG_VOLATILE) != 0) { result->rtype = expr1->rtype; result->flags = expr1->flags; result->data.cond.expr1 = expr1; diff --git a/compiler_and_linker/unsorted/CFunc.c b/compiler_and_linker/unsorted/CFunc.c index 647977a..2ea883b 100644 --- a/compiler_and_linker/unsorted/CFunc.c +++ b/compiler_and_linker/unsorted/CFunc.c @@ -1339,7 +1339,7 @@ static void makeifstatement(ENode *expr, CLabel *label1, CLabel *label2, Boolean if (!flag1) stmt->type = ST_IFNGOTO; if (flag2) - stmt->flags |= StmtFlag_4; + stmt->flags = stmt->flags | StmtFlag_4; } static void CFunc_HasDtorTempCallBack(ENode *expr) { @@ -1359,7 +1359,7 @@ static void ifstatement(Boolean flag1, ENode *expr, CLabel *label, Boolean flag2 stmt->label = label; stmt->expr = expr; if (flag2) - stmt->flags |= StmtFlag_4; + stmt->flags = stmt->flags | StmtFlag_4; return; } } @@ -3030,7 +3030,7 @@ void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean i stmt16->expr->rtype == &stvoid && (stmt16->expr->flags & ENODE_FLAG_VOLATILE) ) - curstmt->flags |= StmtFlag_8; + curstmt->flags = curstmt->flags | StmtFlag_8; } CheckCLabels(); diff --git a/compiler_and_linker/unsorted/CInit.c b/compiler_and_linker/unsorted/CInit.c index 2d2930f..5493e15 100644 --- a/compiler_and_linker/unsorted/CInit.c +++ b/compiler_and_linker/unsorted/CInit.c @@ -643,7 +643,7 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val pos = tbitfield->unkB + tbitfield->unkA - 1; step = -1; } - for (i = 0; i < tbitfield->unkB; i++) { + for (i = 0; i < tbitfield->unkB; i++, pos += step) { if (CInt64_GetULong(&val) & 1) { if (copts.littleendian) { buffer[pos >> 3] |= 1 << (pos & 7); @@ -652,7 +652,6 @@ static void CInit_SetBitfield(TypeBitfield *tbitfield, UInt8 *buffer, CInt64 val } } val = CInt64_ShrU(val, cint64_one); - pos += step; } } @@ -1916,7 +1915,7 @@ static void CInit_AutoInit(Type *type, ENode *valueexpr, Boolean flag) { copy = galloc(sizeof(TypePointer)); *TYPE_POINTER(copy) = *TYPE_POINTER(type); type = copy; - type->size++; + copy->size++; } expr = create_objectrefnode(cinit_initinfo->obj1C); if (!IS_TYPE_POINTER_ONLY(expr->rtype)) { @@ -2022,13 +2021,11 @@ static ENode *CInit_GenericData(Object *obj, Type *type, UInt32 qual, ExprCB exp case TYPEPOINTER: case TYPEMEMBERPOINTER: generic_type: - if (obj) { - cv = obj->qual; - cv &= Q_CONST | Q_VOLATILE; - } else { - cv = cinit_initinfo->obj1C->qual; - cv &= Q_CONST | Q_VOLATILE; - } + if (obj) + cv = obj->qual & Q_CV; + else + cv = cinit_initinfo->obj1C->qual & Q_CV; + if (tk == '{') { tk = lex(); expr = assignment_expression(); @@ -2771,7 +2768,7 @@ void CInit_InitializeData(Object *obj) { } else { if (obj->flags & OBJECT_FLAGS_4) CError_Error(CErrorStr329, obj); - obj->flags |= OBJECT_FLAGS_4; + obj->flags = obj->flags | OBJECT_FLAGS_4; needs_construction = 0; if (IS_TYPE_ARRAY(obj->type)) { @@ -3050,7 +3047,7 @@ static void declaredata(Object *obj, void *data, OLinkList *list, SInt32 size, B if (cparamblkptr->precompile == 1) { PreComp_StaticData(obj, data, list, size); } else { - obj->flags |= OBJECT_FLAGS_4; + obj->flags = obj->flags | OBJECT_FLAGS_4; if (!fatalerrors) { for (scan = list; scan; scan = scan->next) CInline_ObjectAddrRef(scan->obj); diff --git a/compiler_and_linker/unsorted/CInt64.c b/compiler_and_linker/unsorted/CInt64.c index a2ccaec..222a63f 100644 --- a/compiler_and_linker/unsorted/CInt64.c +++ b/compiler_and_linker/unsorted/CInt64.c @@ -75,9 +75,8 @@ CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) { result.hi = result.lo = 0; bbbb = lhs.lo; cccc = rhs.hi; - dddd = rhs.lo; - while (bbbb != 0) { + for (dddd = aaaa; bbbb != 0; dddd <<= 1, bbbb >>= 1) { if (bbbb & 1) { work1.hi = cccc; work1.lo = dddd; @@ -86,8 +85,6 @@ CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs) { cccc <<= 1; if (dddd & 0x80000000) cccc |= 1; - dddd <<= 1; - bbbb >>= 1; } eeee = lhs.hi; @@ -449,29 +446,31 @@ CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs) { } void CInt64_ConvertInt32(CInt64 *i) { - CInt64_Extend32(i); + i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0; } void CInt64_ConvertUInt32(CInt64 *i) { - CInt64_SetULong(i, (UInt32) i->lo); + i->hi = 0; } void CInt64_ConvertInt16(CInt64 *i) { i->lo = (SInt16) i->lo; - CInt64_Extend32(i); + i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0; } void CInt64_ConvertUInt16(CInt64 *i) { - CInt64_SetULong(i, (UInt16) i->lo); + i->lo = (UInt16) i->lo; + i->hi = 0; } void CInt64_ConvertInt8(CInt64 *i) { i->lo = (SInt8) i->lo; - CInt64_Extend32(i); + i->hi = (i->lo & 0x80000000) ? 0xFFFFFFFF : 0; } void CInt64_ConvertUInt8(CInt64 *i) { - CInt64_SetULong(i, (UInt8) i->lo); + i->lo = (UInt8) i->lo; + i->hi = 0; } void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value) { @@ -648,7 +647,6 @@ char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail) { } char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) { - /* NOT MATCHING */ int digit; CInt64 tmp; UInt32 a; @@ -658,7 +656,8 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) { pResult->hi = pResult->lo = 0; for (;;) { - if ((digit = str[0]) >= '0' && digit <= '9') + digit = str[0]; + if (digit >= '0' && digit <= '9') digit = digit - '0'; else if (digit >= 'A' && digit <= 'F') digit = digit - 'A' + 10; @@ -667,9 +666,9 @@ char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail) { else break; + ++str; a = pResult->hi; b = pResult->lo; - ++str; if (a & 0xF0000000) *pFail = 1; @@ -705,9 +704,9 @@ char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail) { else break; + ++str; a = pResult->hi; b = pResult->lo; - ++str; if (a & 0x80000000) *pFail = 1; @@ -788,8 +787,8 @@ int CInt64_PrintDec(char *output, CInt64 value) { if (CInt64_IsNegative(&value)) { value = CInt64_Neg(value); *output = '-'; - length++; output++; + length++; } if (!CInt64_IsZero(&value)) { @@ -801,7 +800,7 @@ int CInt64_PrintDec(char *output, CInt64 value) { rem = CInt64_ModU(value, divisor); *(bufp++) = rem.lo + '0'; value = CInt64_DivU(value, divisor); - if (CInt64_IsZero(&value) != 0) + if (CInt64_IsZero(&value)) break; } @@ -841,7 +840,7 @@ int CInt64_PrintHex(char *output, CInt64 value) { else *(bufp++) = rem.lo + '0'; value = CInt64_ShrU(value, shift); - if (CInt64_IsZero(&value) != 0) + if (CInt64_IsZero(&value)) break; } @@ -874,7 +873,7 @@ int CInt64_PrintBin(char *output, CInt64 value) { else *(bufp++) = '0'; value = CInt64_ShrU(value, cint64_one); - if (CInt64_IsZero(&value) != 0) + if (CInt64_IsZero(&value)) break; } diff --git a/compiler_and_linker/unsorted/COptimizer.c b/compiler_and_linker/unsorted/COptimizer.c index f7614ed..9833a2b 100644 --- a/compiler_and_linker/unsorted/COptimizer.c +++ b/compiler_and_linker/unsorted/COptimizer.c @@ -1518,10 +1518,10 @@ static void removeunusedlabels(Statement *stmt) { for (action = scan->dobjstack; action; action = action->prev) { if (action->type == EAT_CATCHBLOCK) { action->data.catch_block.catch_label->stmt->marked = 1; - action->data.catch_block.catch_label->stmt->flags |= StmtFlag_1; + action->data.catch_block.catch_label->stmt->flags = action->data.catch_block.catch_label->stmt->flags | StmtFlag_1; } else if (action->type == EAT_SPECIFICATION) { action->data.specification.unexp_label->stmt->marked = 1; - action->data.specification.unexp_label->stmt->flags |= StmtFlag_1; + action->data.specification.unexp_label->stmt->flags = action->data.specification.unexp_label->stmt->flags | StmtFlag_1; } } } @@ -1798,7 +1798,7 @@ static void COpt_Optimize(Object *obj, Statement *stmt) { static void COpt_ELABELCallBack(ENode *expr) { CError_ASSERT(2195, expr->data.label->stmt && expr->data.label->stmt->type == ST_LABEL); - expr->data.label->stmt->flags |= StmtFlag_1; + expr->data.label->stmt->flags = expr->data.label->stmt->flags | StmtFlag_1; } void COpt_SimpleOptimizer(Object *obj, Statement *stmt) { diff --git a/compiler_and_linker/unsorted/CSOM.c b/compiler_and_linker/unsorted/CSOM.c index bd1a75e..394ea2b 100644 --- a/compiler_and_linker/unsorted/CSOM.c +++ b/compiler_and_linker/unsorted/CSOM.c @@ -219,7 +219,7 @@ typedef struct TypeSig { UInt8 x2; } TypeSig; -static UInt8 CSOM_GetTypeSig(TypeSig *sig, Type *type, Boolean flag) { +static int CSOM_GetTypeSig(TypeSig *sig, Type *type, Boolean flag) { if (type->size > 4) sig->x1 |= fgAnyNon4Bytes; @@ -370,7 +370,7 @@ void CSOM_MakeSOMClass(TypeClass *tclass) { tclass->sominfo = info; info->classdataobject = CSOM_MakeObject(tclass->classname->name, "ClassData", 28); - info->classdataobject->flags |= OBJECT_FLAGS_40; + info->classdataobject->flags = info->classdataobject->flags | OBJECT_FLAGS_40; } } @@ -604,7 +604,7 @@ typedef struct SOMGenerator { static SOMAncestor *CSOM_FindAddAncestor(SOMGenerator *gen, TypeClass *tclass, TypeClass *ancestorClass, UInt16 *resultIndex) { SOMAncestor *ancestor; SOMAncestor *scan; - int index; + UInt16 index; ancestor = gen->ancestors; for (scan = ancestor, index = 0; scan; scan = scan->next, index++) { @@ -618,8 +618,8 @@ static SOMAncestor *CSOM_FindAddAncestor(SOMGenerator *gen, TypeClass *tclass, T if (ancestor) { index = 1; while (ancestor->next) { - ancestor = ancestor->next; index++; + ancestor = ancestor->next; } ancestor->next = lalloc(sizeof(SOMAncestor)); @@ -709,7 +709,7 @@ static void CSOM_GenerateOverrideIntroLists(SOMGenerator *gen, TypeClass *tclass SOMReleaseOrder *order; SOMReleaseOrder *order2; SInt32 index; - SInt32 index2; + UInt16 index2; for (order = tclass->sominfo->order, index = 0; order; order = order->next, index++) { method = lalloc(sizeof(SOMMethod)); @@ -795,15 +795,13 @@ static void CSOM_GenerateClassAncestors(SOMGenerator *gen, TypeClass *tclass) { relocs = NULL; size = 0; - ancestor = gen->ancestors; - while (ancestor) { + for (ancestor = gen->ancestors; ancestor; ancestor = ancestor->next) { OLinkList *reloc = lalloc(sizeof(OLinkList)); reloc->next = relocs; relocs = reloc; reloc->obj = ancestor->tclass->sominfo->classdataobject; reloc->offset = size; reloc->somevalue = 0; - ancestor = ancestor->next; size += 4; } @@ -831,22 +829,18 @@ static void CSOM_GenerateOverrideProcs(SOMGenerator *gen, TypeClass *tclass) { relocs = NULL; offset = 0; - ancestor = gen->ancestors; - while (ancestor) { + for (ancestor = gen->ancestors; ancestor; ancestor = ancestor->next) { if (ancestor->overrides) { - override = ancestor->overrides; - while (override) { + for (override = ancestor->overrides; override; override = override->next) { OLinkList *reloc = lalloc(sizeof(OLinkList)); reloc->next = relocs; relocs = reloc; reloc->obj = override->a; reloc->offset = offset; reloc->somevalue = 0; - override = override->next; offset += 4; } } - ancestor = ancestor->next; } buf = lalloc(size); @@ -872,8 +866,8 @@ static Object *CSOM_GenerateOverrideData(SOMGenerator *gen) { override = ancestor->overrides; overrideCount = 0; while (override) { - override = override->next; overrideCount++; + override = override->next; } AppendGListWord(&name_mangle_list, CTool_EndianConvertWord16(overrideCount)); @@ -993,8 +987,8 @@ static void CSOM_GenerateSpecialProcs(SOMGenerator *gen, TypeClass *tclass) { static Object *CSOM_GenerateParentVersion(SOMGenerator *gen) { SInt32 size; UInt32 *buf; - SInt32 offset; SOMAncestor *ancestor; + SInt32 offset; size = 8 * (gen->counts.numDirectParents + gen->counts.numMetaClasses); buf = lalloc(size); @@ -1009,7 +1003,7 @@ static Object *CSOM_GenerateParentVersion(SOMGenerator *gen) { return CInit_DeclareString((char *) buf, size, 0, 0); } -static void CSOM_SetNibble(UInt8 *buf, int offset, UInt8 value) { +static void CSOM_SetNibble(char *buf, int offset, UInt8 value) { int i = offset >> 1; if (offset & 1) { int left = buf[i] & 0xF0; @@ -1025,7 +1019,7 @@ static void CSOM_SetNibble(UInt8 *buf, int offset, UInt8 value) { static Object *CSOM_GenerateSlotUsage(SOMGenerator *gen) { SInt32 size; SOMMethod *method; - UInt8 *buf; + char *buf; int offset; size = (gen->counts.classTokenCount + 1) / 2; @@ -1046,7 +1040,7 @@ static Object *CSOM_GenerateSlotUsage(SOMGenerator *gen) { } } - return CInit_DeclareString((char *) buf, size, 0, 0); + return CInit_DeclareString(buf, size, 0, 0); } static Object *CSOM_GenerateSignature(SOMGenerator *gen) { @@ -1264,7 +1258,7 @@ static void CSOM_GenerateClassDataObject(SOMGenerator *gen, TypeClass *tclass) { SOMMethod *method; relocs = NULL; - for (size = 24, method = gen->methods; method; method = method->next, size += 4) { + for (size = 24, method = gen->methods; method; method = method->next) { if (method->state == SOMMS_Method) { reloc = lalloc(sizeof(OLinkList)); reloc->next = relocs; @@ -1273,6 +1267,7 @@ static void CSOM_GenerateClassDataObject(SOMGenerator *gen, TypeClass *tclass) { reloc->offset = size; reloc->somevalue = 0; } + size += 4; } buf = lalloc(size); @@ -2056,7 +2051,7 @@ ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag) { NULL); expr->rtype = indirectExpr->rtype; if (copts.som_env_check && tclass3->sominfo->oidl_callstyle == 0) - expr->flags |= ENODE_FLAG_10; + expr->flags = expr->flags | ENODE_FLAG_10; } else { CSOM_FindIntroClassOffset(tclass2, func, &tclass3, &offset); if (copts.som_call_optimize && CSOM_CanUseGlueCall(TYPE_FUNC(func->type))) @@ -2067,7 +2062,7 @@ ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag) { expr = makemonadicnode(expr, EINDIRECT); expr->rtype = CDecl_NewPointerType(func->type); if (copts.som_env_check && tclass3->sominfo->oidl_callstyle == 0) - expr->flags |= ENODE_FLAG_10; + expr->flags = expr->flags | ENODE_FLAG_10; } return expr; diff --git a/compiler_and_linker/unsorted/CTemplateNew.c b/compiler_and_linker/unsorted/CTemplateNew.c index fdbf194..9c94349 100644 --- a/compiler_and_linker/unsorted/CTemplateNew.c +++ b/compiler_and_linker/unsorted/CTemplateNew.c @@ -318,11 +318,10 @@ static UInt8 CTempl_GetTemplateNestIndex(NameSpace *nspace) { return count; } -static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *paramList, int index, UInt8 nindex) { - TemplParam *param; +static TemplParam *CTempl_ParseParam(NameSpace *nspace, TemplParam *param, UInt16 index, UInt8 nindex) { DeclInfo di; - short startToken; SInt32 savedState; + short startToken; param = galloc(sizeof(TemplParam)); memclrw(param, sizeof(TemplParam)); @@ -447,7 +446,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) { TemplParam **ptr; TemplParam *param; TemplParam *scan; - int index; + UInt16 index; params = NULL; index = 0; @@ -484,7 +483,7 @@ static TemplParam *CTempl_ParseParamList(NameSpace *nspace, UInt8 nindex) { TemplArg *CTempl_ParseUncheckTemplArgs(TemplParam *params, Boolean is_global) { TemplArg *args; TemplArg *last; - int index; + UInt16 index; if (tk != '<') { CError_Error(CErrorStr230); @@ -988,7 +987,7 @@ static void CTempl_ParseConversionFunctionTemplate(DeclInfo *di, DeclFucker *wha return; } - tclass->flags |= CLASS_FLAGS_40; + tclass->flags = tclass->flags | CLASS_FLAGS_40; CError_QualifierCheck(di->qual & ~Q_INLINE); conversion_type_name(di); diff --git a/compiler_and_linker/unsorted/CodeGen.c b/compiler_and_linker/unsorted/CodeGen.c index 19c7d1d..908f71b 100644 --- a/compiler_and_linker/unsorted/CodeGen.c +++ b/compiler_and_linker/unsorted/CodeGen.c @@ -231,9 +231,9 @@ static void retain_argument_register(Object *obj, short reg) { } static void allocate_local_vregs(void) { - VarInfo *vi; ObjectList *list; Object *obj; + VarInfo *vi; if (copts.codegen_pic && uses_globals && assignable_registers[RegClass_GPR]) { if (assignable_registers[RegClass_GPR]) { @@ -863,7 +863,6 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B Statement *stmt; Boolean has_varargs; PCodeBlock *tmp; - Object *obj; SInt32 size; CodeGen_InitialSanityCheck(); @@ -877,8 +876,11 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B if (!func) { func = createstaticinitobject(); - } else if (func && func->name) { - PrintProgressFunction(func->name->name); + } else { +#ifdef CW_CLT + if (func && func->name) + PrintProgressFunction(func->name->name); +#endif } gFunction = func; @@ -981,8 +983,7 @@ void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, B break; case ST_ENDCATCHDTOR: CError_ASSERT(2056, stmt->expr->data.objref->datatype == DLOCAL); - obj = stmt->expr->data.objref; - add_immediate(3, local_base_register(obj), obj, 0); + add_immediate(3, local_base_register(stmt->expr->data.objref), stmt->expr->data.objref, 0); { UInt32 masks[RegClassMax] = {0, 0, 0, 0, 0}; masks[RegClass_GPR] |= 1 << 3; @@ -1467,7 +1468,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "unroll_speculative")) { + if (!strcmp(name->name, "ppc_unroll_speculative")) { if (plex() == TK_IDENTIFIER) { if (!strcmp(tkidentifier->name, "off")) { copts.unroll_speculative = 0; @@ -1484,7 +1485,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "unroll_instr_limit")) { + if (!strcmp(name->name, "ppc_unroll_instructions_limit")) { t = plex(); if (t == TK_INTCONST) { copts.unroll_instr_limit = CInt64_GetULong(&tkintconst); @@ -1539,7 +1540,7 @@ void CodeGen_ParsePragma(HashNameNode *name) { return; } - if (!strcmp(name->name, "unroll_factor_limit")) { + if (!strcmp(name->name, "ppc_unroll_factor_limit")) { t = plex(); if (t == TK_INTCONST) { copts.unroll_factor_limit = CInt64_GetULong(&tkintconst); diff --git a/compiler_and_linker/unsorted/IrOptimizer.c b/compiler_and_linker/unsorted/IrOptimizer.c index 121c65f..c9544a2 100644 --- a/compiler_and_linker/unsorted/IrOptimizer.c +++ b/compiler_and_linker/unsorted/IrOptimizer.c @@ -115,7 +115,6 @@ static void CountUsage(void) { Statement *IRO_Optimizer(Object *func, Statement *statements) { Boolean changed; - Boolean changed2; int pass; int passCount; @@ -292,30 +291,30 @@ Statement *IRO_Optimizer(Object *func, Statement *statements) { IRO_RemoveUnreachable(); IRO_DumpAfterPhase("IRO_RemoveUnreachable", 0); - changed2 = IRO_RemoveRedundantJumps(); + changed = IRO_RemoveRedundantJumps(); IRO_DumpAfterPhase("IRO_RemoveRedundantJumps", 0); - changed2 |= IRO_RemoveLabels(); + changed |= IRO_RemoveLabels(); IRO_DumpAfterPhase("IRO_RemoveLabels", 0); - changed2 |= IRO_DoJumpChaining(); + changed |= IRO_DoJumpChaining(); IRO_DumpAfterPhase("IRO_DoJumpChaining", 0); if (copts.propagation) { IRO_RenumberInts(); IRO_DumpAfterPhase("Before IRO_CopyAndConstantPropagation", 0); - changed2 |= IRO_CopyAndConstantPropagation(); + changed |= IRO_CopyAndConstantPropagation(); IRO_DumpAfterPhase("After IRO_CopyAndConstantPropagation", 0); IRO_ConstantFolding(); } if (copts.deadstore || copts.propagation) - changed2 |= IRO_UseDef(copts.deadstore, copts.propagation); + changed |= IRO_UseDef(copts.deadstore, copts.propagation); IRO_DumpAfterPhase("IRO_UseDef", 0); - changed2 |= IRO_EvaluateConditionals(); + changed |= IRO_EvaluateConditionals(); IRO_DumpAfterPhase("IRO_EvaluateConditionals", 0); - } while (changed2); + } while (changed); } if (copts.lifetimes) { diff --git a/compiler_and_linker/unsorted/ObjGenMachO.c b/compiler_and_linker/unsorted/ObjGenMachO.c index 244a1bc..684316e 100644 --- a/compiler_and_linker/unsorted/ObjGenMachO.c +++ b/compiler_and_linker/unsorted/ObjGenMachO.c @@ -29,7 +29,7 @@ typedef struct Reloc { SInt32 relocID; SInt32 picOffset; struct Reloc *next; - RelocType relocType; + char relocType; MWReloc mwRelType; } Reloc; @@ -113,7 +113,8 @@ SInt32 pic_base_offset; #define RELOC_DATA(_id) (((RelocDataT *) (*RelocData.data))[(_id)]) -static Section SegmentForceCreate = SECT_TEXT; +enum { ForceCreateCount = 1 }; +static Section SegmentForceCreate[ForceCreateCount] = { SECT_TEXT }; // forward decls static void CreateTheSegment(void); @@ -884,13 +885,13 @@ void ObjGen_Finish(void) { argMask = 0xFFFF; if (value & 0x8000) value += 0x10000; - value = (value >> 16) & 0xFFFF; + value = (value & 0xFFFF0000) >> 16; nextRelType = PPC_RELOC_HA16_SECTDIFF; break; case MW_RELOC_6_HI16: opMask = 0xFFFF0000; argMask = 0xFFFF; - value = (value >> 16) & 0xFFFF; + value = (value & 0xFFFF0000) >> 16; nextRelType = PPC_RELOC_HI16_SECTDIFF; break; case MW_RELOC_8: @@ -945,13 +946,13 @@ void ObjGen_Finish(void) { argMask = 0xFFFF; if (value & 0x8000) value += 0x10000; - value = (value >> 16) & 0xFFFF; + value = (value & 0xFFFF0000) >> 16; nextRelType = PPC_RELOC_HA16; break; case MW_RELOC_6_HI16: opMask = 0xFFFF0000; argMask = 0xFFFF; - value = (value >> 16) & 0xFFFF; + value = (value & 0xFFFF0000) >> 16; nextRelType = PPC_RELOC_HI16; break; case MW_RELOC_8: @@ -1011,8 +1012,11 @@ void ObjGen_SetupSym(void) { } static void CreateTheSegment(void) { + int i; + TheSegment = MachO_CreateSegment("", 7, 7, 0); - Sections[SegmentForceCreate] = ObjGen_GetSection(SegmentForceCreate); + for (i = 0; i < ForceCreateCount; i++) + Sections[SegmentForceCreate[i]] = ObjGen_GetSection(SegmentForceCreate[i]); } static void patchuplazyptr(Object *object) { @@ -1143,9 +1147,9 @@ static void declaredata(Object *object, char *data, OLinkList *olinklist, UInt32 if (!align) align = 1; - if (offset % align) { + if ((offset % align) != 0) { // issue here - SInt32 adjust = align - (offset % align); + int adjust = align - (offset % align); offset = offset + adjust; } @@ -1223,7 +1227,7 @@ void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag) { if (name && copts.absolutepath) ptr = buf1 + strlen(buf1); else - ptr = strrchr(buf1, '/'); + ptr = strrchr(buf1, OS_PATHSEP); if ((flag || name) && ptr && copts.absolutepath) { if (!strncmp(buf1, "Mac OS X:", strlen("Mac OS X:"))) { @@ -1236,8 +1240,20 @@ void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag) { ptr3 = buf1; } - while (ptr3 <= ptr) - *(ptr2++) = *(ptr3++); + while (ptr3 <= ptr) { +#ifdef CW_HOST_MAC_CLASSIC + if (*ptr3 == '/') + *ptr2 = ':'; + else if (*ptr3 == ':') + *ptr2 = '/'; + else + *ptr2 = *ptr3; +#else + *ptr2 = *ptr3; +#endif + ptr2++; + ptr3++; + } *ptr2 = 0; if (flag && !name) { @@ -1305,8 +1321,7 @@ MachOSection *ObjGen_DeclareCode(Object *object, SInt32 size) { return section; } -MachOSection *ObjGen_DeclareMachSection() { - // unknown args +MachOSection *ObjGen_DeclareMachSection(char *segname, char *sectname, UInt32 align, UInt32 flags) { CError_FATAL(2020); return NULL; } @@ -1589,7 +1604,7 @@ void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data, flag22 = 0; if (len == 8) { - if (CTool_EndianConvertWord16(*((UInt16 *) data) & 8) >> 3) { + if ((CTool_EndianConvertWord16(*((UInt16 *) data)) >> 3) & 1) { *((UInt16 *) data) = CTool_EndianConvertWord16(CTool_EndianConvertWord16(*((UInt16 *) data)) & ~8); len = 4; } diff --git a/compiler_and_linker/unsorted/Operands.c b/compiler_and_linker/unsorted/Operands.c index e61d5b0..08eee12 100644 --- a/compiler_and_linker/unsorted/Operands.c +++ b/compiler_and_linker/unsorted/Operands.c @@ -23,10 +23,10 @@ void load_immediate(short reg, SInt32 value) { short tmpreg2; if (!FITS_IN_SHORT(value)) { - if (copts.optimizationlevel > 1 && value) + if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(value)) tmpreg = used_virtual_registers[RegClass_GPR]++; emitpcode(PC_LIS, tmpreg2 = tmpreg, 0, (short) HIGH_PART(value)); - if (LOW_PART(value)) + if (LOW_PART_BUGGY(value)) emitpcode(PC_ADDI, reg, tmpreg2, 0, LOW_PART(value)); } else { emitpcode(PC_LI, reg, value); @@ -263,7 +263,7 @@ void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut) { emitpcode(PC_ADDI, opOut->regOffset, opB->regOffset, 0, LOW_PART(opA->immediate)); } else { emitpcode(PC_ADDIS, opOut->regOffset, opB->regOffset, 0, (short) HIGH_PART(opA->immediate)); - if (LOW_PART(opA->immediate)) + if (LOW_PART_BUGGY(opA->immediate)) emitpcode(PC_ADDI, opOut->regOffset, opOut->regOffset, 0, LOW_PART(opA->immediate)); } break; @@ -381,10 +381,10 @@ void Coerce_to_register(Operand *op, Type *type, short output_reg) { emitpcode(PC_LI, reg, offset); } else { tmp = reg; - if (copts.optimizationlevel > 1 && offset) + if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset)) tmp = used_virtual_registers[RegClass_GPR]++; emitpcode(PC_LIS, tmp, 0, (short) HIGH_PART(offset)); - if (LOW_PART(offset)) + if (LOW_PART_BUGGY(offset)) emitpcode(PC_ADDI, reg, tmp, 0, LOW_PART(offset)); } break; @@ -530,10 +530,10 @@ void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short ou emitpcode(PC_LI, reg, offset); } else { tmp1 = reg; - if (copts.optimizationlevel > 1 && offset) + if (copts.optimizationlevel > 1 && LOW_PART_BUGGY(offset)) tmp1 = used_virtual_registers[RegClass_GPR]++; emitpcode(PC_LIS, tmp1, 0, (short) HIGH_PART(offset)); - if (LOW_PART(offset)) + if (LOW_PART_BUGGY(offset)) emitpcode(PC_ADDI, reg, tmp1, 0, LOW_PART(offset)); } regHi = output_regHi ? output_regHi : used_virtual_registers[RegClass_GPR]++; |