summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAsh Wolf <ninji@wuffs.org>2022-11-07 03:06:21 +0000
committerAsh Wolf <ninji@wuffs.org>2022-11-07 03:06:21 +0000
commit9a46dd0e2e80790d9848c0bbd718932a27c23269 (patch)
treee7a8e976c7138d50a69ff4778c4e8572efd94452 /includes
parentd0b9848c54e6f85ab713f059dcd1ddef7e57caa6 (diff)
downloadMWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.tar.gz
MWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.zip
honk
Diffstat (limited to '')
-rw-r--r--includes/compiler.h806
-rw-r--r--includes/compiler/CABI.h39
-rw-r--r--includes/compiler/CClass.h71
-rw-r--r--includes/compiler/CDecl.h127
-rw-r--r--includes/compiler/CError.h7
-rw-r--r--includes/compiler/CExpr.h237
-rw-r--r--includes/compiler/CFunc.h147
-rw-r--r--includes/compiler/CInit.h77
-rw-r--r--includes/compiler/CInline.h121
-rw-r--r--includes/compiler/CInt64.h6
-rw-r--r--includes/compiler/CMachine.h84
-rw-r--r--includes/compiler/CMangler.h35
-rw-r--r--includes/compiler/CParser.h385
-rw-r--r--includes/compiler/CPrep.h122
-rw-r--r--includes/compiler/CPrepTokenizer.h32
-rw-r--r--includes/compiler/CScope.h107
-rw-r--r--includes/compiler/CodeGen.h79
-rw-r--r--includes/compiler/Operands.h85
-rw-r--r--includes/compiler/PCode.h194
-rw-r--r--includes/compiler/PCodeInfo.h1335
-rw-r--r--includes/compiler/PCodeUtilities.h23
-rw-r--r--includes/compiler/StackFrame.h60
-rw-r--r--includes/compiler/TOC.h60
-rw-r--r--includes/compiler/common.h81
-rw-r--r--includes/compiler/enode.h36
-rw-r--r--includes/compiler/objects.h45
-rw-r--r--includes/compiler/templates.h7
-rw-r--r--includes/compiler/tokens.h16
-rw-r--r--includes/compiler/types.h101
-rw-r--r--includes/cos.h2
-rw-r--r--includes/oslib.h2
31 files changed, 3893 insertions, 636 deletions
diff --git a/includes/compiler.h b/includes/compiler.h
index 319f95e..6557749 100644
--- a/includes/compiler.h
+++ b/includes/compiler.h
@@ -8,276 +8,29 @@
#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 {
+
+
+
+struct DefArgCtorInfo {
Object *default_func;
ENode *default_arg;
-} DefArgCtorInfo;
+};
typedef struct XRefOffset {
UInt32 xrefoffset;
SInt32 offset;
} XRefOffset;
-typedef struct InlineXRef {
- struct InlineXRef *next;
+struct InlineXRef {
+ 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,
@@ -301,8 +54,8 @@ typedef enum ExceptionActionType {
EAT_NACTIONS
} ExceptionActionType;
-typedef struct ExceptionAction {
- struct ExceptionAction *prev;
+struct ExceptionAction {
+ ExceptionAction *prev;
union {
struct {
Object *local;
@@ -385,32 +138,10 @@ typedef struct ExceptionAction {
} 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;
+};
+
+struct MemInitializer {
+ MemInitializer *next;
union {
ENodeList *nodes;
ENode *expr;
@@ -421,7 +152,7 @@ typedef struct MemInitializer {
} u;
Boolean is_ivar;
Boolean is_expr;
-} MemInitializer;
+};
typedef enum DepNameType {
@@ -434,8 +165,8 @@ typedef enum DepNameType {
DNT_TYPENAME
} DepNameType;
-typedef struct DepName {
- struct DepName *next;
+struct DepName {
+ DepName *next;
union {
HashNameNode *name;
NameSpace *nspace;
@@ -453,7 +184,7 @@ typedef struct DepName {
} tname;
} u;
DepNameType type;
-} DepName;
+};
@@ -479,314 +210,110 @@ typedef struct Substitution {
SubKind kind;
} Substitution;
+// Registers.c
+enum {
+ RegisterMax = 32
+};
+const char RegClass_SPR = 0;
+const char RegClass_CRFIELD = 1;
+const char RegClass_VR = 2;
+const char RegClass_FPR = 3;
+const char RegClass_GPR = 4;
+const char RegClassMax = 5;
+/*enum RegClass {
+ RegClass_SPR,
+ RegClass_CRFIELD,
+ RegClass_VR,
+ RegClass_FPR,
+ RegClass_GPR,
+ RegClassMax
+};*/
-// 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;
+enum {
+ RegState0 = 0,
+ RegState1 = 1,
+ RegState2 = 2
+};
-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();
+extern int used_virtual_registers[RegClassMax];
+extern int used_nonvolatile_registers[RegClassMax];
+extern int assignable_registers[RegClassMax];
+extern int n_real_registers[RegClassMax];
+extern int n_scratch_registers[RegClassMax];
+extern int scratch_registers[RegClassMax][RegisterMax];
+extern int n_nonvolatile_registers[RegClassMax];
+extern int nonvolatile_registers[RegClassMax][RegisterMax];
+extern UInt8 reg_state[RegClassMax][RegisterMax];
+extern int first_temporary_register[RegClassMax];
+extern int last_temporary_register[RegClassMax];
+extern char *register_class_name[RegClassMax];
+extern char *register_class_format[RegClassMax];
+extern int coloring;
+extern int optimizing;
+
+extern void init_registers();
+extern void assign_register_to_variable(Object *obj, char rclass);
+extern void retain_register_for_argument(Object *obj, char rclass, short reg);
+extern int available_registers(char rclass);
+extern UInt32 volatile_registers(char rclass);
+extern short obtain_nonvolatile_register(char rclass);
+extern void open_temp_registers();
+extern void check_temp_registers();
+extern void close_temp_registers();
+extern int count_scratch_registers();
+extern void init_modified_registers();
+extern void note_modified_registers(Object *obj);
+extern void find_modified_registers(Object *obj, UInt32 *masks);
+
+// RegisterInfo.c
+extern short last_exception_register[RegClassMax];
+extern short first_fe_temporary_register[RegClassMax];
+extern short last_argument_register[RegClassMax];
+extern short _FP_;
+extern short _CALLER_SP_;
+extern char *special_register_names[RegClassMax][RegisterMax];
+extern short spr_to_sysreg[4];
+
+extern void asm_used_register(char rclass, short reg);
+extern void retain_register(Object *obj, char rclass, short reg);
+extern void retain_GPR_pair(Object *obj, short reg, short regHi);
+extern int is_register_object(Object *obj);
+extern int GetABIFirstNonVolatile(char rclass);
+extern char GetRegisterClassName(char rclass);
+extern void setup_diagnostic_reg_strings();
+extern void init_target_registers();
+extern void assign_register_by_type(Object *obj);
+extern void assign_GPR_pair(Object *obj);
+extern void open_fe_temp_registers();
+extern void set_last_exception_registers();
+extern VarInfo *Registers_GetVarInfo(Object *obj);
+extern int used_vrstate_VRs();
+extern UInt32 colored_vrs_as_vrsave(PCodeBlock *block);
+extern void save_before_coloring_nonvolatile_registers(char rclass);
+extern void reset_nonvolatile_registers(char rclass);
+extern int is_nonvolatile_register(char rclass, int reg);
+extern void init_endian();
+extern void update_asm_nonvolatile_registers();
// LOOSE DECLS
-extern Boolean C_Compiler(CParams *param);
+extern short high_offset;
+extern short low_offset;
+extern short high_reg;
+extern short low_reg;
+extern short high_reg2;
+extern short low_reg2;
extern void PrecompilerRead(short refnum, void *buffer);
+extern void PrecompilerWrite();
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 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;
@@ -794,17 +321,7 @@ 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 ParserTryBlock *trychain;
extern Boolean in_assembler;
extern Boolean preprocessing_only;
extern void AssemblerError();
@@ -817,14 +334,25 @@ extern short lookahead();
extern Object *CClass_Constructor(TypeClass *tclass);
extern Object *CClass_Destructor(TypeClass *tclass);
extern int CClass_CheckPures(TypeClass *tclass);
+extern Boolean CClass_IsConstructor(Object *func);
+extern short CABI_GetStructResultArgumentIndex();
+extern Boolean CParser_HasInternalLinkage(Object *obj);
+extern HashNameNode *CParser_GetUniqueName();
+extern SInt32 CParser_GetUniqueID();
+extern Boolean CParserIsVolatileExpr(ENode *expr);
+extern Boolean CParserIsConstExpr(ENode *expr);
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 Boolean CTemplTool_IsTemplateArgumentDependentType(Type *type);
extern TypeTemplDep *CDecl_NewTemplDepType(TypeTemplDepType tdtype);
+extern Type *CDecl_NewPointerType(Type *type);
+extern Type *CDecl_NewStructType(SInt32 size, SInt32 align);
+extern Type *CDecl_NewArrayType(Type *type, SInt32 num);
extern GList name_mangle_list;
extern void CPrep_UnLex();
extern Type *CTempl_ClassGetType(TypeClass *tclass);
-extern short is_typesame(Type *t1, Type *t2);
+//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);
@@ -835,14 +363,95 @@ 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 Object *CClass_ThisSelfObject();
extern AccessType global_access;
+extern HashNameNode *this_name_node;
+extern void CParser_Setup();
+extern Boolean CParser_IsConst(Type *type, UInt32 qual);
+extern void CParser_Cleanup();
+extern void SetupPrecompiler(Boolean flag);
+extern void CleanupPrecompiler();
+extern void SetupAssembler();
+extern void CleanupAssembler();
+extern void ObjGen_Setup();
+extern void ObjGen_Finish();
+extern void ObjGen_Cleanup();
+extern void ObjGen_CodeCleanup();
+extern void ObjGen_DeclareFloatConst(Object *obj);
+extern void ObjGen_DeclareVectorConst(Object *obj);
+extern void ObjGen_DeclareCodeLabel(Object *labelobj, SInt32 offset, Object *funcobj);
+extern Boolean ObjGen_IsExported(Object *obj);
+extern void PointerAnalysis_Setup();
+extern void PointerAnalysis_Cleanup();
+extern Boolean CPrep_Preprocess();
+extern void cparser();
+extern void CBrowse_Setup(CParams *param);
+extern void CBrowse_Finish(CParams *param);
+extern void CBrowse_Cleanup(CParams *param);
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 void CPrep_PreprocessDumpNewLine();
extern Boolean gForceSourceLoc;
extern void ObjGen_SegmentName(); // might take an arg, not sure since it's empty
+extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 modDate, Boolean flag);
+extern char *precomp_target_str;
+extern Object *CParser_ParseObject();
+extern void PointerAnalysis_PragmaMode();
+extern void CExcept_Terminate();
+extern void CExcept_ArrayInit();
+extern void CExcept_Magic();
+extern void CSOM_PragmaReleaseOrder();
+extern void CSOM_PragmaClassVersion();
+extern void CSOM_PragmaMetaClass();
+extern void CSOM_PragmaCallStyle();
+extern short GetPrec(short t);
+extern short localcount;
+extern Boolean InlineAsm_gccmode;
+extern void initialize_aliases();
+extern Statement *current_statement;
+extern int pclist_bad_operand;
+extern int n_real_registers[];
+extern short pic_base_reg;
+extern Object pic_base;
+extern ObjectList *exceptionlist;
+extern ObjectList *arguments;
+extern ObjectList *locals;
+extern ObjectList *toclist;
+extern Boolean uses_globals;
+extern Boolean requires_frame;
+extern void assign_locals_to_memory(ObjectList *locals);
+extern PCodeLabel *pic_base_pcodelabel;
+extern void *make_alias(Object *obj, SInt32 offset, SInt32 size);
+extern Boolean is_volatile_object(Object *obj);
+extern Boolean is_pascal_object(Object *obj);
+extern Boolean local_is_16bit_offset(Object *obj);
+extern Boolean can_add_displ_to_local(Object *obj, SInt32 displ);
+extern int local_base_register(Object *obj);
+extern int disable_optimizer;
+extern Boolean IsTempName(HashNameNode *name);
+extern void assign_local_memory(Object *obj);
+extern void move_varargs_to_memory();
+extern Type stvoid;
+extern TypePointer void_ptr;
+extern int countexceptionactionregisters(ExceptionAction *exc);
+extern void noteexceptionactionregisters(ExceptionAction *exc, PCodeArg *);
+extern void recordexceptionactions(PCode *pc, ExceptionAction *exc);
+extern SInt32 functionbodyoffset;
+extern Object *CParser_NewRTFunc(Type *returntype, HashNameNode *name, Boolean unkflag, int argcount, ...);
+extern SInt32 curstmtvalue;
+extern Object *__memcpy_object;
+extern void CInit_RewriteString(ENode *expr, Boolean flag);
+extern int is_intrinsic_function_call(ENode *expr);
+extern SInt32 I8_log2n(SInt64 value);
+extern void PPCError_Error(int code);
+
+enum {
+ INTRINSIC_8 = 8,
+ INTRINSIC_35 = 35,
+ INTRINSIC_36 = 36
+};
enum {
CPU_PPC401,
@@ -875,6 +484,11 @@ enum {
extern char *ScanFloat(char *input, double *output, Boolean *fail);
+#define FITS_IN_SHORT(value) ( (value) == ((short) (value)) )
+// should HIGH_PART have (short) around it?
+#define HIGH_PART(value) ( (((value) >> 16) + (((value) & 0x8000) >> 15)) )
+#define LOW_PART(value) ( (short) (value) )
+
#ifdef __MWERKS__
#pragma options align=reset
#endif
diff --git a/includes/compiler/CABI.h b/includes/compiler/CABI.h
new file mode 100644
index 0000000..fde5b21
--- /dev/null
+++ b/includes/compiler/CABI.h
@@ -0,0 +1,39 @@
+#ifndef COMPILER_CABI_H
+#define COMPILER_CABI_H
+
+#include "compiler/common.h"
+#include "compiler/CDecl.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+extern short CABI_GetStructResultArgumentIndex(void);
+extern Type *CABI_GetSizeTType(void);
+extern Type *CABI_GetPtrDiffTType(void);
+extern SInt16 CABI_StructSizeAlignValue(Type *type, SInt32 size);
+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(Object *obj, TypeClass *tclass);
+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_AddLayeredDestructors(TypeClass *tclass);
+extern ENode *CABI_DestroyObject(Object *dtor, ENode *objexpr, UInt8 mode, Boolean flag1, Boolean flag2);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CClass.h b/includes/compiler/CClass.h
new file mode 100644
index 0000000..edefa92
--- /dev/null
+++ b/includes/compiler/CClass.h
@@ -0,0 +1,71 @@
+#ifndef COMPILER_CCLASS_H
+#define COMPILER_CCLASS_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct VTableObjectLink {
+ struct VTableObjectLink *next;
+ Object *methodobj;
+ SInt32 offset;
+ SInt32 xC;
+} 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 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 Object *CClass_AssignmentOperator(TypeClass *tclass);
+extern Object *CClass_CopyConstructor(TypeClass *tclass);
+extern NameSpaceObjectList *CClass_MemberObject(TypeClass *tclass, HashNameNode *name);
+extern Object *CClass_Constructor(TypeClass *tclass);
+extern Object *CClass_Destructor(TypeClass *tclass);
+extern Boolean CClass_IsConstructor(Object *obj);
+extern Boolean CClass_IsDestructor(Object *obj);
+extern Boolean CClass_IsPODClass(TypeClass *tclass);
+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 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_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_OverridesBaseMember(TypeClass *tclass, HashNameNode *name, Object *obj);
+extern void CClass_DefineCovariantFuncs(Object *method, CI_FuncData *ifuncdata);
+extern void CClass_CheckOverrides(TypeClass *tclass);
+extern void CClass_ClassDefaultFuncAction(TypeClass *tclass);
+extern void CClass_ClassAction(TypeClass *tclass);
+extern void CClass_MakeStaticActionClass(TypeClass *tclass);
+extern Object *CClass_CheckPures(TypeClass *tclass);
+extern void CClass_MemberDef(Object *obj, TypeClass *tclass);
+extern Object *CClass_ThisSelfObject(void);
+extern ENode *CClass_CreateThisSelfExpr(void);
+extern void CClass_CheckPathAccess(BClassList *path, Object *obj, AccessType access);
+extern void CClass_CheckStaticAccess(BClassList *path, TypeClass *tclass, AccessType access);
+extern void CClass_CheckObjectAccess(BClassList *path, Object *obj);
+extern void CClass_CheckEnumAccess(BClassList *path, ObjEnumConst *objec);
+extern Type *CClass_CombineClassAccessQualifiers(Type *type, UInt32 qual1, UInt32 qual2, UInt32 *outflags);
+extern ENode *CClass_AccessMember(ENode *classexpr, Type *type, UInt32 qual, SInt32 offset);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CDecl.h b/includes/compiler/CDecl.h
new file mode 100644
index 0000000..eda8669
--- /dev/null
+++ b/includes/compiler/CDecl.h
@@ -0,0 +1,127 @@
+#ifndef COMPILER_CDECL_H
+#define COMPILER_CDECL_H
+
+#include "compiler/common.h"
+#include "compiler/tokens.h"
+#include "compiler/types.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+// named because it's 0xE bytes big (hurr)
+typedef struct DeclE {
+ ObjBase **objlist;
+ void *x4;
+ unsigned short x8;
+ unsigned short xA;
+ Boolean xC;
+} DeclE;
+
+struct DeclInfo {
+ Type *thetype;
+ UInt32 qual;
+ NameSpace *nspace;
+ HashNameNode *name;
+ Object *x10;
+ NameSpaceObjectList *x14;
+ void *x18;
+ void *x1C;
+ Type *x20;
+ ENode *x24;
+ TemplClass *x28;
+ TemplArg *expltargs;
+ void *x30;
+ void *x34;
+ void *x38;
+ Boolean x3C;
+ Boolean x3D;
+ short x3E;
+ short storageclass;
+ UInt8 section;
+ UInt8 exportflags;
+ Boolean x44;
+ Boolean x45;
+ Boolean x46;
+ Boolean x47;
+ Boolean x48;
+ Boolean x49;
+ Boolean x4A;
+ Boolean x4B;
+ Boolean x4C;
+ Boolean x4D;
+ Boolean x4E;
+ Boolean x4F;
+ Boolean x50;
+ Boolean x51;
+ Boolean has_expltargs;
+ Boolean x53;
+ Boolean x54;
+ Boolean x55;
+ Boolean x56;
+ Boolean x57;
+ FileOffsetInfo fileoffsetinfo;
+};
+
+typedef struct BigDeclInfo {
+ DeclInfo declinfo;
+ DeclInfo declinfo2;
+ Boolean xCC;
+ Boolean xCD;
+} BigDeclInfo;
+
+extern AccessType global_access;
+extern FileOffsetInfo member_fileoffset;
+
+extern Type *CDecl_NewStructType(SInt32 size, SInt16 align);
+extern Type *CDecl_NewArrayType(Type *type, SInt32 size);
+extern Type *CDecl_NewPointerType(Type *type);
+extern Type *CDecl_NewRefPointerType(Type *type);
+extern Type *CDecl_NewTemplDepType(TypeTemplDepType tdt);
+extern void CDecl_SetResultReg(TypeFunc *tfunc);
+extern void CDecl_SetFuncFlags(TypeFunc *tfunc, UInt32 flags);
+extern void CDecl_NewConvFuncType(DeclInfo *declinfo);
+extern void CDecl_CompleteType(Type *type);
+extern Boolean IsCompleteType(Type *type);
+extern Boolean CanAllocObject(Type *type);
+extern Boolean CanCreateObject(Type *type);
+extern void makethetypepointer(DeclInfo *declinfo, UInt32 qual);
+extern void CDecl_AddThisPointerArgument(TypeFunc *tfunc, TypeClass *tclass);
+extern void CDecl_MakePTMFuncType(TypeFunc *tfunc);
+extern void CDecl_AddArgument(TypeFunc *tfunc, Type *argtype);
+extern Boolean CDecl_CheckArrayIntegr(Type *type);
+extern void CDecl_ParseDirectFuncDecl(DeclInfo *declinfo);
+extern void makememberpointertype(DeclInfo *declinfo, TypeClass *tclass, UInt32 qual);
+extern void CDecl_ScanPointer(DeclInfo *declinfo, NameSpace *nspace, Boolean flag);
+extern void scandeclarator(DeclInfo *declinfo);
+extern void conversion_type_name(DeclInfo *declinfo);
+extern void MergeDefaultArgs(FuncArg *a, FuncArg *b);
+extern void CheckDefaultArgs(FuncArg *args);
+extern Object *CDecl_GetFunctionObject(DeclInfo *declinfo, NameSpace *nspace, Boolean *pflag, Boolean someotherflag);
+extern void CDecl_TypedefDeclarator(DeclInfo *declinfo);
+extern Boolean CDecl_FunctionDeclarator(DeclInfo *declinfo, NameSpace *nspace, Boolean flag, Boolean flag2);
+extern void CDecl_ScanDeclarator(DeclInfo *declinfo);
+extern void scandeclaratorlist(DeclInfo *declinfo);
+extern void CDecl_ComputeUnderlyingEnumType(TypeEnum *tenum);
+extern void scanenum(DeclInfo *declinfo);
+extern void CDecl_ScanStructDeclarator(BigDeclInfo *bde);
+extern void scanstruct(DeclInfo *declinfo, short structtype);
+extern void CDecl_ExtractClassExportFlags(DeclInfo *declinfo, UInt8 flags);
+extern TypeMethod *CDecl_MakeTypeMemberFunc(TypeFunc *tfunc, TypeClass *tclass, Boolean flag);
+extern void CDecl_PackDeclInfo(PackedDeclInfo *packed, DeclInfo *declinfo);
+extern void CDecl_UnpackDeclInfo(DeclInfo *declinfo, PackedDeclInfo *packed);
+extern void CDecl_AddFriend(TypeClass *tclass, Object *friendfunc, TypeClass *friendclass);
+extern void CDecl_CheckCtorIntegrity(FuncArg *args, TypeClass *tclass);
+extern void CDecl_MakeVBaseList(TypeClass *tclass);
+extern Boolean CDecl_CheckNewBase(TypeClass *a, TypeClass *b, Boolean flag);
+extern TypeMethod *CDecl_MakeDefaultDtorType(TypeClass *tclass, Boolean is_virtual);
+extern void CDecl_CompleteClass(DeclE *decle, TypeClass *tclass);
+extern TypeClass *CDecl_DefineClass(NameSpace *nspace, HashNameNode *name, TypeClass *tclass, short mode, Boolean flag2, Boolean flag3);
+extern void CDecl_ParseClassDeclSpec(UInt8 *declspec);
+extern void CDecl_ParseClass(DeclInfo *declinfo, short mode, Boolean flag1, UInt8 class_declspec);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CError.h b/includes/compiler/CError.h
index 89f67e4..dbe80c0 100644
--- a/includes/compiler/CError.h
+++ b/includes/compiler/CError.h
@@ -311,6 +311,11 @@ typedef struct _CErrorBuffer {
UInt32 remaining;
} CErrorBuffer;
+extern TStreamElement *cerror_locktoken;
+extern char cerror_synchdata[32];
+extern short cerror_synchoffset;
+extern int CError_BreakPointcount;
+
extern void CError_Init();
extern void CError_SetErrorToken(TStreamElement *token);
extern void CError_SetNullErrorToken();
@@ -354,7 +359,7 @@ 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_Internal(char *filename, int line);
extern void CError_ExpressionTooComplex();
extern void CError_NoMem();
extern void CError_UserBreak();
diff --git a/includes/compiler/CExpr.h b/includes/compiler/CExpr.h
new file mode 100644
index 0000000..a82e56e
--- /dev/null
+++ b/includes/compiler/CExpr.h
@@ -0,0 +1,237 @@
+#ifndef COMPILER_CEXPR_H
+#define COMPILER_CEXPR_H
+
+#include "compiler/common.h"
+#include "compiler/enode.h"
+#include "compiler/types.h"
+#include "compiler/CScope.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct ConIteratorList {
+ struct ConIteratorList *next;
+ struct ConIterator *iter;
+} ConIteratorList;
+
+typedef struct ConIterator {
+ struct ConIterator *parent;
+ ConIteratorList *children;
+ TypeClass *tclass;
+} ConIterator;
+
+typedef struct ConversionIterator {
+ CScopeObjectIterator objiter;
+ ConIterator myconiter;
+ ConIterator *coniter;
+} ConversionIterator;
+
+enum {
+ CheckResult0,
+ CheckResult1,
+ CheckResult2,
+ CheckResult3,
+ CheckResult4
+};
+
+// Rename me to StdMatch?
+typedef struct Match5 {
+ short x0;
+ short x2;
+ short x4;
+ short x6;
+ short x8;
+} Match5;
+
+typedef struct Match13 {
+ short x0;
+ short x2;
+ short x4;
+ short x6;
+ short x8;
+ short xA;
+ short xC;
+ short xE;
+ Match5 match5;
+} Match13;
+
+// CExpr.c
+extern Boolean (*name_obj_check)(void *, Object *); // TODO figure out the right type
+extern Boolean disallowgreaterthan;
+
+// CExpr2.c
+extern ENode *assign_node;
+extern Boolean temp_reference_init;
+
+// CExpr.c
+extern void CExpr_RewriteConst();
+extern void optimizecomm(ENode *expr);
+extern short canadd(ENode *expr, SInt32 value);
+extern ENode *checkreference(ENode *expr);
+extern ENode *pointer_generation(ENode *expr);
+extern void CExpr_PointerGeneration();
+extern void oldassignmentpromotion();
+extern ENode *argumentpromotion(ENode *expr, Type *type, short qual, Boolean flag);
+extern ENode *classargument(ENode *expr);
+extern ENodeList *CExpr_ScanExpressionList(Boolean flag);
+extern void CExpr_DoExplicitConversion();
+extern void CExpr_MakeNameLookupResultExpr();
+extern void scansizeof();
+extern void scanalignof();
+extern ENode *getnodeaddress(ENode *expr, Boolean flag);
+extern void getpointertomemberfunc();
+extern void CExpr_New_ELOGNOT_Node();
+extern void CExpr_New_EMONMIN_Node();
+extern void CExpr_New_EBINNOT_Node();
+extern ENode *unary_expression(void);
+extern ENode *do_castnullcheck(ENode *a, ENode *b);
+extern void CExpr_SafeClassPointerCast();
+extern ENode *PointerToMemberCast(ENode *expr, TypeMemberPointer *tm1, TypeMemberPointer *tm2, Boolean flag);
+extern void CExpr_MemberPointerConversion();
+extern ENode *do_typecast(ENode *expr, Type *type, UInt32 qual);
+extern void cast_expression();
+extern void CExpr_New_EMUL_Node();
+extern void CExpr_New_EDIV_Node();
+extern void CExpr_New_EMODULO_Node();
+extern void CExpr_New_EADD_Node();
+extern void CExpr_New_ESUB_Node();
+extern void CExpr_New_ESHL_Node();
+extern void CExpr_New_ESHR_Node();
+extern void CExpr_New_ELESS_Node();
+extern void CExpr_New_ELESSEQU_Node();
+extern void CExpr_New_EGREATER_Node();
+extern void CExpr_New_EGREATEREQU_Node();
+extern ENode *memberpointercompare(ENodeType t, ENode *left, ENode *right);
+extern void CExpr_New_EEQU_Node();
+extern void CExpr_New_ENOTEQU_Node();
+extern void CExpr_New_EAND_Node();
+extern void CExpr_New_EXOR_Node();
+extern void CExpr_New_EOR_Node();
+extern void CExpr_New_ELAND_Node();
+extern void CExpr_New_ELOR_Node();
+extern void CExpr_NewDyadicNode();
+extern void CExpr_New_ECOND_Node();
+extern ENode *assignment_expression(void);
+extern ENode *conv_assignment_expression(void);
+extern void CExpr_CheckUnusedExpression();
+extern void s_expression();
+extern ENode *expression(void);
+extern CInt64 CExpr_IntegralConstExprType(Type **tint);
+extern ENode *CExpr_IntegralConstOrDepExpr(void);
+extern CInt64 CExpr_IntegralConstExpr(void);
+extern void CExpr_CheckUnwantedAssignment();
+extern void CExpr_ParseAsmExpr();
+
+// CExpr2.c
+typedef void (*CExprSearchCB)(ENode *expr);
+typedef ENode *(*CExprReplaceCB)(ENode *expr);
+
+extern void CExpr_SearchExprTree(ENode *expr, CExprSearchCB callback, int count, ...);
+extern ENode *CExpr_SearchExprTreeReplace(ENode *expr, CExprReplaceCB callback, int count, ...);
+extern Boolean CExpr_HasFuncCall(ENode *expr);
+extern void CExpr_AliasTransform(ENode *expr);
+extern ENode *CExpr_UnaryFloatExpression(ENode *expr);
+extern ENode *CExpr_BinaryFloatExpression(ENode *expr);
+extern ENode *CExpr_NewENode(ENodeType ty);
+extern ENode *CExpr_NewTemplDepENode(TemplDepSubType t);
+extern ENode *nullnode(void);
+extern ENode *intconstnode(Type *type, SInt32 value);
+extern ENode *stringconstnode(char *str);
+extern ENode *forceintegral(ENode *expr);
+extern ENode *makemonadicnode(ENode *inner, ENodeType ty);
+extern ENode *makediadicnode(ENode *left, ENode *right, ENodeType ty);
+extern ENode *makecommaexpression(ENode *left, ENode *right);
+extern short iszero(ENode *expr);
+extern short isnotzero(ENode *expr);
+extern Boolean CExpr_IsOne(ENode *expr);
+extern Boolean CExpr_AllBitsSet(ENode *expr);
+extern ENode *CExpr_NewETEMPNode(Type *type, Boolean assign_id);
+extern ENode *CExpr_GetETEMPCopy(ENode *expr);
+extern ENode *integralpromote(ENode *expr);
+extern CInt64 CExpr_IntConstConvert(Type *a, Type *b, CInt64 val);
+extern ENode *promote(ENode *expr, Type *type);
+extern void CExpr_ArithmeticConversion(ENode **left, ENode **right);
+extern ENode *CExpr_TempModifyExpr(ENode *expr);
+extern Boolean CExpr_IsLValue(ENode *expr);
+extern ENode *CExpr_LValue(ENode *expr, Boolean flag1, Boolean flag2);
+extern ENode *CExpr_MakeObjRefNode(Object *obj, Boolean flag);
+extern ENode *create_objectrefnode(Object *obj);
+extern ENode *create_objectnode2(Object *obj);
+extern ENode *create_objectnode(Object *obj);
+extern ENode *CExpr_IsTempConstruction(ENode *expr, Type *type, ENode **resultexpr);
+extern ENode *CExpr_AdjustFunctionCall(ENode *expr);
+extern ENode *funccallexpr(Object *func, ENode *arg1, ENode *arg2, ENode *arg3, ENode *arg4);
+extern ENode *CExpr_FuncCallSix(Object *func, ENode *arg1, ENode *arg2, ENode *arg3, ENode *arg4, ENode *arg5, ENode *arg6);
+extern void CExpr_MatchCV(Type *t1, UInt32 q1, Type *t2, UInt32 q2, Match13 *match);
+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 void CExpr_ConversionIteratorInit(ConversionIterator *iter, TypeClass *tclass);
+extern Object *CExpr_ConversionIteratorNext(ConversionIterator *iter);
+extern void user_assign_check();
+extern ENode *CExpr_ConvertToCondition(ENode *expr);
+extern void CExpr_ConvertToIntegral();
+extern void CExpr_CheckArithmConversion();
+extern void get_address_of_temp_copy();
+extern short assign_check(ENode *expr, Type *type, UInt32 qual, Boolean flag1, Boolean flag2, Boolean flag3);
+extern void CExpr_MatchCompare();
+extern void CExpr_GetFuncMatchArgs();
+extern ENode *CExpr_GetDefaultArgument(ENode *funcexpr, FuncArg *arg);
+extern ENode *CExpr_VarArgPromotion(ENode *expr, Boolean flag);
+extern void CExpr_GenericFuncCall();
+extern void CExpr_GenericPtmfCall();
+extern void CExpr_MakeFunctionCall();
+extern void CExpr_CheckOperatorConversion();
+extern void CExpr_CheckOperator();
+extern ENode *CExpr_ConstructObject(TypeClass *tclass, ENode *addr_expr, ENodeList *args, Boolean flag1, Boolean flag2, Boolean flag3, Boolean flag4, Boolean flag5);
+extern void scannew();
+extern void scandelete();
+
+// 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();
+// 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 void CExpr_CondOperatorMatch();
+extern void CExpr_OperatorMatch();
+// static void CExpr_ClassCopyInit();
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CFunc.h b/includes/compiler/CFunc.h
new file mode 100644
index 0000000..2247e5e
--- /dev/null
+++ b/includes/compiler/CFunc.h
@@ -0,0 +1,147 @@
+#ifndef COMPILER_CFUNC_H
+#define COMPILER_CFUNC_H
+
+#include "compiler/common.h"
+#include "compiler/CScope.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct DeclBlock {
+ struct DeclBlock *next;
+ ExceptionAction *dobjstack; // is type right?
+ NameSpace *parent_nspace;
+ short index;
+} DeclBlock;
+
+struct CLabel {
+ CLabel *next;
+ Statement *stmt;
+ HashNameNode *uniquename;
+ HashNameNode *name;
+ PCodeLabel *pclabel;
+ //void *sicg_label;
+};
+
+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;
+
+enum {
+ StmtFlag_1 = 1
+};
+
+struct Statement {
+ Statement *next;
+ StatementType type;
+ char marked;
+ UInt8 flags;
+ UInt16 value;
+ ENode *expr;
+ CLabel *label;
+ ExceptionAction *dobjstack;
+ SInt32 sourceoffset;
+ HashNameNode *sourcefilepath;
+};
+
+typedef struct InitExpr {
+ struct InitExpr *next;
+ ENode *expr;
+ Object *object;
+} InitExpr;
+
+typedef struct CtorChain {
+ struct CtorChain *next;
+ UInt8 what;
+ ENode *objexpr;
+ union {
+ ClassList *base; // 0
+ VClassList *vbase; // 1
+ ObjMemberVar *membervar; // 2
+ } u;
+} CtorChain;
+
+typedef struct CFuncSave {
+ CScopeSave scope;
+ // lots of fields
+} CFuncSave;
+
+struct DeclThing {
+ Type *thetype;
+ UInt32 qual;
+ NameSpace *nspace;
+ CLabel *xC;
+ CLabel *x10;
+};
+
+extern FuncArg elipsis;
+extern FuncArg oldstyle;
+extern ObjectList *arguments;
+extern ObjectList *locals;
+extern short localcount;
+extern SInt32 curstmtvalue;
+extern SInt32 sourceoffset;
+extern HashNameNode *sourcefilepath;
+extern SInt32 functionbodyoffset;
+extern HashNameNode *functionbodypath;
+extern InitExpr *init_expressions;
+extern CLabel *Labels;
+extern CtorChain *ctor_chain;
+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 Boolean CFunc_ParseFakeArgList(Boolean flag);
+extern FuncArg *parameter_type_list(DeclInfo *declinfo);
+extern CLabel *findlabel(void);
+extern CLabel *newlabel(void);
+extern Statement *CFunc_AppendStatement(StatementType sttype);
+extern Statement *CFunc_InsertStatement(StatementType sttype, Statement *after);
+extern Statement *CFunc_InsertBeforeStatement(StatementType sttype, Statement *before);
+extern void CheckCLabels(void);
+extern Object *create_temp_object(Type *type);
+extern ENode *create_temp_node(Type *type);
+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 void CFunc_CompoundStatement(DeclThing *thing);
+extern void CFunc_SetupNewFuncArgs(Object *obj, FuncArg *args);
+extern NameSpace *CFunc_FuncGenSetup(Statement *stmt);
+extern void CFunc_GetGlobalCompilerState(CFuncSave *state);
+extern void CFunc_SetGlobalCompilerState(CFuncSave *state);
+extern void CFunc_Gen(Statement *stmt, Object *obj, 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 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);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CInit.h b/includes/compiler/CInit.h
new file mode 100644
index 0000000..9b1c24b
--- /dev/null
+++ b/includes/compiler/CInit.h
@@ -0,0 +1,77 @@
+#ifndef COMPILER_CINIT_H
+#define COMPILER_CINIT_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+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 *(*TempNodeCB)(Type *type, Boolean flag);
+
+typedef struct OLinkList {
+ struct OLinkList *next;
+ Object *obj;
+ SInt32 offset;
+ SInt32 somevalue;
+} OLinkList;
+
+typedef struct PooledString {
+ struct PooledString *next;
+ Object *obj;
+ int offset;
+ char *data;
+ SInt32 size;
+ Boolean ispascal;
+ Boolean iswide;
+} PooledString;
+
+typedef struct InitInfo {
+ Object *obj;
+ OLinkList *list;
+ void *x8;
+ SInt32 expr_offset;
+ ExprCB expr_cb;
+ Boolean expr_cb_called;
+ Boolean x15;
+ Boolean x16;
+ InitExprRegisterCB init_expr_register_cb;
+ Object *obj1C;
+ InsertExprCB insert_expr_cb;
+ RegisterObjectCB register_object_cb;
+ char *buffer;
+ SInt32 size;
+ SInt32 bufferSize;
+ struct InitInfo *next;
+} InitInfo;
+
+extern TempNodeCB cinit_tempnodefunc;
+extern InitInfo *cinit_initinfo;
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+extern void CInit_Init(void);
+extern Boolean CInit_RelocInitCheck(ENode *expr, Object **objptr, CInt64 *valptr, Boolean flag);
+extern void CInit_ExportConst(Object *obj);
+extern Statement *CInit_ConstructClassArray(Statement *stmt, TypeClass *tclass, Object *ctor, Object *dtor, ENode *firstarg, SInt32 count);
+extern ENode *CInit_AutoObject(Object *obj, Type *type, UInt32 qual);
+extern void CInit_InitializeAutoData(Object *obj, InsertExprCB insert_cb, RegisterObjectCB register_cb);
+extern void CInit_InitializeStaticData(Object *obj, InitExprRegisterCB cb);
+extern void CInit_InitializeData(Object *obj);
+extern Object *CInit_DeclareString(char *data, SInt32 size, Boolean ispascal, Boolean iswide);
+extern PooledString *CInit_DeclarePooledString(char *data, SInt32 size, Boolean ispascal);
+extern PooledString *CInit_DeclarePooledWString(char *data, SInt32 size);
+extern void CInit_RewriteString(ENode *expr, Boolean flag);
+extern void CInit_DeclarePooledStrings(void);
+extern void CInit_DeclareData(Object *obj, void *data, OLinkList *list, SInt32 size);
+extern void CInit_DeclareReadOnlyData(Object *obj, void *data, OLinkList *list, SInt32 size);
+extern void CInit_DefineTentativeData(void);
+
+#endif
diff --git a/includes/compiler/CInline.h b/includes/compiler/CInline.h
new file mode 100644
index 0000000..1b5abd5
--- /dev/null
+++ b/includes/compiler/CInline.h
@@ -0,0 +1,121 @@
+#ifndef COMPILER_CINLINE_H
+#define COMPILER_CINLINE_H
+
+#include "compiler/common.h"
+#include "compiler/tokens.h"
+#include "compiler/CFunc.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct CI_Var {
+ HashNameNode *name;
+ Type *type;
+ UInt32 qual;
+ UInt8 sflags;
+ UInt8 xD;
+ UInt8 xE;
+} CI_Var;
+
+typedef struct CI_Switch {
+ int fix_me;
+} CI_Switch;
+
+typedef struct CI_Statement {
+ StatementType type;
+ UInt8 flags;
+ UInt16 value;
+ SInt32 sourceoffset;
+ HashNameNode *sourcefilepath;
+ ExceptionAction *dobjstack;
+ union {
+ SInt16 statementnum;
+ ENode *expr;
+ struct {
+ ENode *expr;
+ SInt16 statementnum;
+ } ifgoto;
+ CI_Switch *switchdata;
+ // TODO: Figure out the one for Inline ASM
+ } u;
+} CI_Statement;
+
+struct CI_FuncData {
+ short numarguments;
+ CI_Var *arguments;
+ short numlocals;
+ CI_Var *locals;
+ short numstatements;
+ CI_Statement *statements;
+ FileOffsetInfo fileoffset;
+ SInt32 symdecloffset;
+ SInt32 functionbodyoffset;
+ HashNameNode *functionbodypath;
+ SInt32 symdeclend;
+ Boolean can_inline;
+};
+
+typedef enum {
+ CI_ActionInlineFunc = 0,
+ CI_ActionMemberFunc = 1,
+ CI_ActionTemplateFunc = 2,
+ CI_ActionDefaultFunc = 3
+} CI_ActionType;
+
+typedef struct CI_Action {
+ struct CI_Action *next;
+ Object *obj;
+ union {
+ struct {
+ FileOffsetInfo fileoffset;
+ TStream stream;
+ TypeClass *tclass;
+ CI_ActionType actiontype;
+ } inlinefunc;
+ struct {
+ Type *a;
+ Type *b;
+ TemplateMember *tmemb;
+ } memberfunc;
+ struct {
+ TemplateFunction *func;
+ TemplFuncInstance *inst;
+ } templatefunc;
+ } u;
+} CI_Action;
+
+typedef enum {
+ CopyMode0,
+ CopyMode1,
+ CopyMode2,
+ CopyMode3,
+ CopyMode4
+} CInlineCopyMode;
+
+extern CI_Action *cinline_tactionlist;
+
+extern void CInline_Init(void);
+extern SInt32 CInline_GetLocalID(Object *obj);
+extern Boolean CInline_ExpressionHasSideEffect(ENode *expr);
+extern ENode *CInline_CopyExpression(ENode *expr, CInlineCopyMode mode);
+extern void CInline_SerializeStatement(Statement *stmt);
+extern Object *CInline_GetLocalObj(SInt32 id, Boolean flag);
+extern SInt32 CInline_GetStatementNumber(Statement *first, Statement *stmt);
+extern void CInline_PackIFunctionData(CI_FuncData *packed, Statement *stmt, Object *obj);
+extern void CInline_UnpackIFunctionData(Object *obj, CI_FuncData *packed, Statement *stmt);
+extern void CInline_AddDefaultFunctionAction(Object *obj);
+extern void CInline_AddInlineFunctionAction(Object *obj, TypeClass *tclass, FileOffsetInfo *fileoffset, TStream *stream, Boolean flag);
+extern void CInline_AddMemberFunctionAction(Object *obj, Type *a, Type *b, TemplateMember *tmemb);
+extern void CInline_AddTemplateFunctionAction(Object *obj, TemplateFunction *func, TemplFuncInstance *inst);
+extern void CInline_ObjectAddrRef(Object *obj);
+extern void CInline_GenFunc(Statement *stmt, Object *obj, UInt8 unk);
+extern Boolean CInline_CanFreeLHeap(void);
+extern Boolean CInline_GenerateDeferredFuncs(void);
+extern void CInline_Finish(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CInt64.h b/includes/compiler/CInt64.h
index 455bf3f..7986a4a 100644
--- a/includes/compiler/CInt64.h
+++ b/includes/compiler/CInt64.h
@@ -13,6 +13,10 @@ extern const CInt64 cint64_min;
inline int CInt64_IsNegative(const CInt64 *n) {
return (n->hi & 0x80000000) != 0;
}
+inline UInt32 CInt64_GetULong(const CInt64 *n) { // 42E660 in mwcppc.exe
+ return n->lo;
+
+}
inline void CInt64_SetLong(CInt64 *pN, SInt32 n) {
pN->lo = n;
pN->hi = (n < 0) ? 0xFFFFFFFF : 0;
@@ -22,7 +26,7 @@ inline void CInt64_SetULong(CInt64 *pN, UInt32 n) {
pN->hi = 0;
}
-inline int CInt64_IsZero(CInt64 *n) {
+inline Boolean CInt64_IsZero(CInt64 *n) {
//if (n->hi == 0 && n->lo == 0)
// return 1;
//else
diff --git a/includes/compiler/CMachine.h b/includes/compiler/CMachine.h
new file mode 100644
index 0000000..a4bc1a5
--- /dev/null
+++ b/includes/compiler/CMachine.h
@@ -0,0 +1,84 @@
+#ifndef COMPILER_CMACHINE_H
+#define COMPILER_CMACHINE_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+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(void);
+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, Boolean flag);
+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(void);
+extern void CMach_AdjustFuntionArgs(void);
+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(void);
+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(void);
+extern Boolean CMach_FloatIsPowerOf2(Float flt);
+extern Float CMach_FloatReciprocal(Float flt);
+extern SInt32 CMach_RoundedSizeOf(Object *object);
+extern void CMach_ReInitRuntimeObjects(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CMangler.h b/includes/compiler/CMangler.h
new file mode 100644
index 0000000..f08ecd8
--- /dev/null
+++ b/includes/compiler/CMangler.h
@@ -0,0 +1,35 @@
+#ifndef COMPILER_CMANGLER_H
+#define COMPILER_CMANGLER_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+extern HashNameNode *constructor_name_node;
+extern HashNameNode *destructor_name_node;
+extern HashNameNode *asop_name_node;
+
+extern void CMangler_Setup(void);
+extern HashNameNode *CMangler_BasicDtorName(void);
+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 HashNameNode *CMangler_OperatorName(short token);
+extern HashNameNode *CMangler_VTableName(TypeClass *tclass);
+extern HashNameNode *CMangler_RTTIObjectName(Type *type, UInt32 qual);
+extern HashNameNode *CMangler_ThunkName(Object *obj, int a, int b, int c);
+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_GetLinkName(Object *obj);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h
new file mode 100644
index 0000000..21a3d59
--- /dev/null
+++ b/includes/compiler/CParser.h
@@ -0,0 +1,385 @@
+#ifndef COMPILER_CPARSER_H
+#define COMPILER_CPARSER_H
+
+#include "compiler/common.h"
+#include "compiler/enode.h"
+#include "compiler/tokens.h"
+#include "compiler/types.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_Packed
+};
+
+// not sure how many of these are char and how many are unsigned char or Boolean
+typedef struct COpts {
+ Boolean little_endian;
+ Boolean codegen_dynamic;
+ Boolean codegen_pic;
+ Boolean 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;
+ Boolean disable_registers;
+ char fp_contract;
+ Boolean no_register_save_helpers;
+ char ppc_unroll_speculative;
+ short ppc_unroll_instructions_limit;
+ short ppc_unroll_factor_limit;
+ Boolean 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;
+ Boolean use_lmw_stmw;
+ char report_heap_info;
+ char misaligned_mem_access;
+ char switch_tables;
+ char prepare_compress;
+ char some_alignment; // used in CMach_AllocationAlignment
+ Boolean asmsemicolcomment;
+ Boolean asmpoundcomment;
+ StringPtr oldprefixname;
+ short inlinelevel;
+ int inline_max_size;
+ int inline_max_total_size;
+ char inline_bottom_up;
+ Boolean cplusplus;
+ Boolean ecplusplus;
+ Boolean objective_c;
+ char objc_strict;
+ Boolean ARM_conform;
+ char ARM_scoping;
+ Boolean require_prototypes;
+ Boolean trigraphs;
+ Boolean only_std_keywords;
+ Boolean enumsalwaysint;
+ Boolean ANSI_strict;
+ Boolean mpwc_relax;
+ Boolean mpwc_newline;
+ Boolean ignore_oldstyle;
+ Boolean cpp_extensions;
+ Boolean pointercast_lvalue;
+ char useRTTI;
+ char delete_exception;
+ char _4B;
+ Boolean oldalignment;
+ Boolean unsignedchars;
+ Boolean multibyteaware;
+ char autoinline;
+ char defer_codegen;
+ Boolean direct_to_som;
+ char som_env_check;
+ char som_call_opt;
+ Boolean booltruefalse;
+ char old_enum_mangler;
+ Boolean longlong;
+ Boolean longlong_enums;
+ char no_tfuncinline;
+ char _59;
+ Boolean flat_include;
+ char syspath_once;
+ Boolean always_import;
+ char simple_class_byval;
+ Boolean wchar_type;
+ Boolean vbase_ctor_offset;
+ char vbase_abi_v2;
+ Boolean def_inherited;
+ char template_patch;
+ char template_friends;
+ char faster_pch_gen;
+ Boolean 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;
+ Boolean reverse_bitfields;
+ Boolean c9x;
+ Boolean float_constants;
+ Boolean no_static_dtors;
+ Boolean longlong_prepeval;
+ Boolean const_strings;
+ char dumpir;
+ char experimental;
+ Boolean gcc_extensions;
+ char stdc_fp_contract;
+ char stdc_fenv_access;
+ char stdc_cx_limitedr;
+ Boolean old_argmatch;
+ char optEH;
+ char optEH2;
+ Boolean new_mangler;
+ char microsoft;
+ Boolean warningerrors;
+ Boolean pedantic;
+ char check_header_flags;
+ Boolean supress_warnings;
+ Boolean warn_illpragma;
+ Boolean warn_emptydecl;
+ char warn_possunwant;
+ char warn_unusedvar;
+ char warn_unusedarg;
+ Boolean warn_extracomma;
+ char warn_hidevirtual;
+ Boolean warn_largeargs;
+ char warn_implicitconv;
+ char warn_notinlined;
+ Boolean warn_structclass;
+ Boolean warn_padding;
+ char warn_no_side_effect;
+ char warn_resultnotused;
+ char warn_ptr_int_conv;
+ char align_mode;
+ Boolean align_array_members;
+ Boolean dont_reuse_strings;
+ Boolean pool_strings;
+ Boolean explicit_zero_data;
+ Boolean readonly_strings;
+ Boolean exceptions;
+ char _99;
+ char dont_inline;
+ char always_inline;
+ Boolean peephole;
+ char global_optimizer;
+ char side_effects;
+ Boolean internal;
+ Boolean import;
+ Boolean export;
+ Boolean lib_export;
+ char nosyminline;
+ char force_active;
+ char optimizationlevel;
+ Boolean optimize_for_size;
+ char optimizewithasm;
+ Boolean 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;
+ Boolean isGeneratingDebugInfo;
+ CWDataType pchCreator;
+ CWDataType pchType;
+ CWDataType text;
+ HashNameNode *forcedSegment; // when set by #pragma segment
+} COpts;
+
+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;
+
+typedef struct CallbackAction {
+ struct CallbackAction *next;
+ Object *obj;
+ TypeClass *tclass;
+} CallbackAction;
+
+extern FileOffsetInfo cparser_fileoffset;
+extern TStreamElement symdecltoken;
+extern ParserTryBlock *trychain;
+extern Boolean inassembler;
+extern Boolean dont_set_references;
+extern TypeStruct ptmstruct;
+extern TypeStruct catchinfostruct;
+extern Boolean in_assembler;
+extern Boolean illegalimplicitconversion;
+extern Boolean in_func_arglist;
+extern NameSpaceName *newp_fobj;
+extern NameSpaceName *newa_fobj;
+extern NameSpaceName *delp_fobj;
+extern NameSpaceName *dela_fobj;
+extern Object *newh_func;
+extern Object *delh_func;
+extern Object *copy_func;
+extern Object *clear_func;
+extern Object *Rgtid_func;
+extern Object *Rdync_func;
+extern Object *rt_ptmf_cast;
+extern Object *rt_ptmf_cmpr;
+extern Object *rt_ptmf_test;
+extern Object *rt_ptmf_call;
+extern Object *rt_ptmf_scall;
+extern Object *rt_ptmf_call4;
+extern Object *rt_ptmf_scall4;
+extern Object *rt_ptmf_null;
+extern Object *rt_som_new;
+extern Object *rt_som_newcheck;
+extern Object *rt_som_check;
+extern Object *rt_som_glue1;
+extern Object *rt_som_glue2;
+extern Object *rt_som_glue3;
+extern Object *carr_func;
+extern Object *cnar_func;
+extern Object *darr_func;
+extern Object *dnar_func;
+extern Object *dnar3_func;
+extern Object *Xgreg_func;
+extern Object *Xthrw_func;
+extern Object *Xicth_func;
+extern Object *Xecth_func;
+extern Object *Xunex_func;
+extern COpts copts;
+extern struct GList name_mangle_list;
+extern HashNameNode *no_name_node;
+extern HashNameNode *temp_argument_name;
+extern HashNameNode *this_name_node;
+extern HashNameNode *self_name_node;
+extern HashNameNode *vptr_name_node;
+extern CallbackAction *callbackactions;
+extern Boolean fatalerrors;
+extern Boolean anyerrors;
+extern jmp_buf errorreturn;
+extern char string[256];
+extern SInt32 compilererrornum;
+extern SInt32 compilererrfile;
+extern SInt32 compilererrline;
+
+extern Type sttemplexpr;
+extern Type stillegal;
+extern Type stvoid;
+extern TypePointer void_ptr;
+extern TypeFunc rt_func;
+
+enum {
+ ATOM_VOID = 1,
+ ATOM_CHAR,
+ ATOM_UCHAR,
+ ATOM_WCHAR,
+ ATOM_SHORT,
+ ATOM_USHORT,
+ ATOM_INT,
+ ATOM_UINT,
+ ATOM_LONG,
+ ATOM_ULONG,
+ ATOM_LONGLONG,
+ ATOM_ULONGLONG,
+ ATOM_FLOAT,
+ ATOM_SHORTDOUBLE,
+ ATOM_DOUBLE,
+ ATOM_LONGDOUBLE
+};
+
+extern Object *CParser_NewRTFunc(Type *rettype, HashNameNode *name, Boolean flag, int argcount, ...);
+extern Boolean CParser_IsPublicRuntimeObject(Object *obj);
+extern Object *CParser_FindPublicRuntimeObject(HashNameNode *name);
+extern Boolean CParser_ReInitRuntimeObjects(Boolean is_precompiler);
+extern void CParser_Setup(void);
+extern void CParser_Cleanup(void);
+extern short GetPrec(short token);
+extern Boolean CParser_ParseOperatorName(short *token, Boolean flag1, Boolean flag2);
+extern SInt32 CParser_GetUniqueID(void);
+extern void CParser_PrintUniqueID(char *buf);
+extern void CParser_SetUniqueID(SInt32 id);
+extern HashNameNode *CParser_GetUniqueName(void);
+extern HashNameNode *CParser_NameConcat(char *a, char *b);
+extern HashNameNode *CParser_AppendUniqueName(char *prefix);
+extern HashNameNode *CParser_AppendUniqueNameFile(char *prefix);
+extern Boolean IsTempName(HashNameNode *name);
+extern void CParser_UpdateObject(Object *object, DeclInfo *declinfo);
+extern Object *CParser_NewObject(DeclInfo *declinfo);
+extern Object *CParser_NewLocalDataObject(DeclInfo *declinfo, Boolean add_to_locals);
+extern Object *CParser_NewGlobalDataObject(DeclInfo *declinfo);
+extern Object *CParser_NewCompilerDefDataObject(void);
+extern Object *CParser_NewFunctionObject(DeclInfo *declinfo);
+extern Object *CParser_NewCompilerDefFunctionObject(void);
+extern Object *CParser_NewAliasObject(Object *object, SInt32 offset);
+extern FuncArg *CParser_NewFuncArg(void);
+extern Type *atomtype(void);
+extern Object *CParser_FindDeallocationObject(Type *type, FuncArg *args, Boolean flag1, Boolean flag2, Boolean *outflag);
+extern short is_memberpointerequal(Type *a, Type *b);
+extern short is_typeequal(Type *a, Type *b);
+extern short iscpp_typeequal(Type *a, Type *b);
+extern short CParser_CompareArgLists(FuncArg *a, FuncArg *b);
+extern Boolean is_arglistsame(FuncArg *a, FuncArg *b);
+extern short is_typesame(Type *a, Type *b);
+extern Type *CParser_GetBoolType(void);
+extern Type *CParser_GetWCharType(void);
+extern short CParser_GetOperator(ENodeType t);
+extern Boolean CParser_IsMoreCVQualified(UInt32 a, UInt32 b);
+extern Boolean CParser_IsSameOrMoreCVQualified(UInt32 a, UInt32 b);
+extern Boolean is_unsigned(Type *type);
+extern StructMember *ismember(TypeStruct *tstruct, HashNameNode *name);
+extern void appendmember(TypeStruct *tstruct, StructMember *member);
+extern Boolean isdeclaration(UInt8 flag1, UInt8 flag2, UInt8 flag3, short token);
+extern Boolean islookaheaddeclaration(void);
+extern Type *CParser_ParseTypeID(UInt32 *qual, Boolean *flag);
+extern Boolean CParser_TryFuncDecl(void);
+extern Boolean CParser_TryParamList(Boolean flag);
+extern Type *CParser_RemoveTopMostQualifiers(Type *type, UInt32 *qual);
+extern UInt32 CParser_GetTypeQualifiers(Type *type, UInt32 qual);
+extern UInt32 CParser_GetCVTypeQualifiers(Type *type, UInt32 qual);
+extern Boolean CParser_IsConst(Type *type, UInt32 qual);
+extern Boolean CParser_IsVolatile(Type *type, UInt32 qual);
+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_IsVirtualFunction(Object *obj, TypeClass **tclass, SInt32 *index);
+extern Boolean is_pascal_object(Object *obj);
+extern Boolean is_cfm_type(Type *type);
+extern Boolean CParser_IsVTableObject(Object *obj);
+extern void TypedefDeclInfo(DeclInfo *declinfo, Type *type, UInt32 qual);
+extern void CParser_ParseAttribute(Type *type, DeclInfo *declinfo);
+extern void CParser_ParseDeclSpec(DeclInfo *declinfo, Boolean flag);
+extern Boolean CParser_CheckTemplateClassUsage(TemplClass *tmclass, Boolean flag);
+extern void CParser_GetDeclSpecs(DeclInfo *di, Boolean flag);
+extern void CParser_RegisterNonGlobalClass(TypeClass *tclass);
+extern void CParser_RegisterSingleExprFunction(Object *func, ENode *expr);
+extern void CParser_RegisterDummyCtorFunction(Object *func, Object *obj);
+extern Boolean CParser_IsAnonymousUnion(DeclInfo *di, Boolean flag);
+extern void CParser_CheckAnonymousUnion(DeclInfo *di, Boolean flag);
+extern void CParser_NewCallBackAction(Object *obj, TypeClass *tclass);
+extern void CParser_NewClassAction(TypeClass *tclass);
+extern void CParser_CallBackAction(Object *obj);
+extern Object *CParser_ParseObject(void);
+extern void CParser_ParseGlobalDeclaration(void);
+extern void cparser(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h
new file mode 100644
index 0000000..a681ec5
--- /dev/null
+++ b/includes/compiler/CPrep.h
@@ -0,0 +1,122 @@
+#ifndef COMPILER_CPREP_H
+#define COMPILER_CPREP_H
+
+#include "compiler/common.h"
+#include "compiler/tokens.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct Macro {
+ struct Macro *next;
+ HashNameNode *name;
+ void *c;
+ unsigned short xC;
+ 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 CPrepFileInfo *cprep_cursymfile;
+extern char *pos;
+extern char *macropos;
+extern char *nextcharpos;
+extern unsigned 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 struct GList pplist;
+extern TStreamElement *ts_current;
+extern SInt32 ts_preread_elements;
+
+extern void CPrep_InsertSpecialMacro(Macro *macro, char *name);
+extern void CPrep_InsertSpecialMacros(void);
+extern void CPrep_RemoveSpecialMacros(void);
+extern Boolean setupprep(void);
+extern void cleanupprep(void);
+extern void CPrep_TSBufferGrow(int amount);
+extern void CPrep_TokenStreamGetState(SInt32 *state);
+extern void CPrep_TokenStreamSetState(SInt32 *state);
+extern void CPrep_UnLex(void);
+extern void CPrep_TokenStreamSetCurState(SInt32 *state);
+typedef void (*CPrepStreamFuncPtr)(TStreamElement *);
+extern void CPrep_StreamGetBlock(TStream *stream, CPrepStreamFuncPtr func, int arg);
+extern void CPrep_StreamGetSemicolon(TStream *stream, CPrepStreamFuncPtr func);
+extern void CPrep_StreamGetTemplate(TStream *stream, CPrepStreamFuncPtr func);
+extern void CPrep_StreamInsert(TStream *stream, SInt32 *state);
+extern void CPrep_StreamRemove(TStream *stream, SInt32 *state);
+extern void CPrep_RemoveTokens(SInt32 amount);
+extern void CPrep_TokenStreamFlush(void);
+extern TStreamElement *CPrep_CurStreamElement(void);
+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(void);
+extern void CPrep_SetSourceFile(FileOffsetInfo *foi);
+extern HashNameNode *CPrep_GetSourceFilePath(CPrepFileInfo *fileinfo);
+extern void CPrep_NewFileOffsetInfo(FileOffsetInfo *foi, TStreamElement *ts);
+extern SInt32 CPrep_GetFileOffsetInfo(FileOffsetInfo *foi);
+extern void CPrep_GetFileOffsetInfo2(FileOffsetInfo *foi, SInt32 *pLine, HashNameNode **pName);
+extern void CPrep_ResetFileInfo(FileOffsetInfo *foi);
+extern void CPrep_GetPrepPos(CPrepFileInfo **file, SInt32 *ppos);
+extern UInt8 C_Compiler(CParams *param);
+extern void poptokenseq(void);
+extern void foundnl(void);
+extern void newline(void);
+extern short notendofline(void);
+extern char *CPrep_GetFileName(char *buffer, Boolean flag1, Boolean flag2);
+extern Boolean macrotest(void);
+extern short CPrep_PragmaLex(Boolean no_err);
+extern void CPrep_PushOption(SInt32 id, char value);
+extern void CPrep_PopOption(SInt32 id);
+extern void preprocessor(void);
+extern SInt32 CPrep_BrowserTokenOffset(FileOffsetInfo *foi);
+extern SInt32 CPrep_BrowserFileOffset(void);
+extern void CPrep_BrowserFilePosition(CPrepFileInfo **fileinfo, SInt32 *offset);
+extern CPrepFileInfo *CPrep_BrowserCurrentFile(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CPrepTokenizer.h b/includes/compiler/CPrepTokenizer.h
new file mode 100644
index 0000000..f65cff6
--- /dev/null
+++ b/includes/compiler/CPrepTokenizer.h
@@ -0,0 +1,32 @@
+#ifndef COMPILER_CPREPTOKENIZER_H
+#define COMPILER_CPREPTOKENIZER_H
+
+#include "compiler/common.h"
+#include "compiler/tokens.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+extern short prepskipnextchar(void);
+extern short prepnextchar(void);
+extern short prepnextstringchar(char *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 void skipendofline(void);
+extern void CPrep_SkipAsmComment(void);
+extern short lookahead(void);
+extern short lookahead_noeol(void);
+extern short lex(void);
+extern short plex(void);
+extern short lexidentifier(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CScope.h b/includes/compiler/CScope.h
new file mode 100644
index 0000000..95266b1
--- /dev/null
+++ b/includes/compiler/CScope.h
@@ -0,0 +1,107 @@
+#ifndef COMPILER_CSCOPE_H
+#define COMPILER_CSCOPE_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+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;
+ UInt32 xC; // qual
+ 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(void);
+extern void CScope_Cleanup(void);
+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(void);
+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, UInt32 *qual);
+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, short access, Boolean flag);
+extern void CScope_ParseNameSpaceAlias(HashNameNode *name);
+extern void CScope_ParseUsingDirective(NameSpace *nspace);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/CodeGen.h b/includes/compiler/CodeGen.h
new file mode 100644
index 0000000..3954d51
--- /dev/null
+++ b/includes/compiler/CodeGen.h
@@ -0,0 +1,79 @@
+#ifndef COMPILER_CODEGEN_H
+#define COMPILER_CODEGEN_H
+
+#include "compiler/common.h"
+#include "compiler/CPrep.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+extern Macro vecM;
+extern Macro altivecM;
+extern Object *gFunction;
+extern PCodeLabel *returnlabel;
+extern PCodeLabel *cleanreturnlabel;
+extern Boolean needs_cleanup;
+extern Statement *current_statement;
+extern int has_catch_blocks;
+extern int disable_optimizer;
+extern SInt32 current_linenumber;
+extern Boolean has_altivec_arrays;
+extern short high_reg;
+extern short low_reg;
+extern short high_offset;
+extern short low_offset;
+extern short low_reg2;
+extern short high_reg2;
+extern PCodeLabel *pic_base_pcodelabel;
+extern Object *dyld_stub_binding_helper;
+extern Object *rt_cvt_fp2unsigned;
+extern Object *rt_profile_entry;
+extern Object *rt_profile_exit;
+extern Object *rt_div2i;
+extern Object *rt_div2u;
+extern Object *rt_mod2i;
+extern Object *rt_mod2u;
+extern Object *rt_shr2i;
+extern Object *rt_shr2u;
+extern Object *rt_shl2i;
+extern Object *rt_cvt_ull_dbl;
+extern Object *rt_cvt_sll_dbl;
+extern Object *rt_cvt_ull_flt;
+extern Object *rt_cvt_sll_flt;
+extern Object *rt_cvt_dbl_usll;
+
+extern VarInfo *CodeGen_GetNewVarInfo(void);
+extern Object *maketemporary(Type *type);
+typedef void (*ArgumentProcessor)(Object *obj, short reg);
+extern void process_arguments(ArgumentProcessor func, Boolean flag);
+extern void move_assigned_argument(Object *obj, short reg);
+extern void assign_labels();
+extern void CodeGen_Generator();
+extern void CodeGen_GenVDispatchThunk();
+extern void CodeGen_SetupRuntimeObjects();
+extern Boolean CodeGen_ReInitRuntimeObjects(Boolean is_precompiler);
+extern Boolean CodeGen_IsPublicRuntimeObject(Object *obj);
+extern void CodeGen_SOMStub();
+extern void CodeGen_ParseDeclSpec(HashNameNode *identifier, DeclInfo *declinfo);
+extern void CodeGen_ParsePragma(HashNameNode *name);
+extern void CodeGen_UpdateObject(Object *object);
+extern void CodeGen_UpdateBackEndOptions();
+extern void CodeGen_objc_method_self_offset();
+extern void CodeGen_objc_method_sel_offset();
+extern void CodeGen_objc_method_arg_offset();
+extern void CodeGen_objc_method_args_size();
+extern void CodeGen_HandleIntrinsicCall();
+extern void CodeGen_HandleTypeCast();
+extern short CodeGen_AssignCheck(ENode *expr, Type *type, Boolean flag1, Boolean flag2);
+extern void CodeGen_CollapseVectorExpression();
+extern void CodeGen_InsertSpecialMacros();
+extern char *CodeGen_ExpandSpecialMacro(Macro *macro);
+extern void CodeGen_reportheapinfo();
+extern void CodeGen_InitialSanityCheck();
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/Operands.h b/includes/compiler/Operands.h
new file mode 100644
index 0000000..8c6aa93
--- /dev/null
+++ b/includes/compiler/Operands.h
@@ -0,0 +1,85 @@
+#ifndef COMPILER_OPERANDS_H
+#define COMPILER_OPERANDS_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+extern Float one_point_zero;
+
+enum OperandType {
+ // Value in a register (identified by 'reg')
+ OpndType_GPR = 0,
+ // Uses 'reg', 'object, 'immOffset'
+ OpndType_GPR_ImmOffset = 1,
+ // Uses 'reg', 'regOffset'
+ OpndType_GPR_Indexed = 2,
+ // Value in two registers (identified by 'reg' and 'regHi')
+ OpndType_GPRPair = 3,
+ // Value at an absolute address (identified by 'abs_address')
+ OpndType_Absolute = 4,
+ // Value in a float register (identified by 'reg')
+ OpndType_FPR = 5,
+ // Value in a vector register (identified by 'reg')
+ OpndType_VR = 6,
+ // Condition value: 'reg' stores which condition register, and 'regOffset' is equal to ENOTEQU, EEQU, EGREATEREQU,
+ // ELESS, ELESS or ELESSEQU
+ OpndType_CRField = 7,
+ // Value of a symbol (identified by 'object')
+ OpndType_Symbol = 8,
+ // Reference to a location (at 'reg', offset using 'object' and 'immOffset')
+ OpndType_IndirectGPR_ImmOffset = 9,
+ // Reference to a location (at 'reg', offset using the value of register 'regOffset')
+ OpndType_IndirectGPR_Indexed = 0xA,
+ // Reference to a symbol (identified by 'object')
+ OpndType_IndirectSymbol = 0xB
+};
+
+// These are probably the same as the PCode Flags and can be unified?
+enum {
+ OpndFlags_Const = 0x40,
+ OpndFlags_Volatile = 0x80
+};
+
+struct Operand {
+ enum OperandType optype;
+ SInt16 reg;
+ SInt16 regHi;
+ SInt16 regOffset;
+ SInt32 immOffset;
+ SInt32 abs_address;
+ Object *object;
+ UInt32 flags;
+};
+
+extern void load_immediate(short reg, SInt32 value);
+extern void symbol_operand(Operand *op, Object *obj);
+extern void indirect(Operand *op, ENode *expr);
+extern void combine(Operand *opA, Operand *opB, short output_reg, Operand *opOut);
+extern void coerce_to_addressable(Operand *op);
+extern void Coerce_to_register(Operand *op, Type *type, short output_reg);
+extern void coerce_to_register_pair(Operand *op, Type *type, short output_reg, short output_regHi);
+extern void Coerce_to_fp_register(Operand *op, TypeIntegral *tint, short output_reg);
+extern void Coerce_to_v_register(Operand *op, TypeStruct *tstruct, short output_reg);
+extern void store(short reg, Operand *op, Type *type);
+extern void store_pair(short reg, short regHi, Operand *op, Type *type);
+extern void store_fp(short reg, Operand *op, TypeIntegral *tint);
+extern void store_v(short reg, Operand *op, TypeStruct *tstruct);
+extern void extend32(Operand *op, Type *type, short output_reg);
+extern void extend64(Operand *op, Type *type, short output_reg, short output_regHi);
+extern void load_floating_constant(short reg, TypeIntegral *type, double *data);
+extern void convert_integer_to_floating(Operand *op, Boolean is_single, short output_reg);
+extern void convert_unsigned_to_floating(Operand *op, Boolean is_single, short output_reg);
+extern void convert_floating_to_integer(Operand *op, short output_reg);
+extern void convert_floating_to_unsigned(Operand *op, short output_reg);
+extern void extract_bitfield(Operand *input_op, TypeBitfield *tbitfield, short output_reg, Operand *output_op);
+extern void insert_bitfield(short reg, Operand *op, TypeBitfield *tbitfield);
+extern void load_address(short dest_reg, Operand *op);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/PCode.h b/includes/compiler/PCode.h
new file mode 100644
index 0000000..55aac38
--- /dev/null
+++ b/includes/compiler/PCode.h
@@ -0,0 +1,194 @@
+#ifndef COMPILER_PCODE_H
+#define COMPILER_PCODE_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+#define PCODE_FLAG_SET_T(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? (pcode)->flags : 0)
+#define PCODE_FLAG_SET_F(pcode) (((pcode)->flags & (fPCodeFlag1 | fPCodeFlag8)) ? 0 : (pcode)->flags)
+
+enum {
+ EffectRead = 1,
+ EffectWrite = 2
+};
+
+typedef enum {
+ PCOp_REGISTER,
+ PCOp_SYSREG,
+ PCOp_IMMEDIATE,
+ PCOp_MEMORY,
+ PCOp_LABEL,
+ PCOp_LABELDIFF,
+ PCOp_PLACEHOLDEROPERAND
+} PCOpKind;
+
+typedef enum {
+ RefType_0,
+ RefType_1,
+ RefType_2,
+ RefType_3,
+ RefType_4,
+ RefType_5,
+ RefType_6,
+ RefType_7,
+ RefType_8,
+ RefType_9,
+ RefType_A,
+ RefType_B,
+ RefType_C,
+ RefType_D
+} PCRefType;
+
+struct PCodeArg {
+ PCOpKind kind;
+ char arg;
+ union {
+ struct {
+ unsigned short effect;
+ short reg;
+ } reg;
+ struct {
+ SInt32 value;
+ Object *obj;
+ } imm;
+ struct {
+ SInt32 offset;
+ Object *obj;
+ } mem;
+ struct {
+ PCodeLabel *label;
+ } label;
+ struct {
+ SInt16 offset;
+ PCodeLabel *labelA;
+ PCodeLabel *labelB;
+ } labeldiff;
+ unsigned char placeholder[10]; // keep the size
+ } data;
+};
+
+struct PCode {
+ PCode *nextPCode;
+ PCode *prevPCode;
+ PCodeBlock *block;
+ unsigned int xx_C;
+ unsigned int _10;
+ int flags;
+ void *_18;
+ SInt32 sourceoffset;
+ short op;
+ short argCount;
+ PCodeArg args[0];
+};
+
+struct PCodeLabel {
+ PCodeLabel *nextLabel;
+ PCodeBlock *block;
+ short resolved;
+ short index;
+};
+
+typedef struct _PCLink {
+ struct _PCLink *nextLink;
+ struct PCodeBlock *block;
+} PCLink;
+
+struct PCodeBlock {
+ struct PCodeBlock *nextBlock;
+ struct PCodeBlock *prevBlock;
+ PCodeLabel *labels;
+ PCLink *predecessors;
+ PCLink *successors;
+ PCode *firstPCode;
+ PCode *lastPCode;
+ int blockIndex;
+ int codeOffset; // in bytes
+ int loopWeight;
+ short pcodeCount;
+ unsigned short flags;
+};
+
+/* PCode Flags */
+enum {
+ fPCodeFlag1 = 1,
+ fPCodeFlag2 = 2,
+ fPCodeFlag4 = 4,
+ fPCodeFlag8 = 8,
+ fPCodeFlag10 = 0x10,
+ fPCodeFlag20 = 0x20,
+ // Always valid
+ fIsConst = 0x40,
+ fIsVolatile = 0x80,
+ fSideEffects = 0x100,
+ fPCodeFlag200 = 0x200, // ?
+ fPCodeFlag400 = 0x400, // ?
+ fPCodeFlag800 = 0x800, // ?
+ fPCodeFlag1000 = 0x1000, // ?
+ fCommutative = 0x2000,
+ fIsCSE = 0x4000,
+ fPCodeFlag8000 = 0x8000,
+ fPCodeFlag20000 = 0x20000, // ?
+ fPCodeFlag40000 = 0x40000, // ?
+ // Set 1 only
+ fLink = 0x1000000,
+ fBranchNotTaken = 0x4000000,
+ fBranchTaken = 0x8000000,
+ fAbsolute = 0x10000000,
+ // Set 2 only
+ fIsPtrOp = 0x20,
+ fOverflow = 0x800000,
+ fSetsCarry = 0x10000000,
+ // ??
+ fPCodeFlag8000000 = 0x8000000,
+ fPCodeFlag10000000 = 0x10000000,
+ fPCodeFlag20000000 = 0x20000000,
+ fPCodeFlag40000000 = 0x40000000,
+ fPCodeFlag80000000 = 0x80000000
+};
+
+enum {
+ fPCBlockFlag1 = 1, // prologue
+ fPCBlockFlag2 = 2, // epilogue
+ fPCBlockFlag4 = 4,
+ fPCBlockFlag8 = 8,
+ fPCBlockFlag10 = 0x10,
+ fPCBlockFlag20 = 0x20,
+ fPCBlockFlag4000 = 0x4000
+};
+
+extern PCodeBlock *pcbasicblocks;
+extern PCodeBlock *pclastblock;
+extern PCodeBlock *prologue;
+extern PCodeBlock *epilogue;
+extern PCodeBlock **depthfirstordering;
+extern int pcblockcount;
+extern int pcloopweight;
+
+extern void initpcode();
+extern PCode *makepcode(short op, ...);
+extern void emitpcode(short op, ...);
+extern PCode *copypcode(PCode *pcode);
+extern PCodeLabel *makepclabel();
+extern PCodeBlock *makepcblock();
+extern void pclabel(PCodeBlock *block, PCodeLabel *label);
+extern void pcbranch(PCodeBlock *block, PCodeLabel *label);
+extern void pccomputepredecessors();
+extern void deleteblock(PCodeBlock *block);
+extern void deleteunreachableblocks();
+extern void appendpcode(PCodeBlock *block, PCode *pcode);
+extern void deletepcode(PCode *pcode);
+extern void insertpcodebefore(PCode *anchor, PCode *newpcode);
+extern void insertpcodeafter(PCode *anchor, PCode *newpcode);
+extern void setpcodeflags(int flags);
+extern void clearpcodeflags(int flags);
+extern int pccomputeoffsets();
+extern void computedepthfirstordering();
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/PCodeInfo.h b/includes/compiler/PCodeInfo.h
new file mode 100644
index 0000000..137e10a
--- /dev/null
+++ b/includes/compiler/PCodeInfo.h
@@ -0,0 +1,1335 @@
+#ifndef COMPILER_PCODEINFO_H
+#define COMPILER_PCODEINFO_H
+
+#include "compiler/PCode.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct _OpcodeInfo {
+ const char *name;
+ const char *format;
+ unsigned char x8;
+ unsigned char x9;
+ int flags;
+ unsigned int insn;
+} OpcodeInfo;
+
+/*enum {
+ PC_B = 0x0,
+ PC_BL = 0x1,
+ PC_BC = 0x2,
+ PC_BCLR = 0x3,
+ PC_BCCTR = 0x4,
+ PC_BT = 0x5,
+ PC_BTLR = 0x6,
+ PC_BTCTR = 0x7,
+ PC_BF = 0x8,
+ PC_BFLR = 0x9,
+ PC_BFCTR = 0xA,
+ PC_BDNZ = 0xB,
+ PC_BDNZT = 0xC,
+ PC_BDNZF = 0xD,
+ PC_BDZ = 0xE,
+ PC_BDZT = 0xF,
+ PC_BDZF = 0x10,
+ PC_BLR = 0x11,
+ PC_BCTR = 0x12,
+ PC_BCTRL = 0x13,
+ PC_BLRL = 0x14,
+ PC_LBZ = 0x15,
+ PC_LBZU = 0x16,
+ PC_LBZX = 0x17,
+ PC_LBZUX = 0x18,
+ PC_LHZ = 0x19,
+ PC_LHZU = 0x1A,
+ PC_LHZX = 0x1B,
+ PC_LHZUX = 0x1C,
+ PC_LHA = 0x1D,
+ PC_LHAU = 0x1E,
+ PC_LHAX = 0x1F,
+ PC_LHAUX = 0x20,
+ PC_LHBRX = 0x21,
+ PC_LWZ = 0x22,
+ PC_LWZU = 0x23,
+ PC_LWZX = 0x24,
+ PC_LWZUX = 0x25,
+ PC_LWBRX = 0x26,
+ PC_LMW = 0x27,
+ PC_STB = 0x28,
+ PC_STBU = 0x29,
+ PC_STBX = 0x2A,
+ PC_STBUX = 0x2B,
+ PC_STH = 0x2C,
+ PC_STHU = 0x2D,
+ PC_STHX = 0x2E,
+ PC_STHUX = 0x2F,
+ PC_STHBRX = 0x30,
+ PC_STW = 0x31,
+ PC_STWU = 0x32,
+ PC_STWX = 0x33,
+ PC_STWUX = 0x34,
+ PC_STWBRX = 0x35,
+ PC_STMW = 0x36,
+ PC_DCBF = 0x37,
+ PC_DCBST = 0x38,
+ PC_DCBT = 0x39,
+ PC_DCBTST = 0x3A,
+ PC_DCBZ = 0x3B,
+ PC_ADD = 0x3C,
+ PC_ADDC = 0x3D,
+ PC_ADDE = 0x3E,
+ PC_ADDI = 0x3F,
+ PC_ADDIC = 0x40,
+ PC_ADDICR = 0x41,
+ PC_ADDIS = 0x42,
+ PC_ADDME = 0x43,
+ PC_ADDZE = 0x44,
+ PC_DIVW = 0x45,
+ PC_DIVWU = 0x46,
+ PC_MULHW = 0x47,
+ PC_MULHWU = 0x48,
+ PC_MULLI = 0x49,
+ PC_MULLW = 0x4A,
+ PC_NEG = 0x4B,
+ PC_SUBF = 0x4C,
+ PC_SUBFC = 0x4D,
+ PC_SUBFE = 0x4E,
+ PC_SUBFIC = 0x4F,
+ PC_SUBFME = 0x50,
+ PC_SUBFZE = 0x51,
+ PC_CMPI = 0x52,
+ PC_CMP = 0x53,
+ PC_CMPLI = 0x54,
+ PC_CMPL = 0x55,
+ PC_ANDI = 0x56,
+ PC_ANDIS = 0x57,
+ PC_ORI = 0x58,
+ PC_ORIS = 0x59,
+ PC_XORI = 0x5A,
+ PC_XORIS = 0x5B,
+ PC_AND = 0x5C,
+ PC_OR = 0x5D,
+ PC_XOR = 0x5E,
+ PC_NAND = 0x5F,
+ PC_NOR = 0x60,
+ PC_EQV = 0x61,
+ PC_ANDC = 0x62,
+ PC_ORC = 0x63,
+ PC_EXTSB = 0x64,
+ PC_EXTSH = 0x65,
+ PC_CNTLZW = 0x66,
+ PC_RLWINM = 0x67,
+ PC_RLWNM = 0x68,
+ PC_RLWIMI = 0x69,
+ PC_SLW = 0x6A,
+ PC_SRW = 0x6B,
+ PC_SRAWI = 0x6C,
+ PC_SRAW = 0x6D,
+ PC_CRAND = 0x6E,
+ PC_CRANDC = 0x6F,
+ PC_CREQV = 0x70,
+ PC_CRNAND = 0x71,
+ PC_CRNOR = 0x72,
+ PC_CROR = 0x73,
+ PC_CRORC = 0x74,
+ PC_CRXOR = 0x75,
+ PC_MCRF = 0x76,
+ PC_MTXER = 0x77,
+ PC_MTCTR = 0x78,
+ PC_MTLR = 0x79,
+ PC_MTCRF = 0x7A,
+ PC_MTMSR = 0x7B,
+ PC_MTSPR = 0x7C,
+ PC_MFMSR = 0x7D,
+ PC_MFSPR = 0x7E,
+ PC_MFXER = 0x7F,
+ PC_MFCTR = 0x80,
+ PC_MFLR = 0x81,
+ PC_MFCR = 0x82,
+ PC_MFFS = 0x83,
+ PC_MTFSF = 0x84,
+ PC_EIEIO = 0x85,
+ PC_ISYNC = 0x86,
+ PC_SYNC = 0x87,
+ PC_RFI = 0x88,
+ PC_LI = 0x89,
+ PC_LIS = 0x8A,
+ PC_MR = 0x8B,
+ PC_NOP = 0x8C,
+ PC_NOT = 0x8D,
+ PC_LFS = 0x8E,
+ PC_LFSU = 0x8F,
+ PC_LFSX = 0x90,
+ PC_LFSUX = 0x91,
+ PC_LFD = 0x92,
+ PC_LFDU = 0x93,
+ PC_LFDX = 0x94,
+ PC_LFDUX = 0x95,
+ PC_STFS = 0x96,
+ PC_STFSU = 0x97,
+ PC_STFSX = 0x98,
+ PC_STFSUX = 0x99,
+ PC_STFD = 0x9A,
+ PC_STFDU = 0x9B,
+ PC_STFDX = 0x9C,
+ PC_STFDUX = 0x9D,
+ PC_FMR = 0x9E,
+ PC_FABS = 0x9F,
+ PC_FNEG = 0xA0,
+ PC_FNABS = 0xA1,
+ PC_FADD = 0xA2,
+ PC_FADDS = 0xA3,
+ PC_FSUB = 0xA4,
+ PC_FSUBS = 0xA5,
+ PC_FMUL = 0xA6,
+ PC_FMULS = 0xA7,
+ PC_FDIV = 0xA8,
+ PC_FDIVS = 0xA9,
+ PC_FMADD = 0xAA,
+ PC_FMADDS = 0xAB,
+ PC_FMSUB = 0xAC,
+ PC_FMSUBS = 0xAD,
+ PC_FNMADD = 0xAE,
+ PC_FNMADDS = 0xAF,
+ PC_FNMSUB = 0xB0,
+ PC_FNMSUBS = 0xB1,
+ PC_FRES = 0xB2,
+ PC_FRSQRTE = 0xB3,
+ PC_FSEL = 0xB4,
+ PC_FRSP = 0xB5,
+ PC_FCTIW = 0xB6,
+ PC_FCTIWZ = 0xB7,
+ PC_FCMPU = 0xB8,
+ PC_FCMPO = 0xB9,
+ PC_LWARX = 0xBA,
+ PC_LSWI = 0xBB,
+ PC_LSWX = 0xBC,
+ PC_STFIWX = 0xBD,
+ PC_STSWI = 0xBE,
+ PC_STSWX = 0xBF,
+ PC_STWCX = 0xC0,
+ PC_ECIWX = 0xC1,
+ PC_ECOWX = 0xC2,
+ PC_DCBI = 0xC3,
+ PC_ICBI = 0xC4,
+ PC_MCRFS = 0xC5,
+ PC_MCRXR = 0xC6,
+ PC_MFTB = 0xC7,
+ PC_MFSR = 0xC8,
+ PC_MTSR = 0xC9,
+ PC_MFSRIN = 0xCA,
+ PC_MTSRIN = 0xCB,
+ PC_MTFSB0 = 0xCC,
+ PC_MTFSB1 = 0xCD,
+ PC_MTFSFI = 0xCE,
+ PC_SC = 0xCF,
+ PC_FSQRT = 0xD0,
+ PC_FSQRTS = 0xD1,
+ PC_TLBIA = 0xD2,
+ PC_TLBIE = 0xD3,
+ PC_TLBLD = 0xD4,
+ PC_TLBLI = 0xD5,
+ PC_TLBSYNC = 0xD6,
+ PC_TW = 0xD7,
+ PC_TRAP = 0xD8,
+ PC_TWI = 0xD9,
+ PC_OPWORD = 0xDA,
+ PC_MFROM = 0xDB,
+ PC_DSA = 0xDC,
+ PC_ESA = 0xDD,
+ PC_DCCCI = 0xDE,
+ PC_DCREAD = 0xDF,
+ PC_ICBT = 0xE0,
+ PC_ICCCI = 0xE1,
+ PC_ICREAD = 0xE2,
+ PC_RFCI = 0xE3,
+ PC_TLBRE = 0xE4,
+ PC_TLBSX = 0xE5,
+ PC_TLBWE = 0xE6,
+ PC_WRTEE = 0xE7,
+ PC_WRTEEI = 0xE8,
+ PC_MFDCR = 0xE9,
+ PC_MTDCR = 0xEA,
+ PC_DCBA = 0xEB,
+ PC_DSS = 0xEC,
+ PC_DSSALL = 0xED,
+ PC_DST = 0xEE,
+ PC_DSTT = 0xEF,
+ PC_DSTST = 0xF0,
+ PC_DSTSTT = 0xF1,
+ PC_LVEBX = 0xF2,
+ PC_LVEHX = 0xF3,
+ PC_LVEWX = 0xF4,
+ PC_LVSL = 0xF5,
+ PC_LVSR = 0xF6,
+ PC_LVX = 0xF7,
+ PC_LVXL = 0xF8,
+ PC_STVEBX = 0xF9,
+ PC_STVEHX = 0xFA,
+ PC_STVEWX = 0xFB,
+ PC_STVX = 0xFC,
+ PC_STVXL = 0xFD,
+ PC_MFVSCR = 0xFE,
+ PC_MTVSCR = 0xFF,
+ PC_VADDCUW = 0x100,
+ PC_VADDFP = 0x101,
+ PC_VADDSBS = 0x102,
+ PC_VADDSHS = 0x103,
+ PC_VADDSWS = 0x104,
+ PC_VADDUBM = 0x105,
+ PC_VADDUBS = 0x106,
+ PC_VADDUHM = 0x107,
+ PC_VADDUHS = 0x108,
+ PC_VADDUWM = 0x109,
+ PC_VADDUWS = 0x10A,
+ PC_VAND = 0x10B,
+ PC_VANDC = 0x10C,
+ PC_VAVGSB = 0x10D,
+ PC_VAVGSH = 0x10E,
+ PC_VAVGSW = 0x10F,
+ PC_VAVGUB = 0x110,
+ PC_VAVGUH = 0x111,
+ PC_VAVGUW = 0x112,
+ PC_VCFSX = 0x113,
+ PC_VCFUX = 0x114,
+ PC_VCMPBFP = 0x115,
+ PC_VCMPEQFP = 0x116,
+ PC_VCMPEQUB = 0x117,
+ PC_VCMPEQUH = 0x118,
+ PC_VCMPEQUW = 0x119,
+ PC_VCMPGEFP = 0x11A,
+ PC_VCMPGTFP = 0x11B,
+ PC_VCMPGTSB = 0x11C,
+ PC_VCMPGTSH = 0x11D,
+ PC_VCMPGTSW = 0x11E,
+ PC_VCMPGTUB = 0x11F,
+ PC_VCMPGTUH = 0x120,
+ PC_VCMPGTUW = 0x121,
+ PC_VCTSXS = 0x122,
+ PC_VCTUXS = 0x123,
+ PC_VEXPTEFP = 0x124,
+ PC_VLOGEFP = 0x125,
+ PC_VMAXFP = 0x126,
+ PC_VMAXSB = 0x127,
+ PC_VMAXSH = 0x128,
+ PC_VMAXSW = 0x129,
+ PC_VMAXUB = 0x12A,
+ PC_VMAXUH = 0x12B,
+ PC_VMAXUW = 0x12C,
+ PC_VMINFP = 0x12D,
+ PC_VMINSB = 0x12E,
+ PC_VMINSH = 0x12F,
+ PC_VMINSW = 0x130,
+ PC_VMINUB = 0x131,
+ PC_VMINUH = 0x132,
+ PC_VMINUW = 0x133,
+ PC_VMRGHB = 0x134,
+ PC_VMRGHH = 0x135,
+ PC_VMRGHW = 0x136,
+ PC_VMRGLB = 0x137,
+ PC_VMRGLH = 0x138,
+ PC_VMRGLW = 0x139,
+ PC_VMULESB = 0x13A,
+ PC_VMULESH = 0x13B,
+ PC_VMULEUB = 0x13C,
+ PC_VMULEUH = 0x13D,
+ PC_VMULOSB = 0x13E,
+ PC_VMULOSH = 0x13F,
+ PC_VMULOUB = 0x140,
+ PC_VMULOUH = 0x141,
+ PC_VNOR = 0x142,
+ PC_VOR = 0x143,
+ PC_VPKPX = 0x144,
+ PC_VPKSHSS = 0x145,
+ PC_VPKSHUS = 0x146,
+ PC_VPKSWSS = 0x147,
+ PC_VPKSWUS = 0x148,
+ PC_VPKUHUM = 0x149,
+ PC_VPKUHUS = 0x14A,
+ PC_VPKUWUM = 0x14B,
+ PC_VPKUWUS = 0x14C,
+ PC_VREFP = 0x14D,
+ PC_VRFIM = 0x14E,
+ PC_VRFIN = 0x14F,
+ PC_VRFIP = 0x150,
+ PC_VRFIZ = 0x151,
+ PC_VRLB = 0x152,
+ PC_VRLH = 0x153,
+ PC_VRLW = 0x154,
+ PC_VRSQRTEFP = 0x155,
+ PC_VSL = 0x156,
+ PC_VSLB = 0x157,
+ PC_VSLH = 0x158,
+ PC_VSLO = 0x159,
+ PC_VSLW = 0x15A,
+ PC_VSPLTB = 0x15B,
+ PC_VSPLTH = 0x15C,
+ PC_VSPLTW = 0x15D,
+ PC_VSPLTISB = 0x15E,
+ PC_VSPLTISH = 0x15F,
+ PC_VSPLTISW = 0x160,
+ PC_VSR = 0x161,
+ PC_VSRAB = 0x162,
+ PC_VSRAH = 0x163,
+ PC_VSRAW = 0x164,
+ PC_VSRB = 0x165,
+ PC_VSRH = 0x166,
+ PC_VSRO = 0x167,
+ PC_VSRW = 0x168,
+ PC_VSUBCUW = 0x169,
+ PC_VSUBFP = 0x16A,
+ PC_VSUBSBS = 0x16B,
+ PC_VSUBSHS = 0x16C,
+ PC_VSUBSWS = 0x16D,
+ PC_VSUBUBM = 0x16E,
+ PC_VSUBUBS = 0x16F,
+ PC_VSUBUHM = 0x170,
+ PC_VSUBUHS = 0x171,
+ PC_VSUBUWM = 0x172,
+ PC_VSUBUWS = 0x173,
+ PC_VSUMSWS = 0x174,
+ PC_VSUM2SWS = 0x175,
+ PC_VSUM4SBS = 0x176,
+ PC_VSUM4SHS = 0x177,
+ PC_VSUM4UBS = 0x178,
+ PC_VUPKHPX = 0x179,
+ PC_VUPKHSB = 0x17A,
+ PC_VUPKHSH = 0x17B,
+ PC_VUPKLPX = 0x17C,
+ PC_VUPKLSB = 0x17D,
+ PC_VUPKLSH = 0x17E,
+ PC_VXOR = 0x17F,
+ PC_VMADDFP = 0x180,
+ PC_VMHADDSHS = 0x181,
+ PC_VMHRADDSHS = 0x182,
+ PC_VMLADDUHM = 0x183,
+ PC_VMSUMMBM = 0x184,
+ PC_VMSUMSHM = 0x185,
+ PC_VMSUMSHS = 0x186,
+ PC_VMSUMUBM = 0x187,
+ PC_VMSUMUHM = 0x188,
+ PC_VMSUMUHS = 0x189,
+ PC_VNMSUBFP = 0x18A,
+ PC_VPERM = 0x18B,
+ PC_VSEL = 0x18C,
+ PC_VSLDOI = 0x18D,
+ PC_VMR = 0x18E,
+ PC_VMRP = 0x18F,
+ PC_SLE = 0x190,
+ PC_SLEQ = 0x191,
+ PC_SLIQ = 0x192,
+ PC_SLLIQ = 0x193,
+ PC_SLLQ = 0x194,
+ PC_SLQ = 0x195,
+ PC_SRAIQ = 0x196,
+ PC_SRAQ = 0x197,
+ PC_SRE = 0x198,
+ PC_SREA = 0x199,
+ PC_SREQ = 0x19A,
+ PC_SRIQ = 0x19B,
+ PC_SRLIQ = 0x19C,
+ PC_SRLQ = 0x19D,
+ PC_SRQ = 0x19E,
+ PC_MASKG = 0x19F,
+ PC_MASKIR = 0x1A0,
+ PC_LSCBX = 0x1A1,
+ PC_DIV = 0x1A2,
+ PC_DIVS = 0x1A3,
+ PC_DOZ = 0x1A4,
+ PC_MUL = 0x1A5,
+ PC_NABS = 0x1A6,
+ PC_ABS = 0x1A7,
+ PC_CLCS = 0x1A8,
+ PC_DOZI = 0x1A9,
+ PC_RLMI = 0x1AA,
+ PC_RRIB = 0x1AB,
+ PC_PENTRY = 0x1AC,
+ PC_PEXIT = 0x1AD,
+ OPCODE_MAX = 0x1AE
+};*/
+//#define PC_B 0x0
+//#define PC_BL 0x1
+//#define PC_BC 0x2
+//#define PC_BCLR 0x3
+//#define PC_BCCTR 0x4
+//#define PC_BT 0x5
+//#define PC_BTLR 0x6
+//#define PC_BTCTR 0x7
+//#define PC_BF 0x8
+//#define PC_BFLR 0x9
+//#define PC_BFCTR 0xA
+//#define PC_BDNZ 0xB
+//#define PC_BDNZT 0xC
+//#define PC_BDNZF 0xD
+//#define PC_BDZ 0xE
+//#define PC_BDZT 0xF
+//#define PC_BDZF 0x10
+//#define PC_BLR 0x11
+//#define PC_BCTR 0x12
+//#define PC_BCTRL 0x13
+//#define PC_BLRL 0x14
+//#define PC_LBZ 0x15
+//#define PC_LBZU 0x16
+//#define PC_LBZX 0x17
+//#define PC_LBZUX 0x18
+//#define PC_LHZ 0x19
+//#define PC_LHZU 0x1A
+//#define PC_LHZX 0x1B
+//#define PC_LHZUX 0x1C
+//#define PC_LHA 0x1D
+//#define PC_LHAU 0x1E
+//#define PC_LHAX 0x1F
+//#define PC_LHAUX 0x20
+//#define PC_LHBRX 0x21
+//#define PC_LWZ 0x22
+//#define PC_LWZU 0x23
+//#define PC_LWZX 0x24
+//#define PC_LWZUX 0x25
+//#define PC_LWBRX 0x26
+//#define PC_LMW 0x27
+//#define PC_STB 0x28
+//#define PC_STBU 0x29
+//#define PC_STBX 0x2A
+//#define PC_STBUX 0x2B
+//#define PC_STH 0x2C
+//#define PC_STHU 0x2D
+//#define PC_STHX 0x2E
+//#define PC_STHUX 0x2F
+//#define PC_STHBRX 0x30
+//#define PC_STW 0x31
+//#define PC_STWU 0x32
+//#define PC_STWX 0x33
+//#define PC_STWUX 0x34
+//#define PC_STWBRX 0x35
+//#define PC_STMW 0x36
+//#define PC_DCBF 0x37
+//#define PC_DCBST 0x38
+//#define PC_DCBT 0x39
+//#define PC_DCBTST 0x3A
+//#define PC_DCBZ 0x3B
+//#define PC_ADD 0x3C
+//#define PC_ADDC 0x3D
+//#define PC_ADDE 0x3E
+//#define PC_ADDI 0x3F
+//#define PC_ADDIC 0x40
+//#define PC_ADDICR 0x41
+//#define PC_ADDIS 0x42
+//#define PC_ADDME 0x43
+//#define PC_ADDZE 0x44
+//#define PC_DIVW 0x45
+//#define PC_DIVWU 0x46
+//#define PC_MULHW 0x47
+//#define PC_MULHWU 0x48
+//#define PC_MULLI 0x49
+//#define PC_MULLW 0x4A
+//#define PC_NEG 0x4B
+//#define PC_SUBF 0x4C
+//#define PC_SUBFC 0x4D
+//#define PC_SUBFE 0x4E
+//#define PC_SUBFIC 0x4F
+//#define PC_SUBFME 0x50
+//#define PC_SUBFZE 0x51
+//#define PC_CMPI 0x52
+//#define PC_CMP 0x53
+//#define PC_CMPLI 0x54
+//#define PC_CMPL 0x55
+//#define PC_ANDI 0x56
+//#define PC_ANDIS 0x57
+//#define PC_ORI 0x58
+//#define PC_ORIS 0x59
+//#define PC_XORI 0x5A
+//#define PC_XORIS 0x5B
+//#define PC_AND 0x5C
+//#define PC_OR 0x5D
+//#define PC_XOR 0x5E
+//#define PC_NAND 0x5F
+//#define PC_NOR 0x60
+//#define PC_EQV 0x61
+//#define PC_ANDC 0x62
+//#define PC_ORC 0x63
+//#define PC_EXTSB 0x64
+//#define PC_EXTSH 0x65
+//#define PC_CNTLZW 0x66
+//#define PC_RLWINM 0x67
+//#define PC_RLWNM 0x68
+//#define PC_RLWIMI 0x69
+//#define PC_SLW 0x6A
+//#define PC_SRW 0x6B
+//#define PC_SRAWI 0x6C
+//#define PC_SRAW 0x6D
+//#define PC_CRAND 0x6E
+//#define PC_CRANDC 0x6F
+//#define PC_CREQV 0x70
+//#define PC_CRNAND 0x71
+//#define PC_CRNOR 0x72
+//#define PC_CROR 0x73
+//#define PC_CRORC 0x74
+//#define PC_CRXOR 0x75
+//#define PC_MCRF 0x76
+//#define PC_MTXER 0x77
+//#define PC_MTCTR 0x78
+//#define PC_MTLR 0x79
+//#define PC_MTCRF 0x7A
+//#define PC_MTMSR 0x7B
+//#define PC_MTSPR 0x7C
+//#define PC_MFMSR 0x7D
+//#define PC_MFSPR 0x7E
+//#define PC_MFXER 0x7F
+//#define PC_MFCTR 0x80
+//#define PC_MFLR 0x81
+//#define PC_MFCR 0x82
+//#define PC_MFFS 0x83
+//#define PC_MTFSF 0x84
+//#define PC_EIEIO 0x85
+//#define PC_ISYNC 0x86
+//#define PC_SYNC 0x87
+//#define PC_RFI 0x88
+//#define PC_LI 0x89
+//#define PC_LIS 0x8A
+//#define PC_MR 0x8B
+//#define PC_NOP 0x8C
+//#define PC_NOT 0x8D
+//#define PC_LFS 0x8E
+//#define PC_LFSU 0x8F
+//#define PC_LFSX 0x90
+//#define PC_LFSUX 0x91
+//#define PC_LFD 0x92
+//#define PC_LFDU 0x93
+//#define PC_LFDX 0x94
+//#define PC_LFDUX 0x95
+//#define PC_STFS 0x96
+//#define PC_STFSU 0x97
+//#define PC_STFSX 0x98
+//#define PC_STFSUX 0x99
+//#define PC_STFD 0x9A
+//#define PC_STFDU 0x9B
+//#define PC_STFDX 0x9C
+//#define PC_STFDUX 0x9D
+//#define PC_FMR 0x9E
+//#define PC_FABS 0x9F
+//#define PC_FNEG 0xA0
+//#define PC_FNABS 0xA1
+//#define PC_FADD 0xA2
+//#define PC_FADDS 0xA3
+//#define PC_FSUB 0xA4
+//#define PC_FSUBS 0xA5
+//#define PC_FMUL 0xA6
+//#define PC_FMULS 0xA7
+//#define PC_FDIV 0xA8
+//#define PC_FDIVS 0xA9
+//#define PC_FMADD 0xAA
+//#define PC_FMADDS 0xAB
+//#define PC_FMSUB 0xAC
+//#define PC_FMSUBS 0xAD
+//#define PC_FNMADD 0xAE
+//#define PC_FNMADDS 0xAF
+//#define PC_FNMSUB 0xB0
+//#define PC_FNMSUBS 0xB1
+//#define PC_FRES 0xB2
+//#define PC_FRSQRTE 0xB3
+//#define PC_FSEL 0xB4
+//#define PC_FRSP 0xB5
+//#define PC_FCTIW 0xB6
+//#define PC_FCTIWZ 0xB7
+//#define PC_FCMPU 0xB8
+//#define PC_FCMPO 0xB9
+//#define PC_LWARX 0xBA
+//#define PC_LSWI 0xBB
+//#define PC_LSWX 0xBC
+//#define PC_STFIWX 0xBD
+//#define PC_STSWI 0xBE
+//#define PC_STSWX 0xBF
+//#define PC_STWCX 0xC0
+//#define PC_ECIWX 0xC1
+//#define PC_ECOWX 0xC2
+//#define PC_DCBI 0xC3
+//#define PC_ICBI 0xC4
+//#define PC_MCRFS 0xC5
+//#define PC_MCRXR 0xC6
+//#define PC_MFTB 0xC7
+//#define PC_MFSR 0xC8
+//#define PC_MTSR 0xC9
+//#define PC_MFSRIN 0xCA
+//#define PC_MTSRIN 0xCB
+//#define PC_MTFSB0 0xCC
+//#define PC_MTFSB1 0xCD
+//#define PC_MTFSFI 0xCE
+//#define PC_SC 0xCF
+//#define PC_FSQRT 0xD0
+//#define PC_FSQRTS 0xD1
+//#define PC_TLBIA 0xD2
+//#define PC_TLBIE 0xD3
+//#define PC_TLBLD 0xD4
+//#define PC_TLBLI 0xD5
+//#define PC_TLBSYNC 0xD6
+//#define PC_TW 0xD7
+//#define PC_TRAP 0xD8
+//#define PC_TWI 0xD9
+//#define PC_OPWORD 0xDA
+//#define PC_MFROM 0xDB
+//#define PC_DSA 0xDC
+//#define PC_ESA 0xDD
+//#define PC_DCCCI 0xDE
+//#define PC_DCREAD 0xDF
+//#define PC_ICBT 0xE0
+//#define PC_ICCCI 0xE1
+//#define PC_ICREAD 0xE2
+//#define PC_RFCI 0xE3
+//#define PC_TLBRE 0xE4
+//#define PC_TLBSX 0xE5
+//#define PC_TLBWE 0xE6
+//#define PC_WRTEE 0xE7
+//#define PC_WRTEEI 0xE8
+//#define PC_MFDCR 0xE9
+//#define PC_MTDCR 0xEA
+//#define PC_DCBA 0xEB
+//#define PC_DSS 0xEC
+//#define PC_DSSALL 0xED
+//#define PC_DST 0xEE
+//#define PC_DSTT 0xEF
+//#define PC_DSTST 0xF0
+//#define PC_DSTSTT 0xF1
+//#define PC_LVEBX 0xF2
+//#define PC_LVEHX 0xF3
+//#define PC_LVEWX 0xF4
+//#define PC_LVSL 0xF5
+//#define PC_LVSR 0xF6
+//#define PC_LVX 0xF7
+//#define PC_LVXL 0xF8
+//#define PC_STVEBX 0xF9
+//#define PC_STVEHX 0xFA
+//#define PC_STVEWX 0xFB
+//#define PC_STVX 0xFC
+//#define PC_STVXL 0xFD
+//#define PC_MFVSCR 0xFE
+//#define PC_MTVSCR 0xFF
+//#define PC_VADDCUW 0x100
+//#define PC_VADDFP 0x101
+//#define PC_VADDSBS 0x102
+//#define PC_VADDSHS 0x103
+//#define PC_VADDSWS 0x104
+//#define PC_VADDUBM 0x105
+//#define PC_VADDUBS 0x106
+//#define PC_VADDUHM 0x107
+//#define PC_VADDUHS 0x108
+//#define PC_VADDUWM 0x109
+//#define PC_VADDUWS 0x10A
+//#define PC_VAND 0x10B
+//#define PC_VANDC 0x10C
+//#define PC_VAVGSB 0x10D
+//#define PC_VAVGSH 0x10E
+//#define PC_VAVGSW 0x10F
+//#define PC_VAVGUB 0x110
+//#define PC_VAVGUH 0x111
+//#define PC_VAVGUW 0x112
+//#define PC_VCFSX 0x113
+//#define PC_VCFUX 0x114
+//#define PC_VCMPBFP 0x115
+//#define PC_VCMPEQFP 0x116
+//#define PC_VCMPEQUB 0x117
+//#define PC_VCMPEQUH 0x118
+//#define PC_VCMPEQUW 0x119
+//#define PC_VCMPGEFP 0x11A
+//#define PC_VCMPGTFP 0x11B
+//#define PC_VCMPGTSB 0x11C
+//#define PC_VCMPGTSH 0x11D
+//#define PC_VCMPGTSW 0x11E
+//#define PC_VCMPGTUB 0x11F
+//#define PC_VCMPGTUH 0x120
+//#define PC_VCMPGTUW 0x121
+//#define PC_VCTSXS 0x122
+//#define PC_VCTUXS 0x123
+//#define PC_VEXPTEFP 0x124
+//#define PC_VLOGEFP 0x125
+//#define PC_VMAXFP 0x126
+//#define PC_VMAXSB 0x127
+//#define PC_VMAXSH 0x128
+//#define PC_VMAXSW 0x129
+//#define PC_VMAXUB 0x12A
+//#define PC_VMAXUH 0x12B
+//#define PC_VMAXUW 0x12C
+//#define PC_VMINFP 0x12D
+//#define PC_VMINSB 0x12E
+//#define PC_VMINSH 0x12F
+//#define PC_VMINSW 0x130
+//#define PC_VMINUB 0x131
+//#define PC_VMINUH 0x132
+//#define PC_VMINUW 0x133
+//#define PC_VMRGHB 0x134
+//#define PC_VMRGHH 0x135
+//#define PC_VMRGHW 0x136
+//#define PC_VMRGLB 0x137
+//#define PC_VMRGLH 0x138
+//#define PC_VMRGLW 0x139
+//#define PC_VMULESB 0x13A
+//#define PC_VMULESH 0x13B
+//#define PC_VMULEUB 0x13C
+//#define PC_VMULEUH 0x13D
+//#define PC_VMULOSB 0x13E
+//#define PC_VMULOSH 0x13F
+//#define PC_VMULOUB 0x140
+//#define PC_VMULOUH 0x141
+//#define PC_VNOR 0x142
+//#define PC_VOR 0x143
+//#define PC_VPKPX 0x144
+//#define PC_VPKSHSS 0x145
+//#define PC_VPKSHUS 0x146
+//#define PC_VPKSWSS 0x147
+//#define PC_VPKSWUS 0x148
+//#define PC_VPKUHUM 0x149
+//#define PC_VPKUHUS 0x14A
+//#define PC_VPKUWUM 0x14B
+//#define PC_VPKUWUS 0x14C
+//#define PC_VREFP 0x14D
+//#define PC_VRFIM 0x14E
+//#define PC_VRFIN 0x14F
+//#define PC_VRFIP 0x150
+//#define PC_VRFIZ 0x151
+//#define PC_VRLB 0x152
+//#define PC_VRLH 0x153
+//#define PC_VRLW 0x154
+//#define PC_VRSQRTEFP 0x155
+//#define PC_VSL 0x156
+//#define PC_VSLB 0x157
+//#define PC_VSLH 0x158
+//#define PC_VSLO 0x159
+//#define PC_VSLW 0x15A
+//#define PC_VSPLTB 0x15B
+//#define PC_VSPLTH 0x15C
+//#define PC_VSPLTW 0x15D
+//#define PC_VSPLTISB 0x15E
+//#define PC_VSPLTISH 0x15F
+//#define PC_VSPLTISW 0x160
+//#define PC_VSR 0x161
+//#define PC_VSRAB 0x162
+//#define PC_VSRAH 0x163
+//#define PC_VSRAW 0x164
+//#define PC_VSRB 0x165
+//#define PC_VSRH 0x166
+//#define PC_VSRO 0x167
+//#define PC_VSRW 0x168
+//#define PC_VSUBCUW 0x169
+//#define PC_VSUBFP 0x16A
+//#define PC_VSUBSBS 0x16B
+//#define PC_VSUBSHS 0x16C
+//#define PC_VSUBSWS 0x16D
+//#define PC_VSUBUBM 0x16E
+//#define PC_VSUBUBS 0x16F
+//#define PC_VSUBUHM 0x170
+//#define PC_VSUBUHS 0x171
+//#define PC_VSUBUWM 0x172
+//#define PC_VSUBUWS 0x173
+//#define PC_VSUMSWS 0x174
+//#define PC_VSUM2SWS 0x175
+//#define PC_VSUM4SBS 0x176
+//#define PC_VSUM4SHS 0x177
+//#define PC_VSUM4UBS 0x178
+//#define PC_VUPKHPX 0x179
+//#define PC_VUPKHSB 0x17A
+//#define PC_VUPKHSH 0x17B
+//#define PC_VUPKLPX 0x17C
+//#define PC_VUPKLSB 0x17D
+//#define PC_VUPKLSH 0x17E
+//#define PC_VXOR 0x17F
+//#define PC_VMADDFP 0x180
+//#define PC_VMHADDSHS 0x181
+//#define PC_VMHRADDSHS 0x182
+//#define PC_VMLADDUHM 0x183
+//#define PC_VMSUMMBM 0x184
+//#define PC_VMSUMSHM 0x185
+//#define PC_VMSUMSHS 0x186
+//#define PC_VMSUMUBM 0x187
+//#define PC_VMSUMUHM 0x188
+//#define PC_VMSUMUHS 0x189
+//#define PC_VNMSUBFP 0x18A
+//#define PC_VPERM 0x18B
+//#define PC_VSEL 0x18C
+//#define PC_VSLDOI 0x18D
+//#define PC_VMR 0x18E
+//#define PC_VMRP 0x18F
+//#define PC_SLE 0x190
+//#define PC_SLEQ 0x191
+//#define PC_SLIQ 0x192
+//#define PC_SLLIQ 0x193
+//#define PC_SLLQ 0x194
+//#define PC_SLQ 0x195
+//#define PC_SRAIQ 0x196
+//#define PC_SRAQ 0x197
+//#define PC_SRE 0x198
+//#define PC_SREA 0x199
+//#define PC_SREQ 0x19A
+//#define PC_SRIQ 0x19B
+//#define PC_SRLIQ 0x19C
+//#define PC_SRLQ 0x19D
+//#define PC_SRQ 0x19E
+//#define PC_MASKG 0x19F
+//#define PC_MASKIR 0x1A0
+//#define PC_LSCBX 0x1A1
+//#define PC_DIV 0x1A2
+//#define PC_DIVS 0x1A3
+//#define PC_DOZ 0x1A4
+//#define PC_MUL 0x1A5
+//#define PC_NABS 0x1A6
+//#define PC_ABS 0x1A7
+//#define PC_CLCS 0x1A8
+//#define PC_DOZI 0x1A9
+//#define PC_RLMI 0x1AA
+//#define PC_RRIB 0x1AB
+//#define PC_PENTRY 0x1AC
+//#define PC_PEXIT 0x1AD
+//#define OPCODE_MAX 0x1AE
+const short PC_B = 0x0;
+const short PC_BL = 0x1;
+const short PC_BC = 0x2;
+const short PC_BCLR = 0x3;
+const short PC_BCCTR = 0x4;
+const short PC_BT = 0x5;
+const short PC_BTLR = 0x6;
+const short PC_BTCTR = 0x7;
+const short PC_BF = 0x8;
+const short PC_BFLR = 0x9;
+const short PC_BFCTR = 0xA;
+const short PC_BDNZ = 0xB;
+const short PC_BDNZT = 0xC;
+const short PC_BDNZF = 0xD;
+const short PC_BDZ = 0xE;
+const short PC_BDZT = 0xF;
+const short PC_BDZF = 0x10;
+const short PC_BLR = 0x11;
+const short PC_BCTR = 0x12;
+const short PC_BCTRL = 0x13;
+const short PC_BLRL = 0x14;
+const short PC_LBZ = 0x15;
+const short PC_LBZU = 0x16;
+const short PC_LBZX = 0x17;
+const short PC_LBZUX = 0x18;
+const short PC_LHZ = 0x19;
+const short PC_LHZU = 0x1A;
+const short PC_LHZX = 0x1B;
+const short PC_LHZUX = 0x1C;
+const short PC_LHA = 0x1D;
+const short PC_LHAU = 0x1E;
+const short PC_LHAX = 0x1F;
+const short PC_LHAUX = 0x20;
+const short PC_LHBRX = 0x21;
+const short PC_LWZ = 0x22;
+const short PC_LWZU = 0x23;
+const short PC_LWZX = 0x24;
+const short PC_LWZUX = 0x25;
+const short PC_LWBRX = 0x26;
+const short PC_LMW = 0x27;
+const short PC_STB = 0x28;
+const short PC_STBU = 0x29;
+const short PC_STBX = 0x2A;
+const short PC_STBUX = 0x2B;
+const short PC_STH = 0x2C;
+const short PC_STHU = 0x2D;
+const short PC_STHX = 0x2E;
+const short PC_STHUX = 0x2F;
+const short PC_STHBRX = 0x30;
+const short PC_STW = 0x31;
+const short PC_STWU = 0x32;
+const short PC_STWX = 0x33;
+const short PC_STWUX = 0x34;
+const short PC_STWBRX = 0x35;
+const short PC_STMW = 0x36;
+const short PC_DCBF = 0x37;
+const short PC_DCBST = 0x38;
+const short PC_DCBT = 0x39;
+const short PC_DCBTST = 0x3A;
+const short PC_DCBZ = 0x3B;
+const short PC_ADD = 0x3C;
+const short PC_ADDC = 0x3D;
+const short PC_ADDE = 0x3E;
+const short PC_ADDI = 0x3F;
+const short PC_ADDIC = 0x40;
+const short PC_ADDICR = 0x41;
+const short PC_ADDIS = 0x42;
+const short PC_ADDME = 0x43;
+const short PC_ADDZE = 0x44;
+const short PC_DIVW = 0x45;
+const short PC_DIVWU = 0x46;
+const short PC_MULHW = 0x47;
+const short PC_MULHWU = 0x48;
+const short PC_MULLI = 0x49;
+const short PC_MULLW = 0x4A;
+const short PC_NEG = 0x4B;
+const short PC_SUBF = 0x4C;
+const short PC_SUBFC = 0x4D;
+const short PC_SUBFE = 0x4E;
+const short PC_SUBFIC = 0x4F;
+const short PC_SUBFME = 0x50;
+const short PC_SUBFZE = 0x51;
+const short PC_CMPI = 0x52;
+const short PC_CMP = 0x53;
+const short PC_CMPLI = 0x54;
+const short PC_CMPL = 0x55;
+const short PC_ANDI = 0x56;
+const short PC_ANDIS = 0x57;
+const short PC_ORI = 0x58;
+const short PC_ORIS = 0x59;
+const short PC_XORI = 0x5A;
+const short PC_XORIS = 0x5B;
+const short PC_AND = 0x5C;
+const short PC_OR = 0x5D;
+const short PC_XOR = 0x5E;
+const short PC_NAND = 0x5F;
+const short PC_NOR = 0x60;
+const short PC_EQV = 0x61;
+const short PC_ANDC = 0x62;
+const short PC_ORC = 0x63;
+const short PC_EXTSB = 0x64;
+const short PC_EXTSH = 0x65;
+const short PC_CNTLZW = 0x66;
+const short PC_RLWINM = 0x67;
+const short PC_RLWNM = 0x68;
+const short PC_RLWIMI = 0x69;
+const short PC_SLW = 0x6A;
+const short PC_SRW = 0x6B;
+const short PC_SRAWI = 0x6C;
+const short PC_SRAW = 0x6D;
+const short PC_CRAND = 0x6E;
+const short PC_CRANDC = 0x6F;
+const short PC_CREQV = 0x70;
+const short PC_CRNAND = 0x71;
+const short PC_CRNOR = 0x72;
+const short PC_CROR = 0x73;
+const short PC_CRORC = 0x74;
+const short PC_CRXOR = 0x75;
+const short PC_MCRF = 0x76;
+const short PC_MTXER = 0x77;
+const short PC_MTCTR = 0x78;
+const short PC_MTLR = 0x79;
+const short PC_MTCRF = 0x7A;
+const short PC_MTMSR = 0x7B;
+const short PC_MTSPR = 0x7C;
+const short PC_MFMSR = 0x7D;
+const short PC_MFSPR = 0x7E;
+const short PC_MFXER = 0x7F;
+const short PC_MFCTR = 0x80;
+const short PC_MFLR = 0x81;
+const short PC_MFCR = 0x82;
+const short PC_MFFS = 0x83;
+const short PC_MTFSF = 0x84;
+const short PC_EIEIO = 0x85;
+const short PC_ISYNC = 0x86;
+const short PC_SYNC = 0x87;
+const short PC_RFI = 0x88;
+const short PC_LI = 0x89;
+const short PC_LIS = 0x8A;
+const short PC_MR = 0x8B;
+const short PC_NOP = 0x8C;
+const short PC_NOT = 0x8D;
+const short PC_LFS = 0x8E;
+const short PC_LFSU = 0x8F;
+const short PC_LFSX = 0x90;
+const short PC_LFSUX = 0x91;
+const short PC_LFD = 0x92;
+const short PC_LFDU = 0x93;
+const short PC_LFDX = 0x94;
+const short PC_LFDUX = 0x95;
+const short PC_STFS = 0x96;
+const short PC_STFSU = 0x97;
+const short PC_STFSX = 0x98;
+const short PC_STFSUX = 0x99;
+const short PC_STFD = 0x9A;
+const short PC_STFDU = 0x9B;
+const short PC_STFDX = 0x9C;
+const short PC_STFDUX = 0x9D;
+const short PC_FMR = 0x9E;
+const short PC_FABS = 0x9F;
+const short PC_FNEG = 0xA0;
+const short PC_FNABS = 0xA1;
+const short PC_FADD = 0xA2;
+const short PC_FADDS = 0xA3;
+const short PC_FSUB = 0xA4;
+const short PC_FSUBS = 0xA5;
+const short PC_FMUL = 0xA6;
+const short PC_FMULS = 0xA7;
+const short PC_FDIV = 0xA8;
+const short PC_FDIVS = 0xA9;
+const short PC_FMADD = 0xAA;
+const short PC_FMADDS = 0xAB;
+const short PC_FMSUB = 0xAC;
+const short PC_FMSUBS = 0xAD;
+const short PC_FNMADD = 0xAE;
+const short PC_FNMADDS = 0xAF;
+const short PC_FNMSUB = 0xB0;
+const short PC_FNMSUBS = 0xB1;
+const short PC_FRES = 0xB2;
+const short PC_FRSQRTE = 0xB3;
+const short PC_FSEL = 0xB4;
+const short PC_FRSP = 0xB5;
+const short PC_FCTIW = 0xB6;
+const short PC_FCTIWZ = 0xB7;
+const short PC_FCMPU = 0xB8;
+const short PC_FCMPO = 0xB9;
+const short PC_LWARX = 0xBA;
+const short PC_LSWI = 0xBB;
+const short PC_LSWX = 0xBC;
+const short PC_STFIWX = 0xBD;
+const short PC_STSWI = 0xBE;
+const short PC_STSWX = 0xBF;
+const short PC_STWCX = 0xC0;
+const short PC_ECIWX = 0xC1;
+const short PC_ECOWX = 0xC2;
+const short PC_DCBI = 0xC3;
+const short PC_ICBI = 0xC4;
+const short PC_MCRFS = 0xC5;
+const short PC_MCRXR = 0xC6;
+const short PC_MFTB = 0xC7;
+const short PC_MFSR = 0xC8;
+const short PC_MTSR = 0xC9;
+const short PC_MFSRIN = 0xCA;
+const short PC_MTSRIN = 0xCB;
+const short PC_MTFSB0 = 0xCC;
+const short PC_MTFSB1 = 0xCD;
+const short PC_MTFSFI = 0xCE;
+const short PC_SC = 0xCF;
+const short PC_FSQRT = 0xD0;
+const short PC_FSQRTS = 0xD1;
+const short PC_TLBIA = 0xD2;
+const short PC_TLBIE = 0xD3;
+const short PC_TLBLD = 0xD4;
+const short PC_TLBLI = 0xD5;
+const short PC_TLBSYNC = 0xD6;
+const short PC_TW = 0xD7;
+const short PC_TRAP = 0xD8;
+const short PC_TWI = 0xD9;
+const short PC_OPWORD = 0xDA;
+const short PC_MFROM = 0xDB;
+const short PC_DSA = 0xDC;
+const short PC_ESA = 0xDD;
+const short PC_DCCCI = 0xDE;
+const short PC_DCREAD = 0xDF;
+const short PC_ICBT = 0xE0;
+const short PC_ICCCI = 0xE1;
+const short PC_ICREAD = 0xE2;
+const short PC_RFCI = 0xE3;
+const short PC_TLBRE = 0xE4;
+const short PC_TLBSX = 0xE5;
+const short PC_TLBWE = 0xE6;
+const short PC_WRTEE = 0xE7;
+const short PC_WRTEEI = 0xE8;
+const short PC_MFDCR = 0xE9;
+const short PC_MTDCR = 0xEA;
+const short PC_DCBA = 0xEB;
+const short PC_DSS = 0xEC;
+const short PC_DSSALL = 0xED;
+const short PC_DST = 0xEE;
+const short PC_DSTT = 0xEF;
+const short PC_DSTST = 0xF0;
+const short PC_DSTSTT = 0xF1;
+const short PC_LVEBX = 0xF2;
+const short PC_LVEHX = 0xF3;
+const short PC_LVEWX = 0xF4;
+const short PC_LVSL = 0xF5;
+const short PC_LVSR = 0xF6;
+const short PC_LVX = 0xF7;
+const short PC_LVXL = 0xF8;
+const short PC_STVEBX = 0xF9;
+const short PC_STVEHX = 0xFA;
+const short PC_STVEWX = 0xFB;
+const short PC_STVX = 0xFC;
+const short PC_STVXL = 0xFD;
+const short PC_MFVSCR = 0xFE;
+const short PC_MTVSCR = 0xFF;
+const short PC_VADDCUW = 0x100;
+const short PC_VADDFP = 0x101;
+const short PC_VADDSBS = 0x102;
+const short PC_VADDSHS = 0x103;
+const short PC_VADDSWS = 0x104;
+const short PC_VADDUBM = 0x105;
+const short PC_VADDUBS = 0x106;
+const short PC_VADDUHM = 0x107;
+const short PC_VADDUHS = 0x108;
+const short PC_VADDUWM = 0x109;
+const short PC_VADDUWS = 0x10A;
+const short PC_VAND = 0x10B;
+const short PC_VANDC = 0x10C;
+const short PC_VAVGSB = 0x10D;
+const short PC_VAVGSH = 0x10E;
+const short PC_VAVGSW = 0x10F;
+const short PC_VAVGUB = 0x110;
+const short PC_VAVGUH = 0x111;
+const short PC_VAVGUW = 0x112;
+const short PC_VCFSX = 0x113;
+const short PC_VCFUX = 0x114;
+const short PC_VCMPBFP = 0x115;
+const short PC_VCMPEQFP = 0x116;
+const short PC_VCMPEQUB = 0x117;
+const short PC_VCMPEQUH = 0x118;
+const short PC_VCMPEQUW = 0x119;
+const short PC_VCMPGEFP = 0x11A;
+const short PC_VCMPGTFP = 0x11B;
+const short PC_VCMPGTSB = 0x11C;
+const short PC_VCMPGTSH = 0x11D;
+const short PC_VCMPGTSW = 0x11E;
+const short PC_VCMPGTUB = 0x11F;
+const short PC_VCMPGTUH = 0x120;
+const short PC_VCMPGTUW = 0x121;
+const short PC_VCTSXS = 0x122;
+const short PC_VCTUXS = 0x123;
+const short PC_VEXPTEFP = 0x124;
+const short PC_VLOGEFP = 0x125;
+const short PC_VMAXFP = 0x126;
+const short PC_VMAXSB = 0x127;
+const short PC_VMAXSH = 0x128;
+const short PC_VMAXSW = 0x129;
+const short PC_VMAXUB = 0x12A;
+const short PC_VMAXUH = 0x12B;
+const short PC_VMAXUW = 0x12C;
+const short PC_VMINFP = 0x12D;
+const short PC_VMINSB = 0x12E;
+const short PC_VMINSH = 0x12F;
+const short PC_VMINSW = 0x130;
+const short PC_VMINUB = 0x131;
+const short PC_VMINUH = 0x132;
+const short PC_VMINUW = 0x133;
+const short PC_VMRGHB = 0x134;
+const short PC_VMRGHH = 0x135;
+const short PC_VMRGHW = 0x136;
+const short PC_VMRGLB = 0x137;
+const short PC_VMRGLH = 0x138;
+const short PC_VMRGLW = 0x139;
+const short PC_VMULESB = 0x13A;
+const short PC_VMULESH = 0x13B;
+const short PC_VMULEUB = 0x13C;
+const short PC_VMULEUH = 0x13D;
+const short PC_VMULOSB = 0x13E;
+const short PC_VMULOSH = 0x13F;
+const short PC_VMULOUB = 0x140;
+const short PC_VMULOUH = 0x141;
+const short PC_VNOR = 0x142;
+const short PC_VOR = 0x143;
+const short PC_VPKPX = 0x144;
+const short PC_VPKSHSS = 0x145;
+const short PC_VPKSHUS = 0x146;
+const short PC_VPKSWSS = 0x147;
+const short PC_VPKSWUS = 0x148;
+const short PC_VPKUHUM = 0x149;
+const short PC_VPKUHUS = 0x14A;
+const short PC_VPKUWUM = 0x14B;
+const short PC_VPKUWUS = 0x14C;
+const short PC_VREFP = 0x14D;
+const short PC_VRFIM = 0x14E;
+const short PC_VRFIN = 0x14F;
+const short PC_VRFIP = 0x150;
+const short PC_VRFIZ = 0x151;
+const short PC_VRLB = 0x152;
+const short PC_VRLH = 0x153;
+const short PC_VRLW = 0x154;
+const short PC_VRSQRTEFP = 0x155;
+const short PC_VSL = 0x156;
+const short PC_VSLB = 0x157;
+const short PC_VSLH = 0x158;
+const short PC_VSLO = 0x159;
+const short PC_VSLW = 0x15A;
+const short PC_VSPLTB = 0x15B;
+const short PC_VSPLTH = 0x15C;
+const short PC_VSPLTW = 0x15D;
+const short PC_VSPLTISB = 0x15E;
+const short PC_VSPLTISH = 0x15F;
+const short PC_VSPLTISW = 0x160;
+const short PC_VSR = 0x161;
+const short PC_VSRAB = 0x162;
+const short PC_VSRAH = 0x163;
+const short PC_VSRAW = 0x164;
+const short PC_VSRB = 0x165;
+const short PC_VSRH = 0x166;
+const short PC_VSRO = 0x167;
+const short PC_VSRW = 0x168;
+const short PC_VSUBCUW = 0x169;
+const short PC_VSUBFP = 0x16A;
+const short PC_VSUBSBS = 0x16B;
+const short PC_VSUBSHS = 0x16C;
+const short PC_VSUBSWS = 0x16D;
+const short PC_VSUBUBM = 0x16E;
+const short PC_VSUBUBS = 0x16F;
+const short PC_VSUBUHM = 0x170;
+const short PC_VSUBUHS = 0x171;
+const short PC_VSUBUWM = 0x172;
+const short PC_VSUBUWS = 0x173;
+const short PC_VSUMSWS = 0x174;
+const short PC_VSUM2SWS = 0x175;
+const short PC_VSUM4SBS = 0x176;
+const short PC_VSUM4SHS = 0x177;
+const short PC_VSUM4UBS = 0x178;
+const short PC_VUPKHPX = 0x179;
+const short PC_VUPKHSB = 0x17A;
+const short PC_VUPKHSH = 0x17B;
+const short PC_VUPKLPX = 0x17C;
+const short PC_VUPKLSB = 0x17D;
+const short PC_VUPKLSH = 0x17E;
+const short PC_VXOR = 0x17F;
+const short PC_VMADDFP = 0x180;
+const short PC_VMHADDSHS = 0x181;
+const short PC_VMHRADDSHS = 0x182;
+const short PC_VMLADDUHM = 0x183;
+const short PC_VMSUMMBM = 0x184;
+const short PC_VMSUMSHM = 0x185;
+const short PC_VMSUMSHS = 0x186;
+const short PC_VMSUMUBM = 0x187;
+const short PC_VMSUMUHM = 0x188;
+const short PC_VMSUMUHS = 0x189;
+const short PC_VNMSUBFP = 0x18A;
+const short PC_VPERM = 0x18B;
+const short PC_VSEL = 0x18C;
+const short PC_VSLDOI = 0x18D;
+const short PC_VMR = 0x18E;
+const short PC_VMRP = 0x18F;
+const short PC_SLE = 0x190;
+const short PC_SLEQ = 0x191;
+const short PC_SLIQ = 0x192;
+const short PC_SLLIQ = 0x193;
+const short PC_SLLQ = 0x194;
+const short PC_SLQ = 0x195;
+const short PC_SRAIQ = 0x196;
+const short PC_SRAQ = 0x197;
+const short PC_SRE = 0x198;
+const short PC_SREA = 0x199;
+const short PC_SREQ = 0x19A;
+const short PC_SRIQ = 0x19B;
+const short PC_SRLIQ = 0x19C;
+const short PC_SRLQ = 0x19D;
+const short PC_SRQ = 0x19E;
+const short PC_MASKG = 0x19F;
+const short PC_MASKIR = 0x1A0;
+const short PC_LSCBX = 0x1A1;
+const short PC_DIV = 0x1A2;
+const short PC_DIVS = 0x1A3;
+const short PC_DOZ = 0x1A4;
+const short PC_MUL = 0x1A5;
+const short PC_NABS = 0x1A6;
+const short PC_ABS = 0x1A7;
+const short PC_CLCS = 0x1A8;
+const short PC_DOZI = 0x1A9;
+const short PC_RLMI = 0x1AA;
+const short PC_RRIB = 0x1AB;
+const short PC_PENTRY = 0x1AC;
+const short PC_PEXIT = 0x1AD;
+const short OPCODE_MAX = 0x1AE;
+
+extern OpcodeInfo opcodeinfo[OPCODE_MAX];
+
+extern void pcode_get_hi_lo(int bits, char typechar, SInt32 *hi, SInt32 *lo);
+extern int pcode_check_imm_bits(SInt32 value, int bits, char typechar);
+extern int pcode_const_from_format(const char *format, int *pResult);
+extern PCode *vformatpcode(short opcode, va_list argList);
+extern int expectandformatoperand(PCodeArg *operand, PCOpKind expectedKind, char a3, int bitCount, char *buf);
+extern int formatoperand(PCodeArg *operand, char *buf);
+extern void formatoperands(PCode *pcode, char *buf, int showBasicBlocks);
+extern PCode *makecopyinstruction(PCodeArg *a, PCodeArg *b);
+extern int is_location_independent(PCode *pcode);
+extern int can_reuse_stored_value(PCode *a, PCode *b);
+extern int nbytes_loaded_or_stored_by(PCode *pcode);
+extern void change_num_operands(PCode *pcode, int newNum);
+extern void change_opcode(PCode *pcode, short opcode);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/PCodeUtilities.h b/includes/compiler/PCodeUtilities.h
new file mode 100644
index 0000000..312dd55
--- /dev/null
+++ b/includes/compiler/PCodeUtilities.h
@@ -0,0 +1,23 @@
+#ifndef COMPILER_PCODEUTILITIES_H
+#define COMPILER_PCODEUTILITIES_H
+
+#include "compiler/common.h"
+
+extern void pcsetrecordbit(PCode *pc);
+extern void pcsetsideeffects(PCode *pc);
+extern void pcsetlinkbit(PCode *pc);
+extern void branch_label(PCodeLabel *label);
+extern void branch_conditional(short a, short compareop, short c, PCodeLabel *label);
+extern void branch_always(PCodeLabel *label);
+extern void branch_decrement_always(short opcode, PCodeLabel *label);
+extern void branch_indirect(Object *obj);
+extern int branch_count_volatiles(void);
+extern PCodeArg *branch_record_volatiles(PCodeArg *arglist, UInt32 *masks);
+extern void branch_subroutine(Object *obj, short add_nop, UInt32 *masks);
+extern void branch_subroutine_ctr(UInt32 *masks);
+extern void add_immediate(short dest_reg, short base_reg, Object *obj, short offset);
+extern PCode *add_immediate_lo(short dest_reg, short base_reg, Object *obj, short offset, char add_to_block);
+extern PCode *op_absolute_ha(short dest_reg, short base_reg, Object *obj, short offset, char add_to_block);
+extern void load_store_register(short opcode, short dest_reg, short base_reg, Object *obj, SInt32 offset);
+
+#endif
diff --git a/includes/compiler/StackFrame.h b/includes/compiler/StackFrame.h
new file mode 100644
index 0000000..3145bdb
--- /dev/null
+++ b/includes/compiler/StackFrame.h
@@ -0,0 +1,60 @@
+#ifndef COMPILER_STACKFRAME_H
+#define COMPILER_STACKFRAME_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+enum ObjClass {
+ ObjClass0,
+ ObjClass1,
+ ObjClass2,
+ ObjClassMax
+};
+
+extern Boolean requires_frame;
+extern Boolean makes_call;
+extern Boolean uses_globals;
+extern Boolean dynamic_stack;
+extern Boolean large_stack;
+extern Object *dummyvaparam;
+extern void *dummyprofiler;
+
+extern void init_stack_globals(void);
+extern void init_frame_sizes(void);
+extern void assign_local_memory(Object *obj);
+extern void assign_locals_to_memory(ObjectList *first);
+extern void compute_frame_sizes(void);
+extern void generate_prologue(PCodeBlock *block);
+extern void generate_epilogue(PCodeBlock *block, Boolean add_blr);
+extern void allocate_dynamic_stack_space(Boolean flag1, int reg1, int reg2, SInt32 size);
+extern char *generate_traceback(SInt32 funcsize, char *funcname, SInt32 *tbsize, Object *func);
+extern void check_dynamic_aligned_frame(void);
+extern void move_varargs_to_memory(void);
+extern void assign_arguments_to_memory(Object *func, UInt8 mysteryFlag, Boolean hasVarargs);
+extern SInt32 set_out_param_displ(SInt32 a, Type *type, Boolean flag, SInt32 *outvar, SInt32 b);
+extern SInt32 out_param_displ_to_offset(SInt32 displ);
+extern Boolean needs_frame(void);
+extern void update_out_param_size(SInt32 size);
+extern void estimate_out_param_size(SInt32 size);
+extern void update_out_param_align(SInt32 align);
+extern void update_in_param_align(SInt32 align);
+extern void update_frame_align(SInt32 align);
+extern SInt32 local_offset_32(Object *obj);
+extern SInt16 local_offset_lo(Object *obj, SInt32 offset);
+extern SInt16 local_offset_ha(Object *obj, SInt32 offset);
+extern SInt16 local_offset_16(Object *obj);
+extern Boolean local_is_16bit_offset(Object *obj);
+extern int local_base_register(Object *obj);
+extern Boolean is_large_frame(void);
+extern void no_frame_for_asm(void);
+extern Boolean can_add_displ_to_local(Object *obj, SInt32 displ);
+extern SInt32 get_alloca_alignment(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/TOC.h b/includes/compiler/TOC.h
new file mode 100644
index 0000000..59ec8a1
--- /dev/null
+++ b/includes/compiler/TOC.h
@@ -0,0 +1,60 @@
+#ifndef COMPILER_TOC_H
+#define COMPILER_TOC_H
+
+#include "compiler/common.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+
+typedef struct CodeLabelList {
+ struct CodeLabelList *next;
+ Object *object;
+ CLabel *label;
+} CodeLabelList;
+
+extern ObjectList *toclist;
+extern ObjectList *exceptionlist;
+extern void *descriptorlist;
+extern void *floatconstpool;
+extern void *doubleconstpool;
+extern ObjectList *floatconstlist;
+extern void *vectorconstpool;
+extern ObjectList *vectorconstlist;
+extern Object toc0;
+extern Boolean no_descriptors;
+extern Object pic_base;
+extern VarInfo pic_base_varinfo;
+extern short pic_base_reg;
+extern CodeLabelList *codelabellist;
+
+extern void setupaddressing(void);
+extern void createNonLazyPointer(Object *obj);
+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 dumpcodelabels(Object *func);
+typedef struct COVCResult {
+ // this struct might be used in other places too???
+ short op1;
+ short op2;
+ unsigned char arg;
+} COVCResult;
+extern Boolean canoptimizevectorconst(MWVector128 *vecp, Type *type, COVCResult *result);
+extern Boolean TOC_use_fsel(ENode *expr);
+extern Boolean TOC_use_isel(ENode *expr, Boolean flag);
+extern SInt32 GetSizeSkip(ENode *expr);
+extern void Optimize64bitMath(ENode *expr);
+extern void expandTOCreferences(Statement **stmts);
+extern void resetTOCvarinfo(void);
+extern Boolean needdescriptor(void);
+extern Object *createstaticinitobject(void);
+
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+#endif
diff --git a/includes/compiler/common.h b/includes/compiler/common.h
index b5909e2..15043f5 100644
--- a/includes/compiler/common.h
+++ b/includes/compiler/common.h
@@ -94,27 +94,34 @@ typedef enum Section {
SECT_MW_SWITCH = 30,
SECT_8BYTE_LITERALS = 31,
SECT_4BYTE_LITERALS = 32,
+ // one of these next 2 is missing in pro7
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
+ SECT_CONST = 34,
+ SECT_CONST_PTR = 35,
+ // everything after here is known ok
+ SECT_NONLAZY_PTRS = 36,
+ SECT_COMMON_VARS = 37,
+ SECT_16BYTE_LITERALS = 38,
+ SECT_TEXT_COALESCE = 39,
+ SECT_DATA_COALESCE = 40,
+ SECT_UDATA_COALESCE = 41,
+ SECT_CONST_COALESCE = 42,
+ SECT_CONST_PTR_COALESCE = 43,
+ SECT_CSTR_COALESCE = 44,
+ N_SECTIONS = 45
} Section;
typedef struct BClassList BClassList;
typedef struct CI_FuncData CI_FuncData;
typedef struct CLabel CLabel;
+typedef struct ClassList ClassList;
+typedef struct CParams CParams;
+typedef struct DeclInfo DeclInfo;
+typedef struct DeclThing DeclThing; // rename me please
typedef struct DefArgCtorInfo DefArgCtorInfo;
typedef struct DepName DepName;
+typedef struct EMemberInfo EMemberInfo;
typedef struct ENode ENode;
typedef struct ENodeList ENodeList;
typedef struct ExceptionAction ExceptionAction;
@@ -139,6 +146,11 @@ typedef struct Object Object;
typedef struct ObjectList ObjectList;
typedef struct ObjCInfo ObjCInfo;
typedef struct ObjCMethod ObjCMethod;
+typedef struct Operand Operand;
+typedef struct PackedDeclInfo PackedDeclInfo;
+typedef struct PCode PCode;
+typedef struct PCodeArg PCodeArg;
+typedef struct PCodeBlock PCodeBlock;
typedef struct PCodeLabel PCodeLabel;
typedef struct PointsToFunction PointsToFunction;
typedef struct PTFList PTFList;
@@ -166,6 +178,7 @@ typedef struct TypeClass TypeClass;
typedef struct TypeEnum TypeEnum;
typedef struct TypeFunc TypeFunc;
typedef struct TypeIntegral TypeIntegral;
+typedef struct TypeList TypeList;
typedef struct TypeMemberPointer TypeMemberPointer;
typedef struct TypeMethod TypeMethod;
typedef struct TypePointer TypePointer;
@@ -173,6 +186,7 @@ typedef struct TypeStruct TypeStruct;
typedef struct TypeTemplDep TypeTemplDep;
typedef struct VarInfo VarInfo;
typedef struct VarRecord VarRecord;
+typedef struct VClassList VClassList;
// Common bits for templates
typedef enum TemplParamType {
@@ -262,7 +276,12 @@ enum {
Q_BYCOPY = 0x2000,
Q_BYREF = 0x4000,
Q_ONEWAY = 0x8000,
+ Q_10000 = 0x10000,
+ Q_20000 = 0x20000,
+ Q_OVERLOAD = 0x40000, // weak
+ Q_80000 = 0x80000,
Q_RESTRICT = 0x200000,
+ Q_1000000 = 0x1000000,
Q_ALIGNED_1 = 0x2000000,
Q_ALIGNED_2 = 0x4000000,
Q_ALIGNED_4 = 0x6000000,
@@ -280,4 +299,42 @@ enum {
Q_ALIGNED_MASK = 0x1E000000
};
+enum {
+ EXPORT_FLAGS_INTERNAL = 0x10,
+ EXPORT_FLAGS_IMPORT = 0x20,
+ EXPORT_FLAGS_EXPORT = 0x40
+};
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+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;
+};
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
#endif
diff --git a/includes/compiler/enode.h b/includes/compiler/enode.h
index 6e0ab2c..e12b1ae 100644
--- a/includes/compiler/enode.h
+++ b/includes/compiler/enode.h
@@ -75,6 +75,7 @@ typedef enum ENodeType {
ESETCONST,
ENEWEXCEPTION,
ENEWEXCEPTIONARRAY,
+ EMYSTERY67, // no name???
EOBJLIST,
EMEMBER,
ETEMPLDEP,
@@ -88,6 +89,15 @@ typedef enum ENodeType {
} ENodeType;
+struct EMemberInfo {
+ BClassList *path;
+ ENodeList *nodes;
+ void *x8;
+ void *xC;
+ void *x10;
+};
+
+
struct ENodeList {
ENodeList *next;
ENode *node;
@@ -116,7 +126,7 @@ typedef union ENodeUnion {
ENodeList *args;
TypeFunc *functype;
} funccall;
- ObjAccess objaccess;
+ //ObjAccess objaccess;
struct {
ENode *accessnode;
ENode *mfpointer;
@@ -135,7 +145,7 @@ typedef union ENodeUnion {
struct {
SInt32 size;
char *data;
- SInt32 segnum;
+ //SInt32 segnum; ??
char ispascal;
char ispacked;
} string;
@@ -159,6 +169,10 @@ typedef union ENodeUnion {
Object *objref;
SInt32 offset;
} addr;
+ struct {
+ NameSpaceObjectList *list;
+ TemplArg *templargs;
+ } objlist;
void *inst;
MemInitializer *ctorinit;
Statement *stmt;
@@ -187,7 +201,7 @@ typedef union ENodeUnion {
HashNameNode *name;
TemplArg *args;
} qualtempl;
- ObjAccess objaccess;
+ //ObjAccess objaccess;
struct {
ENode *expr;
TStreamElement *token;
@@ -197,7 +211,8 @@ typedef union ENodeUnion {
ENode *expr;
ENodeList *args;
} funccall;
- struct {
+ // have my doubts about this one
+ /*struct {
Type *type;
UInt32 qual;
ENode *arraydim;
@@ -205,7 +220,7 @@ typedef union ENodeUnion {
ENodeList *initlist;
Boolean is_global;
Boolean has_init;
- } nw;
+ } nw;*/
struct {
ENode *expr;
Boolean is_global;
@@ -242,7 +257,7 @@ typedef union ENodeUnion {
struct ENode {
ENodeType type;
UInt8 cost;
- UInt16 flags; // &1, &2 correspond to quals
+ UInt16 flags;
Boolean ignored;
Boolean hascall;
// void *loc; - might not be in pro7?
@@ -254,9 +269,16 @@ struct ENode {
enum {
ENODE_FLAG_CONST = Q_CONST,
ENODE_FLAG_VOLATILE = Q_VOLATILE,
- ENODE_FLAG_QUALS = Q_CONST | Q_VOLATILE
+ ENODE_FLAG_QUALS = Q_CONST | Q_VOLATILE,
+ ENODE_FLAG_10 = 0x10,
+ ENODE_FLAG_80 = 0x80
};
+#define ENODE_IS(_enode, _etype) ( (_enode)->type == (_etype) )
+#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_IS_RANGE(_enode, _lo, _hi) ( ((_enode)->type >= (_lo)) && ((_enode)->type <= (_hi)) )
+
#ifdef __MWERKS__
#pragma options align=reset
#endif
diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h
index 32552ec..5f01d26 100644
--- a/includes/compiler/objects.h
+++ b/includes/compiler/objects.h
@@ -47,7 +47,7 @@ struct ObjType {
ObjectType otype;
AccessType access;
Type *type;
- void *unk6;
+ UInt32 qual;
};
@@ -184,6 +184,25 @@ struct Object {
} u;
};
+enum {
+ OBJECT_FLAGS_UNUSED = 1,
+ OBJECT_FLAGS_2 = 2,
+ OBJECT_FLAGS_4 = 4,
+ OBJECT_FLAGS_8 = 8,
+ OBJECT_FLAGS_10 = 0x10, // internal
+ OBJECT_FLAGS_20 = 0x20, // import
+ OBJECT_FLAGS_40 = 0x40, // export
+ 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))
@@ -193,8 +212,30 @@ struct Object {
#define OBJ_MEMBER_VAR_PATH(obj) ((ObjMemberVarPath *) (obj))
#define OBJECT(obj) ((Object *) (obj))
-#endif
+
+struct VarInfo { // OK!
+ Object *func;
+ SInt32 usage;
+ TStreamElement deftoken;
+ SInt16 varnumber;
+ Boolean noregister;
+ Boolean used;
+ UInt8 flags;
+ UInt8 rclass;
+ SInt16 reg;
+ SInt16 regHi;
+};
+
+enum {
+ VarInfoFlag1 = 1, // is parameter?
+ VarInfoFlag2 = 2,
+ VarInfoFlag4 = 4,
+ VarInfoFlag40 = 0x40,
+ VarInfoFlag80 = 0x80
+};
#ifdef __MWERKS__
#pragma options align=reset
#endif
+
+#endif
diff --git a/includes/compiler/templates.h b/includes/compiler/templates.h
index f188e0d..85bc5ec 100644
--- a/includes/compiler/templates.h
+++ b/includes/compiler/templates.h
@@ -143,6 +143,10 @@ struct TemplClass {
UInt8 flags;
};
+enum {
+ TEMPLCLASS_FLAGS_2 = 2
+};
+
struct TemplClassInst {
TypeClass theclass;
TemplClassInst *next;
@@ -150,7 +154,8 @@ struct TemplClassInst {
TemplClass *templ;
TemplArg *inst_args;
TemplArg *oargs;
- void *x46;
+ Boolean x46;
+ Boolean x47;
};
#define TEMPL_CLASS(ty) ( (TemplClass *) (ty) )
diff --git a/includes/compiler/tokens.h b/includes/compiler/tokens.h
index b574a81..2f49f98 100644
--- a/includes/compiler/tokens.h
+++ b/includes/compiler/tokens.h
@@ -39,7 +39,15 @@ typedef enum EToken {
TK_UNION,
TK_ENUM,
TK_CLASS,
- TK_UU_VECTOR = 283,
+ TK_UNK_113,
+ TK_UNK_114,
+ TK_UNK_115,
+ TK_UNK_116,
+ TK_UNK_117,
+ TK_UNK_118,
+ TK_UNK_119,
+ TK_UNK_11A,
+ TK_UU_VECTOR,
TK_UU_TYPEOF_UU,
TK_BOOL,
TK_WCHAR_T,
@@ -138,7 +146,9 @@ typedef enum EToken {
TK_AT_DEFS,
TK_SELF,
TK_SUPER,
- TK_UU_ALIGNOF_UU = 388,
+ TK_NEW_ARRAY,
+ TK_DELETE_ARRAY,
+ TK_UU_ALIGNOF_UU,
TK_RESTRICT,
TK_UU_ATTRIBUTE_UU,
TK_UU_UUIDOF
@@ -146,7 +156,7 @@ typedef enum EToken {
typedef struct FileOffsetInfo {
CPrepFileInfo *file;
- SInt32 offset;
+ SInt32 tokenline;
SInt32 tokenoffset;
Boolean is_inline;
} FileOffsetInfo;
diff --git a/includes/compiler/types.h b/includes/compiler/types.h
index 9b07590..e5b4d94 100644
--- a/includes/compiler/types.h
+++ b/includes/compiler/types.h
@@ -90,6 +90,7 @@ struct StructMember {
enum {
STRUCT_TYPE_STRUCT = 0,
STRUCT_TYPE_UNION = 1,
+ STRUCT_TYPE_CLASS = 2,
STRUCT_TYPE_4 = 4,
STRUCT_TYPE_5 = 5,
STRUCT_TYPE_6 = 6,
@@ -104,23 +105,23 @@ enum {
};
-typedef struct ClassList { // checked via CPrec
- struct ClassList *next;
+struct ClassList { // checked via CPrec
+ ClassList *next;
TypeClass *base;
SInt32 offset;
SInt32 voffset;
AccessType access;
Boolean is_virtual;
-} ClassList;
+};
-typedef struct VClassList { // checked via CPrec
- struct VClassList *next;
+struct VClassList { // checked via CPrec
+ VClassList *next;
TypeClass *base;
SInt32 offset;
SInt32 voffset;
Boolean has_override;
char alignsave;
-} VClassList;
+};
typedef struct ClassFriend { // checked via CPrec
struct ClassFriend *next;
@@ -162,14 +163,42 @@ struct TypeClass {
UInt8 eflags;
};
+typedef enum {
+ CLASS_MODE_0 = 0,
+ CLASS_MODE_1 = 1,
+ CLASS_MODE_2 = 2
+} ClassMode;
+
enum {
+ CLASS_FLAGS_1 = 1,
CLASS_FLAGS_2 = 2,
+ CLASS_FLAGS_ABSTRACT = 8,
+ CLASS_FLAGS_10 = 0x10,
CLASS_FLAGS_20 = 0x20,
+ CLASS_FLAGS_40 = 0x40,
+ CLASS_FLAGS_80 = 0x80,
CLASS_FLAGS_100 = 0x100, // is TemplClass
CLASS_FLAGS_800 = 0x800, // is TemplClassInst
- CLASS_FLAGS_900 = 0x900
+ CLASS_FLAGS_900 = 0x900,
+ CLASS_FLAGS_1000 = 0x1000,
+ CLASS_FLAGS_2000 = 0x2000,
+ CLASS_FLAGS_4000 = 0x4000,
+ CLASS_FLAGS_8000 = 0x8000
};
+/// maps to TypeClass::eflags
+enum {
+ CLASS_EFLAGS_INTERNAL = 1,
+ CLASS_EFLAGS_IMPORT = 2,
+ CLASS_EFLAGS_EXPORT = 4
+};
+
+enum {
+ CLASS_ACTION_0 = 0,
+ CLASS_ACTION_1 = 1,
+ CLASS_ACTION_2 = 2,
+ CLASS_ACTION_3 = 3 // __javaobject
+};
typedef struct ExceptSpecList {
struct ExceptSpecList *next;
@@ -199,14 +228,29 @@ struct TypeFunc {
};
enum {
FUNC_FLAGS_PASCAL = 1, // on TypeFunc::flags
+ FUNC_FLAGS_2 = 2,
+ FUNC_FLAGS_4 = 4,
+ FUNC_FLAGS_8 = 8, // abstract?
FUNC_FLAGS_METHOD = 0x10,
FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()"
+ FUNC_FLAGS_80 = 0x80,
+ FUNC_FLAGS_100 = 0x100,
+ FUNC_FLAGS_200 = 0x200,
+ FUNC_FLAGS_NOTHROW = 0x400,
+ FUNC_FLAGS_800 = 0x800,
FUNC_FLAGS_1000 = 0x1000,
FUNC_FLAGS_2000 = 0x2000,
- FUNC_FLAGS_100000 = 0x100000,
- FUNC_FLAGS_900000 = 0x900000
+ FUNC_FLAGS_CONST = 0x8000,
+ FUNC_FLAGS_VOLATILE = 0x10000,
+ FUNC_FLAGS_100000 = 0x100000, // is template?
+ FUNC_FLAGS_800000 = 0x800000,
+ FUNC_FLAGS_900000 = 0x900000,
+ FUNC_FLAGS_4000000 = 0x4000000,
+ FUNC_FLAGS_10000000 = 0x10000000,
+ FUNC_FLAGS_F0000000 = 0xF0000000
};
+// This is actually called TypeMemberFunc...
// There seems to be a version of this which adds a class pointer at the end
struct TypeMethod {
TypeType type;
@@ -217,7 +261,7 @@ struct TypeMethod {
UInt32 qual;
UInt32 flags;
TypeClass *theclass;
- void *x1E;
+ SInt32 x1E; // vtable offset?
void *x22;
Boolean x26;
};
@@ -227,7 +271,7 @@ struct TypeBitfield {
TypeType type;
SInt32 size;
Type *bitfieldtype;
- unsigned char unkA;
+ char unkA;
char unkB;
};
@@ -305,7 +349,14 @@ struct TypePointer {
// ObjCID
+struct TypeList {
+ TypeList *next;
+ Type *type;
+};
+
+
// Not sure if these existed originally, but they'll help
+#define TYPE(ty) ((Type *) (ty))
#define TYPE_INTEGRAL(ty) ((TypeIntegral *) (ty))
#define TYPE_ENUM(ty) ((TypeEnum *) (ty))
#define TYPE_STRUCT(ty) ((TypeStruct *) (ty))
@@ -317,6 +368,34 @@ struct TypePointer {
#define TYPE_MEMBER_POINTER(ty) ((TypeMemberPointer *) (ty))
#define TYPE_POINTER(ty) ((TypePointer *) (ty))
+#define IS_TYPE_VOID(ty) ( (ty)->type == TYPEVOID )
+#define IS_TYPE_INT(ty) ( (ty)->type == TYPEINT )
+#define IS_TYPE_ENUM(ty) ( (ty)->type == TYPEENUM )
+#define IS_TYPE_INT_OR_ENUM(ty) ( IS_TYPE_INT(ty) || IS_TYPE_ENUM(ty) )
+#define IS_TYPE_FLOAT(ty) ( (ty)->type == TYPEFLOAT )
+#define IS_TYPE_STRUCT(ty) ( (ty)->type == TYPESTRUCT )
+#define IS_TYPE_CLASS(ty) ( (ty)->type == TYPECLASS )
+#define IS_TYPE_FUNC(ty) ( (ty)->type == TYPEFUNC )
+#define IS_TYPEFUNC_METHOD(ty) ( (ty)->flags & FUNC_FLAGS_METHOD )
+#define IS_TYPE_TEMPLATE(ty) ( (ty)->type == TYPETEMPLATE )
+#define IS_TYPE_POINTER(ty) ( (ty)->type == TYPEPOINTER || (ty)->type == TYPEARRAY )
+#define IS_TYPE_POINTER_ONLY(ty) ( (ty)->type == TYPEPOINTER )
+#define IS_TYPE_REFERENCE(ty) ( (ty)->type == TYPEPOINTER && (TYPE_POINTER(ty)->qual & Q_REFERENCE) )
+#define IS_TYPEPOINTER_REFERENCE(ty) ( (ty)->qual & Q_REFERENCE )
+#define IS_TYPE_ARRAY(ty) ( (ty)->type == TYPEARRAY )
+#define IS_TYPE_BITFIELD(ty) ( (ty)->type == TYPEBITFIELD )
+#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 )
+#define IS_TYPE_4BYTES_MEMBERPOINTER(ty) ( ((ty)->type == TYPEMEMBERPOINTER) && ((ty)->size == 4u) )
+#define IS_TYPE_12BYTES_MEMBERPOINTER(ty) ( ((ty)->type == TYPEMEMBERPOINTER) && ((ty)->size == 12u) )
+#define TYPE_FITS_IN_REGISTER(ty) ( ((ty)->type == TYPEINT) || ((ty)->type == TYPEENUM) || (IS_TYPE_POINTER(ty) && ((ty)->type != TYPEARRAY)) || IS_TYPE_4BYTES_MEMBERPOINTER(ty) )
+#define TYPE_IS_8BYTES(ty) ( (((ty)->type == TYPEINT) || ((ty)->type == TYPEENUM)) && ((ty)->size == 8) )
+
+#define OBJ_GET_TARGET_VOLATILE(obj) ( IS_TYPE_POINTER((obj)->type) ? (TYPE_POINTER((obj)->type)->qual & Q_VOLATILE) : ((obj)->qual & Q_VOLATILE) )
+#define OBJ_GET_TARGET_CONST(obj) ( IS_TYPE_POINTER((obj)->type) ? (TYPE_POINTER((obj)->type)->qual & Q_CONST) : ((obj)->qual & Q_CONST) )
+
#ifdef __MWERKS__
#pragma options align=reset
#endif
diff --git a/includes/cos.h b/includes/cos.h
index 777b380..3cb9402 100644
--- a/includes/cos.h
+++ b/includes/cos.h
@@ -22,7 +22,7 @@ extern SInt32 COS_GetTicks();
extern SInt32 COS_GetTime();
extern void COS_GetString(char *buffer, SInt16 strListID, SInt16 index);
extern void COS_GetPString(StringPtr buffer, SInt16 strListID, SInt16 index);
-extern Boolean COS_IsMultiByte(const char *str, int offset);
+extern Boolean COS_IsMultiByte(const char *str1, const char *str2);
extern OSErr COS_FileNew(const FSSpec *spec, SInt16 *refNum, OSType creator, OSType fileType);
extern OSErr COS_FileOpen(const FSSpec *spec, SInt16 *refNum);
extern OSErr COS_FileGetType(const FSSpec *spec, OSType *fileType);
diff --git a/includes/oslib.h b/includes/oslib.h
index 9aedb8d..4de46e9 100644
--- a/includes/oslib.h
+++ b/includes/oslib.h
@@ -176,7 +176,7 @@ extern int OS_OpenLibrary(const char *a, void **lib);
extern int OS_GetLibrarySymbol(void *a, void *b, void **sym);
extern int OS_CloseLibrary(void *a);
extern int OS_LoadMacResourceFork(const OSSpec *spec, void **file_data, SInt32 *file_len);
-extern Boolean OS_IsMultiByte(const char *str, int offset);
+extern Boolean OS_IsMultiByte(const char *str1, const char *str2);
/********************************/
/* FileHandles */