diff options
Diffstat (limited to '')
38 files changed, 264 insertions, 209 deletions
diff --git a/includes/compiler.h b/includes/compiler.h index cea535f..c811e6a 100644 --- a/includes/compiler.h +++ b/includes/compiler.h @@ -12,23 +12,7 @@ -struct DefArgCtorInfo { - Object *default_func; - ENode *default_arg; -}; - -typedef struct XRefOffset { - UInt32 xrefoffset; - SInt32 offset; -} XRefOffset; -struct InlineXRef { - InlineXRef *next; - Object *object; - UInt16 xrefmode; - UInt16 numxrefs; - XRefOffset xref[1]; -}; diff --git a/includes/compiler/CABI.h b/includes/compiler/CABI.h index 735eeea..6e190d5 100644 --- a/includes/compiler/CABI.h +++ b/includes/compiler/CABI.h @@ -8,6 +8,13 @@ #pragma options align=mac68k #endif +typedef enum CABIDestroyMode { + CABIDestroy0 = 0, + CABIDestroy1 = 1, + CABIDestroy2 = 2, + CABIDestroy3 = 3 +} CABIDestroyMode; + extern short CABI_GetStructResultArgumentIndex(TypeFunc *tfunc); extern Type *CABI_GetSizeTType(void); extern Type *CABI_GetPtrDiffTType(void); @@ -16,21 +23,21 @@ extern void CABI_ReverseBitField(TypeBitfield *tbitfield); extern void CABI_AddVTable(TypeClass *tclass); extern SInt32 CABI_GetVTableOffset(TypeClass *tclass); extern void CABI_LayoutClass(DeclE *decle, TypeClass *tclass); -extern void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *obj); +extern void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *func); extern ENode *CABI_MakeThisExpr(TypeClass *tclass, SInt32 offset); extern SInt32 CABI_GetCtorOffsetOffset(TypeClass *tclass, TypeClass *base); extern Object *CABI_ConstructorCallsNew(TypeClass *tclass); typedef Statement *(*TransConstructorCallback)(Statement *stmt, TypeClass *tclass, TypeClass *base, SInt32 offset, Boolean flag); -extern void CABI_TransConstructor(Object *obj, Statement *stmt, TypeClass *tclass, TransConstructorCallback callback, Boolean flag); -extern void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *obj); -extern void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *obj); -extern void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *obj); -extern void CABI_TransDestructor(Object *obj1, Object *obj2, Statement *stmt, TypeClass *tclass); -extern void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *obj); -extern void CABI_MakeLayeredDestructor(TypeClass *tclass, Object *obj); -extern Object *CABI_GetDestructorObject(Object *obj, int what); +extern void CABI_TransConstructor(Object *obj, Statement *stmt, TypeClass *tclass, TransConstructorCallback callback, Boolean has_try); +extern void CABI_MakeDefaultConstructor(TypeClass *tclass, Object *func); +extern void CABI_MakeDefaultCopyConstructor(TypeClass *tclass, Object *func); +extern void CABI_MakeDefaultAssignmentOperator(TypeClass *tclass, Object *func); +extern void CABI_TransDestructor(Object *obj1, Object *obj2, Statement *stmt, TypeClass *tclass, CABIDestroyMode mode); +extern void CABI_MakeDefaultDestructor(TypeClass *tclass, Object *func); +extern void CABI_MakeLayeredDestructor(TypeClass *tclass, Object *func); +extern Object *CABI_GetDestructorObject(Object *obj, CABIDestroyMode mode); extern void CABI_AddLayeredDestructors(TypeClass *tclass); -extern ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, UInt8 mode, Boolean flag1, Boolean flag2); +extern ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, CABIDestroyMode mode, Boolean flag1, Boolean flag2); #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/CClass.h b/includes/compiler/CClass.h index 083588c..bb952de 100644 --- a/includes/compiler/CClass.h +++ b/includes/compiler/CClass.h @@ -7,21 +7,21 @@ #pragma options align=mac68k #endif -typedef struct VTableObjectLink { +/*typedef struct VTableObjectLink { struct VTableObjectLink *next; Object *methodobj; SInt32 offset; SInt32 xC; -} VTableObjectLink; +} VTableObjectLink;*/ extern void CClass_Init(void); extern void CClass_GenThunks(void); extern UInt8 CClass_GetOverrideKind(TypeFunc *a, TypeFunc *b, Boolean errorflag); extern Boolean CClass_IsEmpty(TypeClass *tclass); -extern Boolean CClass_IsNonStaticMemberFunc(TypeMethod *tmethod); +extern Boolean CClass_IsNonStaticMemberFunc(TypeFunc *tfunc); extern Object *CClass_DefaultConstructor(TypeClass *tclass); extern Object *CClass_DummyDefaultConstructor(TypeClass *tclass); -extern ENode *CClass_DefaultConstructorCall(TypeClass *a, TypeClass *b, ENode *expr, SInt32 unkshortparam, Boolean flag1, Boolean flag2, Boolean *errorflag); +extern ENode *CClass_DefaultConstructorCall(TypeClass *tclass, TypeClass *b, ENode *objexpr, SInt32 varg, Boolean flag1, Boolean flag2, Boolean *errorflag); extern Object *CClass_AssignmentOperator(TypeClass *tclass); extern Object *CClass_CopyConstructor(TypeClass *tclass); extern NameSpaceObjectList *CClass_MemberObject(TypeClass *tclass, HashNameNode *name); @@ -34,19 +34,19 @@ extern Boolean CClass_IsTrivialCopyClass(TypeClass *tclass); extern Boolean CClass_IsTrivialCopyAssignClass(TypeClass *tclass); extern Boolean CClass_ReferenceArgument(TypeClass *tclass); extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean is_global); -extern BClassList *CClass_AppendPath(BClassList *a, BClassList *b); +extern BClassList *CClass_AppendPath(BClassList *dest, BClassList *src); extern Boolean CClass_IsMoreAccessiblePath(BClassList *path1, BClassList *path2); extern BClassList *CClass_GetBasePath(TypeClass *a, TypeClass *b, short *founddepth, Boolean *isambigbase); extern Boolean CClass_IsBaseClass(TypeClass *a, TypeClass *b, short *founddepth, Boolean pathcheckflag, Boolean ambigerrorflag); extern TypeClass *CClass_GetQualifiedClass(void); -extern ENode *CClass_AccessPathCast(BClassList *path, ENode *expr, Boolean flag); +extern ENode *CClass_AccessPathCast(BClassList *path, ENode *expr, Boolean reverse); extern ENode *CClass_ClassPointerCast(ENode *expr, TypeClass *a, TypeClass *b, Boolean typconflag, Boolean ambigerrorflag, Boolean pathcheckflag); extern ENode *CClass_DirectBasePointerCast(ENode *expr, TypeClass *a, TypeClass *b); extern SInt32 CClass_GetPathOffset(BClassList *path); -extern Boolean CClass_ClassDominates(TypeClass *a, TypeClass *b); -extern SInt32 CClass_VirtualBaseOffset(TypeClass *a, TypeClass *b); -extern SInt32 CClass_VirtualBaseVTableOffset(TypeClass *a, TypeClass *b); -extern SInt32 CClass_GetMemberOffset(TypeClass *tclass, HashNameNode *name, ObjMemberVar **obj); +extern Boolean CClass_ClassDominates(TypeClass *tclass, TypeClass *baseclass); +extern SInt32 CClass_VirtualBaseOffset(TypeClass *tclass, TypeClass *baseclass); +extern SInt32 CClass_VirtualBaseVTableOffset(TypeClass *tclass, TypeClass *baseclass); +extern SInt32 CClass_GetMemberOffset(TypeClass *tclass, HashNameNode *name, ObjMemberVar **resultIvar); extern Boolean CClass_OverridesBaseMember(TypeClass *tclass, HashNameNode *name, Object *obj); extern void CClass_DefineCovariantFuncs(Object *method, CI_FuncData *ifuncdata); extern void CClass_CheckOverrides(TypeClass *tclass); diff --git a/includes/compiler/CDecl.h b/includes/compiler/CDecl.h index a4c28e2..331a53b 100644 --- a/includes/compiler/CDecl.h +++ b/includes/compiler/CDecl.h @@ -12,7 +12,7 @@ // named because it's 0xE bytes big (hurr) struct DeclE { ObjBase **objlist; - void *x4; + ObjMemberVar *vtable_ivar; unsigned short x8; // lex_order_count? unsigned short xA; Boolean xC; @@ -31,8 +31,8 @@ struct DeclInfo { HashNameNode *name; Object *x10; NameSpaceObjectList *x14; - void *x18; - void *x1C; + FuncArg *x18; + NameSpace *x1C; Type *x20; ENode *x24; TemplClass *x28; @@ -46,8 +46,8 @@ struct DeclInfo { short storageclass; UInt8 section; UInt8 exportflags; - Boolean x44; - Boolean x45; + Boolean x44; // has args in identifier list + Boolean x45; // has oldstyle args Boolean x46; Boolean x47; Boolean x48; @@ -56,7 +56,7 @@ struct DeclInfo { Boolean x4B; Boolean x4C; Boolean x4D; - Boolean x4E; + Boolean x4E; // is_extern_c? Boolean x4F; Boolean x50; Boolean x51; @@ -70,7 +70,7 @@ struct DeclInfo { CPrepFileInfo *file; CPrepFileInfo *file2; SInt32 x60; // file offset? - short x64; + Boolean x64; }; typedef struct BigDeclInfo { diff --git a/includes/compiler/CException.h b/includes/compiler/CException.h index 0e19380..361cddd 100644 --- a/includes/compiler/CException.h +++ b/includes/compiler/CException.h @@ -3,6 +3,13 @@ #include "compiler/common.h" +typedef struct DtorTemp { + struct DtorTemp *next; + Object *object; + Object *dtor; + Object *temp; +} DtorTemp; + extern ExceptionAction *cexcept_dobjstack; extern Boolean cexcept_hasdobjects; extern Boolean cexcept_magic; diff --git a/includes/compiler/CExpr.h b/includes/compiler/CExpr.h index 24f0646..bdc0789 100644 --- a/includes/compiler/CExpr.h +++ b/includes/compiler/CExpr.h @@ -64,7 +64,9 @@ typedef struct Conversion { } Conversion; // CExpr.c -extern Boolean (*name_obj_check)(HashNameNode *, Object *); +typedef Boolean (*NameObjCheckCB)(HashNameNode *, Object *); + +extern NameObjCheckCB name_obj_check; extern Boolean disallowgreaterthan; // CExpr2.c @@ -174,7 +176,7 @@ extern void CExpr_MatchCV(Type *t1, UInt32 q1, Type *t2, UInt32 q2, Match13 *mat extern Boolean CExpr_MatchAssign(Type *type, UInt32 qual, ENode *expr, Match13 *match); extern ENode *CExpr_ClassPointerCast(BClassList *cls, ENode *expr, Boolean nullcheckflag); extern ENode *CExpr_GetClassAccessNode(BClassList *a, BClassList *b, ENode *expr, Object *obj, AccessType access, Boolean flag); -extern ENode *CExpr_ConvertToBool(ENode *expr, Boolean flag); +extern ENode *CExpr_ConvertToBool(ENode *expr, Boolean isExplicit); extern void CExpr_ConversionIteratorInit(ConversionIterator *iter, TypeClass *tclass); extern Object *CExpr_ConversionIteratorNext(ConversionIterator *iter); extern short user_assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2, Boolean flag3); @@ -197,45 +199,12 @@ extern ENode *scannew(Boolean flag); extern ENode *scandelete(Boolean flag); // CExprConvMatch.c -// static void CExpr_GetImplictObjectParamType(); -// static void CExpr_GetParamType(); -// static void CExpr_HasNParams(); -// static void CExpr_TypeCompare(); -// static void CExpr_IsReferenceCompatible(); -// static void CExpr_IsBaseOf(); -// static void CExpr_IsBetterClassConversion(); -// static void CExpr_IsBetterStandardConv(); -// static void CExpr_IsBetterImplicitConv(); -// static void CExpr_SetupStandardConversionResult(); -// static void CExpr_SetQualConversionResult(); -// static void CExpr_OverloadFuncMatch(); -// static void CExpr_StandardConversionMatch(); -// static void CExpr_UserConversion(); -// static void CExpr_UserConversionMatch(); -// static void CExpr_ImplicitConversionMatch(); -extern Boolean CExpr_CanImplicitlyConvert(ENode *expr, Type *type, UInt32 qual); -// static void CExpr_DerivedToBase(); -// static void CExpr_ClassReferenceConversion(); -// static void CExpr_BindToReference(); -extern ENode *CExpr_Convert(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2); -extern ENode *CExpr_AssignmentPromotion(ENode *expr, Type *type, UInt32 qual, Boolean flag); -// static void CExpr_IsBetterMatch(); -// static void CExpr_MatchArgs(); -// static void CExpr_GetMatchObject(); -// static void CExpr_FindBestMatch(); -extern void CExpr_FuncArgMatch(NameSpaceObjectList *nsol, TemplArg *templargs, ENodeList *argexprs, Match13 *match, ENode *expr, Boolean flag); -// static void CExpr_BuildConversionTypeList(); -// static void CExpr_NextPromotedIntegralType(); -// static void CExpr_NextArithmeticType(); -// static void CExpr_NextPromotedArithmeticType(); -// static void CExpr_MatchBuiltin(); -// static void CExpr_CheckIncDecBuiltin(); -// static void CExpr_CheckUnaryBuiltin(); -// static void CExpr_CheckBinaryBuiltin(); -// static void CExpr_MatchOperands(); +extern Boolean CExpr_CanImplicitlyConvert(ENode *expr, Type *type2, UInt32 qual2); +extern ENode *CExpr_Convert(ENode *expr, Type *type, UInt32 qual, Boolean isExplicit, Boolean flag2); +extern ENode *CExpr_AssignmentPromotion(ENode *expr, Type *type2, UInt32 qual2, Boolean flag); +extern void CExpr_FuncArgMatch(NameSpaceObjectList *list, TemplArg *templargs, ENodeList *argexprs, Match13 *match13, ENode *expr, Boolean flag); extern Boolean CExpr_CondOperatorMatch(ENode *left, ENode *right, Conversion *conv); extern Boolean CExpr_OperatorMatch(short token, ENode *left, ENode *right, Conversion *conv); -// static void CExpr_ClassCopyInit(); #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/CFunc.h b/includes/compiler/CFunc.h index bed511f..a64cc74 100644 --- a/includes/compiler/CFunc.h +++ b/includes/compiler/CFunc.h @@ -49,6 +49,7 @@ typedef enum StatementType { enum { StmtFlag_1 = 1, StmtFlag_2 = 2, + StmtFlag_4 = 4, StmtFlag_8 = 8, StmtFlag_10 = 0x10 }; @@ -80,9 +81,15 @@ typedef struct InitExpr { Object *object; } InitExpr; +typedef enum CtorChainType { + CtorChain_Base = 0, + CtorChain_VBase = 1, + CtorChain_MemberVar = 2 +} CtorChainType; + typedef struct CtorChain { struct CtorChain *next; - UInt8 what; + CtorChainType what; ENode *objexpr; union { ClassList *base; // 0 @@ -91,17 +98,19 @@ typedef struct CtorChain { } u; } CtorChain; -typedef struct CFuncSave { - CScopeSave scope; - // lots of fields -} CFuncSave; +typedef struct CFuncSave CFuncSave; struct DeclThing { Type *thetype; UInt32 qual; - NameSpace *nspace; - CLabel *xC; - CLabel *x10; + SwitchInfo *switchinfo; + CLabel *loopContinue; + CLabel *loopBreak; +}; + +struct DefArgCtorInfo { + Object *default_func; + ENode *default_arg; }; extern FuncArg elipsis; @@ -122,7 +131,7 @@ extern Statement *curstmt; extern DeclBlock *CFunc_NewDeclBlock(void); extern void CFunc_RestoreBlock(DeclBlock *block); extern void CFunc_SetupLocalVarInfo(Object *obj); -extern void CFunc_DefaultArg(Type *type, short qual, FuncArg *args); +extern ENode *CFunc_DefaultArg(Type *type, UInt32 qual, FuncArg *args); extern Boolean CFunc_ParseFakeArgList(Boolean flag); extern FuncArg *parameter_type_list(DeclInfo *declinfo); extern CLabel *findlabel(void); @@ -137,19 +146,19 @@ extern ENode *create_temp_node2(Type *type); extern void CFunc_WarnUnused(void); extern void CFunc_CodeCleanup(Statement *stmt); extern void CFunc_DestructorCleanup(Statement *stmt); -extern Statement *CFunc_GenerateLoop(Statement *stmt, Type *type, ENode *expr1, ENode *expr2, ENode *expr3, ENode *expr4, ENode (*callback)(ENode *, ENode *)); +extern Statement *CFunc_GenerateLoop(Statement *stmt, Type *type, ENode *lowerBound, ENode *upperBound, ENode *increment1, ENode *increment2, ENode *(*callback)(ENode *, ENode *)); extern void CFunc_CompoundStatement(DeclThing *thing); -extern void CFunc_SetupNewFuncArgs(Object *obj, FuncArg *args); +extern void CFunc_SetupNewFuncArgs(Object *func, FuncArg *args); extern NameSpace *CFunc_FuncGenSetup(Statement *stmt, Object *func); -extern void CFunc_GetGlobalCompilerState(CFuncSave *state); +extern CFuncSave *CFunc_GetGlobalCompilerState(void); extern void CFunc_SetGlobalCompilerState(CFuncSave *state); -extern void CFunc_Gen(Statement *stmt, Object *obj, UInt8 unk); +extern void CFunc_Gen(Statement *stmt, Object *func, UInt8 unk); extern void CFunc_CheckClassCtors(TypeClass *tclass); -extern void CFunc_ParseFuncDef(Object *obj, DeclInfo *declinfo, TypeClass *tclass, Boolean is_method, Boolean is_static, NameSpace *nspace); +extern void CFunc_ParseFuncDef(Object *func, DeclInfo *di, TypeClass *tclass, Boolean is_method, Boolean is_static, NameSpace *nspace); extern void InitExpr_Register(ENode *expr, Object *object); -extern void CFunc_GenerateDummyFunction(Object *a); -extern void CFunc_GenerateSingleExprFunc(Object *a, ENode *expr); -extern void CFunc_GenerateDummyCtorFunc(Object *a, Object *b); +extern void CFunc_GenerateDummyFunction(Object *func); +extern void CFunc_GenerateSingleExprFunc(Object *func, ENode *expr); +extern void CFunc_GenerateDummyCtorFunc(Object *func, Object *real_ctor); #ifdef __MWERKS__ #pragma options align=reset diff --git a/includes/compiler/CInit.h b/includes/compiler/CInit.h index e6e3d61..dc5d759 100644 --- a/includes/compiler/CInit.h +++ b/includes/compiler/CInit.h @@ -10,8 +10,7 @@ typedef void (*ExprCB)(Type *type, ENode *expr, Boolean flag); typedef void (*InitExprRegisterCB)(ENode *expr); typedef void (*InsertExprCB)(ENode *expr); -// fix last arg -typedef ENode *(*RegisterObjectCB)(Type *type, Object *obj, SInt32 offset, void *); +typedef ENode *(*RegisterObjectCB)(Type *type, Object *obj, SInt32 offset, Boolean flag); typedef ENode *(*TempNodeCB)(Type *type, Boolean flag); struct OLinkList { diff --git a/includes/compiler/CInline.h b/includes/compiler/CInline.h index 52cdf13..4fae90a 100644 --- a/includes/compiler/CInline.h +++ b/includes/compiler/CInline.h @@ -9,6 +9,22 @@ #pragma options align=mac68k #endif +// Not sure if these two are actually in CInline or not +typedef struct XRefOffset { + UInt32 xrefoffset; + SInt32 offset; +} XRefOffset; + +struct InlineXRef { + InlineXRef *next; + Object *object; + UInt16 xrefmode; + UInt16 numxrefs; + XRefOffset xref[1]; +}; + + + typedef struct CI_Var { HashNameNode *name; Type *type; @@ -33,10 +49,10 @@ typedef struct CI_SwitchCase { typedef struct CI_Switch { ENode *expr; - void *unkSwitch8; + Type *unkSwitch8; short defaultlabelID; short numcases; - CI_SwitchCase cases[0]; + CI_SwitchCase cases[1]; } CI_Switch; typedef struct CI_Statement { diff --git a/includes/compiler/CMangler.h b/includes/compiler/CMangler.h index f08ecd8..2e84032 100644 --- a/includes/compiler/CMangler.h +++ b/includes/compiler/CMangler.h @@ -17,15 +17,15 @@ extern HashNameNode *CMangler_VBaseDtorName(void); extern HashNameNode *CMangler_ArrayDtorName(void); extern HashNameNode *CMangler_SDeleteDtorName(void); extern HashNameNode *CMangler_DeleteDtorName(void); -extern char *CMangler_GetOperator(HashNameNode *opname); +extern char *CMangler_GetOperator(HashNameNode *name); extern HashNameNode *CMangler_OperatorName(short token); -extern HashNameNode *CMangler_VTableName(TypeClass *tclass); +extern HashNameNode *CMangler_VTableName(TypeClass *theclass); extern HashNameNode *CMangler_RTTIObjectName(Type *type, UInt32 qual); -extern HashNameNode *CMangler_ThunkName(Object *obj, int a, int b, int c); +extern HashNameNode *CMangler_ThunkName(Object *vfunc, SInt32 this_delta, SInt32 return_delta, SInt32 ctoroffset); extern HashNameNode *CMangler_TemplateInstanceName(HashNameNode *basename, TemplArg *args); extern void CMangler_MangleType(Type *type, UInt32 qual); extern HashNameNode *CMangler_ConversionFuncName(Type *type, UInt32 qual); -extern HashNameNode *CMangler_GetCovariantFunctionName(Object *obj, Type *type); +extern HashNameNode *CMangler_GetCovariantFunctionName(Object *dobj, TypeClass *theclass); extern HashNameNode *CMangler_GetLinkName(Object *obj); #ifdef __MWERKS__ diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h index 5d9a67a..7312e33 100644 --- a/includes/compiler/CParser.h +++ b/includes/compiler/CParser.h @@ -77,7 +77,7 @@ typedef struct COpts { Boolean altivec_model; UInt8 altivec_vrsave; UInt8 code_alignment; - char x1D; + UInt8 x1D; UInt8 x1E; // some register used in TOC_use_isel UInt8 gen_fsel; Boolean ppc_opt_bclr_bcctr; @@ -99,7 +99,7 @@ typedef struct COpts { Boolean objective_c; Boolean objc_strict; Boolean ARM_conform; - char ARM_scoping; + Boolean ARM_scoping; Boolean require_prototypes; Boolean trigraphs; Boolean only_std_keywords; @@ -130,14 +130,14 @@ typedef struct COpts { Boolean flat_include; char syspath_once; Boolean always_import; - char simple_class_byval; + Boolean simple_class_byval; Boolean wchar_type; Boolean vbase_ctor_offset; - char vbase_abi_v2; + Boolean vbase_abi_v2; Boolean def_inherited; Boolean template_patch; char template_friends; - char faster_pch_gen; + Boolean faster_pch_gen; Boolean array_new_delete; Boolean dollar_identifiers; char def_inline_tfuncs; @@ -146,7 +146,7 @@ typedef struct COpts { Boolean line_prepdump; Boolean fullpath_prepdump; char old_mtemplparser; - char suppress_init_code; + Boolean suppress_init_code; Boolean reverse_bitfields; Boolean c9x; Boolean float_constants; @@ -166,15 +166,15 @@ typedef struct COpts { char microsoft; Boolean warningerrors; Boolean pedantic; - char check_header_flags; + Boolean check_header_flags; Boolean supress_warnings; Boolean warn_illpragma; Boolean warn_emptydecl; Boolean warn_possunwant; - char warn_unusedvar; - char warn_unusedarg; + Boolean warn_unusedvar; + Boolean warn_unusedarg; Boolean warn_extracomma; - char warn_hidevirtual; + Boolean warn_hidevirtual; Boolean warn_largeargs; Boolean warn_implicitconv; Boolean warn_notinlined; @@ -182,7 +182,7 @@ typedef struct COpts { Boolean warn_padding; Boolean warn_no_side_effect; Boolean warn_resultnotused; - char warn_ptr_int_conv; + Boolean warn_ptr_int_conv; char align_mode; Boolean align_array_members; Boolean dont_reuse_strings; @@ -208,16 +208,16 @@ typedef struct COpts { Boolean crippled; Boolean opt_common_subs; Boolean opt_loop_invariants; - char opt_propagation; - char opt_dead_assignments; + Boolean opt_propagation; + Boolean opt_dead_assignments; Boolean opt_strength_reduction; Boolean opt_strength_reduction_strict; - char opt_dead_code; - char opt_lifetimes; + Boolean opt_dead_code; + Boolean opt_lifetimes; char _B1; // unused? - char opt_unroll_loops; + Boolean opt_unroll_loops; char opt_vectorize_loops; - char _B4; // amount of IRO passes? + Boolean _B4; // amount of IRO passes? Boolean opt_pointer_analysis; unsigned char opt_pointer_analysis_mode; char loop_unroll_count; @@ -386,8 +386,8 @@ extern Boolean is_const_object(Object *obj); extern Boolean is_volatile_object(Object *obj); extern Boolean CParserIsConstExpr(ENode *expr); extern Boolean CParserIsVolatileExpr(ENode *expr); -extern Boolean CParser_HasInternalLinkage(Object *obj); -extern Boolean CParser_HasInternalLinkage2(Object *obj); +extern Boolean CParser_HasInternalLinkage(const Object *obj); +extern Boolean CParser_HasInternalLinkage2(const Object *obj); extern Boolean CParser_IsVirtualFunction(Object *obj, TypeClass **tclass, SInt32 *index); extern Boolean is_pascal_object(Object *obj); extern Boolean is_cfm_type(Type *type); diff --git a/includes/compiler/CPrec.h b/includes/compiler/CPrec.h new file mode 100644 index 0000000..a2ac87c --- /dev/null +++ b/includes/compiler/CPrec.h @@ -0,0 +1,12 @@ +#ifndef COMPILER_CPREC_H +#define COMPILER_CPREC_H + +#include "compiler/common.h" + +extern void SetupPrecompiler(void); +extern void CleanupPrecompiler(void); +extern void PreComp_StaticData(Object *obj, const void *data, OLinkList *links, SInt32 size); +extern void PrecompilerWrite(void); +extern void PrecompilerRead(short refnum, void *buffer); + +#endif diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h index e9b7dcd..aeb341b 100644 --- a/includes/compiler/CPrep.h +++ b/includes/compiler/CPrep.h @@ -11,11 +11,11 @@ struct Macro { Macro *next; HashNameNode *name; - void *c; + char *c; unsigned short xC; Boolean is_special; Boolean xF; - void *e; + HashNameNode *names[1]; }; typedef struct TokenStack { char *pos; @@ -71,6 +71,7 @@ extern CPrepFileInfo *prep_file; extern short filesp; extern SInt32 linenumber; extern struct GList pplist; +extern TStreamElement *ts_last; extern TStreamElement *ts_current; extern SInt32 ts_preread_elements; diff --git a/includes/compiler/CPrepTokenizer.h b/includes/compiler/CPrepTokenizer.h index f65cff6..d6ea7c3 100644 --- a/includes/compiler/CPrepTokenizer.h +++ b/includes/compiler/CPrepTokenizer.h @@ -10,13 +10,13 @@ extern short prepskipnextchar(void); extern short prepnextchar(void); -extern short prepnextstringchar(char *str, Boolean flag); +extern short prepnextstringchar(StringPtr str, Boolean flag); extern void CPrep_MatchChar(char ch, Boolean flag); extern char *CPrep_MatchChar2(char *start, char ch, Boolean flag); extern short prepcurchar(void); -extern char *ReadIdentifier(char *p); -extern char *CPrep_SkipNewComment(char *str); -extern Boolean skipendoflinematch(char *str, short token); +extern char *ReadIdentifier(const char *p); +extern StringPtr CPrep_SkipNewComment(StringPtr str); +extern Boolean skipendoflinematch(StringPtr str, short token); extern void skipendofline(void); extern void CPrep_SkipAsmComment(void); extern short lookahead(void); diff --git a/includes/compiler/CScope.h b/includes/compiler/CScope.h index a1da819..f9ba72c 100644 --- a/includes/compiler/CScope.h +++ b/includes/compiler/CScope.h @@ -57,7 +57,7 @@ extern void CScope_SetNameSpaceScope(NameSpace *nspace, CScopeSave *save); extern void CScope_SetClassScope(TypeClass *cls, CScopeSave *save); extern void CScope_SetClassDefScope(TypeClass *cls, CScopeSave *save); extern void CScope_SetFunctionScope(Object *function, CScopeSave *save); -extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean unknownFlag, CScopeSave *save); +extern void CScope_SetMethodScope(Object *function, TypeClass *cls, Boolean is_static, CScopeSave *save); extern void CScope_RestoreScope(CScopeSave *saved); extern Boolean CScope_IsEmptySymTable(void); extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace); diff --git a/includes/compiler/CodeGen.h b/includes/compiler/CodeGen.h index 1f012ec..46fe8fc 100644 --- a/includes/compiler/CodeGen.h +++ b/includes/compiler/CodeGen.h @@ -65,7 +65,7 @@ extern SInt32 CodeGen_objc_method_arg_offset(ObjCMethod *meth, ObjCMethodArg *ar extern SInt32 CodeGen_objc_method_args_size(ObjCMethod *meth); extern ENode *CodeGen_HandleIntrinsicCall(Object *func, ENodeList *arg_exprs); extern ENode *CodeGen_HandleTypeCast(ENode *expr, Type *type, UInt32 qual); -extern short CodeGen_AssignCheck(ENode *expr, Type *type, Boolean flag1, Boolean flag2); +extern short CodeGen_AssignCheck(const ENode *expr, const Type *type, Boolean flag1, Boolean flag2); extern Boolean CodeGen_CollapseVectorExpression(ENode *expr, MWVector128 *vec, Type *type); extern void CodeGen_InsertSpecialMacros(void); extern char *CodeGen_ExpandSpecialMacro(Macro *macro); diff --git a/includes/compiler/CompilerTools.h b/includes/compiler/CompilerTools.h index d44d766..82ef228 100644 --- a/includes/compiler/CompilerTools.h +++ b/includes/compiler/CompilerTools.h @@ -128,7 +128,7 @@ extern UInt32 CTool_EndianReadWord32(void *ptr); #define CTool_EndianConvertWord32(value) value #define CTool_EndianConvertWord16(value) value #define CTool_EndianConvertMem(data, len) ((void)0) -#define CTool_EndianReadWord32(ptr) (*((UInt32 *) (ptr))) +#define CTool_EndianReadWord32(ptr) (*((SInt32 *) (ptr))) #endif extern void CTool_EndianConvertWord64(CInt64 ci, char *result); extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x); diff --git a/includes/compiler/Exceptions.h b/includes/compiler/Exceptions.h index cc485b0..01efcde 100644 --- a/includes/compiler/Exceptions.h +++ b/includes/compiler/Exceptions.h @@ -143,10 +143,10 @@ typedef struct PCAction { extern EANode *DAG[EAT_NACTIONS]; +extern void initializeexceptiontables(void); extern int countexceptionactionregisters(ExceptionAction *actions); extern void noteexceptionactionregisters(ExceptionAction *actions, PCodeArg *ops); extern void recordexceptionactions(PCode *instr, ExceptionAction *actions); -extern void deleteexceptionaction(PCAction *pca); extern void dumpexceptiontables(Object *function, SInt32 codesize); #endif diff --git a/includes/compiler/GCCInlineAsm.h b/includes/compiler/GCCInlineAsm.h index 0b61384..18e24d0 100644 --- a/includes/compiler/GCCInlineAsm.h +++ b/includes/compiler/GCCInlineAsm.h @@ -3,7 +3,7 @@ #include "compiler/common.h" -extern void InlineAsm_SkipComment(); +extern void InlineAsm_SkipComment(void); extern void InlineAsm_gcc_parse(void); extern Statement *first_ST_ASM; diff --git a/includes/compiler/InlineAsm.h b/includes/compiler/InlineAsm.h index ba92400..ca0032e 100644 --- a/includes/compiler/InlineAsm.h +++ b/includes/compiler/InlineAsm.h @@ -160,6 +160,11 @@ typedef struct IAEffect { SInt32 size; } IAEffect; +enum { + IAMaxOperands = 16, + IAMaxLabels = 16 +}; + typedef struct IAEffects { Boolean x0; Boolean x1; @@ -169,8 +174,8 @@ typedef struct IAEffects { Boolean x5; SInt32 numoperands; SInt32 numlabels; - IAEffect operands[16]; - CLabel *labels[16]; + IAEffect operands[IAMaxOperands]; + CLabel *labels[IAMaxLabels]; } IAEffects; #ifdef __MWERKS__ diff --git a/includes/compiler/InlineAsmPPC.h b/includes/compiler/InlineAsmPPC.h index a3d8655..d20bb42 100644 --- a/includes/compiler/InlineAsmPPC.h +++ b/includes/compiler/InlineAsmPPC.h @@ -4,6 +4,16 @@ #include "compiler/common.h" #include "compiler/InlineAsm.h" +typedef enum AssemblerType { + AssemblerType_0, + AssemblerType_1 +} AssemblerType; + +enum { + NO_REG = 0, + INVALID_PIC_REG = -2 +}; + extern char asm_alloc_flags[10]; extern Section sm_section; extern UInt32 cpu; @@ -11,7 +21,7 @@ extern SInt32 fralloc_parameter_area_size; extern Boolean user_responsible_for_frame; extern Boolean supports_hardware_fpu; extern UInt32 assembledinstructions; -extern UInt8 assembler_type; +extern AssemblerType assembler_type; extern char volatileasm; extern Boolean InlineAsm_gccmode; extern Boolean InlineAsm_labelref; @@ -68,8 +78,8 @@ enum { }; extern void InlineAsm_InitializePPC(void); -extern void InlineAsm_Initialize(UInt8 assemblertype); -extern SInt32 InlineAsm_IsDirective(UInt8 assemblertype); +extern void InlineAsm_Initialize(AssemblerType assemblertype); +extern SInt32 InlineAsm_IsDirective(AssemblerType assemblertype); extern void InlineAsm_ProcessDirective(SInt32 directive); extern void InlineAsm_ScanAssemblyDirective(void); extern void InlineAsm_ScanAssemblyInstruction(void); diff --git a/includes/compiler/IrOptimizer.h b/includes/compiler/IrOptimizer.h index 2061a5d..287e279 100644 --- a/includes/compiler/IrOptimizer.h +++ b/includes/compiler/IrOptimizer.h @@ -22,7 +22,7 @@ extern Boolean IRO_CPFirstTime; extern Boolean VectorPhaseCalledFromUnroll; extern Boolean IRO_Log; -extern Statement *IRO_Optimizer(Object *obj, Statement *stmt); +extern Statement *IRO_Optimizer(Object *func, Statement *statements); extern void IRO_Setup(void); extern void IRO_Cleanup(void); extern void CodeGen_UpdateOptimizerOptions(void); diff --git a/includes/compiler/IroEval.h b/includes/compiler/IroEval.h index 9a4b2bf..a011a47 100644 --- a/includes/compiler/IroEval.h +++ b/includes/compiler/IroEval.h @@ -3,8 +3,12 @@ #include "compiler/IrOptimizer.h" -// TODO -extern void IRO_TruncateBitfieldValueToType(CInt64 *val, Type *type, Type *type2); +extern void IRO_InitializeIsAssociativeENodeTypeArray(void); extern void IRO_TruncateValueToType(CInt64 *val, Type *type); +extern void IRO_TruncateBitfieldValueToType(CInt64 *val, Type *type, Type *type2); +extern void IRO_ConstantFolding(void); +extern Boolean IRO_EvaluateConditionals(void); +extern int IRO_SimplifyConditionals(void); +extern Boolean IRO_EvaluateDefinitePointers(Object *func); #endif diff --git a/includes/compiler/IroLinearForm.h b/includes/compiler/IroLinearForm.h index 6ba0021..1e7df4f 100644 --- a/includes/compiler/IroLinearForm.h +++ b/includes/compiler/IroLinearForm.h @@ -157,7 +157,9 @@ extern void IRO_RestoreLinearIR(IROLinearIRSave *save); #define IS_LINEAR_ENODE(_linear, _nodetype) ( ((_linear)->type == IROLinearOperand) && ((_linear)->u.node->type) == (_nodetype) ) #define IS_LINEAR_MONADIC(_linear, _nodetype) ( ((_linear)->type == IROLinearOp1Arg) && ((_linear)->nodetype) == (_nodetype) ) +#define IS_LINEAR_MONADIC_2(_linear, _nodetype1, _nodetype2) ( ((_linear)->type == IROLinearOp1Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2)) ) #define IS_LINEAR_DIADIC(_linear, _nodetype) ( ((_linear)->type == IROLinearOp2Arg) && ((_linear)->nodetype) == (_nodetype) ) #define IS_LINEAR_DIADIC_2(_linear, _nodetype1, _nodetype2) ( ((_linear)->type == IROLinearOp2Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2)) ) +#define IS_LINEAR_DIADIC_3(_linear, _nodetype1, _nodetype2, _nodetype3) ( ((_linear)->type == IROLinearOp2Arg) && (((_linear)->nodetype) == (_nodetype1) || ((_linear)->nodetype) == (_nodetype2) || ((_linear)->nodetype) == (_nodetype3)) ) #endif diff --git a/includes/compiler/IroLoop.h b/includes/compiler/IroLoop.h index 8357830..0c60589 100644 --- a/includes/compiler/IroLoop.h +++ b/includes/compiler/IroLoop.h @@ -5,32 +5,32 @@ #include "compiler/BitVector.h" typedef enum IROLoopIndFlags { - LoopInd_1 = 1, - LoopInd_2 = 2, + LoopInd_HasMod = 1, + LoopInd_HasDiv = 2, LoopInd_4 = 4, LoopInd_8 = 8 } IROLoopIndFlags; typedef enum IROLoopFlags { - LoopFlags_1 = 1, + LoopFlags_1 = 1, // LP_INDUCTION_AT_LEFT LP_LOOP_HAS_CALLS = 2, LP_LOOP_HAS_CNTRLFLOW = 4, - LoopFlags_8 = 8, + LoopFlags_8 = 8, // LP_HAS_NONASSIGN LP_INDUCTION_NOT_FOUND = 0x10, LP_IFEXPR_NON_CANONICAL = 0x20, LP_HAS_MULTIPLE_INDUCTIONS = 0x40, LP_LOOP_HDR_HAS_SIDEEFFECTS = 0x80, - LoopFlags_100 = 0x100, - LoopFlags_200 = 0x200, + LP_LOOP_STEP_ISADD = 0x100, + LoopFlags_200 = 0x200, // LP_HEADER_FOLLOWS_UPDATE? LP_LOOP_STEP_ISPOS = 0x400, - LoopFlags_800 = 0x800, - LoopFlags_1000 = 0x1000, - LoopFlags_2000 = 0x2000, + LoopFlags_800 = 0x800, // LP_IND_USED_IN_LOOP + LoopFlags_1000 = 0x1000, // LP_HAS_MULTIPLE_EXITS + LoopFlags_2000 = 0x2000, // inverse of LP_LOOP_STEP_ISADD? LP_LOOP_STEP_ISNEG = 0x4000, LP_LOOP_HAS_ASM = 0x8000, - LoopFlags_10000 = 0x10000, - LoopFlags_20000 = 0x20000, - LoopFlags_40000 = 0x40000 + LoopFlags_10000 = 0x10000, // LP_WHILE_LOOP + LoopFlags_20000 = 0x20000, // maybe LP_RECURSIVE_LOOP? + LoopFlags_40000 = 0x40000 // LP_IS_REDUCTION_CAND } IROLoopFlags; #ifdef __MWERKS__ @@ -50,10 +50,10 @@ struct IROLoop { SInt32 flags; IRONode *fnode; int x8; - int xC; - int x10; + IRONode *xC; + IRONode *x10; IROLinear *nd14; // assignment expression that sets the initial value of induction - IROLinear *nd18; + IROLinear *nd18; // ifexpr? IROLoopInd *induction; int index20; int index24; diff --git a/includes/compiler/IroPointerAnalysis.h b/includes/compiler/IroPointerAnalysis.h index 3266047..a6ed2c2 100644 --- a/includes/compiler/IroPointerAnalysis.h +++ b/includes/compiler/IroPointerAnalysis.h @@ -13,7 +13,7 @@ extern Boolean PointerAnalysis_IsENodePointerExprDefinite(Object *proc, ENode *n extern Boolean PointerAnalysis_IsVariableValueDefinite(Object *proc, VarRecord *var, PointsToFunction *pointsTo); extern void PointerAnalysis_LookupLinearNodePointerExpr(Object *proc, IROLinear *indirect, IROListNode **list); extern void PointerAnalysis_LookupENodePointerExpr(Object *proc, ENode *indirect, ENodeList **list); -extern void PointerAnalysis_LookupVariableIntoLinearNodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, IROList **list); +extern void PointerAnalysis_LookupVariableIntoLinearNodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, IROListNode **list); extern void PointerAnalysis_LookupVariableIntoENodeExprs(Object *proc, VarRecord *var, PointsToFunction *pointsTo, ENodeList **list); extern void PointerAnalysis_GetFunctionKills(Object *proc, IROLinear *funccall, ObjectList **list); extern void PointerAnalysis_GetFunctionDependencies(Object *proc, IROLinear *funccall, ObjectList **list); diff --git a/includes/compiler/IroTransform.h b/includes/compiler/IroTransform.h index 0ec4f4c..90bcf30 100644 --- a/includes/compiler/IroTransform.h +++ b/includes/compiler/IroTransform.h @@ -3,7 +3,11 @@ #include "compiler/IrOptimizer.h" -// TODO -extern Boolean IRO_TransformSelfAssignmentToAssignment(IROLinear *linear); +extern void IRO_InitializeAssignmentOpArray(void); +extern void IRO_InitializeComplementaryOpArray(void); +extern void IRO_InitializeComplementaryOpLogicalArray(void); +extern void IRO_DoTransformations(void); +extern Boolean IRO_TransformSelfAssignmentToAssignment(IROLinear *nd); +extern void IRO_TransformTree(Statement *statements); #endif diff --git a/includes/compiler/IroUnrollLoop.h b/includes/compiler/IroUnrollLoop.h index 9e08d03..8a51a9b 100644 --- a/includes/compiler/IroUnrollLoop.h +++ b/includes/compiler/IroUnrollLoop.h @@ -2,21 +2,22 @@ #define COMPILER_IROUNROLLLOOP_H #include "compiler/IrOptimizer.h" +#include "compiler/IroLinearForm.h" extern void IRO_LoopUnroller(void); -extern void IRO_IterateForLoopBody(); -extern void IRO_LinearizeForLoopPostLoop(); -extern void BuildEarlyLoopExitTest(); -extern void BuildLoopExitTest(); -extern void IsIterationCountConstant(); -extern void NoOpBlock(); -extern void IRO_TestConstantIterationCount(); -extern void BuildOrigIterationCount(); -extern void BuildNewFinalvalue(); -extern void BuildUnrolledBodyEntryTest(); -extern void ChangeInductionReference(); -extern void UpdateInductionIncrement(); -extern void GenInitialAssignment(); -extern void GenNewInduction(); +extern void IRO_IterateForLoopBody(IRONode *start, IRONode *end, IROLoop *loop, IROLinear *destnode, SInt32 addConst, CInt64 *val, Boolean funkyFlag); +extern void IRO_LinearizeForLoopPostLoop(IRONode *fnode1, IRONode *fnode2, IROLoop *loop, IRONode *fnode3, UInt32 unrollFactor); +extern IROLinear *BuildEarlyLoopExitTest(IROLinearType type, IROList *list); +extern IROLinear *BuildLoopExitTest(IROLinearType type, IROList *list); +extern int IsIterationCountConstant(IROLoop *loop, CInt64 *pval); +extern void NoOpBlock(IRONode *fnode); +extern void IRO_TestConstantIterationCount(IROLoop *loop, CInt64 *iterCount, SInt32 vectorStride, UInt32 *unrollFactor, SInt32 *leftOver, UInt32 *needOrigLoop, UInt32 *needUnrollBodyTest, UInt32 *resetUnrolledFinalValue); +extern IROLinear *BuildOrigIterationCount(IROList *list, IROLoop *loop); +extern IROLinear *BuildNewFinalvalue(IROLinear *iterCount, UInt32 unrollFactor, IROList *list, IROLoop *loop); +extern void BuildUnrolledBodyEntryTest(IROList *list, IROLinear *iterCount, UInt32 unrollFactor, CLabel *label); +extern void ChangeInductionReference(IROLinear *first, IROLinear *last, CInt64 val, IROLoop *loop); +extern IROLinear *UpdateInductionIncrement(IROLoop *loop, SInt32 value, IROLinear *before); +extern void GenInitialAssignment(IROLoop *loop, Object *var, IROList *list); +extern void GenNewInduction(void); #endif diff --git a/includes/compiler/IroUtil.h b/includes/compiler/IroUtil.h index 68d34f5..502d0cd 100644 --- a/includes/compiler/IroUtil.h +++ b/includes/compiler/IroUtil.h @@ -2,6 +2,7 @@ #define COMPILER_IROUTIL_H #include "compiler/IrOptimizer.h" +#include "compiler/CInt64.h" #include "compiler/CParser.h" #ifdef __MWERKS__ @@ -87,7 +88,7 @@ extern IROLinear *IRO_LocateFather_Cut_And_Paste(IROLinear *a, IROLinear *b); extern IROLinear *IRO_LocateFather_Cut_And_Paste_Without_Nopping(IROLinear *a, IROLinear *b); extern void IRO_ReplaceReference(IROLinear *a, Object *obj, IROLinear *b); extern void IRO_ReplaceReferenceWithNode(IROLinear *a, IROLinear *b); -extern void IRO_GetTemp(IROExpr *expr); +extern VarRecord *IRO_GetTemp(IROExpr *expr); extern IROLinear *IRO_AssignToTemp(IROExpr *expr); extern IROLinear *IRO_FindStart(IROLinear *linear); extern void IRO_DeleteCommaNode(IROLinear *linear, IROExpr *expr); @@ -99,7 +100,7 @@ typedef void (*WalkObjFunc)(Object *obj); extern void IRO_WalkExcActions(ExceptionAction *action, WalkObjFunc func); extern Boolean IRO_FunctionCallMightThrowException(IROLinear *linear); extern IROLinear *IRO_NewIntConst(CInt64 val, Type *type); -extern IROLinear *IRO_NewFloatConst(Float val, Type *type); +extern IROLinear *IRO_NewFloatConst(const Float val, Type *type); extern Boolean IRO_IsAddressMultiply(IROLinear *linear); extern void IRO_SetupForUserBreakChecking(void); extern void IRO_CheckForUserBreak(void); @@ -109,4 +110,18 @@ inline Boolean IRO_IsUnsignedType(Type *type) { return is_unsigned(type); } +// 4B4D40 +inline CInt64 IRO_MakeULong(UInt32 i) { + CInt64 val; + CInt64_SetULong(&val, i); + return val; +} + +// 4BAAA0 +inline CInt64 IRO_MakeLong(SInt32 i) { + CInt64 val; + CInt64_SetLong(&val, i); + return val; +} + #endif diff --git a/includes/compiler/LoopDetection.h b/includes/compiler/LoopDetection.h index 28dbb7a..5d9a729 100644 --- a/includes/compiler/LoopDetection.h +++ b/includes/compiler/LoopDetection.h @@ -86,7 +86,7 @@ typedef struct InductionVar { extern Loop *loopsinflowgraph; extern int loopdetection_nblocks; extern BitVector *LoopTemp; -extern void *LoopList_First; +extern struct LoopList *LoopList_First; extern void addblocktoloop(Loop *loop, PCodeBlock *block); extern void insertpreheaderblock(Loop *loop); diff --git a/includes/compiler/PCode.h b/includes/compiler/PCode.h index b38d9e1..9b6103b 100644 --- a/includes/compiler/PCode.h +++ b/includes/compiler/PCode.h @@ -198,17 +198,18 @@ enum { }; enum { - fPCBlockFlag1 = 1, // prologue - fPCBlockFlag2 = 2, // epilogue - fPCBlockFlag4 = 4, - fPCBlockFlag8 = 8, // scheduled? - fPCBlockFlag10 = 0x10, - fPCBlockFlag20 = 0x20, + fPCBlockFlag1 = 1, // fIsProlog + fPCBlockFlag2 = 2, // fIsEpilogue + fPCBlockFlag4 = 4, // fVisited + fPCBlockFlag8 = 8, // fScheduled + fPCBlockFlag10 = 0x10, // maybe fIsSwitch based off v3? + fPCBlockFlag20 = 0x20, // fDeleted fPCBlockFlag2000 = 0x2000, fPCBlockFlag4000 = 0x4000, fPCBlockFlag6000 = 0x6000, fPCBlockFlag8000 = 0x8000 }; +// v3 has fCCisLiveOnExit, fUnrolled, fAlignBlock extern PCodeBlock *pcbasicblocks; extern PCodeBlock *pclastblock; diff --git a/includes/compiler/StackFrame.h b/includes/compiler/StackFrame.h index 16c5316..af81845 100644 --- a/includes/compiler/StackFrame.h +++ b/includes/compiler/StackFrame.h @@ -7,12 +7,12 @@ #pragma options align=mac68k #endif -enum ObjClass { +typedef enum ObjClass { ObjClass0, ObjClass1, ObjClass2, ObjClassMax -}; +} ObjClass; extern Boolean requires_frame; extern Boolean makes_call; diff --git a/includes/compiler/Switch.h b/includes/compiler/Switch.h index 15e7d51..aeac03e 100644 --- a/includes/compiler/Switch.h +++ b/includes/compiler/Switch.h @@ -18,7 +18,7 @@ typedef struct CaseRange { struct SwitchInfo { SwitchCase *cases; CLabel *defaultlabel; - void *x8; + Type *x8; }; extern ObjectList *switchtables; diff --git a/includes/compiler/TOC.h b/includes/compiler/TOC.h index c5eabb0..2d6d3be 100644 --- a/includes/compiler/TOC.h +++ b/includes/compiler/TOC.h @@ -13,13 +13,20 @@ typedef struct CodeLabelList { CLabel *label; } CodeLabelList; +typedef struct PoolEntry { + struct PoolEntry *next; + Object *object; + SInt32 offset; + void *buffer; +} PoolEntry; + extern ObjectList *toclist; extern ObjectList *exceptionlist; extern void *descriptorlist; -extern void *floatconstpool; -extern void *doubleconstpool; +extern PoolEntry *floatconstpool; +extern PoolEntry *doubleconstpool; extern ObjectList *floatconstlist; -extern void *vectorconstpool; +extern PoolEntry *vectorconstpool; extern ObjectList *vectorconstlist; extern Object toc0; extern Boolean no_descriptors; @@ -34,8 +41,8 @@ extern void referenceIndirectPointer(Object *obj); extern Object *createIndirect(Object *obj, Boolean flag1, Boolean flag2); extern Object *createfloatconstant(Type *type, Float *data); extern Object *createvectorconstant(Type *type, MWVector128 *data); -extern void DeclarePooledConstants(); -extern Object *CreateFloatConst(Type *type, Float *data, SInt32 *unkptr); +extern void DeclarePooledConstants(void); +extern Object *CreateFloatConst(Type *type, Float *data, SInt32 *pOffset); extern void dumpcodelabels(Object *func); typedef struct COVCResult { // this struct might be used in other places too??? diff --git a/includes/compiler/common.h b/includes/compiler/common.h index b5cb718..5eefd2c 100644 --- a/includes/compiler/common.h +++ b/includes/compiler/common.h @@ -235,6 +235,7 @@ typedef enum TemplDepSubType { enum { Q_CONST = 1, Q_VOLATILE = 2, + Q_CV = Q_CONST | Q_VOLATILE, Q_ASM = 4, Q_PASCAL = 8, Q_INLINE = 0x10, diff --git a/includes/compiler/enode.h b/includes/compiler/enode.h index 3697135..f7174f0 100644 --- a/includes/compiler/enode.h +++ b/includes/compiler/enode.h @@ -230,6 +230,7 @@ enum { #define ENODE_IS2(_enode, _etype1, _etype2) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) ) #define ENODE_IS3(_enode, _etype1, _etype2, _etype3) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) ) #define ENODE_IS4(_enode, _etype1, _etype2, _etype3, _etype4) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) ) +#define ENODE_IS5(_enode, _etype1, _etype2, _etype3, _etype4, _etype5) ( ENODE_IS((_enode), (_etype1)) || ENODE_IS((_enode), (_etype2)) || ENODE_IS((_enode), (_etype3)) || ENODE_IS((_enode), (_etype4)) || ENODE_IS((_enode), (_etype5)) ) #define ENODE_IS_RANGE(_enode, _lo, _hi) ( ((_enode)->type >= (_lo)) && ((_enode)->type <= (_hi)) ) #define ENODE_QUALS(_enode) ( (UInt32) ( (_enode)->flags & ENODE_FLAG_QUALS ) ) #define ENODE_IS_INDIRECT_TO(_enode, _etype) ( ENODE_IS((_enode), EINDIRECT) && ENODE_IS((_enode)->data.monadic, (_etype)) ) @@ -288,6 +289,7 @@ enum { case EBCLR: \ case EBSET +// 9 to 0x2F #define ENODE_CASE_DIADIC_ALL \ case EMUL: \ case EMULV: \ diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h index a9816cf..52bbf36 100644 --- a/includes/compiler/objects.h +++ b/includes/compiler/objects.h @@ -156,12 +156,12 @@ struct Object { TemplFuncInstance *inst; PTFList *ptfList; ObjectList *argList; - } func; + } func; // Used with DFUNC and DVFUNC struct { char *data; SInt32 size; InlineXRef *xrefs; - } ifunc; + } ifunc; // Used with DINLINEFUNC struct { VarInfo *info; SInt32 uid; @@ -198,14 +198,6 @@ enum { OBJECT_FLAGS_60 = 0x60 // lib export }; -enum { - OBJECT_SCLASS_101 = 0x101, - OBJECT_SCLASS_102 = 0x102, - OBJECT_SCLASS_103 = 0x103, - OBJECT_SCLASS_104 = 0x104, - OBJECT_SCLASS_12B = 0x12B -}; - #define OBJ_BASE(obj) ((ObjBase *) (obj)) #define OBJ_ENUM_CONST(obj) ((ObjEnumConst *) (obj)) #define OBJ_TYPE(obj) ((ObjType *) (obj)) @@ -238,6 +230,8 @@ enum { VarInfoFlag80 = 0x80 }; +#define OBJECT_OR_ALIAS(_object) ( ((_object)->datatype == DALIAS) ? ((_object)->u.alias.object) : (_object) ) + // placing these here until further notice // unknown name, mwcppc.exe 7.0: 484870 diff --git a/includes/compiler/types.h b/includes/compiler/types.h index 3bbba4f..4d6e16e 100644 --- a/includes/compiler/types.h +++ b/includes/compiler/types.h @@ -142,8 +142,8 @@ struct ClassList { // checked via CPrec struct VClassList { // checked via CPrec VClassList *next; TypeClass *base; - SInt32 offset; - SInt32 voffset; + SInt32 offset; // offset within the class instance + SInt32 voffset; // offset within the vtable Boolean has_override; char alignsave; }; @@ -205,7 +205,7 @@ enum { CLASS_FLAGS_100 = 0x100, // is TemplClass CLASS_FLAGS_800 = 0x800, // is TemplClassInst CLASS_FLAGS_900 = 0x900, - CLASS_FLAGS_1000 = 0x1000, + CLASS_FLAGS_1000 = 0x1000, // is empty class CLASS_FLAGS_2000 = 0x2000, CLASS_FLAGS_4000 = 0x4000, CLASS_FLAGS_8000 = 0x8000 @@ -215,7 +215,8 @@ enum { enum { CLASS_EFLAGS_INTERNAL = 1, CLASS_EFLAGS_IMPORT = 2, - CLASS_EFLAGS_EXPORT = 4 + CLASS_EFLAGS_EXPORT = 4, + CLASS_EFLAGS_F0 = 0xF0 }; enum { @@ -269,8 +270,10 @@ enum { FUNC_FLAGS_4000 = 0x4000, // objc method? FUNC_FLAGS_CONST = 0x8000, FUNC_FLAGS_VOLATILE = 0x10000, + FUNC_FLAGS_CV = FUNC_FLAGS_CONST | FUNC_FLAGS_VOLATILE, FUNC_FLAGS_100000 = 0x100000, // is template? FUNC_FLAGS_200000 = 0x200000, + FUNC_FLAGS_400000 = 0x400000, // covariant? FUNC_FLAGS_800000 = 0x800000, FUNC_FLAGS_900000 = 0x900000, FUNC_FLAGS_4000000 = 0x4000000, @@ -412,10 +415,12 @@ struct TypeList { #define IS_TYPE_INT_OR_FLOAT(ty) ( IS_TYPE_INT(ty) || IS_TYPE_FLOAT(ty) ) #define IS_TYPE_STRUCT(ty) ( (ty)->type == TYPESTRUCT ) #define IS_TYPE_CLASS(ty) ( (ty)->type == TYPECLASS ) +#define IS_TYPE_SOM_CLASS(ty) ( (ty)->type == TYPECLASS && TYPE_CLASS((ty))->sominfo ) #define IS_TYPE_OBJC_CLASS(ty) ( (ty)->type == TYPECLASS && TYPE_CLASS((ty))->objcinfo ) #define IS_TYPE_FUNC(ty) ( (ty)->type == TYPEFUNC ) #define IS_TYPEFUNC_METHOD(ty) ( (ty)->flags & FUNC_FLAGS_METHOD ) #define IS_TYPE_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) ) +#define IS_TYPE_NONMETHOD(ty) ( IS_TYPE_FUNC(ty) && !IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) ) #define IS_TYPE_NONSTATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && !TYPE_METHOD(ty)->x26 ) #define IS_TYPE_STATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && TYPE_METHOD(ty)->x26 ) #define IS_TYPEFUNC_NONSTATIC_METHOD(ty) ( IS_TYPEFUNC_METHOD(ty) && !TYPE_METHOD(ty)->x26 ) @@ -428,7 +433,7 @@ struct TypeList { #define IS_TYPE_ARRAY(ty) ( (ty)->type == TYPEARRAY ) #define IS_TYPE_BITFIELD(ty) ( (ty)->type == TYPEBITFIELD ) #define IS_TYPE_TEMPLDEPEXPR(ty) ( (ty)->type == TYPETEMPLDEPEXPR ) -#define IS_TYPESTRUCT_VECTOR(ty) ( TYPE_STRUCT(ty)->stype >= STRUCT_TYPE_4 && TYPE_STRUCT(ty)->stype <= STRUCT_TYPE_E ) +#define IS_TYPESTRUCT_VECTOR(ty) ( (ty)->stype >= STRUCT_TYPE_4 && (ty)->stype <= STRUCT_TYPE_E ) #define IS_TYPE_VECTOR(ty) ( (ty)->type == TYPESTRUCT && IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(ty)) ) #define IS_TYPE_NONVECTOR_STRUCT(ty) ( (ty)->type == TYPESTRUCT && !IS_TYPESTRUCT_VECTOR(TYPE_STRUCT(ty)) ) #define IS_TYPE_MEMBERPOINTER(ty) ( (ty)->type == TYPEMEMBERPOINTER ) |