diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/cmdline.h | 5 | ||||
-rw-r--r-- | includes/common.h | 7 | ||||
-rw-r--r-- | includes/compiler.h | 880 | ||||
-rw-r--r-- | includes/compiler/CError.h | 364 | ||||
-rw-r--r-- | includes/compiler/CInt64.h | 88 | ||||
-rw-r--r-- | includes/compiler/CompilerTools.h | 129 | ||||
-rw-r--r-- | includes/compiler/common.h | 283 | ||||
-rw-r--r-- | includes/compiler/enode.h | 264 | ||||
-rw-r--r-- | includes/compiler/objc.h | 80 | ||||
-rw-r--r-- | includes/compiler/objects.h | 200 | ||||
-rw-r--r-- | includes/compiler/scopes.h | 53 | ||||
-rw-r--r-- | includes/compiler/som.h | 35 | ||||
-rw-r--r-- | includes/compiler/templates.h | 237 | ||||
-rw-r--r-- | includes/compiler/tokens.h | 182 | ||||
-rw-r--r-- | includes/compiler/types.h | 324 | ||||
-rw-r--r-- | includes/cw_common.h | 5 | ||||
-rw-r--r-- | includes/oslib.h | 6 | ||||
-rw-r--r-- | includes/pref_structs.h | 6 |
18 files changed, 3140 insertions, 8 deletions
diff --git a/includes/cmdline.h b/includes/cmdline.h index 2861794..2c40cb1 100644 --- a/includes/cmdline.h +++ b/includes/cmdline.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef CMDLINE_H +#define CMDLINE_H #include "cw_common.h" #include "pref_structs.h" @@ -747,3 +748,5 @@ extern OSErr GetMacFileType(const FSSpec *spec, OSType *mactype); #ifdef __cplusplus } #endif + +#endif diff --git a/includes/common.h b/includes/common.h index b1b5b61..a18f8f6 100644 --- a/includes/common.h +++ b/includes/common.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef ROOT_COMMON_H +#define ROOT_COMMON_H /* * Common imports and Mac OS types @@ -113,7 +114,7 @@ typedef const unsigned char *ConstStr255Param; // XXX: MacTypes.h defines StrLength() which is an inline for C++ and a macro for C // This might be useful? -#ifdef __MWERKS__ +#ifdef __MWERKS__ #pragma options align=mac68k #endif typedef struct Point { @@ -302,3 +303,5 @@ typedef CInfoPBRec *CInfoPBPtr; #ifdef __MWERKS__ #pragma options align=reset #endif + +#endif diff --git a/includes/compiler.h b/includes/compiler.h new file mode 100644 index 0000000..319f95e --- /dev/null +++ b/includes/compiler.h @@ -0,0 +1,880 @@ +#include "compiler/common.h" + +// THESE TYPES ARE NOT YET SORTED +#include "compiler/tokens.h" +#include "compiler/CompilerTools.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +enum { + AlignMode0_Mac68k, + AlignMode1_Mac68k4byte, + AlignMode2_PPC, + AlignMode3_1Byte, + AlignMode4_2Byte, + AlignMode5_4Byte, + AlignMode6_8Byte, + AlignMode7_16Byte, + AlignMode8 +}; + +// not sure how many of these are char and how many are unsigned char or Boolean +typedef struct COpts { + char little_endian; + char codegen_dynamic; + char codegen_pic; + char no_common; + char no_implicit_templates; + char absolutepath; // determines the path written to debug info + char x06; // linker/objgen related + short cpu; + char schedule_cpu; + unsigned char schedule_mode; // may be an enum?? + SInt32 debuglisting; + char profile; + char traceback; + char disable_registers; + char fp_contract; + char no_register_save_helpers; + char ppc_unroll_speculative; + short ppc_unroll_instructions_limit; + short ppc_unroll_factor_limit; + char altivec_model; + UInt8 x1B; // altivec/vrsave related + UInt8 code_alignment; + char x1D; + UInt8 x1E; // some register used in TOC_use_isel + UInt8 gen_fsel; + char ppc_opt_bclr_bcctr; + char use_lmw_stmw; + char report_heap_info; + char misaligned_mem_access; + char switch_tables; + char prepare_compress; + char some_alignment; // used in CMach_AllocationAlignment + char asmsemicolcomment; + char asmpoundcomment; + StringPtr oldprefixname; + short inlinelevel; + int inline_max_size; + int inline_max_total_size; + char inline_bottom_up; + Boolean cplusplus; + Boolean ecplusplus; + char objective_c; + char objc_strict; + char ARM_conform; + char ARM_scoping; + char require_prototypes; + char trigraphs; + char only_std_keywords; + char enumsalwaysint; + char ANSI_strict; + char mpwc_relax; + char mpwc_newline; + char ignore_oldstyle; + char cpp_extensions; + char pointercast_lvalue; + char useRTTI; + char delete_exception; + char _4B; + Boolean oldalignment; + char unsignedchars; + char multibyteaware; + char autoinline; + char defer_codegen; + Boolean direct_to_som; + char som_env_check; + char som_call_opt; + char booltruefalse; + char old_enum_mangler; + char longlong; + char longlong_enums; + char no_tfuncinline; + char _59; + char flat_include; + char syspath_once; + char always_import; + char simple_class_byval; + char wchar_type; + char vbase_ctor_offset; + char vbase_abi_v2; + char def_inherited; + char template_patch; + char template_friends; + char faster_pch_gen; + char array_new_delete; + Boolean dollar_identifiers; + char def_inline_tfuncs; + char arg_dep_lookup; + Boolean simple_prepdump; + char line_prepdump; + char fullpath_prepdump; + char old_mtemplparser; + char suppress_init_code; + char reverse_bitfields; + Boolean c9x; + char float_constants; + char no_static_dtors; + char longlong_prepeval; + char const_strings; + char dumpir; + char experimental; + char gcc_extensions; + char stdc_fp_contract; + char stdc_fenv_access; + char stdc_cx_limitedr; + char old_argmatch; + char optEH; + char optEH2; + char new_mangler; + char microsoft; + Boolean warningerrors; + char pedantic; + char check_header_flags; + Boolean supress_warnings; + Boolean warn_illpragma; + char warn_emptydecl; + char warn_possunwant; + char warn_unusedvar; + char warn_unusedarg; + char warn_extracomma; + char warn_hidevirtual; + char warn_largeargs; + char warn_implicitconv; + char warn_notinlined; + char warn_structclass; + char warn_padding; + char warn_no_side_effect; + char warn_resultnotused; + char warn_ptr_int_conv; + char align_mode; + Boolean align_array_members; + char dont_reuse_strings; + char pool_strings; + char explicit_zero_data; + char readonly_strings; + char exceptions; + char _99; + char dont_inline; + char always_inline; + char peephole; + char global_optimizer; + char side_effects; + char internal; + char import; + char export; + char lib_export; + char nosyminline; + char force_active; + char optimizationlevel; + char optimize_for_size; + char optimizewithasm; + char crippled; + char opt_common_subs; + char opt_loop_invariants; + char opt_propagation; + char opt_dead_assignments; + char opt_strength_reduction; + char opt_strength_reduction_strict; + char opt_dead_code; + char opt_lifetimes; + char _B1; // unused? + char opt_unroll_loops; + char opt_vectorize_loops; + char _B4; // amount of IRO passes? + char opt_pointer_analysis; + char opt_pointer_analysis_mode; + char loop_unroll_count; + char loop_unroll_size_threshold; + char isGeneratingDebugInfo; + CWDataType pchCreator; + CWDataType pchType; + CWDataType text; + HashNameNode *forcedSegment; // when set by #pragma segment +} COpts; + +typedef struct CParams { + CWPluginContext context; + CWObjectData objectdata; + Handle objectDataHandle; + Handle browseDataHandle; + SInt32 pluginRequest; + SInt32 apiVersion; + FSSpec projectFile; + SInt32 projectFileCount; + SInt32 mainFileNumber; + FSSpec mainFileSpec; + const char *mainFileText; + SInt32 mainFileTextLength; + Boolean isPrecompiling; + Boolean isAutoPrecompiling; + Boolean isPreprocessing; + Boolean isGeneratingDebugInfo; + Boolean isCachingPrecompiledHeaders; + CWBrowseOptions browseOptions; + Boolean field276; + SInt16 mainFileID; + CWDataType targetOS; + CWDataType targetCPU; + char *targetName; +} CParams; + + +typedef struct VarInfo { // OK! + Object *func; + SInt32 usage; + TStreamElement deftoken; + SInt16 varnumber; + Boolean noregister; + Boolean used; + UInt8 flags; + UInt8 rclass; + SInt16 reg; + SInt16 regHi; +} VarInfo; + + + +typedef struct DefArgCtorInfo { + Object *default_func; + ENode *default_arg; +} DefArgCtorInfo; + +typedef struct XRefOffset { + UInt32 xrefoffset; + SInt32 offset; +} XRefOffset; + +typedef struct InlineXRef { + struct InlineXRef *next; + Object *object; + UInt16 xrefmode; + UInt16 numxrefs; + XRefOffset xref[1]; +} InlineXRef; + + +typedef enum StatementType { + ST_NOP = 1, + ST_LABEL, + ST_GOTO, + ST_EXPRESSION, + ST_SWITCH, + ST_IFGOTO, + ST_IFNGOTO, + ST_RETURN, + ST_OVF, + ST_EXIT, + ST_ENTRY, + ST_BEGINCATCH, + ST_ENDCATCH, + ST_ENDCATCHDTOR, + ST_GOTOEXPR, + ST_ASM, + ST_BEGINLOOP, + ST_ENDLOOP, + ST_ILLEGAL +} StatementType; + +typedef enum ExceptionActionType { + EAT_NOP, + EAT_DESTROYLOCAL, + EAT_DESTROYLOCALCOND, + EAT_DESTROYLOCALOFFSET, + EAT_DESTROYLOCALPOINTER, + EAT_DESTROYLOCALARRAY, + EAT_DESTROYPARTIALARRAY, + EAT_DESTROYMEMBER, + EAT_DESTROYMEMBERCOND, + EAT_DESTROYMEMBERARRAY, + EAT_DELETEPOINTER, + EAT_DELETELOCALPOINTER, + EAT_DELETEPOINTERCOND, + EAT_CATCHBLOCK, + EAT_ACTIVECATCHBLOCK, + EAT_SPECIFICATION, + EAT_TERMINATE, + EAT_DESTROYBASE, + EAT_NACTIONS +} ExceptionActionType; + +typedef struct ExceptionAction { + struct ExceptionAction *prev; + union { + struct { + Object *local; + Object *dtor; + } destroy_local; + struct { + Object *local; + Object *cond; + Object *dtor; + } destroy_local_cond; + struct { + Object *local; + Object *dtor; + SInt32 offset; + } destroy_local_offset; + struct { + Object *pointer; + Object *dtor; + } destroy_local_pointer; + struct { + Object *localarray; + Object *dtor; + SInt32 elements; + SInt32 element_size; + } destroy_local_array; + struct { + Object *arraypointer; + Object *arraycounter; + Object *dtor; + Object *element_size; + } destroy_partial_array; + struct { + Object *objectptr; + Object *dtor; + SInt32 offset; + } destroy_member; + struct { + Object *objectptr; + Object *cond; + Object *dtor; + SInt32 offset; + } destroy_member_cond; + struct { + Object *objectptr; + Object *dtor; + SInt32 offset; + SInt32 elements; + SInt32 element_size; + } destroy_member_array; + struct { + Object *pointerobject; + Object *deletefunc; + } delete_pointer; + struct { + Object *pointerobject; + Object *deletefunc; + Object *cond; + } delete_pointer_cond; + struct { + Object *catch_object; + Object *catch_info_object; + CLabel *catch_label; + Object *catch_typeid; + Type *catch_type; + UInt32 catch_qual; + } catch_block; + struct { + Object *catch_info_object; + Boolean call_dtor; + } active_catch_block; + struct { + SInt32 unexp_ids; + Object **unexp_id; + CLabel *unexp_label; + Object *unexp_info_object; + } specification; + struct { + Object *object; + Boolean is_dep; + } local; + } data; + ExceptionActionType type; +} ExceptionAction; + +typedef struct Statement { + struct Statement *next; + StatementType type; + char marked; + UInt8 flags; + UInt16 value; + ENode *expr; + CLabel *label; + ExceptionAction *dobjstack; + SInt32 sourceoffset; + HashNameNode *sourcefilepath; +} Statement; + +typedef struct CLabel { + struct CLabel *next; + Statement *stmt; + HashNameNode *uniquename; + HashNameNode *name; + PCodeLabel *pclabel; + void *sicg_label; +} CLabel; + +typedef struct MemInitializer { + struct MemInitializer *next; + union { + ENodeList *nodes; + ENode *expr; + } e; + union { + ObjMemberVar *ivar; + Type *type; + } u; + Boolean is_ivar; + Boolean is_expr; +} MemInitializer; + + +typedef enum DepNameType { + DNT_NAME, + DNT_CONVERSION, + DNT_DTOR, + DNT_NAMESPACE, + DNT_QUALNAME, + DNT_TEMPLATE, + DNT_TYPENAME +} DepNameType; + +typedef struct DepName { + struct DepName *next; + union { + HashNameNode *name; + NameSpace *nspace; + struct { + Type *type; + UInt32 qual; + } conv; + struct { + HashNameNode *name; + TemplArg *args; + } templ; + struct { + HashNameNode *name; + Type *type; + } tname; + } u; + DepNameType type; +} DepName; + + + + + +typedef enum SubKind { + SUBKIND_NAMESPACE, + SUBKIND_TYPE, + SUBKIND_OBJECT +} SubKind; + +typedef struct Substitution { + struct Substitution *next; + union { + NameSpace *nspace; + struct { + Type *type; + UInt32 qual; + } type; + Object *obj; + } u; + int id; + SubKind kind; +} Substitution; + + +// CScope.c +extern Boolean cscope_is_member_func; +extern Object *cscope_currentfunc; +extern TypeClass *cscope_currentclass; +extern NameSpace *cscope_current; +extern NameSpace *cscope_root; + +typedef struct CScopeSave { + NameSpace *current; + TypeClass *currentclass; + Object *currentfunc; + Boolean is_member_func; +} CScopeSave; // assumed name + +typedef struct CScopeParseResult { + NameSpace *nspace_0; + HashNameNode *name_4; + Type *x8; + void *xC; + ObjBase *obj_10; + NameSpaceObjectList *nsol_14; + BClassList *bcl_18; + Boolean x1C; + Boolean x1D; + Boolean isambig; + Boolean x1F; + Boolean x20; + Boolean x21; +} CScopeParseResult; + +typedef struct CScopeNSIterator { + NameSpace *nspace; + NameSpaceLookupList *lookup; + CScopeParseResult *result; +} CScopeNSIterator; + +typedef struct CScopeObjectIterator { + NameSpace *nspace; + NameSpaceName *nextname; + NameSpaceObjectList *currlist; + int hashindex; +} CScopeObjectIterator; + +extern void CScope_Setup(); +extern void CScope_Cleanup(); +extern void CScope_GetScope(CScopeSave *save); +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_RestoreScope(CScopeSave *saved); +extern Boolean CScope_IsEmptySymTable(); +extern Boolean CScope_IsInLocalNameSpace(NameSpace *nspace); +extern NameSpaceObjectList *CScope_FindName(NameSpace *nspace, HashNameNode *name); +extern NameSpaceName *CScope_FindNameSpaceName(NameSpace *nspace, HashNameNode *name); +extern NameSpaceObjectList *CScope_InsertName(NameSpace *nspace, HashNameNode *name); +extern NameSpaceObjectList *CScope_ArgumentDependentNameLookup(NameSpaceObjectList *list, HashNameNode *name, ENodeList *argNodes, Boolean flag); +extern NameSpace *CScope_NewHashNameSpace(HashNameNode *name); +extern NameSpace *CScope_NewListNameSpace(HashNameNode *name, Boolean is_global); +extern NameSpace *CScope_FindNonClassNonFunctionNS(NameSpace *nspace); +extern NameSpace *CScope_FindGlobalNS(NameSpace *nspoce); +extern Boolean CScope_IsStdNameSpace(NameSpace *nspace); +extern Boolean CScope_IsEmptyNameSpace(NameSpace *nspace); +extern void CScope_MergeNameSpace(NameSpace *dst, NameSpace *src); +extern void CScope_AddObject(NameSpace *nspace, HashNameNode *name, ObjBase *obj); +extern void CScope_AddGlobalObject(Object *obj); +extern NameSpaceLookupList *CScope_BuildNameSpaceLookupList(NameSpace *nspace); +extern Boolean CScope_FindQualifiedClassMember(CScopeParseResult *result, TypeClass *tclass, HashNameNode *name); +extern Type *CScope_GetType(NameSpace *nspace, HashNameNode *name, void **unk6); +extern Type *CScope_GetTagType(NameSpace *nspace, HashNameNode *name); +extern Boolean CScope_ParseExprName(CScopeParseResult *result); +extern Boolean CScope_ParseDeclName(CScopeParseResult *result); +extern Boolean CScope_ParseQualifiedNameSpace(CScopeParseResult *result, Boolean flag1, Boolean flag2); +extern Boolean CScope_ParseElaborateName(CScopeParseResult *result); +extern Boolean CScope_FindObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name); +extern Boolean CScope_FindNonClassObject(NameSpace *nspace, CScopeParseResult *result, HashNameNode *name); +extern NameSpaceObjectList *CScope_FindObjectList(CScopeParseResult *result, HashNameNode *name); +extern Boolean CScope_PossibleTypeName(HashNameNode *name); +extern Boolean CScope_FindClassMemberObject(TypeClass *tclass, CScopeParseResult *result, HashNameNode *name); +extern void CScope_InitObjectIterator(CScopeObjectIterator *iterator, NameSpace *nspace); +extern ObjBase *CScope_NextObjectIteratorObject(CScopeObjectIterator *iterator); +extern NameSpaceObjectList *CScope_NextObjectIteratorObjectList(CScopeObjectIterator *iterator); +extern void CScope_DefineTypeTag(NameSpace *nspace, HashNameNode *name, Type *type); +extern Type *CScope_GetLocalTagType(NameSpace *nspace, HashNameNode *name); +extern Boolean CScope_FindTypeName(NameSpace *nspace, HashNameNode *name, CScopeParseResult *result); +extern NameSpaceObjectList *CScope_GetLocalObject(NameSpace *nspace, HashNameNode *name); +extern BClassList *CScope_GetClassAccessPath(BClassList *list, TypeClass *tclass); +extern Boolean CScope_ParseMemberName(TypeClass *tclass, CScopeParseResult *result, Boolean flag); +extern void CScope_AddClassUsingDeclaration(TypeClass *tclass, TypeClass *tclass2, HashNameNode *name, AccessType access); +extern void CScope_ParseUsingDeclaration(NameSpace *nspace, AccessType access); +extern void CScope_ParseNameSpaceAlias(HashNameNode *name); +extern void CScope_ParseUsingDirective(NameSpace *nspace); + +// CMachine.c +extern TypeIntegral stbool; +extern TypeIntegral stchar; +extern TypeIntegral stsignedchar; +extern TypeIntegral stunsignedchar; +extern TypeIntegral stwchar; +extern TypeIntegral stsignedshort; +extern TypeIntegral stunsignedshort; +extern TypeIntegral stsignedint; +extern TypeIntegral stunsignedint; +extern TypeIntegral stsignedlong; +extern TypeIntegral stunsignedlong; +extern TypeIntegral stsignedlonglong; +extern TypeIntegral stunsignedlonglong; +extern TypeIntegral stfloat; +extern TypeIntegral stshortdouble; +extern TypeIntegral stdouble; +extern TypeIntegral stlongdouble; + +extern TypeStruct stvectorunsignedchar; +extern TypeStruct stvectorsignedchar; +extern TypeStruct stvectorboolchar; +extern TypeStruct stvectorunsignedshort; +extern TypeStruct stvectorsignedshort; +extern TypeStruct stvectorboolshort; +extern TypeStruct stvectorunsignedlong; +extern TypeStruct stvectorsignedlong; +extern TypeStruct stvectorboollong; +extern TypeStruct stvectorfloat; +extern TypeStruct stvectorpixel; +extern TypeStruct stvector; + +extern void CMach_Configure(); +extern SInt32 CMach_GetQUALalign(UInt32 qual); +extern SInt32 CMach_ArgumentAlignment(Type *type); +extern SInt32 CMach_AllocationAlignment(Type *type, UInt32 qual); +extern CInt64 CMach_CalcIntDiadic(Type *type, CInt64 left, short op, CInt64 right); +extern CInt64 CMach_CalcIntMonadic(Type *type, short op, CInt64 val); +extern CInt64 CMach_CalcIntConvertFromFloat(Type *type, Float fval); +extern void CMach_InitIntMem(Type *type, CInt64 val, void *mem); +extern void CMach_InitVectorMem(Type *type, MWVector128 val, void *mem); +extern Float CMach_CalcFloatDiadic(Type *type, Float left, short op, Float right); +extern Float CMach_CalcFloatMonadic(Type *type, short op, Float fval); +extern Boolean CMach_CalcFloatDiadicBool(Type *type, Float left, short op, Float right); +extern Boolean CMach_CalcVectorDiadicBool(Type *type, MWVector128 *left, short op, MWVector128 *right); +extern char *CMach_FloatScan(char *input, Float *result, Boolean *fail); +extern Float CMach_CalcFloatConvertFromInt(Type *type, CInt64 val); +extern Float CMach_CalcFloatConvert(Type *type, Float fval); +extern Boolean CMach_FloatIsZero(Float fval); +extern Boolean CMach_FloatIsOne(Float fval); +extern Boolean CMach_FloatIsNegOne(Float fval); +extern void CMach_InitFloatMem(Type *type, Float val, void *mem); +extern void CMach_PrintFloat(char *buf, Float val); +extern void CMach_PragmaParams(); +extern void CMach_AdjustFuntionArgs(); +extern SInt16 CMach_GetStructAlign(TypeStruct *tstruct); +extern SInt16 CMach_GetClassAlign(TypeClass *tclass); +extern SInt16 CMach_GetTypeAlign(Type *type); +extern SInt16 CMach_MemberAlignValue(Type *type, SInt32 var); +extern void CMach_StructLayoutInitOffset(SInt32 offset); +extern SInt32 CMach_StructLayoutGetCurSize(); +extern SInt32 CMach_StructLayoutGetOffset(Type *type, UInt32 qual); +extern SInt32 CMach_StructLayoutBitfield(TypeBitfield *tbitfield, UInt32 qual); +extern UInt8 CMach_GetFunctionResultClass(TypeFunc *tfunc); +extern Boolean CMach_PassResultInHiddenArg(Type *type); +extern const char *CMach_GetCPU(); +extern Boolean CMach_FloatIsPowerOf2(Float flt); +extern Float CMach_FloatReciprocal(Float flt); +extern SInt32 CMach_RoundedSizeOf(Object *object); +extern void CMach_ReInitRuntimeObjects(); + +// CPrep.c +typedef struct Macro { + struct Macro *next; + HashNameNode *name; + void *c; + Boolean xC; + Boolean xD; + Boolean is_special; + Boolean xF; + void *e; +} Macro; +typedef struct TokenStack { + char *pos; + char *macrostart; + Macro *macro; + Boolean macrocheck; +} TokenStack; + +extern CParams *cparamblkptr; +extern short tk; +extern CInt64 tkintconst; +extern Float tkfloatconst; +extern char *tkstring; +extern HashNameNode *tkidentifier; +extern SInt32 tksize; +extern short ispascalstring; +extern short nlflag; +extern SInt32 lines; +extern Boolean spaceskip; +extern struct Macro **macrohashtable; +extern Boolean cprep_nomem_exit; +extern Boolean cprep_nostring; +extern Boolean cprep_eoltokens; +extern TokenStack tokenstack[128]; +extern short tokenstacklevel; +extern SInt32 cprep_cursymfile; // might be a ptr? +extern char *pos; +extern char *macropos; +extern char *nextcharpos; +extern char CPrep_SkipNewCommentChar; +extern Boolean preprocessing_only; +extern Handle stringmem; +extern SInt32 maxstringsize; +extern char cprep_idarray[256]; +extern Boolean was_escchar; +extern Boolean macrocheck; +extern Boolean widestring; +extern Boolean at_linestart; +extern char *prep_file_start; +extern char *prep_file_end; +extern char *macrostart; +extern Boolean cprep_strconcat; +extern CPrepFileInfo *prep_file; +extern short filesp; +extern SInt32 linenumber; +extern GList pplist; +extern TStreamElement *ts_current; +extern SInt32 ts_preread_elements; + +extern void CPrep_InsertSpecialMacro(Macro *macro, char *name); +extern void CPrep_InsertSpecialMacros(); +extern void CPrep_RemoveSpecialMacros(); +extern Boolean setupprep(); +extern void cleanupprep(); +extern void CPrep_TSBufferGrow(int amount); +extern void CPrep_TokenStreamGetState(SInt32 *state); +extern void CPrep_TokenStreamSetState(SInt32 *state); +extern void CPrep_UnLex(); +extern void CPrep_TokenStreamSetCurState(SInt32 *state); +extern void CPrep_StreamGetBlock(); +extern void CPrep_StreamGetSemicolon(); +extern void CPrep_StreamGetTemplate(); +extern void CPrep_StreamInsert(); +extern void CPrep_StreamRemove(); +extern void CPrep_RemoveTokens(); +extern void CPrep_TokenStreamFlush(); +extern void CPrep_CurStreamElement(); +extern void CPrep_GetTokenContext(TStreamElement *token, CPrepFileInfo **tokenfile, SInt32 *selectionoffset, short *tokensize, SInt32 *linenumber, char *buf1, short *tokenoffset, short *tokenlength, char *buf2, short *lastarg); +extern void CPrep_Error(short code); +extern void CPrep_ErrorName(short code, const char *name); +extern void CPrep_Warning(short code); +extern void CPrep_WarningName(short code, const char *name); +extern void CPrep_ErrorMessage(int errTable, char *str, Boolean flag1, Boolean flag2); +extern void CPrep_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2); +extern void popfile(); +extern void CPrep_SetSourceFile(); +extern void CPrep_GetSourceFilePath(); +extern void CPrep_NewFileOffsetInfo(); +extern void CPrep_GetFileOffsetInfo(); +extern void CPrep_GetFileOffsetInfo2(); +extern void CPrep_ResetFileInfo(); +extern void CPrep_GetPrepPos(); +extern Boolean C_Compiler(CParams *param); +extern void poptokenseq(); +extern void foundnl(); +extern void newline(); +extern short notendofline(); +extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2); +extern void macrotest(); +extern void CPrep_PragmaLex(); +extern void CPrep_PushOption(); +extern void CPrep_PopOption(); +extern void preprocessor(); +extern void CPrep_BrowserTokenOffset(); +extern void CPrep_BrowserFileOffset(); +extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset); +extern CPrepFileInfo *CPrep_BrowserCurrentFile(); + +// CPrepTokenizer.c +extern short prepskipnextchar(); +extern short prepnextchar(); +extern short prepnextstringchar(char *str, Boolean flag); +extern void CPrep_MatchChar(char ch, Boolean flag); +extern char *CPrep_MatchChar2(char *str, char ch, Boolean flag); +extern short prepcurchar(); +extern char *ReadIdentifier(char *str); +extern char *CPrep_SkipNewComment(char *str); +extern Boolean skipendoflinematch(char *str, Boolean flag); +extern void skipendofline(); +extern void CPrep_SkipAsmComment(); +extern short lookahead(); +extern short lookahead_noeol(); +extern short lex(); +extern short plex(); +extern short lexidentifier(); + +// LOOSE DECLS +extern Boolean C_Compiler(CParams *param); +extern void PrecompilerRead(short refnum, void *buffer); +extern void CodeGen_InitCompiler(); +extern void CodeGen_TermCompiler(); +extern void CodeGen_InitBackEndOptions(); +extern void CodeGen_UpdateOptimizerOptions(); +extern void CodeGen_UpdateBackEndOptions(); +extern void MWUnmangle(const char *name, char *buf, int size); +extern COpts copts; +extern CParams *cparamblkptr; +extern FuncArg elipsis; +extern FuncArg oldstyle; +extern HashNameNode *constructor_name_node; +extern HashNameNode *destructor_name_node; +extern char *CMangler_GetOperator(HashNameNode *str); +extern jmp_buf errorreturn; +extern Boolean cprep_nomem_exit; +extern Boolean anyerrors; +extern Boolean fatalerrors; +extern SInt32 lines; +extern char string[256]; +extern TemplStack *ctempl_curinstance; +typedef struct ParserTryBlock { + struct ParserTryBlock *next; + jmp_buf jmpbuf; + NameSpace *cscope_current; + TypeClass *cscope_currentclass; + Object *cscope_currentfunc; + TemplStack *ctempl_curinstance; + TStreamElement *cerror_locktoken; + Boolean cscope_is_member_func; +} ParserTryBlock; +extern ParserTryBlock *trychain; +extern Boolean in_assembler; +extern Boolean preprocessing_only; +extern void AssemblerError(); +#include "compiler/types.h" +extern short tk; +extern HashNameNode *tkidentifier; +extern short lex(); +extern short notendofline(); +extern short lookahead(); +extern Object *CClass_Constructor(TypeClass *tclass); +extern Object *CClass_Destructor(TypeClass *tclass); +extern int CClass_CheckPures(TypeClass *tclass); +extern Boolean CParser_IsPublicRuntimeObject(Object *obj); +extern Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2); +extern Boolean CTemplTool_EqualArgs(TemplArg *a, TemplArg *b); +extern TypeTemplDep *CDecl_NewTemplDepType(TypeTemplDepType tdtype); +extern GList name_mangle_list; +extern void CPrep_UnLex(); +extern Type *CTempl_ClassGetType(TypeClass *tclass); +extern short is_typesame(Type *t1, Type *t2); +extern Boolean is_unsigned(Type *type); +extern void CDecl_CompleteType(Type *type); +extern TemplArg *CTempl_ParseUncheckTemplArgs(void *fixmelater, Boolean flag); +extern SInt32 CClass_VirtualBaseOffset(TypeClass *tclass, TypeClass *base); +extern Boolean CClass_IsMoreAccessiblePath(BClassList *a, BClassList *b); +extern Boolean CClass_ClassDominates(TypeClass *a, TypeClass *b); +extern Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag); +extern Type *CTempl_ParseTemplTemplParam(Type *t); +extern void CClass_CheckPathAccess(BClassList *bcl, void *unk, AccessType access); +extern BClassList *CClass_GetPathCopy(BClassList *path, Boolean flag); +extern AccessType global_access; +extern UInt32 CParser_GetTypeQualifiers(Type *type, UInt32 qual); +extern void CTemplClass_RegisterUsingDecl(TemplClass *tclass, Type *target, AccessType access); +extern void CodeGen_InsertSpecialMacros(); +extern char *CodeGen_ExpandSpecialMacro(Macro *macro); +extern void CPrep_PreprocessDumpFileInfo(Boolean flag); +extern Boolean gForceSourceLoc; +extern void ObjGen_SegmentName(); // might take an arg, not sure since it's empty + +enum { + CPU_PPC401, + CPU_PPC403, + CPU_PPC505, + CPU_PPC509, + CPU_PPC555, + CPU_PPC601, + CPU_PPC602, + CPU_PPC603, + CPU_PPC603e, + CPU_PPC604, + CPU_PPC604e, + CPU_PPC740, + CPU_PPC750, + CPU_PPC801, + CPU_PPC821, + CPU_PPC823, + CPU_PPC850, + CPU_PPC860, + CPU_PPC8240, + CPU_PPC8260, + CPU_PPC7400 = 0x15, + CPU_PPCGEKKO, + CPU_PPCELF, + CPU_PPC7450, + CPU_PPC556, + CPU_PPC565 +}; + +extern char *ScanFloat(char *input, double *output, Boolean *fail); + +#ifdef __MWERKS__ +#pragma options align=reset +#endif diff --git a/includes/compiler/CError.h b/includes/compiler/CError.h new file mode 100644 index 0000000..89f67e4 --- /dev/null +++ b/includes/compiler/CError.h @@ -0,0 +1,364 @@ +#ifndef COMPILER_CERROR_H +#define COMPILER_CERROR_H + +#include "compiler/common.h" + +#define CError_ASSERT(cond) if (!(cond)) { CError_Internal(__FILE__, __LINE__); } +#define CError_FAIL(cond) if (cond) { CError_Internal(__FILE__, __LINE__); } +#define CError_FATAL() do { CError_Internal(__FILE__, __LINE__); } while (0) + +enum { + CErrorStr100 = 100, + CErrorStr101 = 101, + CErrorStr102 = 102, + CErrorStr103 = 103, + CErrorStr104 = 104, + CErrorStr105 = 105, + CErrorStr106 = 106, + CErrorStr107 = 107, + CErrorStr108 = 108, + CErrorStr109 = 109, + CErrorStr110 = 110, + CErrorStr111 = 111, + CErrorStr112 = 112, + CErrorStr113 = 113, + CErrorStr114 = 114, + CErrorStr115 = 115, + CErrorStr116 = 116, + CErrorStr117 = 117, + CErrorStr118 = 118, + CErrorStr119 = 119, + CErrorStr120 = 120, + CErrorStr121 = 121, + CErrorStr122 = 122, + CErrorStr123 = 123, + CErrorStr124 = 124, + CErrorStr125 = 125, + CErrorStr126 = 126, + CErrorStr127 = 127, + CErrorStr128 = 128, + CErrorStr129 = 129, + CErrorStr130 = 130, + CErrorStr131 = 131, + CErrorStr132 = 132, + CErrorStr133 = 133, + CErrorStr134 = 134, + CErrorStr135 = 135, + CErrorStr136 = 136, + CErrorStr137 = 137, + CErrorStr138 = 138, + CErrorStr139 = 139, + CErrorStr140 = 140, + CErrorStr141 = 141, + CErrorStr142 = 142, + CErrorStr143 = 143, + CErrorStr144 = 144, + CErrorStr145 = 145, + CErrorStr146 = 146, + CErrorStr147 = 147, + CErrorStr148 = 148, + CErrorStr149 = 149, + CErrorStr150 = 150, + CErrorStr151 = 151, + CErrorStr152 = 152, + CErrorStr153 = 153, + CErrorStr154 = 154, + CErrorStr155 = 155, + CErrorStr156 = 156, + CErrorStr157 = 157, + CErrorStr158 = 158, + CErrorStr159 = 159, + CErrorStr160 = 160, + CErrorStr161 = 161, + CErrorStr162 = 162, + CErrorStr163 = 163, + CErrorStr164 = 164, + CErrorStr165 = 165, + CErrorStr166 = 166, + CErrorStr167 = 167, + CErrorStr168 = 168, + CErrorStr169 = 169, + CErrorStr170 = 170, + CErrorStr171 = 171, + CErrorStr172 = 172, + CErrorStr173 = 173, + CErrorStr174 = 174, + CErrorStr175 = 175, + CErrorStr176 = 176, + CErrorStr177 = 177, + CErrorStr178 = 178, + CErrorStr179 = 179, + CErrorStr180 = 180, + CErrorStr181 = 181, + CErrorStr182 = 182, + CErrorStr183 = 183, + CErrorStr184 = 184, + CErrorStr185 = 185, + CErrorStr186 = 186, + CErrorStr187 = 187, + CErrorStr188 = 188, + CErrorStr189 = 189, + CErrorStr190 = 190, + CErrorStr191 = 191, + CErrorStr192 = 192, + CErrorStr193 = 193, + CErrorStr194 = 194, + CErrorStr195 = 195, + CErrorStr196 = 196, + CErrorStr197 = 197, + CErrorStr198 = 198, + CErrorStr199 = 199, + CErrorStr200 = 200, + CErrorStr201 = 201, + CErrorStr202 = 202, + CErrorStr203 = 203, + CErrorStr204 = 204, + CErrorStr205 = 205, + CErrorStr206 = 206, + CErrorStr207 = 207, + CErrorStr208 = 208, + CErrorStr209 = 209, + CErrorStr210 = 210, + CErrorStr211 = 211, + CErrorStr212 = 212, + CErrorStr213 = 213, + CErrorStr214 = 214, + CErrorStr215 = 215, + CErrorStr216 = 216, + CErrorStr217 = 217, + CErrorStr218 = 218, + CErrorStr219 = 219, + CErrorStr220 = 220, + CErrorStr221 = 221, + CErrorStr222 = 222, + CErrorStr223 = 223, + CErrorStr224 = 224, + CErrorStr225 = 225, + CErrorStr226 = 226, + CErrorStr227 = 227, + CErrorStr228 = 228, + CErrorStr229 = 229, + CErrorStr230 = 230, + CErrorStr231 = 231, + CErrorStr232 = 232, + CErrorStr233 = 233, + CErrorStr234 = 234, + CErrorStr235 = 235, + CErrorStr236 = 236, + CErrorStr237 = 237, + CErrorStr238 = 238, + CErrorStr239 = 239, + CErrorStr240 = 240, + CErrorStr241 = 241, + CErrorStr242 = 242, + CErrorStr243 = 243, + CErrorStr244 = 244, + CErrorStr245 = 245, + CErrorStr246 = 246, + CErrorStr247 = 247, + CErrorStr248 = 248, + CErrorStr249 = 249, + CErrorStr250 = 250, + CErrorStr251 = 251, + CErrorStr252 = 252, + CErrorStr253 = 253, + CErrorStr254 = 254, + CErrorStr255 = 255, + CErrorStr256 = 256, + CErrorStr257 = 257, + CErrorStr258 = 258, + CErrorStr259 = 259, + CErrorStr260 = 260, + CErrorStr261 = 261, + CErrorStr262 = 262, + CErrorStr263 = 263, + CErrorStr264 = 264, + CErrorStr265 = 265, + CErrorStr266 = 266, + CErrorStr267 = 267, + CErrorStr268 = 268, + CErrorStr269 = 269, + CErrorStr270 = 270, + CErrorStr271 = 271, + CErrorStr272 = 272, + CErrorStr273 = 273, + CErrorStr274 = 274, + CErrorStr275 = 275, + CErrorStr276 = 276, + CErrorStr277 = 277, + CErrorStr278 = 278, + CErrorStr279 = 279, + CErrorStr280 = 280, + CErrorStr281 = 281, + CErrorStr282 = 282, + CErrorStr283 = 283, + CErrorStr284 = 284, + CErrorStr285 = 285, + CErrorStr286 = 286, + CErrorStr287 = 287, + CErrorStr288 = 288, + CErrorStr289 = 289, + CErrorStr290 = 290, + CErrorStr291 = 291, + CErrorStr292 = 292, + CErrorStr293 = 293, + CErrorStr294 = 294, + CErrorStr295 = 295, + CErrorStr296 = 296, + CErrorStr297 = 297, + CErrorStr298 = 298, + CErrorStr299 = 299, + CErrorStr300 = 300, + CErrorStr301 = 301, + CErrorStr302 = 302, + CErrorStr303 = 303, + CErrorStr304 = 304, + CErrorStr305 = 305, + CErrorStr306 = 306, + CErrorStr307 = 307, + CErrorStr308 = 308, + CErrorStr309 = 309, + CErrorStr310 = 310, + CErrorStr311 = 311, + CErrorStr312 = 312, + CErrorStr313 = 313, + CErrorStr314 = 314, + CErrorStr315 = 315, + CErrorStr316 = 316, + CErrorStr317 = 317, + CErrorStr318 = 318, + CErrorStr319 = 319, + CErrorStr320 = 320, + CErrorStr321 = 321, + CErrorStr322 = 322, + CErrorStr323 = 323, + CErrorStr324 = 324, + CErrorStr325 = 325, + CErrorStr326 = 326, + CErrorStr327 = 327, + CErrorStr328 = 328, + CErrorStr329 = 329, + CErrorStr330 = 330, + CErrorStr331 = 331, + CErrorStr332 = 332, + CErrorStr333 = 333, + CErrorStr334 = 334, + CErrorStr335 = 335, + CErrorStr336 = 336, + CErrorStr337 = 337, + CErrorStr338 = 338, + CErrorStr339 = 339, + CErrorStr340 = 340, + CErrorStr341 = 341, + CErrorStr342 = 342, + CErrorStr343 = 343, + CErrorStr344 = 344, + CErrorStr345 = 345, + CErrorStr346 = 346, + CErrorStr347 = 347, + CErrorStr348 = 348, + CErrorStr349 = 349, + CErrorStr350 = 350, + CErrorStr351 = 351, + CErrorStr352 = 352, + CErrorStr353 = 353, + CErrorStr354 = 354, + CErrorStr355 = 355, + CErrorStr356 = 356, + CErrorStr357 = 357, + CErrorStr358 = 358, + CErrorStr359 = 359, + CErrorStr360 = 360, + CErrorStr361 = 361, + CErrorStr362 = 362, + CErrorStr363 = 363, + CErrorStr364 = 364, + CErrorStr365 = 365, + CErrorStr366 = 366, + CErrorStr367 = 367, + CErrorStr368 = 368, + CErrorStr369 = 369, + CErrorStr370 = 370, + CErrorStr371 = 371, + CErrorStr372 = 372, + CErrorStr373 = 373, + CErrorStr374 = 374, + CErrorStr375 = 375, + CErrorStr376 = 376, + CErrorStr377 = 377, + CErrorStr378 = 378, + CErrorStr379 = 379, + CErrorStr380 = 380, + CErrorStr381 = 381, + CErrorStr382 = 382, + CErrorStr383 = 383, + CErrorStr384 = 384, + CErrorStr385 = 385, + CErrorStr386 = 386, + CErrorStr387 = 387, + CErrorStr388 = 388, + CErrorStr389 = 389, + CErrorStr390 = 390, + CErrorStr391 = 391, + CErrorStr392 = 392, + CErrorStrMAX = 393 +}; + +typedef struct _CErrorBuffer { + char *start; + char *end; + UInt32 size; + UInt32 remaining; +} CErrorBuffer; + +extern void CError_Init(); +extern void CError_SetErrorToken(TStreamElement *token); +extern void CError_SetNullErrorToken(); +extern void CError_LockErrorPos(TStreamElement *token, TStreamElement **saved); +extern void CError_UnlockErrorPos(TStreamElement **saved); +extern void CError_ResetErrorSkip(); +extern void CError_GetErrorString(char *buf, short code); +extern void CError_BufferInit(CErrorBuffer *eb, char *buf, SInt32 bufSize); +extern void CError_BufferGrow(CErrorBuffer *eb, SInt32 amount); +extern void CError_BufferAppendChar(CErrorBuffer *eb, char ch); +extern void CError_BufferAppendString(CErrorBuffer *eb, const char *str); +extern void CError_BufferTerminate(CErrorBuffer *eb); +extern void CError_BufferAppendQualifier(CErrorBuffer *eb, UInt32 qual); +extern void CError_BufferAppendTemplArgExpr(CErrorBuffer *eb, ENode *node); +extern void CError_BufferAppendTemplArg(CErrorBuffer *eb, TemplArg *targ); +extern void CError_BufferAppendTemplArgs(CErrorBuffer *eb, TemplArg *targs); +extern void CError_BufferAppendNameSpace(CErrorBuffer *eb, NameSpace *nspace); +extern void CError_BufferAppendPType(CErrorBuffer *eb, Type *ty); +extern void CError_BufferAppendTemplDepType(CErrorBuffer *eb, TypeTemplDep *type); +extern void CError_BufferAppendFuncArgs(CErrorBuffer *eb, TypeFunc *tfunc, Boolean isMethod); +extern void CError_BufferAppendType(CErrorBuffer *eb, Type *ty, UInt32 qual); +extern char *CError_GetTypeName(Type *ty, UInt32 qual, Boolean useGlobalHeap); +extern void CError_AppendUnqualFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc); +extern void CError_AppendFunctionName(CErrorBuffer *eb, NameSpace *nspace, HashNameNode *name, TemplArg *templargs, TypeFunc *tfunc); +extern void CError_AppendObjectName(CErrorBuffer *eb, Object *obj); +extern void CError_AppendMethodName(CErrorBuffer *eb, ObjCMethod *meth); +extern char *CError_GetQualifiedName(NameSpace *nspace, HashNameNode *name); +extern char *CError_GetFunctionName(NameSpace *nspace, HashNameNode *name, TypeFunc *tfunc); +extern char *CError_GetObjectName(Object *obj); +extern char *CError_GetNameString(NameSpace *nspace, HashNameNode *operatorName); +extern void CError_ErrorMessage(int errTable, char *buf, Boolean flag1, Boolean flag2); +extern void CError_BufferAppendTemplateStack(CErrorBuffer *eb); +extern void CError_ErrorMessageVA(int code, const char *format, va_list list, Boolean flag1, Boolean flag2); +extern void CError_VAErrorMessage(int code, va_list list, Boolean flag1, Boolean flag2); +extern void CError_Error(int code, ...); +extern void CError_ErrorTerm(short code); +extern void CError_ErrorSkip(int code, ...); +extern void CError_ErrorFuncCall(short code, NameSpaceObjectList *args, ENodeList *argNodes); +extern void CError_OverloadedFunctionError2(Object *obj, ObjectList *olst, ENodeList *argNodes); +extern void CError_OverloadedFunctionError(Object *obj, ObjectList *olst); +extern void CError_AbstractClassError(TypeClass *tclass); +extern void CError_Warning(int code, ...); +extern void CError_BreakPoint(const char *a, const char *b); +extern void CError_Internal(); +extern void CError_ExpressionTooComplex(); +extern void CError_NoMem(); +extern void CError_UserBreak(); +extern void CError_CannotOpen(); +extern void CError_QualifierCheck(UInt32 qual); + +#endif diff --git a/includes/compiler/CInt64.h b/includes/compiler/CInt64.h new file mode 100644 index 0000000..455bf3f --- /dev/null +++ b/includes/compiler/CInt64.h @@ -0,0 +1,88 @@ +#ifndef COMPILER_CINT64_H +#define COMPILER_CINT64_H + +#include "compiler/common.h" + +// make sure this is in the right place +extern const CInt64 cint64_negone; +extern const CInt64 cint64_zero; +extern const CInt64 cint64_one; +extern const CInt64 cint64_max; +extern const CInt64 cint64_min; + +inline int CInt64_IsNegative(const CInt64 *n) { + return (n->hi & 0x80000000) != 0; +} +inline void CInt64_SetLong(CInt64 *pN, SInt32 n) { + pN->lo = n; + pN->hi = (n < 0) ? 0xFFFFFFFF : 0; +} +inline void CInt64_SetULong(CInt64 *pN, UInt32 n) { + pN->lo = n; + pN->hi = 0; +} + +inline int CInt64_IsZero(CInt64 *n) { + //if (n->hi == 0 && n->lo == 0) + // return 1; + //else + // return 0; + return n->hi == 0 && n->lo == 0; +} +inline void CInt64_Extend32(CInt64 *n) { // assumed name + n->hi = (n->lo >> 31) ? 0xFFFFFFFF : 0; +} + +extern void CInt64_Init(); +extern CInt64 CInt64_Not(CInt64 input); +extern CInt64 CInt64_Inv(CInt64 input); +extern CInt64 CInt64_Add(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Neg(CInt64 input); +extern CInt64 CInt64_Sub(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_MulU(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Mul(CInt64 lhs, CInt64 rhs); +extern void CInt64_DivMod(const CInt64 *lhs, const CInt64 *rhs, CInt64 *pDiv, CInt64 *pMod); +extern CInt64 CInt64_Div(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_DivU(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Mod(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_ModU(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Shl(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Shr(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_ShrU(CInt64 lhs, CInt64 rhs); +extern int CInt64_UnsignedCompare(const CInt64 *lhs, const CInt64 *rhs); +extern int CInt64_SignedCompare(const CInt64 *lhs, const CInt64 *rhs); +extern Boolean CInt64_Less(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_Greater(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_LessEqualU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_GreaterEqualU(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_Equal(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_NotEqual(CInt64 lhs, CInt64 rhs); +extern Boolean CInt64_IsInRange(CInt64 value, short len); +extern Boolean CInt64_IsInURange(CInt64 value, short len); +extern CInt64 CInt64_And(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Xor(CInt64 lhs, CInt64 rhs); +extern CInt64 CInt64_Or(CInt64 lhs, CInt64 rhs); +extern void CInt64_ConvertInt32(CInt64 *i); +extern void CInt64_ConvertUInt32(CInt64 *i); +extern void CInt64_ConvertInt16(CInt64 *i); +extern void CInt64_ConvertUInt16(CInt64 *i); +extern void CInt64_ConvertInt8(CInt64 *i); +extern void CInt64_ConvertUInt8(CInt64 *i); +extern void CInt64_ConvertUFromLongDouble(CInt64 *pResult, double value); +extern void CInt64_ConvertFromLongDouble(CInt64 *pResult, double value); +extern double CInt64_ConvertUToLongDouble(const CInt64 *value); +extern double CInt64_ConvertToLongDouble(const CInt64 *value); +extern char *CInt64_ScanOctString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanDecString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanHexString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanBinString(CInt64 *pResult, char *str, Boolean *pFail); +extern char *CInt64_ScanAsmNumber(CInt64 *pResult, char *str, Boolean *pFail); +extern int CInt64_PrintDec(char *output, CInt64 value); +extern int CInt64_PrintHex(char *output, CInt64 value); +extern int CInt64_PrintBin(char *output, CInt64 value); + +#endif diff --git a/includes/compiler/CompilerTools.h b/includes/compiler/CompilerTools.h new file mode 100644 index 0000000..50581b0 --- /dev/null +++ b/includes/compiler/CompilerTools.h @@ -0,0 +1,129 @@ +#ifndef COMPILER_COMPILERTOOLS_H +#define COMPILER_COMPILERTOOLS_H + +#include "compiler/common.h" + +extern void CompilerGetPString(short index, unsigned char *string); +extern void CompilerGetCString(short index, char *string); +extern unsigned char *CTool_CtoPstr(char *cstr); + +typedef struct HeapBlock { + struct HeapBlock *next; + Handle blockhandle; + SInt32 blocksize; + SInt32 blockfree; +} HeapBlock; + +typedef struct HeapMem { + HeapBlock *blocks; + /// The minimum size for a new block + SInt32 allocsize; + HeapBlock *curblock; + char *curfreep; + SInt32 curfree; +} HeapMem; + +typedef struct _HeapInfo { + /// The amount of blocks in this heap + SInt32 blocks; + /// The value of allocsize for the heap + SInt32 allocsize; + /// The total amount of bytes across all blocks + SInt32 total_size; + /// The amount of free bytes across all blocks + SInt32 total_free; + /// The average size of a block + SInt32 average_block_size; + /// The average amount of free space in a block + SInt32 average_block_free; + /// The amount of bytes in the largest contiguous section of free space + SInt32 largest_free_block; +} HeapInfo; + +typedef struct GList { + char **data; + SInt32 size; + SInt32 hndlsize; + SInt32 growsize; +} GList; + +extern long hash_name_id; +extern HashNameNode **name_hash_nodes; +extern void (*GListErrorProc)(); + +extern short InitGList(GList *gl, SInt32 size); +extern void FreeGList(GList *gl); +extern void LockGList(GList *gl); +extern void UnlockGList(GList *gl); +extern void ShrinkGList(GList *gl); +extern void AppendGListData(GList *gl, const void *data, SInt32 size); +extern void AppendGListNoData(GList *gl, SInt32 size); +extern void AppendGListByte(GList *gl, SInt8 thebyte); +extern void AppendGListWord(GList *gl, SInt16 theword); +extern void AppendGListTargetEndianWord(GList *gl, SInt16 theword); +extern void AppendGListLong(GList *gl, SInt32 theword); +extern void AppendGListTargetEndianLong(GList *gl, SInt32 theword); +extern void AppendGListID(GList *gl, const char *name); +extern void AppendGListName(GList *gl, const char *name); +extern void RemoveGListData(GList *gl, SInt32 size); +extern SInt16 GetGListByte(GList *gl); +extern SInt16 GetGListWord(GList *gl); +extern SInt32 GetGListLong(GList *gl); +extern short GetGListID(GList *gl, char *name); +extern void GetGListData(GList *gl, char *where, SInt32 size); + +extern SInt16 CHash(const char *string); +extern HashNameNode *GetHashNameNode(const char *name); +extern HashNameNode *GetHashNameNodeHash(const char *name, SInt16 hashval); +extern HashNameNode *GetHashNameNodeHash2(const char *name, SInt16 hashval); +extern HashNameNode *GetHashNameNodeExport(const char *name); +extern SInt32 GetHashNameNodeExportID(HashNameNode *node); +extern HashNameNode *GetHashNameNodeByID(SInt32 id); +extern void NameHashExportReset(); +extern void NameHashWriteNameTable(GList *glist); +extern void NameHashWriteTargetEndianNameTable(GList *glist); +extern void InitNameHash(); + +typedef void (*heaperror_t)(); + +extern SInt32 CTool_TotalHeapSize(); +extern void CTool_GetHeapInfo(HeapInfo *result, unsigned char heapID); +extern short initheaps(heaperror_t heaperrorproc); +extern short initgheap(heaperror_t heaperrorproc); +extern heaperror_t getheaperror(); +extern void setheaperror(heaperror_t heaperrorproc); +extern void releaseheaps(); +extern void releasegheap(); +extern void releaseoheap(); +extern void *galloc(SInt32 s); +extern void *lalloc(SInt32 s); +extern void *aalloc(SInt32 s); +extern void *oalloc(SInt32 s); +extern void *balloc(SInt32 s); + +extern void locklheap(); +extern void unlocklheap(); +extern void freelheap(); +extern void freeaheap(); +extern void freeoheap(); +extern void freebheap(); + +extern char *ScanHex(char *string, UInt32 *result, Boolean *overflow); +extern char *ScanOct(char *string, UInt32 *result, Boolean *overflow); +extern char *ScanDec(char *string, UInt32 *result, Boolean *overflow); + +extern void OldUnmangle(char *name, char *out, Boolean full); + +extern short hash(char *a); +extern void memclr(void *ptr, SInt32 size); +extern void memclrw(void *ptr, SInt32 size); +extern void CToLowercase(char *a, char *b); +extern short getbit(SInt32 l); +extern void CTool_EndianConvertWord64(CInt64 ci, char *result); +extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x); +extern UInt32 CTool_EndianConvertInPlaceWord32Ptr(UInt32 *x); +extern void CTool_EndianConvertVector128(); // not correct but idc +extern HashNameNode *CTool_GetPathName(const FSSpec *fss, SInt32 *moddateptr); +extern int strcat_safe(char *dest, const char *src, SInt32 len); + +#endif diff --git a/includes/compiler/common.h b/includes/compiler/common.h new file mode 100644 index 0000000..b5909e2 --- /dev/null +++ b/includes/compiler/common.h @@ -0,0 +1,283 @@ +#ifndef COMPILER_COMMON_H +#define COMPILER_COMMON_H + +#include "cw_common.h" + +typedef struct HashNameNode { + struct HashNameNode *next; + SInt32 id; + SInt16 hashval; + char name[1]; +} HashNameNode; + +typedef struct CPrepFileInfo CPrepFileInfo; + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif +// TODO move me into CPrep.h or something? +struct CPrepFileInfo { + FSSpec textfile; + HashNameNode *nameNode; + SInt32 fileModDate; + char *textbuffer; + SInt32 textlength; + SInt32 linenumber; + SInt32 pos; + Boolean hasprepline; + SInt16 fileID; + Boolean recordbrowseinfo; + Boolean unkfield123; + Boolean unkfield124; + Boolean unkfield125; + Boolean unkfield126; +}; +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +typedef struct CInt64 { + SInt32 hi; + UInt32 lo; +} CInt64; + +typedef struct Float { + double value; +} Float; + +typedef union MWVector128 { + UInt8 uc[16]; + UInt16 us[8]; + UInt32 ul[4]; + float f[4]; +} MWVector128; + +typedef enum AccessType { + ACCESSPUBLIC, + ACCESSPRIVATE, + ACCESSPROTECTED, + ACCESSNONE +} AccessType; + +typedef enum Section { + SECT_DEFAULT = 0, + SECT_TEXT = 1, + SECT_DATA = 2, + SECT_UDATA = 3, + SECT_DATA_FAR = 4, + SECT_DATA_NEAR = 5, + SECT_INIT = 6, + SECT_OBJC_CAT_CLS_METH = 7, + SECT_OBJC_CAT_INST_METH = 8, + SECT_OBJC_STRING_OBJECT = 9, + SECT_OBJC_CSTRING_OBJECT = 10, + SECT_OBJC_MESSAGE_REFS = 11, + SECT_OBJC_SEL_FIXUP = 12, + SECT_OBJC_CLS_REFS = 13, + SECT_OBJC_CLASS = 14, + SECT_OBJC_META_CLASS = 15, + SECT_OBJC_CLS_METH = 16, + SECT_OBJC_INST_METH = 17, + SECT_OBJC_PROTOCOL = 18, + SECT_OBJC_CLASS_NAMES = 19, + SECT_OBJC_METH_VAR_TYPES = 20, + SECT_OBJC_METH_VAR_NAMES = 21, + SECT_OBJC_CATEGORY = 22, + SECT_OBJC_CLASS_VARS = 23, + SECT_OBJC_INSTANCE_VARS = 24, + SECT_OBJC_MODULE_INFO = 25, + SECT_OBJC_MSYMBOLS = 26, + SECT_TEXT_CSTRING = 27, + SECT_BACKEND_SPECIFIC = 28, + SECT_MW_EX_TABLE = 28, + SECT_MW_EX_TABLE_INDEX = 29, + SECT_MW_SWITCH = 30, + SECT_8BYTE_LITERALS = 31, + SECT_4BYTE_LITERALS = 32, + SECT_MOD_INIT_FUNC = 33, + SECT_MOD_TERM_FUNC = 34, + SECT_CONST = 35, + SECT_CONST_PTR = 36, + SECT_NONLAZY_PTRS = 37, + SECT_COMMON_VARS = 38, + SECT_16BYTE_LITERALS = 39, + SECT_TEXT_COALESCE = 40, + SECT_DATA_COALESCE = 41, + SECT_UDATA_COALESCE = 42, + SECT_CONST_COALESCE = 43, + SECT_CONST_PTR_COALESCE = 44, + SECT_CSTR_COALESCE = 45, + N_SECTIONS = 46 +} Section; + +typedef struct BClassList BClassList; +typedef struct CI_FuncData CI_FuncData; +typedef struct CLabel CLabel; +typedef struct DefArgCtorInfo DefArgCtorInfo; +typedef struct DepName DepName; +typedef struct ENode ENode; +typedef struct ENodeList ENodeList; +typedef struct ExceptionAction ExceptionAction; +typedef struct ExtendedParam ExtendedParam; +typedef struct FuncArg FuncArg; +typedef struct Initializer Initializer; +typedef struct InlineXRef InlineXRef; +typedef struct MemInitializer MemInitializer; +typedef struct NameSpace NameSpace; +typedef struct NameSpaceName NameSpaceName; +typedef struct NameSpaceList NameSpaceList; +typedef struct NameSpaceLookupList NameSpaceLookupList; +typedef struct NameSpaceObjectList NameSpaceObjectList; +typedef struct ObjBase ObjBase; +typedef struct ObjEnumConst ObjEnumConst; +typedef struct ObjMemberVar ObjMemberVar; +typedef struct ObjMemberVarPath ObjMemberVarPath; +typedef struct ObjNameSpace ObjNameSpace; +typedef struct ObjType ObjType; +typedef struct ObjTypeTag ObjTypeTag; +typedef struct Object Object; +typedef struct ObjectList ObjectList; +typedef struct ObjCInfo ObjCInfo; +typedef struct ObjCMethod ObjCMethod; +typedef struct PCodeLabel PCodeLabel; +typedef struct PointsToFunction PointsToFunction; +typedef struct PTFList PTFList; +typedef struct SOMInfo SOMInfo; +typedef struct Statement Statement; +typedef struct StructMember StructMember; +typedef struct Template Template; +typedef struct TemplateAction TemplateAction; +typedef struct TemplateFriend TemplateFriend; +typedef struct TemplateMember TemplateMember; +typedef struct TemplArg TemplArg; +typedef struct TemplClass TemplClass; +typedef struct TemplClassInst TemplClassInst; +typedef struct TemplateFunction TemplateFunction; +typedef struct TemplFuncInstance TemplFuncInstance; +typedef struct TemplInstance TemplInstance; +typedef struct TemplParam TemplParam; +typedef struct TemplPartialSpec TemplPartialSpec; +typedef struct TemplStack TemplStack; +typedef struct TStream TStream; +typedef struct TStreamElement TStreamElement; +typedef struct Type Type; +typedef struct TypeBitfield TypeBitfield; +typedef struct TypeClass TypeClass; +typedef struct TypeEnum TypeEnum; +typedef struct TypeFunc TypeFunc; +typedef struct TypeIntegral TypeIntegral; +typedef struct TypeMemberPointer TypeMemberPointer; +typedef struct TypeMethod TypeMethod; +typedef struct TypePointer TypePointer; +typedef struct TypeStruct TypeStruct; +typedef struct TypeTemplDep TypeTemplDep; +typedef struct VarInfo VarInfo; +typedef struct VarRecord VarRecord; + +// Common bits for templates +typedef enum TemplParamType { + TPT_TYPE = 0, + TPT_NONTYPE, + TPT_TEMPLATE +} TemplParamType; + +typedef struct TemplParamID { + UInt16 index; + UInt8 nindex; + TemplParamType type; +} TemplParamID; + +typedef enum TemplDepSubType { + TDE_PARAM, + TDE_TYPEEXPR, + TDE_CAST, + TDE_QUALNAME, + TDE_QUALTEMPL, + TDE_OBJACCESS, + TDE_SOURCEREF, + TDE_FUNCCALL, + TDE_LOCAL, + TDE_MONAND, + TDE_MONPLUS, + TDE_MONMUL, + TDE_NEW, + TDE_DELETE, + TDE_ARRAY, + TDE_DYNAMIC_CAST, + TDE_STATIC_CAST, + TDE_REINTERPRET_CAST, + TDE_CONST_CAST, + TDE_TYPEID, + TDE_MEMBERACCESS, + TDE_THROW, + TDE_EXCEPTIONINIT, + TDE_LOCALINIT, + TDE_STATICINIT, + TDE_LOCALDESTROY, + TDE_ILLEGAL +} TemplDepSubType; + +/// Things that can be applied to a type expression +typedef enum TEFuncSel { + TEFS_SIZEOF, + TEFS_ALIGNOF, + TEFS_UUIDOF, + TEFS_BI_ALIGN, + TEFS_BI_TYPE, + TEFS_BI_VTYPE, + TEFS_BI_CTYPE +} TEFuncSel; + +/// How to access an object +/// this might not actually be in Pro7 lol +typedef struct ObjAccess { + NameSpaceObjectList *list; + TypeClass *naming; + TypeClass *member; + TemplArg *targs; + HashNameNode *name; + ENode *expr; + Boolean is_qualified; + Boolean is_member; + Boolean is_ambig : 1; + Boolean is_ptm : 1; + Boolean ext_only : 1; +} ObjAccess; + +/// Qualifiers +enum { + Q_CONST = 1, + Q_VOLATILE = 2, + Q_ASM = 4, + Q_PASCAL = 8, + Q_INLINE = 0x10, + Q_REFERENCE = 0x20, + Q_EXPLICIT = 0x40, + Q_MUTABLE = 0x80, + Q_VIRTUAL = 0x100, + Q_FRIEND = 0x200, + Q_IN = 0x400, + Q_OUT = 0x800, + Q_INOUT = 0x1000, + Q_BYCOPY = 0x2000, + Q_BYREF = 0x4000, + Q_ONEWAY = 0x8000, + Q_RESTRICT = 0x200000, + Q_ALIGNED_1 = 0x2000000, + Q_ALIGNED_2 = 0x4000000, + Q_ALIGNED_4 = 0x6000000, + Q_ALIGNED_8 = 0x8000000, + Q_ALIGNED_16 = 0xA000000, + Q_ALIGNED_32 = 0xC000000, + Q_ALIGNED_64 = 0x10000000, + Q_ALIGNED_128 = 0x12000000, + Q_ALIGNED_256 = 0x14000000, + Q_ALIGNED_512 = 0x16000000, + Q_ALIGNED_1024 = 0x18000000, + Q_ALIGNED_2048 = 0x1A000000, + Q_ALIGNED_4096 = 0x1C000000, + Q_ALIGNED_8192 = 0x1E000000, + Q_ALIGNED_MASK = 0x1E000000 +}; + +#endif diff --git a/includes/compiler/enode.h b/includes/compiler/enode.h new file mode 100644 index 0000000..6e0ab2c --- /dev/null +++ b/includes/compiler/enode.h @@ -0,0 +1,264 @@ +#ifndef COMPILER_ENODE_H +#define COMPILER_ENODE_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef enum ENodeType { + EPOSTINC, + EPOSTDEC, + EPREINC, + EPREDEC, + EINDIRECT, + EMONMIN, + EBINNOT, + ELOGNOT, + EFORCELOAD, + EMUL, + EMULV, + EDIV, + EMODULO, + EADDV, + ESUBV, + EADD, + ESUB, + ESHL, + ESHR, + ELESS, + EGREATER, + ELESSEQU, + EGREATEREQU, + EEQU, + ENOTEQU, + EAND, + EXOR, + EOR, + ELAND, + ELOR, + EASS, + EMULASS, + EDIVASS, + EMODASS, + EADDASS, + ESUBASS, + ESHLASS, + ESHRASS, + EANDASS, + EXORASS, + EORASS, + ECOMMA, + EPMODULO, + EROTL, + EROTR, + EBCLR, + EBTST, + EBSET, + ETYPCON, + EBITFIELD, + EINTCONST, + EFLOATCONST, + ESTRINGCONST, + ECOND, + EFUNCCALL, + EFUNCCALLP, + EOBJREF, + EMFPOINTER, + ENULLCHECK, + EPRECOMP, + ETEMP, + EARGOBJ, + ELOCOBJ, + ELABEL, + ESETCONST, + ENEWEXCEPTION, + ENEWEXCEPTIONARRAY, + EOBJLIST, + EMEMBER, + ETEMPLDEP, + EINSTRUCTION, + EDEFINE, + EREUSE, + EASSBLK, + EVECTOR128CONST, + ECONDASS, + MAXEXPR +} ENodeType; + + +struct ENodeList { + ENodeList *next; + ENode *node; +}; + + +typedef union ENodeUnion { + CInt64 intval; + Float floatval; + SInt32 longval; + ENode *monadic; + Object *objref; + CLabel *label; + MWVector128 vector128val; + struct { + ENode *left; + ENode *right; + } diadic; + struct { + ENode *cond; + ENode *expr1; + ENode *expr2; + } cond; + struct { + ENode *funcref; + ENodeList *args; + TypeFunc *functype; + } funccall; + ObjAccess objaccess; + struct { + ENode *accessnode; + ENode *mfpointer; + } mfpointer; + struct { + ENode *nullcheckexpr; + ENode *condexpr; + SInt32 precompid; + } nullcheck; + SInt32 precompid; + struct { + Type *type; + SInt32 uniqueid; + Boolean needs_dtor; + } temp; + struct { + SInt32 size; + char *data; + SInt32 segnum; + char ispascal; + char ispacked; + } string; + struct { + SInt32 size; + char *data; + } set; + struct { + ENode *initexpr; + ENode *tryexpr; + Object *pointertemp; + Object *deletefunc; + } newexception; + struct { + ENode *initexpr; + ENode *tryexpr; + ENode *catchexpr; + ENode *result; + } itc; + struct { + Object *objref; + SInt32 offset; + } addr; + void *inst; + MemInitializer *ctorinit; + Statement *stmt; + struct { + union { + TemplParamID pid; + struct { + union { + Type *type; + ENode *expr; + } u; + TEFuncSel sel; + Boolean is_expr; + } typeexpr; + struct { + ENodeList *args; + Type *type; + UInt32 qual; + } cast; + struct { + TypeTemplDep *type; + HashNameNode *name; + } qual; + struct { + TypeTemplDep *type; + HashNameNode *name; + TemplArg *args; + } qualtempl; + ObjAccess objaccess; + struct { + ENode *expr; + TStreamElement *token; + } sourceref; + ENode *monadic; + struct { + ENode *expr; + ENodeList *args; + } funccall; + struct { + Type *type; + UInt32 qual; + ENode *arraydim; + ENodeList *placement; + ENodeList *initlist; + Boolean is_global; + Boolean has_init; + } nw; + struct { + ENode *expr; + Boolean is_global; + Boolean is_array; + } del; + struct { + ENode *left; + ENode *right; + } dyadic; + struct { + ENode *expr; + Type *type; + UInt32 qual; + } newcast; + struct { + ENode *expr; + DepName *dname; + Boolean is_pointer; + } member; + struct { + Object *object; + Object *info; + } exinit; + struct { + Object *obj; + Initializer *init; + } varinit; + Object *obj; + } u; + TemplDepSubType subtype; + } templdep; +} ENodeUnion; + +struct ENode { + ENodeType type; + UInt8 cost; + UInt16 flags; // &1, &2 correspond to quals + Boolean ignored; + Boolean hascall; + // void *loc; - might not be in pro7? + Type *rtype; + PointsToFunction *pointsTo; + ENodeUnion data; +}; + +enum { + ENODE_FLAG_CONST = Q_CONST, + ENODE_FLAG_VOLATILE = Q_VOLATILE, + ENODE_FLAG_QUALS = Q_CONST | Q_VOLATILE +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/objc.h b/includes/compiler/objc.h new file mode 100644 index 0000000..ce3ebe4 --- /dev/null +++ b/includes/compiler/objc.h @@ -0,0 +1,80 @@ +#ifndef COMPILER_OBJC_H +#define COMPILER_OBJC_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef struct ObjCMethodArg { // bigger in v7 (0x20 vs 0x14) + struct ObjCMethodArg *next; + HashNameNode *selector; + HashNameNode *name; + Type *type; + UInt32 qual; + UInt32 unk14; + UInt32 unk18; + UInt32 unk1C; +} ObjCMethodArg; + +typedef struct ObjCMethodList { // verified via CPrec + struct ObjCMethodList *next; + struct ObjCMethod *method; +} ObjCMethodList; + +typedef struct ObjCSelector { // verified via CPrec + struct ObjCSelector *next; + Object *selobject; + HashNameNode *name; + struct ObjCMethodList *methods; +} ObjCSelector; + +typedef struct ObjCMethod { // verified via CPrec + struct ObjCMethod *next; + Object *object; + TypeFunc *functype; + ObjCSelector *selector; + Type *return_type; + UInt32 return_qual; + ObjCMethodArg *selector_args; + Boolean has_valist; + Boolean is_class_method; + Boolean is_defined; +} ObjCMethod; + +typedef struct ObjCProtocol { // verified via CPrec + struct ObjCProtocol *next; + HashNameNode *name; + struct ObjCProtocolList *protocols; + ObjCMethod *methods; + Object *object; +} ObjCProtocol; + +typedef struct ObjCProtocolList { // verified via CPrec + struct ObjCProtocolList *next; + ObjCProtocol *protocol; +} ObjCProtocolList; + +typedef struct ObjCCategory { // verified via CPrec + struct ObjCCategory *next; + HashNameNode *name; + ObjCProtocolList *protocols; + ObjCMethod *methods; +} ObjCCategory; + +struct ObjCInfo { // verified via CPrec + Object *classobject; + Object *metaobject; + Object *classrefobj; + ObjCMethod *methods; + ObjCProtocolList *protocols; + ObjCCategory *categories; + Boolean is_implemented; +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h new file mode 100644 index 0000000..32552ec --- /dev/null +++ b/includes/compiler/objects.h @@ -0,0 +1,200 @@ +#ifndef COMPILER_OBJECTS_H +#define COMPILER_OBJECTS_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef enum ObjectType { + OT_ENUMCONST, + OT_TYPE, + OT_TYPETAG, + OT_NAMESPACE, + OT_MEMBERVAR, + OT_OBJECT, + OT_ILLEGAL +} ObjectType; + + +struct ObjectList { + ObjectList *next; + Object *object; +}; + + +/// General structure with all shared fields for all kinds of objects +struct ObjBase { + ObjectType otype; + AccessType access; +}; + + +/// Type 0 (OT_ENUMCONST) +struct ObjEnumConst { + ObjectType otype; + AccessType access; + ObjEnumConst *next; + HashNameNode *name; + Type *type; + CInt64 val; +}; + + +/// Type 1 (OT_TYPE) +struct ObjType { + ObjectType otype; + AccessType access; + Type *type; + void *unk6; +}; + + +/// Type 2 (OT_TYPETAG) +struct ObjTypeTag { + ObjectType otype; + AccessType access; + Type *type; +}; + + +/// Type 3 (OT_NAMESPACE) +struct ObjNameSpace { + ObjectType otype; + AccessType access; + NameSpace *nspace; +}; + + +/// Type 4 (OT_MEMBERVAR) +struct ObjMemberVar { + ObjectType otype; + AccessType access; + Boolean anonunion; + Boolean has_path; + struct ObjMemberVar *next; + HashNameNode *name; + Type *type; + UInt32 qual; + UInt32 offset; +}; +struct ObjMemberVarPath { + ObjectType otype; + AccessType access; + Boolean anonunion; + Boolean has_path; + struct ObjMemberVar *next; + HashNameNode *name; + Type *type; + UInt32 qual; + UInt32 offset; + BClassList *path; +}; + + +typedef enum DataType { + DDATA, + DLOCAL, + DABSOLUTE, + DFUNC, + DVFUNC, + DINLINEFUNC, + DALIAS, + DEXPR, + DNONLAZYPTR, + DLABEL, + DUNUSED +} DataType; + +/// Type 5 (OT_OBJECT) +struct Object { + ObjectType otype; + AccessType access; + DataType datatype; + Section section; + NameSpace *nspace; + HashNameNode *name; + Type *type; + UInt32 qual; + SInt16 sclass; + UInt8 flags; + ExtendedParam *extParam; + Object *toc; + void *any; + //char reg; // notsure? + //VarRecord *varptr; // notsure? + // union starts at 0x24 in v7 + union { + struct { + union { + CInt64 intconst; + Float *floatconst; + MWVector128 *vector128const; + char *string; + struct { + char *data; + SInt32 size; + } switchtable; + } u; + VarInfo *info; + HashNameNode *linkname; + Boolean islocalstatic; + } data; + UInt32 address; + struct { + VarInfo *info; + HashNameNode *linkname; + Object *over_load; + } toc; + struct { + union { + TemplateFunction *templ; + CI_FuncData *ifuncdata; + SInt32 intrinsicid; + } u; + DefArgCtorInfo *defargdata; + HashNameNode *linkname; + TemplFuncInstance *inst; + PTFList *ptfList; + ObjectList *argList; + } func; + struct { + char *data; + SInt32 size; + InlineXRef *xrefs; + } ifunc; + struct { + VarInfo *info; + SInt32 uid; + SInt32 offset; + Object *realObj; + } var; + struct { + Object *object; + //TypeClass *member; + BClassList *member; // ??? + SInt32 offset; + } alias; + struct { + Object *function; + HashNameNode *labelname; + } label; + ENode *expr; + } u; +}; + +#define OBJ_BASE(obj) ((ObjBase *) (obj)) +#define OBJ_ENUM_CONST(obj) ((ObjEnumConst *) (obj)) +#define OBJ_TYPE(obj) ((ObjType *) (obj)) +#define OBJ_TYPE_TAG(obj) ((ObjTypeTag *) (obj)) +#define OBJ_NAMESPACE(obj) ((ObjNameSpace *) (obj)) +#define OBJ_MEMBER_VAR(obj) ((ObjMemberVar *) (obj)) +#define OBJ_MEMBER_VAR_PATH(obj) ((ObjMemberVarPath *) (obj)) +#define OBJECT(obj) ((Object *) (obj)) + +#endif + +#ifdef __MWERKS__ +#pragma options align=reset +#endif diff --git a/includes/compiler/scopes.h b/includes/compiler/scopes.h new file mode 100644 index 0000000..ea2ae98 --- /dev/null +++ b/includes/compiler/scopes.h @@ -0,0 +1,53 @@ +#ifndef COMPILER_SCOPES_H +#define COMPILER_SCOPES_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +struct NameSpace { + NameSpace *parent; + HashNameNode *name; + NameSpaceList *usings; + TypeClass *theclass; + NameSpaceName *tparams; + union { + NameSpaceName **hash; + NameSpaceName *list; + } data; + UInt32 names; + Boolean is_hash; + Boolean is_global; + Boolean is_unnamed; + Boolean is_templ; +}; + +struct NameSpaceList { + NameSpaceList *next; + NameSpace *nspace; +}; + +struct NameSpaceObjectList { + NameSpaceObjectList *next; + ObjBase *object; +}; + +struct NameSpaceName { + NameSpaceName *next; + HashNameNode *name; + NameSpaceObjectList first; +}; + +struct NameSpaceLookupList { // assumed name + NameSpaceLookupList *next; + NameSpace *nspace; + NameSpaceList *namespaces; +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/som.h b/includes/compiler/som.h new file mode 100644 index 0000000..ab541ef --- /dev/null +++ b/includes/compiler/som.h @@ -0,0 +1,35 @@ +#ifndef COMPILER_SOM_H +#define COMPILER_SOM_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef enum SOMMethodState { + SOMMS_Deleted, + SOMMS_Method, + SOMMS_Migrated +} SOMMethodState; + +typedef struct SOMReleaseOrder { // checked via CPrec + struct SOMReleaseOrder *next; + HashNameNode *name; + SOMMethodState state; +} SOMReleaseOrder; + +struct SOMInfo { // checked via CPrec + TypeClass *metaclass; + Object *classdataobject; + SOMReleaseOrder *order; + UInt32 majorversion; + UInt32 minorversion; + UInt8 oidl_callstyle; +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/templates.h b/includes/compiler/templates.h new file mode 100644 index 0000000..f188e0d --- /dev/null +++ b/includes/compiler/templates.h @@ -0,0 +1,237 @@ +#ifndef COMPILER_TEMPLATES_H +#define COMPILER_TEMPLATES_H + +#include "compiler/common.h" +#include "compiler/types.h" +#include "compiler/tokens.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef struct PackedDeclInfo { // ok + Type *thetype; + UInt32 qual; + NameSpace *nspace; + HashNameNode *name; + TemplArg *expltargs; + SInt16 storageclass; + Section section; + UInt8 exportflags; + Boolean has_expltargs; +} PackedDeclInfo; + +struct Template { + Template *parent; + TemplInstance *parentinst; + TemplParam *params; + Boolean is_class; +}; + +struct TemplateFriend { // verified via CPrec + PackedDeclInfo decl; + FileOffsetInfo fileoffset; + TStream stream; +}; + +struct TemplateMember { // verified via CPrec + struct TemplateMember *next; + TemplParam *params; + Object *object; + FileOffsetInfo fileoffset; + TStream stream; + CPrepFileInfo *srcfile; + SInt32 startoffset; + SInt32 endoffset; +}; + +struct TemplInstance { + // Template *templ; + TemplInstance *parent; + TemplArg *args; + Boolean is_instantiated; + Boolean is_specialized; + Boolean is_extern; + Boolean static_instantiated; +}; +/* +struct __attribute__((packed)) TemplInstance +{ + Template *templ; + TemplInstance *parent; + TemplArg *args; + unsigned __int8 is_instantiated; + unsigned __int8 is_specialized; + unsigned __int8 is_extern; + unsigned __int8 static_instantiated; +}; + + */ + +struct TemplParam { // verified via CPrec + TemplParam *next; + HashNameNode *name; + TemplParamID pid; + union { + struct { + Type *type; + UInt32 qual; + } typeparam; + struct { + Type *type; + UInt32 qual; + ENode *defaultarg; + } paramdecl; + struct { + TemplParam *plist; + Type *defaultarg; + } templparam; + } data; +}; + +struct TemplArg { // verified by CPrec + TemplArg *next; + TemplParamID pid; + union { + struct { + Type *type; + UInt32 qual; + } typeparam; + struct { + ENode *expr; + Boolean is_ref; + } paramdecl; + Type *ttargtype; + } data; + Boolean is_deduced; +}; + +struct TemplPartialSpec { // confirmed via CPrec (but templ might be a different type?) + TemplPartialSpec *next; + TemplClass *templ; + TemplArg *args; +}; + +struct TemplStack { + TemplStack *next; + union { + Object *func; + TypeClass *theclass; + } u; + Boolean is_func; + Boolean is_poi; +}; + +/***********/ +/* Classes */ +/***********/ + +struct TemplClass { + TypeClass theclass; + TemplClass *next; + TemplClass *templ__parent; + Type *x3A_maybe_parentinst; + TemplParam *templ__params; + TemplateMember *members; + TemplClassInst *instances; + TemplClass *pspec_owner; + TemplPartialSpec *pspecs; + TemplateAction *actions; + // not confirmed these last 3 fields yet but there is space for them + UInt16 lex_order_count; + SInt8 align; + UInt8 flags; +}; + +struct TemplClassInst { + TypeClass theclass; + TemplClassInst *next; + Type *x36; // not sure what this represents + TemplClass *templ; + TemplArg *inst_args; + TemplArg *oargs; + void *x46; +}; + +#define TEMPL_CLASS(ty) ( (TemplClass *) (ty) ) +#define TEMPL_CLASS_INST(ty) ( (TemplClassInst *) (ty) ) + +/*************/ +/* Functions */ +/*************/ + +struct TemplateFunction { // verified via CPrec + TemplateFunction *next; + TemplateFunction *unk4; // parent? + HashNameNode *name; + TemplParam *params; + TStream stream; + TStreamElement deftoken; + Object *tfunc; + TemplFuncInstance *instances; + CPrepFileInfo *srcfile; + SInt32 startoffset; + SInt32 endoffset; +}; + +struct TemplFuncInstance { // verified via CPrec + TemplFuncInstance *next; + Object *object; + TemplArg *args; + Boolean is_instantiated; + Boolean is_specialized; + Boolean is_extern; + Boolean static_instantiated; +}; + +/***********/ +/* Actions */ +/***********/ + +typedef enum TemplateActionType { + TAT_NESTEDCLASS, + TAT_ENUMTYPE, + TAT_FRIEND, + TAT_ENUMERATOR, // in pro7 but not pro8 + TAT_BASE, + TAT_OBJECTINIT, + TAT_USINGDECL, + TAT_OBJECTDEF, + TAT_ILLEGAL +} TemplateActionType; + +struct TemplateAction { // verified via CPrec + TemplateAction *next; + TStreamElement source_ref; + union { + TemplClass *tclasstype; + TypeEnum *enumtype; + TemplateFriend *tfriend; + struct { + ObjEnumConst *objenumconst; + ENode *initexpr; + } enumerator; + struct { + Type *type; + ClassList *insert_after; + AccessType access; + Boolean is_virtual; + } base; + struct { + Object *object; + ENode *initexpr; + } objectinit; + struct { + TypeTemplDep *type; + AccessType access; + } usingdecl; + ObjBase *refobj; + } u; + TemplateActionType type; +}; + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/compiler/tokens.h b/includes/compiler/tokens.h new file mode 100644 index 0000000..b574a81 --- /dev/null +++ b/includes/compiler/tokens.h @@ -0,0 +1,182 @@ +#ifndef COMPILER_TOKENS_H +#define COMPILER_TOKENS_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +#define TKD_OPERATOR 328 +#define TKD_TEMPLATE 332 +#define TKD_IDENTIFIER -3 +#define TKD_COLON_COLON 372 + +typedef enum EToken { + TK_INTCONST = -1, + TK_FLOATCONST = -2, + TK_IDENTIFIER = -3, + TK_STRING = -4, + TK_STRING_WIDE = -5, + TK_NEG6 = -6, + TK_NEG7 = -7, + TK_AUTO = 256, + TK_REGISTER, + TK_STATIC, + TK_EXTERN, + TK_TYPEDEF, + TK_INLINE, + TK_VOID, + TK_CHAR, + TK_SHORT, + TK_INT, + TK_LONG, + TK_FLOAT, + TK_DOUBLE, + TK_SIGNED, + TK_UNSIGNED, + TK_STRUCT, + TK_UNION, + TK_ENUM, + TK_CLASS, + TK_UU_VECTOR = 283, + TK_UU_TYPEOF_UU, + TK_BOOL, + TK_WCHAR_T, + TK_U_COMPLEX, + TK_U_IMAGINARY, + TK_TYPENAME, + TK_CONST, + TK_VOLATILE, + TK_PASCAL, + TK_UU_DECLSPEC, + TK_UU_STDCALL, + TK_UU_CDECL, + TK_UU_FASTCALL, + TK_UU_FAR, + TK_EXPLICIT, + TK_MUTABLE, + TK_ONEWAY, + TK_IN, + TK_INOUT, + TK_OUT, + TK_BYCOPY, + TK_BYREF, + TK_ASM = 310, + TK_CASE, + TK_DEFAULT, + TK_IF, + TK_ELSE, + TK_SWITCH, + TK_WHILE, + TK_DO, + TK_FOR, + TK_GOTO, + TK_CONTINUE, + TK_BREAK, + TK_RETURN, + TK_SIZEOF, + TK_CATCH, + TK_DELETE, + TK_FRIEND, + TK_NEW, + TK_OPERATOR, + TK_PRIVATE, + TK_PROTECTED, + TK_PUBLIC, + TK_TEMPLATE, + TK_THIS, + TK_THROW, + TK_TRY, + TK_VIRTUAL, + TK_INHERITED, + TK_CONST_CAST, + TK_DYNAMIC_CAST, + TK_NAMESPACE, + TK_REINTERPRET_CAST, + TK_STATIC_CAST, + TK_USING, + TK_TRUE, + TK_FALSE, + TK_TYPEID, + TK_EXPORT, + TK_MULT_ASSIGN, + TK_DIV_ASSIGN, + TK_MOD_ASSIGN, + TK_ADD_ASSIGN, + TK_SUB_ASSIGN, + TK_SHL_ASSIGN, + TK_SHR_ASSIGN, + TK_AND_ASSIGN, + TK_XOR_ASSIGN, + TK_OR_ASSIGN, + TK_LOGICAL_OR, + TK_LOGICAL_AND, + TK_LOGICAL_EQ, + TK_LOGICAL_NE, + TK_LESS_EQUAL, + TK_GREATER_EQUAL, + TK_SHL, + TK_SHR, + TK_INCREMENT, + TK_DECREMENT, + TK_ARROW, + TK_ELLIPSIS, + TK_DOT_STAR, + TK_ARROW_STAR, + TK_COLON_COLON, + TK_AT_INTERFACE, + TK_AT_IMPLEMENTATION, + TK_AT_PROTOCOL, + TK_AT_END, + TK_AT_PRIVATE, + TK_AT_PROTECTED, + TK_AT_PUBLIC, + TK_AT_CLASS, + TK_AT_SELECTOR, + TK_AT_ENCODE, + TK_AT_DEFS, + TK_SELF, + TK_SUPER, + TK_UU_ALIGNOF_UU = 388, + TK_RESTRICT, + TK_UU_ATTRIBUTE_UU, + TK_UU_UUIDOF +} EToken; + +typedef struct FileOffsetInfo { + CPrepFileInfo *file; + SInt32 offset; + SInt32 tokenoffset; + Boolean is_inline; +} FileOffsetInfo; + +typedef union TData { + HashNameNode *tkidentifier; + CInt64 tkintconst; + Float tkfloatconst; + struct { + char *data; + SInt32 size; + } tkstring; +} TData; + +struct TStreamElement { + SInt16 tokentype; + SInt16 subtype; + CPrepFileInfo *tokenfile; + SInt32 tokenoffset; + SInt32 tokenline; + TData data; +}; + +struct TStream { + SInt32 tokens; + TStreamElement *firsttoken; +}; + +#endif + +#ifdef __MWERKS__ +#pragma options align=reset +#endif diff --git a/includes/compiler/types.h b/includes/compiler/types.h new file mode 100644 index 0000000..9b07590 --- /dev/null +++ b/includes/compiler/types.h @@ -0,0 +1,324 @@ +#ifndef COMPILER_TYPES_H +#define COMPILER_TYPES_H + +#include "compiler/common.h" + +#ifdef __MWERKS__ +#pragma options align=mac68k +#endif + +typedef enum TypeType { + TYPEVOID = 0, + TYPEINT, + TYPEFLOAT, + TYPEENUM, + TYPESTRUCT, + TYPECLASS, + TYPEFUNC, + TYPEBITFIELD, + TYPELABEL, + TYPETEMPLATE, + TYPEMEMBERPOINTER, + TYPEPOINTER, + TYPEARRAY, + TYPEOBJCID, + TYPETEMPLDEPEXPR, + TYPEILLEGAL = -1 +} TypeType; + + +/// Common fields across all kinds of types +struct Type { + TypeType type; + SInt32 size; +}; + + +typedef enum IntegralType { + IT_BOOL = 0, + IT_CHAR = 1, + IT_SCHAR = 2, + IT_UCHAR = 3, + IT_WCHAR_T = 4, + IT_SHORT = 5, + IT_USHORT = 6, + IT_INT = 7, + IT_UINT = 8, + IT_LONG = 9, + IT_ULONG = 10, + IT_LONGLONG = 11, + IT_ULONGLONG = 12, + IT_FLOAT = 13, + IT_SHORTDOUBLE = 14, + IT_DOUBLE = 15, + IT_LONGDOUBLE = 16 +} IntegralType; + +struct TypeIntegral { + TypeType type; + SInt32 size; + unsigned char integral; +}; + + +struct TypeEnum { // checked via CPrec + TypeType type; + SInt32 size; + NameSpace *nspace; + ObjEnumConst *enumlist; + Type *enumtype; + HashNameNode *enumname; +}; + + +struct TypeStruct { + TypeType type; + SInt32 size; + HashNameNode *name; + StructMember *members; + char stype; + SInt16 align; +}; +struct StructMember { + StructMember *next; + Type *type; + HashNameNode *name; + SInt32 offset; + UInt32 qual; +}; + +enum { + STRUCT_TYPE_STRUCT = 0, + STRUCT_TYPE_UNION = 1, + STRUCT_TYPE_4 = 4, + STRUCT_TYPE_5 = 5, + STRUCT_TYPE_6 = 6, + STRUCT_TYPE_7 = 7, + STRUCT_TYPE_8 = 8, + STRUCT_TYPE_9 = 9, + STRUCT_TYPE_A = 10, + STRUCT_TYPE_B = 11, + STRUCT_TYPE_C = 12, + STRUCT_TYPE_D = 13, + STRUCT_TYPE_E = 14 +}; + + +typedef struct ClassList { // checked via CPrec + struct ClassList *next; + TypeClass *base; + SInt32 offset; + SInt32 voffset; + AccessType access; + Boolean is_virtual; +} ClassList; + +typedef struct VClassList { // checked via CPrec + struct VClassList *next; + TypeClass *base; + SInt32 offset; + SInt32 voffset; + Boolean has_override; + char alignsave; +} VClassList; + +typedef struct ClassFriend { // checked via CPrec + struct ClassFriend *next; + union { + TypeClass *theclass; + Object *obj; + } u; + Boolean isclass; +} ClassFriend; + +struct BClassList { // checked via CPrec + struct BClassList *next; + Type *type; +}; + +typedef struct VTable { // checked via CPrec + Object *object; + TypeClass *owner; + SInt32 offset; + SInt32 size; +} VTable; + +struct TypeClass { + TypeType type; + SInt32 size; + NameSpace *nspace; + HashNameNode *classname; + ClassList *bases; + VClassList *vbases; + ObjMemberVar *ivars; + ClassFriend *friends; + VTable *vtable; + SOMInfo *sominfo; + ObjCInfo *objcinfo; + UInt16 flags; + SInt8 mode; + SInt8 action; + SInt16 align; + UInt8 eflags; +}; + +enum { + CLASS_FLAGS_2 = 2, + CLASS_FLAGS_20 = 0x20, + CLASS_FLAGS_100 = 0x100, // is TemplClass + CLASS_FLAGS_800 = 0x800, // is TemplClassInst + CLASS_FLAGS_900 = 0x900 +}; + + +typedef struct ExceptSpecList { + struct ExceptSpecList *next; + Type *type; + UInt32 qual; +} ExceptSpecList; + +struct FuncArg { // ok + struct FuncArg *next; + HashNameNode *name; + ENode *dexpr; + Type *type; + UInt32 qual; + SInt16 sclass; + Boolean is_array; + Boolean has_defdefarg; +}; + +struct TypeFunc { + TypeType type; + SInt32 size; + FuncArg *args; + ExceptSpecList *exspecs; + Type *functype; + UInt32 qual; + UInt32 flags; +}; +enum { + FUNC_FLAGS_PASCAL = 1, // on TypeFunc::flags + FUNC_FLAGS_METHOD = 0x10, + FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()" + FUNC_FLAGS_1000 = 0x1000, + FUNC_FLAGS_2000 = 0x2000, + FUNC_FLAGS_100000 = 0x100000, + FUNC_FLAGS_900000 = 0x900000 +}; + +// There seems to be a version of this which adds a class pointer at the end +struct TypeMethod { + TypeType type; + SInt32 size; + FuncArg *args; + ExceptSpecList *exspecs; + Type *functype; + UInt32 qual; + UInt32 flags; + TypeClass *theclass; + void *x1E; + void *x22; + Boolean x26; +}; + + +struct TypeBitfield { + TypeType type; + SInt32 size; + Type *bitfieldtype; + unsigned char unkA; + char unkB; +}; + + +// Label + + +typedef enum TypeTemplDepType { + TEMPLDEP_ARGUMENT, + TEMPLDEP_QUALNAME, + TEMPLDEP_TEMPLATE, + TEMPLDEP_ARRAY, + TEMPLDEP_QUALTEMPL, + TEMPLDEP_BITFIELD, + TEMPLDEP_VALUEDEP, // not in v7? + TEMPLDEP_ENUMVAL, // not in v7? + TEMPLDEP_TYPEOF // not in v7? +} TypeTemplDepType; + +struct TypeTemplDep { + TypeType type; + SInt32 size; + TypeTemplDepType dtype; + union { + TemplParamID pid; + struct { + TypeTemplDep *type; + HashNameNode *name; + } qual; + struct { + TemplClass *templ; + TemplArg *args; + } templ; + struct { + Type *type; + ENode *index; + } array; + struct { + TypeTemplDep *type; + TemplArg *args; + } qualtempl; + struct { + Type *type; + ENode *size; + } bitfield; + // the following ones may not be in v7 + Type *vdep; + ENode *tof; + struct { + TypeEnum *etype; + ENode *expr; + } enumval; + } u; +}; + + +struct TypeMemberPointer { + TypeType type; + SInt32 size; + Type *ty1; + Type *ty2; + UInt32 qual; +}; + + +/// Used for TYPEPOINTER and TYPEARRAY +struct TypePointer { + TypeType type; + SInt32 size; + Type *target; + UInt32 qual; +}; + + +// ObjCID + + +// Not sure if these existed originally, but they'll help +#define TYPE_INTEGRAL(ty) ((TypeIntegral *) (ty)) +#define TYPE_ENUM(ty) ((TypeEnum *) (ty)) +#define TYPE_STRUCT(ty) ((TypeStruct *) (ty)) +#define TYPE_CLASS(ty) ((TypeClass *) (ty)) +#define TYPE_FUNC(ty) ((TypeFunc *) (ty)) +#define TYPE_METHOD(ty) ((TypeMethod *) (ty)) +#define TYPE_BITFIELD(ty) ((TypeBitfield *) (ty)) +#define TYPE_TEMPLATE(ty) ((TypeTemplDep *) (ty)) +#define TYPE_MEMBER_POINTER(ty) ((TypeMemberPointer *) (ty)) +#define TYPE_POINTER(ty) ((TypePointer *) (ty)) + +#ifdef __MWERKS__ +#pragma options align=reset +#endif + +#endif diff --git a/includes/cw_common.h b/includes/cw_common.h index bea498a..eb016f1 100644 --- a/includes/cw_common.h +++ b/includes/cw_common.h @@ -1,4 +1,5 @@ -#pragma once +#ifndef ROOT_CW_COMMON_H +#define ROOT_CW_COMMON_H /* * Things that seem to be shared across different CodeWarrior modules @@ -41,3 +42,5 @@ typedef struct ParserPluginCallbacks { CWPLUGIN_ENTRY (*SupportsPlugin)(const CLPluginInfo *pluginfo, OSType cpu, OSType os, Boolean *isSupported); CWPLUGIN_ENTRY (*SupportsPanels)(int numPanels, const char **panelNames, Boolean *isSupported); } ParserPluginCallbacks; + +#endif diff --git a/includes/oslib.h b/includes/oslib.h index dfa3827..9aedb8d 100644 --- a/includes/oslib.h +++ b/includes/oslib.h @@ -1,4 +1,6 @@ -#pragma once +#ifndef CMDLINE_OSLIB_H +#define CMDLINE_OSLIB_H + #include "common.h" #define OS_PATHSEP '/' @@ -236,3 +238,5 @@ extern int HPrintF(Handle text, const char *format, ...); #ifdef __cplusplus } #endif + +#endif diff --git a/includes/pref_structs.h b/includes/pref_structs.h index b443bf7..ee016b6 100644 --- a/includes/pref_structs.h +++ b/includes/pref_structs.h @@ -211,9 +211,9 @@ typedef struct PFrontEndC { Boolean ecplusplus; Boolean objective_c; Boolean defer_codegen; - Boolean templateparser; - Boolean c99; - Boolean bottomupinline; + // Boolean templateparser; + // Boolean c99; + // Boolean bottomupinline; } PFrontEndC; typedef struct PWarningC { |