summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--includes/compiler/BitVector.h3
-rw-r--r--includes/compiler/CABI.h2
-rw-r--r--includes/compiler/CBrowse.h24
-rw-r--r--includes/compiler/CDecl.h30
-rw-r--r--includes/compiler/CError.h6
-rw-r--r--includes/compiler/CException.h26
-rw-r--r--includes/compiler/CFunc.h3
-rw-r--r--includes/compiler/CIRTransform.h5
-rw-r--r--includes/compiler/CInit.h8
-rw-r--r--includes/compiler/CInline.h64
-rw-r--r--includes/compiler/CObjC.h35
-rw-r--r--includes/compiler/CObjCModern.h4
-rw-r--r--includes/compiler/CParser.h42
-rw-r--r--includes/compiler/CPrep.h6
-rw-r--r--includes/compiler/CPreprocess.h4
-rw-r--r--includes/compiler/CRTTI.h7
-rw-r--r--includes/compiler/CSOM.h37
-rw-r--r--includes/compiler/CScope.h4
-rw-r--r--includes/compiler/CTemplateClass.h17
-rw-r--r--includes/compiler/CTemplateFunc.h13
-rw-r--r--includes/compiler/CTemplateNew.h17
-rw-r--r--includes/compiler/CTemplateTools.h40
-rw-r--r--includes/compiler/CodeGen.h10
-rw-r--r--includes/compiler/CompilerTools.h21
-rw-r--r--includes/compiler/Exceptions.h30
-rw-r--r--includes/compiler/FuncLevelAsmPPC.h8
-rw-r--r--includes/compiler/FunctionCalls.h2
-rw-r--r--includes/compiler/GenStabs.h12
-rw-r--r--includes/compiler/GlobalOptimizer.h2
-rw-r--r--includes/compiler/InlineAsmPPC.h2
-rw-r--r--includes/compiler/Intrinsics.h325
-rw-r--r--includes/compiler/IroFlowgraph.h3
-rw-r--r--includes/compiler/MachO.h280
-rw-r--r--includes/compiler/ObjGenMachO.h70
-rw-r--r--includes/compiler/PCode.h53
-rw-r--r--includes/compiler/PCodeAssembly.h24
-rw-r--r--includes/compiler/PCodeInfo.h4
-rw-r--r--includes/compiler/PCodeUtilities.h11
-rw-r--r--includes/compiler/Peephole.h4
-rw-r--r--includes/compiler/Registers.h3
-rw-r--r--includes/compiler/ScanFloat.h8
-rw-r--r--includes/compiler/StackFrame.h8
-rw-r--r--includes/compiler/StructMoves.h7
-rw-r--r--includes/compiler/Switch.h11
-rw-r--r--includes/compiler/Unmangle.h3
-rw-r--r--includes/compiler/common.h88
-rw-r--r--includes/compiler/enode.h103
-rw-r--r--includes/compiler/objc.h60
-rw-r--r--includes/compiler/objects.h11
-rw-r--r--includes/compiler/templates.h66
-rw-r--r--includes/compiler/tokens.h4
-rw-r--r--includes/compiler/types.h46
-rw-r--r--includes/compiler/uDump.h14
53 files changed, 1373 insertions, 317 deletions
diff --git a/includes/compiler/BitVector.h b/includes/compiler/BitVector.h
index f8f8143..724bb8f 100644
--- a/includes/compiler/BitVector.h
+++ b/includes/compiler/BitVector.h
@@ -27,8 +27,7 @@ inline void Bv_SetBit(UInt32 bit, BitVector *bv) {
if ((bit / 32) < bv->size) {
bv->data[bit / 32] |= 1 << (bit & 31);
} else {
-#line 56
- CError_FATAL();
+ CError_FATAL(56);
}
}
diff --git a/includes/compiler/CABI.h b/includes/compiler/CABI.h
index 8f0d3f4..735eeea 100644
--- a/includes/compiler/CABI.h
+++ b/includes/compiler/CABI.h
@@ -16,7 +16,7 @@ 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 void CABI_MakeDefaultArgConstructor(TypeClass *tclass, Object *obj);
extern ENode *CABI_MakeThisExpr(TypeClass *tclass, SInt32 offset);
extern SInt32 CABI_GetCtorOffsetOffset(TypeClass *tclass, TypeClass *base);
extern Object *CABI_ConstructorCallsNew(TypeClass *tclass);
diff --git a/includes/compiler/CBrowse.h b/includes/compiler/CBrowse.h
index 2bcfb51..cbca85d 100644
--- a/includes/compiler/CBrowse.h
+++ b/includes/compiler/CBrowse.h
@@ -3,4 +3,28 @@
#include "compiler/common.h"
+extern Boolean gUseTokenStreamSource;
+extern Boolean gForceSourceLoc;
+extern Boolean gUseNameTable;
+
+extern void CBrowse_Setup(CParams *params);
+extern void CBrowse_Finish(CParams *params);
+extern void CBrowse_Cleanup(CParams *params);
+extern void CBrowse_BeginClass(DeclInfo *di, GList *gl);
+extern void CBrowse_AddClassMemberVar(ObjMemberVar *ivar, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_AddClassMemberFunction(Object *object, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_AddClassMemberData(Object *object, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_EndClass(SInt32 offset, GList *gl);
+extern void CBrowse_BeginStruct(DeclInfo *di, TypeStruct *tstruct, GList *gl);
+extern void CBrowse_AddStructMember(StructMember *member, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_EndStruct(SInt32 offset, GList *gl);
+extern void CBrowse_NewTypedef(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file1, CPrepFileInfo *file2, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewEnum(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file1, CPrepFileInfo *file2, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewEnumConstant(NameSpace *nspace, HashNameNode *name, CPrepFileInfo *file1, CPrepFileInfo *file2, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewFunction(Object *object, CPrepFileInfo *file1, CPrepFileInfo *file2, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewData(Object *object, CPrepFileInfo *file1, CPrepFileInfo *file2, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewMacro(Macro *macro, CPrepFileInfo *file, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewTemplateClass(TemplClass *tmclass, CPrepFileInfo *file, SInt32 startOffset, SInt32 endOffset);
+extern void CBrowse_NewTemplateFunc(TemplateFunction *tmfunc);
+
#endif
diff --git a/includes/compiler/CDecl.h b/includes/compiler/CDecl.h
index eda8669..a4c28e2 100644
--- a/includes/compiler/CDecl.h
+++ b/includes/compiler/CDecl.h
@@ -10,13 +10,19 @@
#endif
// named because it's 0xE bytes big (hurr)
-typedef struct DeclE {
+struct DeclE {
ObjBase **objlist;
void *x4;
- unsigned short x8;
+ unsigned short x8; // lex_order_count?
unsigned short xA;
Boolean xC;
-} DeclE;
+};
+
+// what the fuck am I?
+struct DeclFucker {
+ NameSpace *nspace;
+ void *mystery4;
+};
struct DeclInfo {
Type *thetype;
@@ -31,10 +37,10 @@ struct DeclInfo {
ENode *x24;
TemplClass *x28;
TemplArg *expltargs;
- void *x30;
- void *x34;
- void *x38;
- Boolean x3C;
+ TemplParam *x30;
+ DeclFucker *fucker34;
+ TemplateFunction *x38;
+ UInt8 x3C; // related to template nindex
Boolean x3D;
short x3E;
short storageclass;
@@ -46,7 +52,7 @@ struct DeclInfo {
Boolean x47;
Boolean x48;
Boolean x49;
- Boolean x4A;
+ Boolean x4A; // objc related
Boolean x4B;
Boolean x4C;
Boolean x4D;
@@ -60,7 +66,11 @@ struct DeclInfo {
Boolean x55;
Boolean x56;
Boolean x57;
- FileOffsetInfo fileoffsetinfo;
+ //FileOffsetInfo fileoffsetinfo;
+ CPrepFileInfo *file;
+ CPrepFileInfo *file2;
+ SInt32 x60; // file offset?
+ short x64;
};
typedef struct BigDeclInfo {
@@ -113,7 +123,7 @@ 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 Boolean CDecl_CheckNewBase(TypeClass *tclass, TypeClass *baseclass, Boolean is_virtual);
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);
diff --git a/includes/compiler/CError.h b/includes/compiler/CError.h
index dbe80c0..a0f1217 100644
--- a/includes/compiler/CError.h
+++ b/includes/compiler/CError.h
@@ -3,9 +3,9 @@
#include "compiler/common.h"
-#define CError_ASSERT(cond) if (!(cond)) { CError_Internal(__FILE__, __LINE__); }
-#define CError_FAIL(cond) if (cond) { CError_Internal(__FILE__, __LINE__); }
-#define CError_FATAL() do { CError_Internal(__FILE__, __LINE__); } while (0)
+#define CError_ASSERT(line, cond) if (!(cond)) { CError_Internal(__FILE__, line); }
+#define CError_FAIL(line, cond) if (cond) { CError_Internal(__FILE__, line); }
+#define CError_FATAL(line) do { CError_Internal(__FILE__, line); } while (0)
enum {
CErrorStr100 = 100,
diff --git a/includes/compiler/CException.h b/includes/compiler/CException.h
index 04af4fa..0e19380 100644
--- a/includes/compiler/CException.h
+++ b/includes/compiler/CException.h
@@ -3,7 +3,29 @@
#include "compiler/common.h"
-// TODO
-extern Boolean CExcept_CanThrowException(Object *obj, Boolean flag);
+extern ExceptionAction *cexcept_dobjstack;
+extern Boolean cexcept_hasdobjects;
+extern Boolean cexcept_magic;
+
+extern void CExcept_Setup(void);
+extern Boolean CExcept_CanThrowException(Object *object, Boolean flag);
+extern void CExcept_CheckStackRefs(ExceptionAction *actions);
+extern void CExcept_CompareSpecifications(ExceptSpecList *a, ExceptSpecList *b);
+extern Boolean CExcept_ActionCompare(ExceptionAction *a, ExceptionAction *b);
+extern int CExcept_IsSubList(ExceptionAction *a, ExceptionAction *b);
+extern Boolean CExcept_ActionNeedsDestruction(ExceptionAction *action);
+extern ENode *CExcept_RegisterDestructorObject(Object *local, SInt32 offset, Object *dtor, Boolean flag);
+extern void CExcept_RegisterLocalArray(Statement *stmt, Object *localarray, Object *dtor, SInt32 elements, SInt32 element_size);
+extern void CExcept_RegisterDeleteObject(Statement *stmt, Object *pointerobject, Object *deletefunc);
+extern void CExcept_Terminate(void);
+extern void CExcept_Magic(void);
+extern void CExcept_ArrayInit(void);
+extern void CExcept_RegisterMember(Statement *stmt, Object *objectptr, SInt32 offset, Object *dtor, Object *cond, Boolean isMember);
+extern void CExcept_RegisterMemberArray(Statement *stmt, Object *objectptr, SInt32 offset, Object *dtor, SInt32 elements, SInt32 element_size);
+extern Statement *CExcept_ActionCleanup(ExceptionAction *ea, Statement *stmt);
+extern void CExcept_ScanExceptionSpecification(TypeFunc *tfunc);
+extern ENode *CExcept_ScanThrowExpression(void);
+extern void CExcept_ScanTryBlock(DeclThing *dt, Boolean flag);
+extern void CExcept_ExceptionTansform(Statement *stmt);
#endif
diff --git a/includes/compiler/CFunc.h b/includes/compiler/CFunc.h
index a0fadad..bed511f 100644
--- a/includes/compiler/CFunc.h
+++ b/includes/compiler/CFunc.h
@@ -48,6 +48,7 @@ typedef enum StatementType {
enum {
StmtFlag_1 = 1,
+ StmtFlag_2 = 2,
StmtFlag_8 = 8,
StmtFlag_10 = 0x10
};
@@ -139,7 +140,7 @@ 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 NameSpace *CFunc_FuncGenSetup(Statement *stmt, Object *func);
extern void CFunc_GetGlobalCompilerState(CFuncSave *state);
extern void CFunc_SetGlobalCompilerState(CFuncSave *state);
extern void CFunc_Gen(Statement *stmt, Object *obj, UInt8 unk);
diff --git a/includes/compiler/CIRTransform.h b/includes/compiler/CIRTransform.h
index b4d9227..edbe8ba 100644
--- a/includes/compiler/CIRTransform.h
+++ b/includes/compiler/CIRTransform.h
@@ -3,4 +3,9 @@
#include "compiler/common.h"
+extern void CIRTrans_Setup(void);
+extern void CIRTrans_Cleanup(void);
+extern ENode *CIRTrans_TransformOpAss(ENode *expr);
+extern void CIRTrans_Transform(void);
+
#endif
diff --git a/includes/compiler/CInit.h b/includes/compiler/CInit.h
index 9b1c24b..e6e3d61 100644
--- a/includes/compiler/CInit.h
+++ b/includes/compiler/CInit.h
@@ -14,12 +14,12 @@ typedef void (*InsertExprCB)(ENode *expr);
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;
+struct OLinkList {
+ OLinkList *next;
+ Object *obj; // the object containing a relocation
SInt32 offset;
SInt32 somevalue;
-} OLinkList;
+};
typedef struct PooledString {
struct PooledString *next;
diff --git a/includes/compiler/CInline.h b/includes/compiler/CInline.h
index 576f7e1..52cdf13 100644
--- a/includes/compiler/CInline.h
+++ b/includes/compiler/CInline.h
@@ -14,12 +14,29 @@ typedef struct CI_Var {
Type *type;
UInt32 qual;
UInt8 sflags;
- UInt8 xD;
- UInt8 xE;
+ SInt8 xD;
+ SInt8 xE;
} CI_Var;
+enum {
+ CI_SFLAGS_NoClass = 0,
+ CI_SFLAGS_Register = 1,
+ CI_SFLAGS_Auto = 2,
+ CI_SFLAGS_HasObjectFlag2 = 0x80
+};
+
+typedef struct CI_SwitchCase {
+ short labelID;
+ CInt64 min;
+ CInt64 max;
+} CI_SwitchCase;
+
typedef struct CI_Switch {
- int fix_me;
+ ENode *expr;
+ void *unkSwitch8;
+ short defaultlabelID;
+ short numcases;
+ CI_SwitchCase cases[0];
} CI_Switch;
typedef struct CI_Statement {
@@ -37,10 +54,23 @@ typedef struct CI_Statement {
SInt16 statementnum;
} ifgoto;
CI_Switch *switchdata;
- // TODO: Figure out the one for Inline ASM
+ struct {
+ void *data;
+ SInt32 size;
+ } asmdata;
} u;
} CI_Statement;
+typedef enum {
+ CI_CanInline0,
+ CI_CanInline1,
+ CI_CanInline2,
+ CI_CanInline3,
+ CI_CanInline4,
+ CI_CanInline5,
+ CI_CanInline6
+} CI_CanInline;
+
struct CI_FuncData {
short numarguments;
CI_Var *arguments;
@@ -53,7 +83,7 @@ struct CI_FuncData {
SInt32 functionbodyoffset;
HashNameNode *functionbodypath;
SInt32 symdeclend;
- Boolean can_inline;
+ UInt8 can_inline;
};
typedef enum {
@@ -71,11 +101,10 @@ typedef struct CI_Action {
FileOffsetInfo fileoffset;
TStream stream;
TypeClass *tclass;
- CI_ActionType actiontype;
} inlinefunc;
struct {
- Type *a;
- Type *b;
+ TemplClass *templ;
+ TemplClassInst *inst;
TemplateMember *tmemb;
} memberfunc;
struct {
@@ -83,6 +112,7 @@ typedef struct CI_Action {
TemplFuncInstance *inst;
} templatefunc;
} u;
+ CI_ActionType actiontype;
} CI_Action;
typedef enum {
@@ -96,20 +126,20 @@ typedef enum {
extern CI_Action *cinline_tactionlist;
extern void CInline_Init(void);
-extern SInt32 CInline_GetLocalID(Object *obj);
+extern SInt32 CInline_GetLocalID(Object *object);
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 SInt16 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 void CInline_PackIFunctionData(CI_FuncData *packed, Statement *stmt, Object *object);
+extern void CInline_UnpackIFunctionData(Object *object, CI_FuncData *packed, Statement *firstStmt);
+extern void CInline_AddDefaultFunctionAction(Object *object);
+extern void CInline_AddInlineFunctionAction(Object *object, TypeClass *tclass, FileOffsetInfo *fileoffset, TStream *stream, Boolean flag);
+extern void CInline_AddMemberFunctionAction(Object *object, TemplClass *templ, TemplClassInst *inst, TemplateMember *tmemb);
+extern void CInline_AddTemplateFunctionAction(Object *object, TemplateFunction *func, TemplFuncInstance *inst);
+extern void CInline_ObjectAddrRef(Object *object);
+extern void CInline_GenFunc(Statement *stmt, Object *object, UInt8 unk);
extern Boolean CInline_CanFreeLHeap(void);
extern Boolean CInline_GenerateDeferredFuncs(void);
extern void CInline_Finish(void);
diff --git a/includes/compiler/CObjC.h b/includes/compiler/CObjC.h
index 92a4efa..cd7686d 100644
--- a/includes/compiler/CObjC.h
+++ b/includes/compiler/CObjC.h
@@ -2,5 +2,40 @@
#define COMPILER_COBJC_H
#include "compiler/common.h"
+#include "compiler/objc.h"
+
+extern Type *cobjc_type_class;
+extern Type *cobjc_type_id;
+extern Type *cobjc_type_sel;
+extern TypeClass *cobjc_currentclass;
+extern ObjCSelector **cobjc_selhashtable;
+extern BClassList *cobjc_classdefs;
+extern ObjCProtocol *cobjc_protocols;
+extern long cobjc_selrefcount;
+extern long cobjc_classrefcount;
+extern long cobjc_stringcount;
+extern Boolean cobjc_encodemethod;
+
+extern void CObjC_Setup(void);
+extern void CObjC_Cleanup(void);
+extern void CObjC_GenerateModule(void);
+extern Type *CObjC_GetObjCType_id(Boolean flag);
+extern Boolean CObjC_IsType_id(Type *type);
+extern Boolean CObjC_IsCompatibleType(Type *a, Type *b);
+extern void CObjC_TranslateSelectorToken(void);
+extern void CObjC_ParseDefs(TypeStruct *tstruct);
+extern Type *CObjC_ParseID(void);
+extern Type *CObjC_ParseTypeProtocol(TypeClass *tclass);
+extern void CObjC_ParseInterface(void);
+extern void CObjC_ParseImplementation(void);
+extern void CObjC_ParseProtocol(void);
+extern void CObjC_ParseClassDeclaration(void);
+extern void *CObjC_ParseIdentifier();
+extern ENode *CObjC_MakeSendMsgExpr(ENode *objexpr, TypeClass *tclass, ObjCNamedArg *namedArgs, ENodeList *unnamedArgs, UInt8 calltype, Boolean isSuper);
+extern ENode *CObjC_ParseMessageExpression(void);
+extern ENode *CObjC_ParseEncodeExpression(void);
+extern ENode *CObjC_ParseAtExpression(void);
+extern ENode *CObjC_ParseProtocolExpression(void);
+extern ENode *CObjC_ParseSelectorExpression(void);
#endif
diff --git a/includes/compiler/CObjCModern.h b/includes/compiler/CObjCModern.h
index df21f56..123b26c 100644
--- a/includes/compiler/CObjCModern.h
+++ b/includes/compiler/CObjCModern.h
@@ -3,4 +3,8 @@
#include "compiler/common.h"
+extern ENode *CObjC_CheckModernSendMessage(TypeClass *tclass, ENode *expr);
+extern ENode *CObjC_New(TypeClass *tclass);
+extern ENode *CObjC_Delete(TypeClass *tclass, ENode *objexpr);
+
#endif
diff --git a/includes/compiler/CParser.h b/includes/compiler/CParser.h
index ee49869..5d9a67a 100644
--- a/includes/compiler/CParser.h
+++ b/includes/compiler/CParser.h
@@ -59,8 +59,8 @@ typedef struct COpts {
Boolean codegen_dynamic;
Boolean codegen_pic;
Boolean no_common;
- char no_implicit_templates;
- char absolutepath; // determines the path written to debug info
+ Boolean no_implicit_templates;
+ Boolean absolutepath; // determines the path written to debug info
char x06; // linker/objgen related
short cpu;
char schedule_cpu;
@@ -80,10 +80,10 @@ typedef struct COpts {
char x1D;
UInt8 x1E; // some register used in TOC_use_isel
UInt8 gen_fsel;
- char ppc_opt_bclr_bcctr;
+ Boolean ppc_opt_bclr_bcctr;
Boolean use_lmw_stmw;
char report_heap_info;
- char misaligned_mem_access;
+ Boolean misaligned_mem_access;
Boolean switch_tables;
char prepare_compress;
char some_alignment; // used in CMach_AllocationAlignment
@@ -93,11 +93,11 @@ typedef struct COpts {
short inlinelevel;
int inline_max_size;
int inline_max_total_size;
- char inline_bottom_up;
+ Boolean inline_bottom_up;
Boolean cplusplus;
Boolean ecplusplus;
Boolean objective_c;
- char objc_strict;
+ Boolean objc_strict;
Boolean ARM_conform;
char ARM_scoping;
Boolean require_prototypes;
@@ -110,17 +110,17 @@ typedef struct COpts {
Boolean ignore_oldstyle;
Boolean cpp_extensions;
Boolean pointercast_lvalue;
- char useRTTI;
+ Boolean useRTTI;
Boolean delete_exception;
char _4B;
Boolean oldalignment;
Boolean unsignedchars;
Boolean multibyteaware;
- char autoinline;
- char defer_codegen;
+ Boolean autoinline;
+ Boolean defer_codegen;
Boolean direct_to_som;
- char som_env_check;
- char som_call_opt;
+ Boolean som_env_check;
+ Boolean som_call_opt;
Boolean booltruefalse;
char old_enum_mangler;
Boolean longlong;
@@ -135,7 +135,7 @@ typedef struct COpts {
Boolean vbase_ctor_offset;
char vbase_abi_v2;
Boolean def_inherited;
- char template_patch;
+ Boolean template_patch;
char template_friends;
char faster_pch_gen;
Boolean array_new_delete;
@@ -143,8 +143,8 @@ typedef struct COpts {
char def_inline_tfuncs;
Boolean arg_dep_lookup;
Boolean simple_prepdump;
- char line_prepdump;
- char fullpath_prepdump;
+ Boolean line_prepdump;
+ Boolean fullpath_prepdump;
char old_mtemplparser;
char suppress_init_code;
Boolean reverse_bitfields;
@@ -154,14 +154,14 @@ typedef struct COpts {
Boolean longlong_prepeval;
Boolean const_strings;
char dumpir;
- char experimental;
+ Boolean experimental;
Boolean gcc_extensions;
char stdc_fp_contract;
char stdc_fenv_access;
char stdc_cx_limitedr;
Boolean old_argmatch;
- char optEH;
- char optEH2;
+ Boolean optEH;
+ Boolean optEH2;
Boolean new_mangler;
char microsoft;
Boolean warningerrors;
@@ -177,7 +177,7 @@ typedef struct COpts {
char warn_hidevirtual;
Boolean warn_largeargs;
Boolean warn_implicitconv;
- char warn_notinlined;
+ Boolean warn_notinlined;
Boolean warn_structclass;
Boolean warn_padding;
Boolean warn_no_side_effect;
@@ -191,8 +191,8 @@ typedef struct COpts {
Boolean readonly_strings;
Boolean exceptions;
char _99;
- char dont_inline;
- char always_inline;
+ Boolean dont_inline;
+ Boolean always_inline;
Boolean peephole;
Boolean global_optimizer;
char side_effects;
@@ -200,7 +200,7 @@ typedef struct COpts {
Boolean import;
Boolean export;
Boolean lib_export;
- char nosyminline;
+ Boolean nosyminline;
char force_active;
char optimizationlevel;
Boolean optimize_for_size;
diff --git a/includes/compiler/CPrep.h b/includes/compiler/CPrep.h
index 749303d..e9b7dcd 100644
--- a/includes/compiler/CPrep.h
+++ b/includes/compiler/CPrep.h
@@ -8,15 +8,15 @@
#pragma options align=mac68k
#endif
-typedef struct Macro {
- struct Macro *next;
+struct Macro {
+ Macro *next;
HashNameNode *name;
void *c;
unsigned short xC;
Boolean is_special;
Boolean xF;
void *e;
-} Macro;
+};
typedef struct TokenStack {
char *pos;
char *macrostart;
diff --git a/includes/compiler/CPreprocess.h b/includes/compiler/CPreprocess.h
index 55ba280..de0269d 100644
--- a/includes/compiler/CPreprocess.h
+++ b/includes/compiler/CPreprocess.h
@@ -3,4 +3,8 @@
#include "compiler/common.h"
+extern void CPrep_PreprocessDumpNewLine(void);
+extern void CPrep_PreprocessDumpFileInfo(Boolean flag);
+extern void CPrep_Preprocess(void);
+
#endif
diff --git a/includes/compiler/CRTTI.h b/includes/compiler/CRTTI.h
index 6543e0f..ca9535f 100644
--- a/includes/compiler/CRTTI.h
+++ b/includes/compiler/CRTTI.h
@@ -3,4 +3,11 @@
#include "compiler/common.h"
+extern OLinkList *CRTTI_ConstructVTableHeaders(TypeClass *tclass, void *data, OLinkList *links);
+extern ENode *CRTTI_ParseTypeID(void);
+extern ENode *CRTTI_Parse_dynamic_cast(void);
+extern ENode *CRTTI_Parse_static_cast(void);
+extern ENode *CRTTI_Parse_reinterpret_cast(void);
+extern ENode *CRTTI_Parse_const_cast(void);
+
#endif
diff --git a/includes/compiler/CSOM.h b/includes/compiler/CSOM.h
index 560993b..36c3ae7 100644
--- a/includes/compiler/CSOM.h
+++ b/includes/compiler/CSOM.h
@@ -2,5 +2,42 @@
#define COMPILER_CSOM_H
#include "compiler/common.h"
+#include "compiler/som.h"
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+typedef struct CSOMStub {
+ struct CSOMStub *next;
+ Object *object;
+ TypeClass *tclass;
+ SInt32 offset;
+ UInt8 x10;
+} CSOMStub;
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+extern CSOMStub *csom_stubs;
+
+extern void CSOM_Setup(Boolean flag);
+extern void CSOM_Cleanup(void);
+extern void CSOM_CheckFuncType(TypeFunc *tfunc);
+extern void CSOM_MakeSOMClass(TypeClass *tclass);
+extern void CSOM_ClassComplete(TypeClass *tclass);
+extern void CSOM_GenerateClassStructures(TypeClass *tclass);
+extern void CSOM_PragmaReleaseOrder(void);
+extern void CSOM_PragmaClassVersion(void);
+extern void CSOM_PragmaMetaClass(void);
+extern void CSOM_PragmaCallStyle(void);
+extern void CSOM_FixNewDeleteFunctype(TypeFunc *tfunc);
+extern ENode *CSOM_New(TypeClass *tclass);
+extern ENode *CSOM_Delete(TypeClass *tclass, ENode *objExpr);
+extern void CSOM_InitAutoClass(Object *object);
+extern ENode *CSOM_SOMSelfObjectExpr(TypeClass *tclass);
+extern void CSOM_InitSOMSelf(TypeClass *tclass, Statement *stmt);
+extern ENode *CSOM_EnvCheck(ENode *funccall, ENodeList *checkArg);
+extern ENode *CSOM_MemberVarAccess(BClassList *path, ObjMemberVar *ivar, ENode *thisExpr);
+extern ENode *CSOM_MethodAccess(BClassList *path, Object *func, Boolean flag);
#endif
diff --git a/includes/compiler/CScope.h b/includes/compiler/CScope.h
index b5c8348..a1da819 100644
--- a/includes/compiler/CScope.h
+++ b/includes/compiler/CScope.h
@@ -13,12 +13,12 @@ extern TypeClass *cscope_currentclass;
extern NameSpace *cscope_current;
extern NameSpace *cscope_root;
-typedef struct CScopeSave {
+struct CScopeSave {
NameSpace *current;
TypeClass *currentclass;
Object *currentfunc;
Boolean is_member_func;
-} CScopeSave; // assumed name
+}; // assumed name
// this might be called NameResult
typedef struct CScopeParseResult {
diff --git a/includes/compiler/CTemplateClass.h b/includes/compiler/CTemplateClass.h
index 747a944..4400480 100644
--- a/includes/compiler/CTemplateClass.h
+++ b/includes/compiler/CTemplateClass.h
@@ -3,4 +3,21 @@
#include "compiler/common.h"
+extern TemplClass *CTemplClass_GetMasterTemplate(TemplClass *tmclass);
+extern void CTemplClass_RegisterUsingDecl(TemplClass *tmclass, TypeTemplDep *type, AccessType access);
+extern void CTemplClass_RegisterFriend(TemplClass *tmclass, DeclInfo *di);
+extern void CTemplClass_RegisterBaseClass(TemplClass *tmclass, Type *type, AccessType access, Boolean is_virtual);
+extern void CTemplClass_RegisterEnumType(TemplClass *tmclass, TypeEnum *enumtype);
+extern void CTemplClass_RegisterEnumerator(TemplClass *tmclass, ObjEnumConst *objenumconst, ENode *initexpr);
+extern void CTemplClass_RegisterObjectInit(TemplClass *tmclass, Object *object, ENode *initexpr);
+extern void CTemplClass_RegisterObjectDef(TemplClass *tmclass, ObjBase *refobj);
+extern void CTemplClass_CompleteClass(TemplClass *templ, DeclE *de);
+extern TemplClassInst *CTemplClass_GetInstance(TemplClass *tmclass, TemplArg *args1, TemplArg *args2);
+extern TemplateMember *CTemplClass_DefineMember(TemplClass *tmclass, Object *object, FileOffsetInfo *foi, TStream *stream);
+extern void CTemplClass_ParsePartialSpecialization(DeclFucker *what_is_this, TemplParam *params, short mode, SInt32 *offset);
+extern void CTemplClass_ParseClass(DeclFucker *what_is_this, TemplParam *params, short mode, SInt32 *offset);
+extern Boolean CTemplClass_FindPartialTemplate(TemplArg *args, TemplClass **resultTempl, TemplArg **resultArgs);
+extern TemplClass *CTemplClass_DefineNestedClass(TemplClass *parent, HashNameNode *name, short mode);
+extern Boolean CTempl_InstantiateTemplateClass(TypeClass *tclass);
+
#endif
diff --git a/includes/compiler/CTemplateFunc.h b/includes/compiler/CTemplateFunc.h
index 1461ee4..bf84460 100644
--- a/includes/compiler/CTemplateFunc.h
+++ b/includes/compiler/CTemplateFunc.h
@@ -2,5 +2,18 @@
#define COMPILER_CTEMPLATEFUNC_H
#include "compiler/common.h"
+#include "compiler/CExpr.h"
+
+extern Boolean CTempl_CanDeduceFunc(Object *object, TypeFunc *tfunc, TemplArg *args);
+extern TemplFuncInstance *CTempl_CheckFuncInstance(Object *object1, TypeFunc *tfunc, TemplArg *args, Object *object2);
+extern TemplFuncInstance *CTempl_DeduceFunc(Object *object1, TypeFunc *tfunc, TemplArg *args, Object *object2, Boolean flag);
+extern Boolean CTempl_FuncIsMoreSpecialized(Object *object1, Object *object2);
+extern Object *CTempl_PartialOrdering(Object *object, ObjectList *list, int count);
+extern int CTempl_GetTemplateArgumentExpressionIndex(TemplArg *arg);
+extern Boolean CTempl_DeduceType(Type *type1, UInt32 qual1, Type *type2, UInt32 qual2, TemplArg *argArray, Boolean flag1, Boolean flag2);
+extern void CTempl_FuncMatch(NameSpaceObjectList *list, TemplArg *args, ENodeList *argexprs, Match13 *match13ptr, ENode *expr);
+extern Object *CTempl_DeduceFromFunctionCall(Object *funcobj, TemplArg *templargs, ENodeList *argexprs);
+extern Object *CTempl_DeduceFromConversion(Object *funcobj, Type *type, UInt32 qual);
+extern Object *CTempl_TemplateFunctionCheck(DeclInfo *di, NameSpaceObjectList *nsol);
#endif
diff --git a/includes/compiler/CTemplateNew.h b/includes/compiler/CTemplateNew.h
index 3fbdeb9..ca92500 100644
--- a/includes/compiler/CTemplateNew.h
+++ b/includes/compiler/CTemplateNew.h
@@ -3,4 +3,21 @@
#include "compiler/common.h"
+extern TemplClass *ctempl_templates;
+extern TemplateFunction *ctempl_templatefuncs;
+extern TemplStack *ctempl_curinstance;
+
+extern void CTempl_Setup(void);
+extern void CTempl_Cleanup(void);
+extern TemplArg *CTempl_ParseUncheckTemplArgs(TemplParam *params, Boolean is_global);
+extern Type *CTempl_ParseTemplTemplParam(TypeTemplDep *type);
+extern Type *CTempl_ClassGetType(TemplClass *templ);
+extern Boolean CTempl_IsQualifiedMember(DeclInfo *di, Type *type, NameSpace **resultnspace);
+extern void CTempl_Parse(TemplClass *templ, AccessType access);
+extern void CTempl_ParseInstanceScopeFunction(Object *funcobj, TemplClassInst *inst, TypeClass *tclass);
+extern Boolean CTempl_GenFuncInstance(TemplateFunction *templ, TemplFuncInstance *inst, Boolean flag);
+extern void CTempl_InstantiateMember(TemplClass *templ, TemplClassInst *inst, TemplateMember *tmemb, Object *object, Boolean flag);
+extern Boolean CTempl_Instantiate(void);
+extern Boolean CTempl_InlineFunctionCheck(Object *funcobj);
+
#endif
diff --git a/includes/compiler/CTemplateTools.h b/includes/compiler/CTemplateTools.h
index df4ad30..9b9cf4f 100644
--- a/includes/compiler/CTemplateTools.h
+++ b/includes/compiler/CTemplateTools.h
@@ -2,5 +2,45 @@
#define COMPILER_CTEMPLATETOOLS_H
#include "compiler/common.h"
+#include "compiler/enode.h"
+
+extern short ctempl_instdepth;
+
+extern void CTemplTool_PushInstance(TemplStack *stack, TypeClass *tmclass, Object *func);
+extern void CTemplTool_PopInstance(TemplStack *stack);
+extern ENode *CTempTool_GetPTMTemplArgExpr(ENode *expr, Type *type);
+extern Boolean CTemplTool_InitDeduceInfo(DeduceInfo *info, TemplParam *params, TemplArg *args, Boolean flag);
+extern void CTemplTool_InsertTemplateParameter(NameSpace *nspace, TemplParam *param);
+extern TemplArg *CTemplTool_MakeTemplArgList(DeduceInfo *info);
+extern Boolean CTemplTool_IsIdenticalTemplArgList(TemplArg *args, TemplParam *params);
+extern Type *CTemplTool_GetSelfRefTemplate(Type *type);
+extern TemplateFunction *CTemplTool_GetFuncTempl(Object *object);
+extern Boolean CTemplTool_ParamHasDefaultArg(TemplParam *param);
+extern void CTemplTool_MergeDefaultArgs(TemplParam *dest, TemplParam *src);
+extern void CTemplTool_MergeArgNames(TypeFunc *src, TypeFunc *dest);
+extern Boolean CTemplTool_EqualParams(TemplParam *a, TemplParam *b, Boolean copyNames);
+extern NameSpace *CTemplTool_SetupTemplateArgumentNameSpace(TemplParam *params, TemplArg *args, Boolean is_global);
+extern void CTemplTool_SetupOuterTemplateArgumentNameSpace(NameSpace *nspace);
+extern NameSpace *CTemplTool_InsertTemplateArgumentNameSpace(TemplParam *params, TemplClassInst *inst, CScopeSave *save);
+extern void CTemplTool_RemoveOuterTemplateArgumentNameSpace(NameSpace *nspace);
+extern void CTemplTool_RemoveTemplateArgumentNameSpace(NameSpace *nspace, TemplClassInst *inst, CScopeSave *save);
+extern Boolean CTemplTool_IsTemplateArgumentDependentType(Type *type);
+extern Boolean CTemplTool_IsTemplateArgumentDependentExpression(ENode *expr);
+extern Boolean CTemplTool_IsSameTemplate(TemplParam *params, TemplArg *args);
+extern TemplClass *CTemplTool_IsTemplate(TypeTemplDep *ttd);
+extern Type *CTemplTool_IsDependentTemplate(TemplClass *tmclass, TemplArg *args);
+extern Boolean CTemplTool_EqualExprTypes(ENode *a, ENode *b);
+extern ENode *CTempl_MakeTemplDepExpr(ENode *left, ENodeType nt, ENode *right);
+extern void CTemplTool_CheckTemplArgType(Type *type);
+extern Boolean CTemplTool_EqualArgs(TemplArg *a, TemplArg *b);
+extern TemplArg *CTemplTool_MakeGlobalTemplArgCopy(TemplArg *args);
+extern Boolean CTemplTool_TemplDepTypeCompare(TypeTemplDep *a, TypeTemplDep *b);
+extern Type *CTemplTool_DeduceArgDepType(TemplArg *args, Type *type, UInt32 qual, UInt32 *resultQual);
+extern ENode *CTemplTool_DeduceExpr(TypeDeduce *deduce, ENode *expr);
+extern ENode *CTemplTool_DeduceDefaultArg(Object *func, ENode *expr);
+extern FuncArg *CTemplTool_DeduceArgCopy(TypeDeduce *deduce, FuncArg *args);
+extern Type *CTemplTool_DeduceTypeCopy(TypeDeduce *deduce, Type *type, UInt32 *resultQual);
+extern Type *CTemplTool_ResolveMemberSelfRefs(TemplClass *templ, Type *type, UInt32 *resultQual);
+extern Boolean CTemplTool_IsSameTemplateType(Type *a, Type *b);
#endif
diff --git a/includes/compiler/CodeGen.h b/includes/compiler/CodeGen.h
index fb8ff94..1f012ec 100644
--- a/includes/compiler/CodeGen.h
+++ b/includes/compiler/CodeGen.h
@@ -49,7 +49,7 @@ 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(Statement *stmt);
-extern void CodeGen_Generator(Statement **statements, Object *func, UInt8 mysteryFlag, Boolean callOnModuleBind);
+extern void CodeGen_Generator(Statement *statements, Object *func, UInt8 mysteryFlag, Boolean callOnModuleBind);
extern void CodeGen_GenVDispatchThunk(Object *thunkobj, Object *obj, SInt32 a, SInt32 b, SInt32 c);
extern void CodeGen_SetupRuntimeObjects(void);
extern Boolean CodeGen_ReInitRuntimeObjects(Boolean is_precompiler);
@@ -59,10 +59,10 @@ extern void CodeGen_ParseDeclSpec(HashNameNode *identifier, DeclInfo *declinfo);
extern void CodeGen_ParsePragma(HashNameNode *name);
extern void CodeGen_UpdateObject(Object *object);
extern void CodeGen_UpdateBackEndOptions(void);
-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 SInt32 CodeGen_objc_method_self_offset(ObjCMethod *meth);
+extern SInt32 CodeGen_objc_method_sel_offset(ObjCMethod *meth);
+extern SInt32 CodeGen_objc_method_arg_offset(ObjCMethod *meth, ObjCMethodArg *arg);
+extern SInt32 CodeGen_objc_method_args_size(ObjCMethod *meth);
extern ENode *CodeGen_HandleIntrinsicCall(Object *func, ENodeList *arg_exprs);
extern ENode *CodeGen_HandleTypeCast(ENode *expr, Type *type, UInt32 qual);
extern short CodeGen_AssignCheck(ENode *expr, Type *type, Boolean flag1, Boolean flag2);
diff --git a/includes/compiler/CompilerTools.h b/includes/compiler/CompilerTools.h
index dbaf7d9..d44d766 100644
--- a/includes/compiler/CompilerTools.h
+++ b/includes/compiler/CompilerTools.h
@@ -40,12 +40,12 @@ typedef struct _HeapInfo {
SInt32 largest_free_block;
} HeapInfo;
-typedef struct GList {
+struct GList {
char **data;
SInt32 size;
SInt32 hndlsize;
SInt32 growsize;
-} GList;
+};
extern long hash_name_id;
extern HashNameNode **name_hash_nodes;
@@ -119,12 +119,17 @@ extern void memclr(void *ptr, SInt32 size);
extern void memclrw(void *ptr, SInt32 size);
extern void CToLowercase(char *a, char *b);
extern short getbit(SInt32 l);
-extern inline SInt32 CTool_EndianReadWord32(void *value) {
- return *((SInt32 *) value);
-}
-extern inline UInt32 CTool_EndianConvertWord32(UInt32 value) {
- return value;
-}
+#ifdef ENDIAN_CONVERSION
+extern UInt16 CTool_EndianConvertWord16(UInt16 theword);
+extern UInt32 CTool_EndianConvertWord32(UInt32 theword);
+extern void CTool_EndianConvertMem(UInt8 *data, short len);
+extern UInt32 CTool_EndianReadWord32(void *ptr);
+#else
+#define CTool_EndianConvertWord32(value) value
+#define CTool_EndianConvertWord16(value) value
+#define CTool_EndianConvertMem(data, len) ((void)0)
+#define CTool_EndianReadWord32(ptr) (*((UInt32 *) (ptr)))
+#endif
extern void CTool_EndianConvertWord64(CInt64 ci, char *result);
extern UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x);
extern UInt32 CTool_EndianConvertInPlaceWord32Ptr(UInt32 *x);
diff --git a/includes/compiler/Exceptions.h b/includes/compiler/Exceptions.h
index f1096c8..cc485b0 100644
--- a/includes/compiler/Exceptions.h
+++ b/includes/compiler/Exceptions.h
@@ -62,6 +62,11 @@ struct ExceptionAction {
Object *dtor;
Object *element_size;
} destroy_partial_array;
+ struct { // TODO: merge me with destroy_member
+ Object *objectptr;
+ Object *dtor;
+ SInt32 offset;
+ } destroy_base;
struct {
Object *objectptr;
Object *dtor;
@@ -115,8 +120,33 @@ struct ExceptionAction {
ExceptionActionType type;
};
+typedef struct EANode {
+ struct EANode *dagListNext;
+ struct EANode *prev;
+ ExceptionAction *action;
+ UInt16 count;
+ UInt16 xE;
+} EANode;
+
+typedef struct PCAction {
+ struct PCAction *next;
+ struct PCAction *prev;
+ PCode *firstInstr;
+ PCode *lastInstr;
+ ExceptionAction *actions;
+ EANode *node;
+} PCAction;
+
#ifdef __MWERKS__
#pragma options align=reset
#endif
+extern EANode *DAG[EAT_NACTIONS];
+
+extern int countexceptionactionregisters(ExceptionAction *actions);
+extern void noteexceptionactionregisters(ExceptionAction *actions, PCodeArg *ops);
+extern void recordexceptionactions(PCode *instr, ExceptionAction *actions);
+extern void deleteexceptionaction(PCAction *pca);
+extern void dumpexceptiontables(Object *function, SInt32 codesize);
+
#endif
diff --git a/includes/compiler/FuncLevelAsmPPC.h b/includes/compiler/FuncLevelAsmPPC.h
index 45c1727..43ed62b 100644
--- a/includes/compiler/FuncLevelAsmPPC.h
+++ b/includes/compiler/FuncLevelAsmPPC.h
@@ -4,9 +4,9 @@
#include "compiler/common.h"
extern void setup_assembly_argument(Object *obj, short i);
-extern void assign_local_addresses();
-extern void Assembler();
-extern void SetupAssembler();
-extern void CleanupAssembler();
+extern void assign_local_addresses(void);
+extern void Assembler(Object *func);
+extern void SetupAssembler(void);
+extern void CleanupAssembler(void);
#endif
diff --git a/includes/compiler/FunctionCalls.h b/includes/compiler/FunctionCalls.h
index b915a39..d524797 100644
--- a/includes/compiler/FunctionCalls.h
+++ b/includes/compiler/FunctionCalls.h
@@ -3,4 +3,6 @@
#include "compiler/common.h"
+extern void call_function(ENode *expr, Operand *output);
+
#endif
diff --git a/includes/compiler/GenStabs.h b/includes/compiler/GenStabs.h
index 16fd204..26beedf 100644
--- a/includes/compiler/GenStabs.h
+++ b/includes/compiler/GenStabs.h
@@ -3,4 +3,16 @@
#include "compiler/common.h"
+extern int unnamedstructs;
+
+extern int GenStab_Type(char *name, Type *type);
+extern void GenStab_Function(Object *func, UInt32 offset);
+extern void GenStab_FunctionEnd(Object *func, SInt32 relocID, UInt32 offset);
+extern void GenStab_Line(UInt32 line, UInt32 offset);
+extern void GenStab_Parameter(Object *object);
+extern void GenStab_Var(Object *object);
+extern void GenStab_IncludeFile(char *path);
+extern void GenStab_SourceFile(char *path);
+extern void GenStab_Setup(void);
+
#endif
diff --git a/includes/compiler/GlobalOptimizer.h b/includes/compiler/GlobalOptimizer.h
index 5460edd..0328646 100644
--- a/includes/compiler/GlobalOptimizer.h
+++ b/includes/compiler/GlobalOptimizer.h
@@ -3,4 +3,6 @@
#include "compiler/common.h"
+extern void globallyoptimizepcode(Object *func);
+
#endif
diff --git a/includes/compiler/InlineAsmPPC.h b/includes/compiler/InlineAsmPPC.h
index feb5132..a3d8655 100644
--- a/includes/compiler/InlineAsmPPC.h
+++ b/includes/compiler/InlineAsmPPC.h
@@ -5,7 +5,7 @@
#include "compiler/InlineAsm.h"
extern char asm_alloc_flags[10];
-extern unsigned char sm_section;
+extern Section sm_section;
extern UInt32 cpu;
extern SInt32 fralloc_parameter_area_size;
extern Boolean user_responsible_for_frame;
diff --git a/includes/compiler/Intrinsics.h b/includes/compiler/Intrinsics.h
index 19150f7..7ef7403 100644
--- a/includes/compiler/Intrinsics.h
+++ b/includes/compiler/Intrinsics.h
@@ -3,4 +3,329 @@
#include "compiler/common.h"
+typedef enum Intrinsics {
+ Intrinsic_000,
+ Intrinsic_001,
+ Intrinsic_002,
+ Intrinsic_003,
+ Intrinsic_004,
+ Intrinsic_005,
+ Intrinsic_006,
+ Intrinsic_007,
+ Intrinsic_008,
+ Intrinsic_009,
+ Intrinsic_010,
+ Intrinsic_011,
+ Intrinsic_012,
+ Intrinsic_013,
+ Intrinsic_014,
+ Intrinsic_015,
+ Intrinsic_016,
+ Intrinsic_017,
+ Intrinsic_018,
+ Intrinsic_019,
+ Intrinsic_020,
+ Intrinsic_021,
+ Intrinsic_022,
+ Intrinsic_023,
+ Intrinsic_024,
+ Intrinsic_025,
+ Intrinsic_026,
+ Intrinsic_027,
+ Intrinsic_028,
+ Intrinsic_029,
+ Intrinsic_030,
+ Intrinsic_031,
+ Intrinsic_032,
+ Intrinsic_033,
+ Intrinsic_034,
+ Intrinsic_035,
+ Intrinsic_036,
+ Intrinsic_037,
+ Intrinsic_038,
+ Intrinsic_039,
+ Intrinsic_040,
+ Intrinsic_041,
+ Intrinsic_042,
+ Intrinsic_043,
+ Intrinsic_044,
+ Intrinsic_045,
+ Intrinsic_046,
+ Intrinsic_047,
+ Intrinsic_048,
+ Intrinsic_049,
+ Intrinsic_050,
+ Intrinsic_051,
+ Intrinsic_052,
+ Intrinsic_053,
+ Intrinsic_054,
+ Intrinsic_055,
+ Intrinsic_056,
+ Intrinsic_057,
+ Intrinsic_058,
+ Intrinsic_059,
+ Intrinsic_060,
+ Intrinsic_061,
+ Intrinsic_062,
+ Intrinsic_063,
+ Intrinsic_064,
+ Intrinsic_065,
+ Intrinsic_066,
+ Intrinsic_067,
+ Intrinsic_068,
+ Intrinsic_069,
+ Intrinsic_070,
+ Intrinsic_071,
+ Intrinsic_072,
+ Intrinsic_073,
+ Intrinsic_074,
+ Intrinsic_075,
+ Intrinsic_076,
+ Intrinsic_077,
+ Intrinsic_078,
+ Intrinsic_079,
+ Intrinsic_080,
+ Intrinsic_081,
+ Intrinsic_082,
+ Intrinsic_083,
+ Intrinsic_084,
+ Intrinsic_085,
+ Intrinsic_086,
+ Intrinsic_087,
+ Intrinsic_088,
+ Intrinsic_089,
+ Intrinsic_090,
+ Intrinsic_091,
+ Intrinsic_092,
+ Intrinsic_093,
+ Intrinsic_094,
+ Intrinsic_095,
+ Intrinsic_096,
+ Intrinsic_097,
+ Intrinsic_098,
+ Intrinsic_099,
+ Intrinsic_100,
+ Intrinsic_101,
+ Intrinsic_102,
+ Intrinsic_103,
+ Intrinsic_104,
+ Intrinsic_105,
+ Intrinsic_106,
+ Intrinsic_107,
+ Intrinsic_108,
+ Intrinsic_109,
+ Intrinsic_110,
+ Intrinsic_111,
+ Intrinsic_112,
+ Intrinsic_113,
+ Intrinsic_114,
+ Intrinsic_115,
+ Intrinsic_116,
+ Intrinsic_117,
+ Intrinsic_118,
+ Intrinsic_119,
+ Intrinsic_120,
+ Intrinsic_121,
+ Intrinsic_122,
+ Intrinsic_123,
+ Intrinsic_124,
+ Intrinsic_125,
+ Intrinsic_126,
+ Intrinsic_127,
+ Intrinsic_128,
+ Intrinsic_129,
+ Intrinsic_130,
+ Intrinsic_131,
+ Intrinsic_132,
+ Intrinsic_133,
+ Intrinsic_134,
+ Intrinsic_135,
+ Intrinsic_136,
+ Intrinsic_137,
+ Intrinsic_138,
+ Intrinsic_139,
+ Intrinsic_140,
+ Intrinsic_141,
+ Intrinsic_142,
+ Intrinsic_143,
+ Intrinsic_144,
+ Intrinsic_145,
+ Intrinsic_146,
+ Intrinsic_147,
+ Intrinsic_148,
+ Intrinsic_149,
+ Intrinsic_150,
+ Intrinsic_151,
+ Intrinsic_152,
+ Intrinsic_153,
+ Intrinsic_154,
+ Intrinsic_155,
+ Intrinsic_156,
+ Intrinsic_157,
+ Intrinsic_158,
+ Intrinsic_159,
+ Intrinsic_160,
+ Intrinsic_161,
+ Intrinsic_162,
+ Intrinsic_163,
+ Intrinsic_164,
+ Intrinsic_165,
+ Intrinsic_166,
+ Intrinsic_167,
+ Intrinsic_168,
+ Intrinsic_169,
+ Intrinsic_170,
+ Intrinsic_171,
+ Intrinsic_172,
+ Intrinsic_173,
+ Intrinsic_174,
+ Intrinsic_175,
+ Intrinsic_176,
+ Intrinsic_177,
+ Intrinsic_178,
+ Intrinsic_179,
+ Intrinsic_180,
+ Intrinsic_181,
+ Intrinsic_182,
+ Intrinsic_183,
+ Intrinsic_184,
+ Intrinsic_185,
+ Intrinsic_186,
+ Intrinsic_187,
+ Intrinsic_188,
+ Intrinsic_189,
+ Intrinsic_190,
+ Intrinsic_191,
+ Intrinsic_192,
+ Intrinsic_193,
+ Intrinsic_194,
+ Intrinsic_195,
+ Intrinsic_196,
+ Intrinsic_197,
+ Intrinsic_198,
+ Intrinsic_199,
+ Intrinsic_200,
+ Intrinsic_201,
+ Intrinsic_202,
+ Intrinsic_203,
+ Intrinsic_204,
+ Intrinsic_205,
+ Intrinsic_206,
+ Intrinsic_207,
+ Intrinsic_208,
+ Intrinsic_209,
+ Intrinsic_210,
+ Intrinsic_211,
+ Intrinsic_212,
+ Intrinsic_213,
+ Intrinsic_214,
+ Intrinsic_215,
+ Intrinsic_216,
+ Intrinsic_217,
+ Intrinsic_218,
+ Intrinsic_219,
+ Intrinsic_220,
+ Intrinsic_221,
+ Intrinsic_222,
+ Intrinsic_223,
+ Intrinsic_224,
+ Intrinsic_225,
+ Intrinsic_226,
+ Intrinsic_227,
+ Intrinsic_228,
+ Intrinsic_229,
+ Intrinsic_230,
+ Intrinsic_231,
+ Intrinsic_232,
+ Intrinsic_233,
+ Intrinsic_234,
+ Intrinsic_235,
+ Intrinsic_236,
+ Intrinsic_237,
+ Intrinsic_238,
+ Intrinsic_239,
+ Intrinsic_240,
+ Intrinsic_241,
+ Intrinsic_242,
+ Intrinsic_243,
+ Intrinsic_244,
+ Intrinsic_245,
+ Intrinsic_246,
+ Intrinsic_247,
+ Intrinsic_248,
+ Intrinsic_249,
+ Intrinsic_250,
+ Intrinsic_251,
+ Intrinsic_252,
+ Intrinsic_253,
+ Intrinsic_254,
+ Intrinsic_255,
+ Intrinsic_256,
+ Intrinsic_257,
+ Intrinsic_258,
+ Intrinsic_259,
+ Intrinsic_260,
+ Intrinsic_261,
+ Intrinsic_262,
+ Intrinsic_263,
+ Intrinsic_264,
+ Intrinsic_265,
+ Intrinsic_266,
+ Intrinsic_267,
+ Intrinsic_268,
+ Intrinsic_269,
+ Intrinsic_270,
+ Intrinsic_271,
+ Intrinsic_272,
+ Intrinsic_273,
+ Intrinsic_274,
+ Intrinsic_275,
+ Intrinsic_276,
+ Intrinsic_277,
+ Intrinsic_278,
+ Intrinsic_279,
+ Intrinsic_280,
+ Intrinsic_281,
+ Intrinsic_282,
+ Intrinsic_283,
+ Intrinsic_284,
+ Intrinsic_285,
+ Intrinsic_286,
+ Intrinsic_287,
+ Intrinsic_288,
+ Intrinsic_289,
+ Intrinsic_290,
+ Intrinsic_291,
+ Intrinsic_292,
+ Intrinsic_293,
+ Intrinsic_294,
+ Intrinsic_295,
+ Intrinsic_296,
+ Intrinsic_297,
+ Intrinsic_298,
+ Intrinsic_299,
+ Intrinsic_300,
+ Intrinsic_301,
+ Intrinsic_302,
+ Intrinsic_303,
+ Intrinsic_304,
+ Intrinsic_305,
+ Intrinsic_306,
+ Intrinsic_307,
+ Intrinsic_308,
+ Intrinsic_309,
+ Intrinsic_310,
+ MaxIntrinsics
+} Intrinsics;
+
+extern Object *__memcpy_object;
+extern int VectorConditions; // unused?
+
+extern int is_intrinsic_function_call(ENode *funccall);
+extern ENode *Intrinsics_HandleIntrinsicCall(Object *func, ENodeList *args);
+extern void call_intrinsic_function(ENode *funccall, short outputReg, Operand *output);
+extern void Intrinsics_SetupRuntimeObjects(void);
+extern Boolean Intrinsics_ReInitRuntimeObjects(Boolean flag);
+extern Boolean Intrinsics_IsPublicRuntimeObject(Object *object);
+
#endif
diff --git a/includes/compiler/IroFlowgraph.h b/includes/compiler/IroFlowgraph.h
index 3a76df0..98b6110 100644
--- a/includes/compiler/IroFlowgraph.h
+++ b/includes/compiler/IroFlowgraph.h
@@ -90,8 +90,7 @@ inline void IROFlowgraph_sub_4C3880(IRONodes *nodes, UInt16 index) {
nodes->indices[(nodes->base + nodes->num) % IRO_NumNodes] = index;
nodes->num++;
} else {
-#line 93
- CError_FATAL();
+ CError_FATAL(93);
}
}
diff --git a/includes/compiler/MachO.h b/includes/compiler/MachO.h
index eb8ad57..9be6c3e 100644
--- a/includes/compiler/MachO.h
+++ b/includes/compiler/MachO.h
@@ -2,5 +2,285 @@
#define COMPILER_MACHO_H
#include "compiler/common.h"
+#include "compiler/CompilerTools.h"
+
+typedef struct MachOReloc MachOReloc;
+typedef struct MachOSection MachOSection;
+typedef struct MachOSegment MachOSegment;
+typedef struct MachOSymbol MachOSymbol;
+typedef struct SymbolData SymbolData;
+
+struct SymbolData {
+ union {
+ char *name;
+ SInt32 strx;
+ } u;
+ UInt8 type;
+ SInt16 desc;
+ UInt32 value;
+ MachOSection *section;
+};
+
+typedef enum RelocType {
+ RT_0,
+ RT_1,
+ RT_2,
+ RT_3,
+ RT_4,
+ RT_5,
+ RT_6,
+ RT_7,
+ RT_8,
+ RT_9
+} RelocType;
+
+typedef struct RelocDataT {
+ RelocType type;
+ UInt8 privFlag;
+ UInt8 x2;
+ UInt8 x3;
+ UInt32 x4;
+ MachOSection *section;
+ UInt32 gapC;
+ MachOSection *sect10;
+ char *name;
+ SInt32 x18;
+} RelocDataT;
+
+#define N_GSYM 0x20
+#define N_FNAME 0x22
+#define N_FUN 0x24
+#define N_STSYM 0x26
+#define N_LCSYM 0x28
+#define N_BNSYM 0x2E
+#define N_OPT 0x3C
+#define N_RSYM 0x40
+#define N_SLINE 0x44
+#define N_ENSYM 0x4E
+#define N_SSYM 0x60
+#define N_SO 0x64
+#define N_OSO 0x66
+#define N_LSYM 0x80
+#define N_BINCL 0x82
+#define N_SOL 0x84
+#define N_PARAMS 0x86
+#define N_VERSION 0x88
+#define N_OLEVEL 0x8A
+#define N_PSYM 0xA0
+#define N_EINCL 0xA2
+#define N_ENTRY 0xA4
+#define N_LBRAC 0xC0
+#define N_EXCL 0xC2
+#define N_RBRAC 0xE0
+#define N_BCOMM 0xE2
+#define N_ECOMM 0xE4
+#define N_ECOML 0xE8
+#define N_LENG 0xFE
+
+#define N_STAB 0xE0
+#define N_PEXT 0x10
+#define N_TYPE 0x0E
+#define N_EXT 0x01
+
+#define N_UNDF 0
+#define N_ABS 2
+#define N_SECT 0xE
+#define N_PBUD 0xC
+#define N_INDR 0xA
+
+// Mach-O header
+struct mach_header {
+ uint32_t magic;
+ SInt32 cputype;
+ SInt32 cpusubtype;
+ uint32_t filetype;
+ uint32_t ncmds;
+ uint32_t sizeofcmds;
+ uint32_t flags;
+};
+
+#define MH_MAGIC 0xfeedface
+#define MH_OBJECT 1
+#define CPU_TYPE_POWERPC 18
+#define CPU_SUBTYPE_MC98000_ALL 0
+
+// load commands
+#define LC_SEGMENT 1
+#define LC_SYMTAB 2
+#define LC_DYSYMTAB 11
+
+// segments
+struct segment_command {
+ uint32_t cmd;
+ uint32_t cmdsize;
+ char segname[16];
+ uint32_t vmaddr;
+ uint32_t vmsize;
+ uint32_t fileoff;
+ uint32_t filesize;
+ SInt32 maxprot;
+ SInt32 initprot;
+ uint32_t nsects;
+ uint32_t flags;
+};
+
+// sections
+struct section {
+ char sectname[16];
+ char segname[16];
+ uint32_t addr;
+ uint32_t size;
+ uint32_t offset;
+ uint32_t align;
+ uint32_t reloff;
+ uint32_t nreloc;
+ uint32_t flags;
+ uint32_t reserved1;
+ uint32_t reserved2;
+};
+
+#define S_REGULAR 0
+#define S_ZEROFILL 1
+#define S_CSTRING_LITERALS 2
+#define S_4BYTE_LITERALS 3
+#define S_8BYTE_LITERALS 4
+#define S_LITERAL_POINTERS 5
+#define S_NON_LAZY_SYMBOL_POINTERS 6
+#define S_LAZY_SYMBOL_POINTERS 7
+#define S_SYMBOL_STUBS 8
+#define S_MOD_INIT_FUNC_POINTERS 9
+#define S_MOD_TERM_FUNC_POINTERS 10
+#define S_COALESCED 11
+#define S_GB_ZEROFILL 12
+#define S_INTERPOSING 13
+#define S_16BYTE_LITERALS 14
+
+#define S_ATTR_PURE_INSTRUCTIONS 0x80000000
+#define S_ATTR_NO_TOC 0x40000000
+#define S_ATTR_STRIP_STATIC_SYMS 0x20000000
+#define S_ATTR_NO_DEAD_STRIP 0x10000000
+#define S_ATTR_LIVE_SUPPORT 0x8000000
+#define S_ATTR_SELF_MODIFYING_CODE 0x4000000
+#define S_ATTR_DBUG 0x2000000
+#define S_ATTR_SOME_INSTRUCTIONS 0x400
+#define S_ATTR_EXT_RELOC 0x200
+#define S_ATTR_LOC_RELOC 0x100
+
+// symbols
+struct symtab_command {
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint32_t symoff;
+ uint32_t nsyms;
+ uint32_t stroff;
+ uint32_t strsize;
+};
+
+struct dysymtab_command {
+ uint32_t cmd;
+ uint32_t cmdsize;
+ uint32_t ilocalsym;
+ uint32_t nlocalsym;
+ uint32_t iextdefsym;
+ uint32_t nextdefsym;
+ uint32_t iundefsym;
+ uint32_t nundefsym;
+ uint32_t tocoff;
+ uint32_t ntoc;
+ uint32_t modtaboff;
+ uint32_t nmodtab;
+ uint32_t extrefsymoff;
+ uint32_t nextrefsyms;
+ uint32_t indirectsymoff;
+ uint32_t nindirectsyms;
+ uint32_t extreloff;
+ uint32_t nextrel;
+ uint32_t locreloff;
+ uint32_t nlocrel;
+};
+
+struct nlist {
+ int32_t n_strx;
+ uint8_t n_type;
+ uint8_t n_sect;
+ int16_t n_desc;
+ uint32_t n_value;
+};
+
+// relocations
+enum reloc_type_ppc {
+ PPC_RELOC_VANILLA,
+ PPC_RELOC_PAIR,
+ PPC_RELOC_BR14,
+ PPC_RELOC_BR24,
+ PPC_RELOC_HI16,
+ PPC_RELOC_LO16,
+ PPC_RELOC_HA16,
+ PPC_RELOC_LO14,
+ PPC_RELOC_SECTDIFF,
+ PPC_RELOC_PB_LA_PTR,
+ PPC_RELOC_HI16_SECTDIFF,
+ PPC_RELOC_LO16_SECTDIFF,
+ PPC_RELOC_HA16_SECTDIFF,
+ PPC_RELOC_JBSR,
+ PPC_RELOC_LO14_SECTDIFF,
+ PPC_RELOC_LOCAL_SECTDIFF
+};
+
+#define R_SCATTERED 0x80000000
+
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+struct MachOSection {
+ struct section section;
+ GList glist;
+ MachOReloc *firstReloc;
+ MachOReloc *lastReloc;
+ int x5C;
+ UInt32 num;
+ UInt32 id;
+ MachOSection *next;
+};
+
+struct MachOSegment {
+ struct segment_command cmd;
+ MachOSection *firstSection;
+ MachOSection *lastSection;
+ MachOSegment *next;
+};
+
+struct MachOReloc {
+ char length; // size of the relocation
+ char reltype;
+ char is_extern;
+ char is_pcrel; // was relocated pc relative already
+ UInt32 address; // offset to what is being relocated
+ UInt32 value;
+ MachOReloc *next;
+};
+
+struct MachOSymbol {
+ SymbolData data;
+ UInt32 index;
+ MachOSymbol *next;
+};
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+extern void MachO_Setup(void);
+extern void MachO_Finish(void);
+extern void MachO_Cleanup(void);
+extern MachOSegment *MachO_CreateSegment(char *segname, int maxprot, int initprot, UInt32 flags);
+extern MachOSection *MachO_CreateSection(MachOSegment *segment, char *segname, char *sectname, UInt32 align, UInt32 flags, UInt32 sectionID);
+extern GList *MachO_GetGList(MachOSection *section);
+extern void MachO_SetSectionSize(void);
+extern void MachO_Relocate(MachOSection *section, UInt32 address, UInt32 value, char length, char is_pcrel, Boolean is_extern, int reltype);
+extern UInt32 MachO_DeclareSymbol(char *name, MachOSection *section, UInt32 value, Boolean isAbsolute, short type, short desc);
+extern void MachO_ReOrderSections(void);
+extern void MachO_AddIndirectSymbol(SInt32 symbol);
+extern UInt32 MachO_NumIndirectSym(void);
+extern SInt32 MachO_OutputStab(SymbolData *data, SInt32 strIndex);
#endif
diff --git a/includes/compiler/ObjGenMachO.h b/includes/compiler/ObjGenMachO.h
index 8d97616..82c8650 100644
--- a/includes/compiler/ObjGenMachO.h
+++ b/includes/compiler/ObjGenMachO.h
@@ -2,8 +2,74 @@
#define COMPILER_OBJGENMACHO_H
#include "compiler/common.h"
+#include "compiler/MachO.h"
-// more stuff goes here
-extern void ObjGen_DeclareSwitchTable(Object *a, Object *b);
+typedef enum MWReloc {
+ MW_RELOC_0 = 0,
+ MW_RELOC_2_BR24 = 2,
+ MW_RELOC_3 = 3,
+ MW_RELOC_4 = 4,
+ MW_RELOC_5_LO16 = 5,
+ MW_RELOC_6_HI16 = 6,
+ MW_RELOC_7_HA16 = 7,
+ MW_RELOC_8 = 8,
+ MW_RELOC_9 = 9
+} MWReloc;
+
+extern Boolean declare_readonly;
+extern SInt32 symdeclend;
+extern SInt32 symdecloffset;
+// this conflicts with other files
+//extern SInt32 nexttypeid;
+extern GList symtypemodule;
+extern SInt32 last_base_offset[N_SECTIONS];
+extern MachOSection *Sections[N_SECTIONS];
+extern Section last_function_sect_id;
+extern MachOSection *last_function_sect;
+extern SInt32 pic_base_offset;
+
+extern SInt32 ObjGen_MakeSectReloc(MachOSection *section);
+extern SInt32 ObjGen_GetHashNodeRelocID(Object *object, MachOSection *section, SInt32 value);
+extern void ObjGen_Setup(void);
+extern void ObjGen_DeclareFloatConst(Object *object);
+extern void ObjGen_DeclareVectorConst(Object *object);
+extern void ObjGen_Finish(void);
+extern void ObjGen_Cleanup(void);
+extern void ObjGen_SetupSym(void);
+extern void ObjGen_DeclareData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
+extern void ObjGen_DeclareReadOnlyData(Object *object, char *data, OLinkList *olinklist, UInt32 size);
+extern void ObjGen_SegmentName(void);
+extern void ObjGen_SymFunc(Object *function);
+extern void ObjGenMach_SymFuncEnd(Object *function, UInt32 offset);
+extern void ObjGen_CodeSetup(void);
+extern void ObjGen_CodeCleanup(void);
+extern void ObjGen_SrcBreakName(HashNameNode *name, SInt32 fileModDate, Boolean flag);
+extern GList *ObjGen_GetSectionGList(MachOSection *section);
+extern MachOSection *ObjGen_DeclareFunction(Object *object);
+extern MachOSection *ObjGen_DeclareCode(Object *object);
+extern MachOSection *ObjGen_DeclareMachSection();
+extern void ObjGen_Relocate(MachOSection *section, SInt32 offset, SInt32 relocID, RelocType relocType, MWReloc mwRelType);
+extern void ObjGen_RelocateObj(MachOSection *section, SInt32 offset, Object *object, MWReloc mwRelType);
+extern SInt32 ObjGen_DeclareLiteralString(UInt32 len, char *data, SInt32 align);
+extern UInt32 ObjGen_GetSectSize(MachOSection *section);
+extern void ObjGen_GetExtName(SInt32 id, char *buf);
+extern void ObjGen_PicRelocate(MachOSection *section, SInt32 offset, SInt32 relocID, SInt32 picOffset);
+extern SInt32 ObjGen_GetRelocOffset(SInt32 id);
+extern Boolean ObjGen_IsExternalVar(SInt32 id);
+extern SInt32 ObjGen_DeclareInit(UInt32 len, char *data, SInt32 align);
+extern void CodeGen_GenDynLinkStub(MachOSection *a, MachOSection *b, SInt32 relocID);
+extern void ObjGen_DeclarePICBase(Object *object, SInt32 offset);
+extern void ObjGen_DeclareEntry(Object *object, SInt32 offset);
+extern void ObjGen_DeclareExceptionTables(Object *object, SInt32 codesize, char *data, SInt32 len, OLinkList *refs);
+extern void ObjGen_DeclareCodeLabel(Object *labelobj, SInt32 offset, Object *funcobj);
+extern void ObjGen_DeclareSwitchTable(Object *tableobj, Object *funcobj);
+extern void ObjGen_DeclareTracebackTable(Object *tableobj, void *data, SInt32 size);
+extern void ObjGen_DeclareSymInfo(void);
+extern void ObjGen_Line(UInt32 line, UInt32 offset);
+extern void ObjGen_OutputDebugInfo(Object *funcobj);
+extern SInt32 ObjGen_OutputStab(SymbolData *symbol, SInt32 strIdx);
+extern void ObjGen_SetSectName();
+extern void ObjGen_DeclareInitFunction(Object *funcobj);
+extern Boolean ObjGen_IsExported(Object *object);
#endif
diff --git a/includes/compiler/PCode.h b/includes/compiler/PCode.h
index f1f786c..b38d9e1 100644
--- a/includes/compiler/PCode.h
+++ b/includes/compiler/PCode.h
@@ -34,19 +34,19 @@ enum {
typedef enum {
RefType_0,
- RefType_1,
- RefType_2,
- RefType_3,
+ RefType_1, // like D, but 32-bit?
+ RefType_2, // matches MW_RELOC_3?
+ RefType_3, // matches MW_RELOC_4?
RefType_4,
RefType_5,
- RefType_6,
- RefType_7,
- RefType_8,
+ RefType_6, // LO16?
+ RefType_7, // HI16?
+ RefType_8, // HA16?
RefType_9,
- RefType_A,
- RefType_B,
- RefType_C,
- RefType_D
+ RefType_A, // another LO
+ RefType_B, // another HA
+ RefType_C, // another HA
+ RefType_D // another LO
} PCRefType;
struct PCodeArg {
@@ -94,6 +94,12 @@ struct PCodeArg {
(_op)->data.reg.reg == (_reg) && \
((_op)->data.reg.effect & EffectWrite))
+#define PC_OP_IS_R_OR_W_REGISTER(_op, _rclass, _reg) \
+((_op)->kind == PCOp_REGISTER && \
+ (_op)->arg == (_rclass) && \
+ (_op)->data.reg.reg == (_reg) && \
+ ((_op)->data.reg.effect & (EffectRead | EffectWrite)))
+
#define PC_OP_IS_ANY_REGISTER(_op, _rclass) \
((_op)->kind == PCOp_REGISTER && \
(_op)->arg == (_rclass))
@@ -152,16 +158,16 @@ struct PCodeBlock {
/* PCode Flags */
enum {
- fPCodeFlag1 = 1,
- fPCodeFlag2 = 2, // some kinda load
- fPCodeFlag4 = 4, // some kinda store
- fPCodeFlag8 = 8,
- fPCodeFlag10 = 0x10,
- fPCodeFlag20 = 0x20,
+ fPCodeFlag1 = 1, // some kinds of branches
+ fPCodeFlag2 = 2, // read from memory
+ fPCodeFlag4 = 4, // write to memory
+ fPCodeFlag8 = 8, // other kinds of branches
+ fPCodeFlag10 = 0x10, // moves
+ fPCodeFlag20 = 0x20, // indexed operations
// Always valid
fIsConst = 0x40,
fIsVolatile = 0x80,
- fSideEffects = 0x100,
+ fSideEffects = 0x100, // instructions that do weird stuff with PPC state
fPCodeFlag200 = 0x200, // ?
fPCodeFlag400 = 0x400, // ?
fPCodeFlag800 = 0x800, // ?
@@ -171,23 +177,24 @@ enum {
fPCodeFlag8000 = 0x8000,
fPCodeFlag20000 = 0x20000, // some kinda load?
fPCodeFlag40000 = 0x40000, // some kinda store?
- // Set 1 only
+ // Set 1 (branches) only
fLink = 0x1000000,
fBranchNotTaken = 0x4000000,
fBranchTaken = 0x8000000,
fAbsolute = 0x10000000,
- // Set 2 only
+ // Set 2 (non-branches) only
fIsPtrOp = 0x20,
fOverflow = 0x800000,
fSetsCarry = 0x10000000,
+ fPCodeFlag20000000 = 0x20000000, // record bit?
// ??
fPCodeFlag2000000 = 0x2000000,
fPCodeFlag4000000 = 0x4000000,
fPCodeFlag8000000 = 0x8000000,
fPCodeFlag10000000 = 0x10000000,
- fPCodeFlag20000000 = 0x20000000, // record bit?
fPCodeFlag40000000 = 0x40000000,
- fPCodeFlag80000000 = 0x80000000
+ fPCodeFlag80000000 = 0x80000000,
+ fPCodeFlagC0000000 = 0xC0000000
};
enum {
@@ -198,7 +205,9 @@ enum {
fPCBlockFlag10 = 0x10,
fPCBlockFlag20 = 0x20,
fPCBlockFlag2000 = 0x2000,
- fPCBlockFlag4000 = 0x4000
+ fPCBlockFlag4000 = 0x4000,
+ fPCBlockFlag6000 = 0x6000,
+ fPCBlockFlag8000 = 0x8000
};
extern PCodeBlock *pcbasicblocks;
diff --git a/includes/compiler/PCodeAssembly.h b/includes/compiler/PCodeAssembly.h
index 41082a3..1819a04 100644
--- a/includes/compiler/PCodeAssembly.h
+++ b/includes/compiler/PCodeAssembly.h
@@ -3,8 +3,26 @@
#include "compiler/common.h"
-extern UInt32 assemblepcode(PCode *instr, UInt32 offset, PCodeArg *dummyArg);
-extern void optimizefinalbranches();
-extern void assemblefunction();
+#ifdef __MWERKS__
+#pragma options align=mac68k
+#endif
+typedef struct WeirdOperand {
+ short type; // matches MWReloc
+ Object *x2;
+ UInt32 x6;
+} WeirdOperand;
+
+typedef struct EntryPoint {
+ struct EntryPoint *next;
+ Object *object;
+ PCodeBlock *block;
+} EntryPoint;
+#ifdef __MWERKS__
+#pragma options align=reset
+#endif
+
+extern UInt32 assemblepcode(PCode *instr, UInt32 offset, WeirdOperand *wop);
+extern SInt32 optimizefinalbranches(SInt32 codesize);
+extern SInt32 assemblefunction(Object *func, EntryPoint *entrypoints);
#endif
diff --git a/includes/compiler/PCodeInfo.h b/includes/compiler/PCodeInfo.h
index 09b0535..b70211a 100644
--- a/includes/compiler/PCodeInfo.h
+++ b/includes/compiler/PCodeInfo.h
@@ -461,9 +461,7 @@ typedef enum Opcode {
PC_DOZI = 0x1A9,
PC_RLMI = 0x1AA,
PC_RRIB = 0x1AB,
- PC_PENTRY = 0x1AC,
- PC_PEXIT = 0x1AD,
- OPCODE_MAX = 0x1AE
+ OPCODE_MAX = 0x1AC
} Opcode;
//#define PC_B 0x0
//#define PC_BL 0x1
diff --git a/includes/compiler/PCodeUtilities.h b/includes/compiler/PCodeUtilities.h
index 312dd55..6a55ff4 100644
--- a/includes/compiler/PCodeUtilities.h
+++ b/includes/compiler/PCodeUtilities.h
@@ -2,6 +2,7 @@
#define COMPILER_PCODEUTILITIES_H
#include "compiler/common.h"
+#include "compiler/PCodeInfo.h"
extern void pcsetrecordbit(PCode *pc);
extern void pcsetsideeffects(PCode *pc);
@@ -9,15 +10,15 @@ 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_decrement_always(Opcode 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);
+extern void add_immediate(short dest_reg, short base_reg, Object *obj, SInt16 offset);
+extern PCode *add_immediate_lo(short dest_reg, short base_reg, Object *obj, SInt16 offset, char add_to_block);
+extern PCode *op_absolute_ha(short dest_reg, short base_reg, Object *obj, SInt16 offset, char add_to_block);
+extern void load_store_register(Opcode opcode, short dest_reg, short base_reg, Object *obj, SInt32 offset);
#endif
diff --git a/includes/compiler/Peephole.h b/includes/compiler/Peephole.h
index d391c09..4c27276 100644
--- a/includes/compiler/Peephole.h
+++ b/includes/compiler/Peephole.h
@@ -3,4 +3,8 @@
#include "compiler/common.h"
+extern void peepholeoptimizeforward(Object *func);
+extern void peepholemergeblocks(Object *func, Boolean flag);
+extern void peepholeoptimizepcode(Object *func);
+
#endif
diff --git a/includes/compiler/Registers.h b/includes/compiler/Registers.h
index 689e895..685aa0d 100644
--- a/includes/compiler/Registers.h
+++ b/includes/compiler/Registers.h
@@ -4,8 +4,11 @@
#include "compiler/common.h"
enum {
+ RegisterInvalid = -1,
Register0 = 0,
Register2 = 2,
+ Register3 = 3,
+ Register4 = 4,
RegisterMax = 32
};
diff --git a/includes/compiler/ScanFloat.h b/includes/compiler/ScanFloat.h
new file mode 100644
index 0000000..91cea8a
--- /dev/null
+++ b/includes/compiler/ScanFloat.h
@@ -0,0 +1,8 @@
+#ifndef COMPILER_SCANFLOAT_H
+#define COMPILER_SCANFLOAT_H
+
+#include "compiler/common.h"
+
+extern char *ScanFloat(const char *str, double *result, Boolean *failed);
+
+#endif
diff --git a/includes/compiler/StackFrame.h b/includes/compiler/StackFrame.h
index 04ebb0d..16c5316 100644
--- a/includes/compiler/StackFrame.h
+++ b/includes/compiler/StackFrame.h
@@ -29,7 +29,7 @@ extern void assign_locals_to_memory(ObjectList *first);
extern void compute_frame_sizes(void);
extern void generate_prologue(PCodeBlock *block, Boolean has_varargs);
extern void generate_epilogue(PCodeBlock *block, Boolean add_blr);
-extern void allocate_dynamic_stack_space(Boolean flag1, int reg1, int reg2, SInt32 size);
+extern void allocate_dynamic_stack_space(Boolean isConstantSize, 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);
@@ -43,9 +43,9 @@ 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 SInt32 local_offset_lo(Object *obj, SInt32 offset);
+extern SInt32 local_offset_ha(Object *obj, SInt32 offset);
+extern SInt32 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);
diff --git a/includes/compiler/StructMoves.h b/includes/compiler/StructMoves.h
index 3a1107b..c2ab102 100644
--- a/includes/compiler/StructMoves.h
+++ b/includes/compiler/StructMoves.h
@@ -3,4 +3,11 @@
#include "compiler/common.h"
+extern void make_addressable(Operand *opnd, SInt32 offset, int unusedArg);
+extern void move_block(Operand *dst, Operand *src, SInt32 len, SInt32 align);
+extern void load_small_block_into_reg(short dstReg, Operand *srcOpnd, Type *type, SInt32 align);
+extern void load_small_block_into_reg_pair(short dstRegLo, short dstRegHi, Operand *srcOpnd, Type *type, SInt32 align);
+extern void store_small_block_from_reg(short srcReg, Operand *dstOpnd, Type *type, SInt32 align);
+extern void store_small_block_from_reg_pair(short srcRegLo, short srcRegHi, Operand *dstOpnd, Type *type, SInt32 align);
+
#endif
diff --git a/includes/compiler/Switch.h b/includes/compiler/Switch.h
index 4d2c2b3..15e7d51 100644
--- a/includes/compiler/Switch.h
+++ b/includes/compiler/Switch.h
@@ -3,22 +3,23 @@
#include "compiler/common.h"
-typedef struct SwitchCase {
- struct SwitchCase *next;
+struct SwitchCase {
+ SwitchCase *next;
CLabel *label;
CInt64 min;
CInt64 max;
-} SwitchCase;
+};
typedef struct CaseRange {
CInt64 min;
CInt64 range;
PCodeLabel *label;
} CaseRange;
-typedef struct SwitchInfo {
+struct SwitchInfo {
SwitchCase *cases;
CLabel *defaultlabel;
-} SwitchInfo;
+ void *x8;
+};
extern ObjectList *switchtables;
diff --git a/includes/compiler/Unmangle.h b/includes/compiler/Unmangle.h
index 5e230b0..7fc6aa8 100644
--- a/includes/compiler/Unmangle.h
+++ b/includes/compiler/Unmangle.h
@@ -3,4 +3,7 @@
#include "compiler/common.h"
+extern void MWUnmangleClassName(const char *input, char *output, size_t maxLen);
+extern void MWUnmangle(const char *input, char *output, size_t maxLen);
+
#endif
diff --git a/includes/compiler/common.h b/includes/compiler/common.h
index f2b2e87..b5cb718 100644
--- a/includes/compiler/common.h
+++ b/includes/compiler/common.h
@@ -92,12 +92,9 @@ 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 = 34,
SECT_CONST_PTR = 35,
- // everything after here is known ok
SECT_NONLAZY_PTRS = 36,
SECT_COMMON_VARS = 37,
SECT_16BYTE_LITERALS = 38,
@@ -106,8 +103,8 @@ typedef enum Section {
SECT_UDATA_COALESCE = 41,
SECT_CONST_COALESCE = 42,
SECT_CONST_PTR_COALESCE = 43,
- SECT_CSTR_COALESCE = 44,
- N_SECTIONS = 45
+ //SECT_CSTR_COALESCE = 44,
+ N_SECTIONS = 44
} Section;
typedef struct Alias Alias;
@@ -117,18 +114,27 @@ typedef struct CLabel CLabel;
typedef struct ClassList ClassList;
typedef struct CParams CParams;
typedef struct CPrepFileInfo CPrepFileInfo;
+typedef struct CScopeSave CScopeSave;
+typedef struct DeclE DeclE;
+typedef struct DeclFucker DeclFucker;
typedef struct DeclInfo DeclInfo;
typedef struct DeclThing DeclThing; // rename me please
+typedef struct DeduceInfo DeduceInfo;
+typedef struct DefAction DefAction;
typedef struct DefArgCtorInfo DefArgCtorInfo;
typedef struct DepName DepName;
typedef struct EMemberInfo EMemberInfo;
typedef struct ENode ENode;
typedef struct ENodeList ENodeList;
typedef struct ExceptionAction ExceptionAction;
+typedef struct ExceptSpecList ExceptSpecList;
typedef struct ExtendedParam ExtendedParam;
+typedef struct FileOffsetInfo FileOffsetInfo;
typedef struct FuncArg FuncArg;
+typedef struct GList GList;
typedef struct Initializer Initializer;
typedef struct InlineXRef InlineXRef;
+typedef struct Macro Macro;
typedef struct MemInitializer MemInitializer;
typedef struct NameSpace NameSpace;
typedef struct NameSpaceName NameSpaceName;
@@ -144,8 +150,17 @@ typedef struct ObjType ObjType;
typedef struct ObjTypeTag ObjTypeTag;
typedef struct Object Object;
typedef struct ObjectList ObjectList;
+typedef struct ObjectTemplated ObjectTemplated;
+typedef struct ObjCCategory ObjCCategory;
typedef struct ObjCInfo ObjCInfo;
typedef struct ObjCMethod ObjCMethod;
+typedef struct ObjCMethodArg ObjCMethodArg;
+typedef struct ObjCMethodList ObjCMethodList;
+typedef struct ObjCNamedArg ObjCNamedArg;
+typedef struct ObjCProtocol ObjCProtocol;
+typedef struct ObjCProtocolList ObjCProtocolList;
+typedef struct ObjCSelector ObjCSelector;
+typedef struct OLinkList OLinkList;
typedef struct Operand Operand;
typedef struct PackedDeclInfo PackedDeclInfo;
typedef struct PCode PCode;
@@ -157,6 +172,8 @@ typedef struct PTFList PTFList;
typedef struct SOMInfo SOMInfo;
typedef struct Statement Statement;
typedef struct StructMember StructMember;
+typedef struct SwitchCase SwitchCase;
+typedef struct SwitchInfo SwitchInfo;
typedef struct Template Template;
typedef struct TemplateAction TemplateAction;
typedef struct TemplateFriend TemplateFriend;
@@ -175,12 +192,14 @@ typedef struct TStreamElement TStreamElement;
typedef struct Type Type;
typedef struct TypeBitfield TypeBitfield;
typedef struct TypeClass TypeClass;
+typedef struct TypeDeduce TypeDeduce;
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 TypeObjCID TypeObjCID;
typedef struct TypePointer TypePointer;
typedef struct TypeStruct TypeStruct;
typedef struct TypeTemplDep TypeTemplDep;
@@ -203,62 +222,15 @@ typedef struct TemplParamID {
typedef enum TemplDepSubType {
TDE_PARAM,
- TDE_TYPEEXPR,
- TDE_unk2, // may actually be 1?
+ TDE_SIZEOF,
+ TDE_ALIGNOF,
TDE_CAST,
TDE_QUALNAME,
- TDE_QUALTEMPL,
- //TDE_OBJACCESS,
- //TDE_SOURCEREF,
- //TDE_FUNCCALL,
- //TDE_LOCAL,
- TDE_MONAND = 7,
- TDE_MONPLUS,
- TDE_MONMUL,
- TDE_NEW,
- TDE_DELETE,
- TDE_ARRAY,
- TDE_DYNAMIC_CAST,
- TDE_STATIC_CAST,
- TDE_REINTERPRET_CAST,
- TDE_CONST_CAST,
- TDE_TYPEID,
- TDE_MEMBERACCESS,
- TDE_THROW,
- TDE_EXCEPTIONINIT,
- TDE_LOCALINIT,
- TDE_STATICINIT,
- TDE_LOCALDESTROY,
- TDE_ILLEGAL
+ TDE_OBJ,
+ TDE_SOURCEREF,
+ TDE_ADDRESS_OF
} TemplDepSubType;
-/// Things that can be applied to a type expression
-typedef enum TEFuncSel {
- TEFS_SIZEOF,
- TEFS_ALIGNOF,
- TEFS_UUIDOF,
- TEFS_BI_ALIGN,
- TEFS_BI_TYPE,
- TEFS_BI_VTYPE,
- TEFS_BI_CTYPE
-} TEFuncSel;
-
-/// How to access an object
-/// this might not actually be in Pro7 lol
-typedef struct ObjAccess {
- NameSpaceObjectList *list;
- TypeClass *naming;
- TypeClass *member;
- TemplArg *targs;
- HashNameNode *name;
- ENode *expr;
- Boolean is_qualified;
- Boolean is_member;
- Boolean is_ambig : 1;
- Boolean is_ptm : 1;
- Boolean ext_only : 1;
-} ObjAccess;
-
/// Qualifiers
enum {
Q_CONST = 1,
@@ -281,7 +253,9 @@ enum {
Q_20000 = 0x20000,
Q_OVERLOAD = 0x40000, // weak
Q_80000 = 0x80000,
+ Q_100000 = 0x100000, // Objective-C ID
Q_RESTRICT = 0x200000,
+ Q_400000 = 0x400000, // is templated from another object?
Q_1000000 = 0x1000000,
Q_ALIGNED_1 = 0x2000000,
Q_ALIGNED_2 = 0x4000000,
diff --git a/includes/compiler/enode.h b/includes/compiler/enode.h
index 833c90e..3697135 100644
--- a/includes/compiler/enode.h
+++ b/includes/compiler/enode.h
@@ -75,7 +75,7 @@ typedef enum ENodeType {
ESETCONST,
ENEWEXCEPTION,
ENEWEXCEPTIONARRAY,
- EMYSTERY67, // no name???
+ EINITTRYCATCH,
EOBJLIST,
EMEMBER,
ETEMPLDEP,
@@ -184,12 +184,7 @@ typedef union ENodeUnion {
union {
TemplParamID pid;
struct {
- union {
- Type *type;
- ENode *expr;
- } u;
- TEFuncSel sel;
- Boolean is_expr;
+ Type *type;
} typeexpr;
struct {
ENodeList *args;
@@ -201,57 +196,10 @@ typedef union ENodeUnion {
HashNameNode *name;
} qual;
struct {
- TypeTemplDep *type;
- HashNameNode *name;
- TemplArg *args;
- } qualtempl;
- //ObjAccess objaccess;
- struct {
ENode *expr;
TStreamElement *token;
} sourceref;
ENode *monadic;
- struct {
- ENode *expr;
- ENodeList *args;
- } funccall;
- // have my doubts about this one
- /*struct {
- Type *type;
- UInt32 qual;
- ENode *arraydim;
- ENodeList *placement;
- ENodeList *initlist;
- Boolean is_global;
- Boolean has_init;
- } nw;*/
- struct {
- ENode *expr;
- Boolean is_global;
- Boolean is_array;
- } del;
- struct {
- ENode *left;
- ENode *right;
- } dyadic;
- struct {
- ENode *expr;
- Type *type;
- UInt32 qual;
- } newcast;
- struct {
- ENode *expr;
- DepName *dname;
- Boolean is_pointer;
- } member;
- struct {
- Object *object;
- Object *info;
- } exinit;
- struct {
- Object *obj;
- Initializer *init;
- } varinit;
Object *obj;
} u;
TemplDepSubType subtype;
@@ -300,7 +248,7 @@ enum {
case ELOGNOT: \
case EFORCELOAD: \
case ETYPCON: \
- case EBITFIELD:
+ case EBITFIELD
// 9 to 0x1B
#define ENODE_CASE_DIADIC_1 \
@@ -322,7 +270,7 @@ enum {
case ENOTEQU: \
case EAND: \
case EXOR: \
- case EOR:
+ case EOR
// 0x1E to 0x28, 0x2D, 0x2F
#define ENODE_CASE_ASSIGN \
@@ -338,7 +286,48 @@ enum {
case EXORASS: \
case EORASS: \
case EBCLR: \
- case EBSET:
+ case EBSET
+
+#define ENODE_CASE_DIADIC_ALL \
+ case EMUL: \
+ case EMULV: \
+ case EDIV: \
+ case EMODULO: \
+ case EADDV: \
+ case ESUBV: \
+ case EADD: \
+ case ESUB: \
+ case ESHL: \
+ case ESHR: \
+ case ELESS: \
+ case EGREATER: \
+ case ELESSEQU: \
+ case EGREATEREQU: \
+ case EEQU: \
+ case ENOTEQU: \
+ case EAND: \
+ case EXOR: \
+ case EOR: \
+ case ELAND: \
+ case ELOR: \
+ case EASS: \
+ case EMULASS: \
+ case EDIVASS: \
+ case EMODASS: \
+ case EADDASS: \
+ case ESUBASS: \
+ case ESHLASS: \
+ case ESHRASS: \
+ case EANDASS: \
+ case EXORASS: \
+ case EORASS: \
+ case ECOMMA: \
+ case EPMODULO: \
+ case EROTL: \
+ case EROTR: \
+ case EBCLR: \
+ case EBTST: \
+ case EBSET
#ifdef __MWERKS__
#pragma options align=reset
diff --git a/includes/compiler/objc.h b/includes/compiler/objc.h
index ce3ebe4..54ff438 100644
--- a/includes/compiler/objc.h
+++ b/includes/compiler/objc.h
@@ -7,31 +7,31 @@
#pragma options align=mac68k
#endif
-typedef struct ObjCMethodArg { // bigger in v7 (0x20 vs 0x14)
- struct ObjCMethodArg *next;
+struct ObjCMethodArg { // bigger in v7 (0x20 vs 0x14)
+ ObjCMethodArg *next;
HashNameNode *selector;
HashNameNode *name;
Type *type;
UInt32 qual;
- UInt32 unk14;
- UInt32 unk18;
- UInt32 unk1C;
-} ObjCMethodArg;
+ //UInt32 unk14;
+ //UInt32 unk18;
+ //UInt32 unk1C;
+};
-typedef struct ObjCMethodList { // verified via CPrec
- struct ObjCMethodList *next;
- struct ObjCMethod *method;
-} ObjCMethodList;
+struct ObjCMethodList { // verified via CPrec
+ ObjCMethodList *next;
+ ObjCMethod *method;
+};
-typedef struct ObjCSelector { // verified via CPrec
- struct ObjCSelector *next;
+struct ObjCSelector { // verified via CPrec
+ ObjCSelector *next;
Object *selobject;
HashNameNode *name;
- struct ObjCMethodList *methods;
-} ObjCSelector;
+ ObjCMethodList *methods;
+};
-typedef struct ObjCMethod { // verified via CPrec
- struct ObjCMethod *next;
+struct ObjCMethod { // verified via CPrec
+ ObjCMethod *next;
Object *object;
TypeFunc *functype;
ObjCSelector *selector;
@@ -41,27 +41,27 @@ typedef struct ObjCMethod { // verified via CPrec
Boolean has_valist;
Boolean is_class_method;
Boolean is_defined;
-} ObjCMethod;
+};
-typedef struct ObjCProtocol { // verified via CPrec
- struct ObjCProtocol *next;
+struct ObjCProtocol { // verified via CPrec
+ ObjCProtocol *next;
HashNameNode *name;
- struct ObjCProtocolList *protocols;
+ ObjCProtocolList *protocols;
ObjCMethod *methods;
Object *object;
-} ObjCProtocol;
+};
-typedef struct ObjCProtocolList { // verified via CPrec
- struct ObjCProtocolList *next;
+struct ObjCProtocolList { // verified via CPrec
+ ObjCProtocolList *next;
ObjCProtocol *protocol;
-} ObjCProtocolList;
+};
-typedef struct ObjCCategory { // verified via CPrec
- struct ObjCCategory *next;
+struct ObjCCategory { // verified via CPrec
+ ObjCCategory *next;
HashNameNode *name;
ObjCProtocolList *protocols;
ObjCMethod *methods;
-} ObjCCategory;
+};
struct ObjCInfo { // verified via CPrec
Object *classobject;
@@ -73,6 +73,12 @@ struct ObjCInfo { // verified via CPrec
Boolean is_implemented;
};
+struct ObjCNamedArg {
+ ObjCNamedArg *next;
+ HashNameNode *name;
+ ENode *expr;
+};
+
#ifdef __MWERKS__
#pragma options align=reset
#endif
diff --git a/includes/compiler/objects.h b/includes/compiler/objects.h
index f824923..a9816cf 100644
--- a/includes/compiler/objects.h
+++ b/includes/compiler/objects.h
@@ -122,10 +122,7 @@ struct Object {
UInt8 flags;
ExtendedParam *extParam;
Object *toc;
- //void *any;
- //char reg; // notsure?
- VarRecord *varptr; // i think?
- // union starts at 0x24 in v7
+ VarRecord *varptr;
union {
struct {
union {
@@ -185,6 +182,11 @@ struct Object {
} u;
};
+struct ObjectTemplated {
+ Object object;
+ Object *parent;
+};
+
enum {
OBJECT_FLAGS_UNUSED = 1,
OBJECT_FLAGS_2 = 2,
@@ -212,6 +214,7 @@ enum {
#define OBJ_MEMBER_VAR(obj) ((ObjMemberVar *) (obj))
#define OBJ_MEMBER_VAR_PATH(obj) ((ObjMemberVarPath *) (obj))
#define OBJECT(obj) ((Object *) (obj))
+#define OBJECT_TEMPL(obj) ((ObjectTemplated *) (obj))
struct VarInfo { // OK!
diff --git a/includes/compiler/templates.h b/includes/compiler/templates.h
index 227dd7b..8fe5c46 100644
--- a/includes/compiler/templates.h
+++ b/includes/compiler/templates.h
@@ -9,7 +9,7 @@
#pragma options align=mac68k
#endif
-typedef struct PackedDeclInfo { // ok
+struct PackedDeclInfo { // ok
Type *thetype;
UInt32 qual;
NameSpace *nspace;
@@ -19,7 +19,7 @@ typedef struct PackedDeclInfo { // ok
Section section;
UInt8 exportflags;
Boolean has_expltargs;
-} PackedDeclInfo;
+};
struct Template {
Template *parent;
@@ -54,19 +54,6 @@ struct TemplInstance {
Boolean is_extern;
Boolean static_instantiated;
};
-/*
-struct __attribute__((packed)) TemplInstance
-{
- Template *templ;
- TemplInstance *parent;
- TemplArg *args;
- unsigned __int8 is_instantiated;
- unsigned __int8 is_specialized;
- unsigned __int8 is_extern;
- unsigned __int8 static_instantiated;
-};
-
- */
struct TemplParam { // verified via CPrec
TemplParam *next;
@@ -106,6 +93,36 @@ struct TemplArg { // verified by CPrec
Boolean is_deduced;
};
+struct DeduceInfo {
+ TemplArg *args;
+ TemplArg argBuffer[16];
+ int maxCount;
+ int count;
+ UInt8 x12C;
+};
+
+struct DefAction {
+ DefAction *next;
+ TemplateAction *action;
+ ObjBase *refobj;
+ int xC;
+ TypeEnum *enumtype;
+};
+
+struct TypeDeduce {
+ TemplClass *tmclass;
+ TemplClassInst *inst;
+ TemplParam *params;
+ TemplArg *args;
+ DefAction *defActions;
+ Boolean x14;
+ Boolean x15;
+ Boolean x16;
+ Boolean x17;
+ UInt8 nindex;
+ Boolean x19;
+};
+
struct TemplPartialSpec { // confirmed via CPrec (but templ might be a different type?)
TemplPartialSpec *next;
TemplClass *templ;
@@ -129,38 +146,41 @@ struct TemplStack {
struct TemplClass {
TypeClass theclass;
TemplClass *next;
- TemplClass *templ__parent;
- Type *x3A_maybe_parentinst;
+ TemplClass *templ_parent; // confirmed by v8
+ TemplClassInst *inst_parent; // confirmed by v8
TemplParam *templ__params;
TemplateMember *members;
TemplClassInst *instances;
TemplClass *pspec_owner;
TemplPartialSpec *pspecs;
TemplateAction *actions;
- // not confirmed these last 3 fields yet but there is space for them
- UInt16 lex_order_count;
+ UInt16 lex_order_count; // confirmed by v8
SInt8 align;
UInt8 flags;
};
enum {
+ TEMPLCLASS_FLAGS_1 = 1,
TEMPLCLASS_FLAGS_2 = 2
};
struct TemplClassInst {
TypeClass theclass;
- TemplClassInst *next;
- Type *x36; // not sure what this represents
+ TemplClassInst *next; // confirmed by v8
+ TemplClassInst *parent; // confirmed by v8
TemplClass *templ;
TemplArg *inst_args;
TemplArg *oargs;
- Boolean x46;
- Boolean x47;
+ Boolean is_instantiated;
+ Boolean is_specialized;
+ Boolean is_extern;
+ Boolean x49;
};
#define TEMPL_CLASS(ty) ( (TemplClass *) (ty) )
#define TEMPL_CLASS_INST(ty) ( (TemplClassInst *) (ty) )
#define IS_TEMPL_CLASS(ty) ( IS_TYPE_CLASS(ty) && (TYPE_CLASS(ty)->flags & CLASS_FLAGS_100) )
+#define IS_TEMPL_CLASS_INST(ty) ( IS_TYPE_CLASS(ty) && (TYPE_CLASS(ty)->flags & CLASS_FLAGS_800) )
/*************/
/* Functions */
diff --git a/includes/compiler/tokens.h b/includes/compiler/tokens.h
index 9a3a258..43c2e85 100644
--- a/includes/compiler/tokens.h
+++ b/includes/compiler/tokens.h
@@ -154,12 +154,12 @@ typedef enum EToken {
TK_UU_UUIDOF
} EToken;
-typedef struct FileOffsetInfo {
+struct FileOffsetInfo {
CPrepFileInfo *file;
SInt32 tokenline;
SInt32 tokenoffset;
Boolean is_inline;
-} FileOffsetInfo;
+};
typedef union TData {
HashNameNode *tkidentifier;
diff --git a/includes/compiler/types.h b/includes/compiler/types.h
index 47f6421..3bbba4f 100644
--- a/includes/compiler/types.h
+++ b/includes/compiler/types.h
@@ -189,14 +189,14 @@ struct TypeClass {
};
typedef enum {
- CLASS_MODE_0 = 0,
- CLASS_MODE_1 = 1,
- CLASS_MODE_2 = 2
+ CLASS_MODE_0 = 0, // struct
+ CLASS_MODE_1 = 1, // union
+ CLASS_MODE_2 = 2 // class
} ClassMode;
enum {
CLASS_FLAGS_1 = 1,
- CLASS_FLAGS_2 = 2,
+ CLASS_FLAGS_2 = 2, // completed class?
CLASS_FLAGS_ABSTRACT = 8,
CLASS_FLAGS_10 = 0x10,
CLASS_FLAGS_20 = 0x20,
@@ -225,11 +225,11 @@ enum {
CLASS_ACTION_3 = 3 // __javaobject
};
-typedef struct ExceptSpecList {
- struct ExceptSpecList *next;
+struct ExceptSpecList {
+ ExceptSpecList *next;
Type *type;
UInt32 qual;
-} ExceptSpecList;
+};
struct FuncArg { // ok
struct FuncArg *next;
@@ -253,21 +253,24 @@ struct TypeFunc {
};
enum {
FUNC_FLAGS_PASCAL = 1, // on TypeFunc::flags
- FUNC_FLAGS_2 = 2,
+ FUNC_FLAGS_2 = 2, // member function that has an inline definition?
FUNC_FLAGS_4 = 4,
- FUNC_FLAGS_8 = 8, // abstract?
+ FUNC_FLAGS_8 = 8, // abstract
FUNC_FLAGS_METHOD = 0x10,
+ FUNC_FLAGS_20 = 0x20,
FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()"
FUNC_FLAGS_80 = 0x80,
FUNC_FLAGS_100 = 0x100,
FUNC_FLAGS_200 = 0x200, // intrinsic?
FUNC_FLAGS_NOTHROW = 0x400,
- FUNC_FLAGS_800 = 0x800,
- FUNC_FLAGS_1000 = 0x1000,
- FUNC_FLAGS_2000 = 0x2000,
+ FUNC_FLAGS_800 = 0x800, // autoinlined?
+ FUNC_FLAGS_1000 = 0x1000, // is ctor
+ FUNC_FLAGS_2000 = 0x2000, // is dtor
+ FUNC_FLAGS_4000 = 0x4000, // objc method?
FUNC_FLAGS_CONST = 0x8000,
FUNC_FLAGS_VOLATILE = 0x10000,
FUNC_FLAGS_100000 = 0x100000, // is template?
+ FUNC_FLAGS_200000 = 0x200000,
FUNC_FLAGS_800000 = 0x800000,
FUNC_FLAGS_900000 = 0x900000,
FUNC_FLAGS_4000000 = 0x4000000,
@@ -287,8 +290,8 @@ struct TypeMethod {
UInt32 flags;
TypeClass *theclass;
SInt32 x1E; // vtable offset?
- void *x22;
- Boolean x26;
+ SInt32 x22; // browser index?
+ Boolean x26; // is static
};
@@ -296,8 +299,8 @@ struct TypeBitfield {
TypeType type;
SInt32 size;
Type *bitfieldtype;
- char unkA;
- char unkB;
+ char unkA; // offset in bits
+ char unkB; // size in bits
};
@@ -371,7 +374,12 @@ struct TypePointer {
};
-// ObjCID
+/// Always has Q_100000 set
+struct TypeObjCID {
+ TypePointer pointer;
+ ObjCProtocolList *protocols;
+ short x12;
+};
struct TypeList {
@@ -394,6 +402,7 @@ struct TypeList {
#define TYPE_POINTER(ty) ((TypePointer *) (ty))
#define TPTR_TARGET(ty) (TYPE_POINTER(ty)->target)
#define TPTR_QUAL(ty) (TYPE_POINTER(ty)->qual)
+#define TYPE_OBJC_ID(ty) ((TypeObjCID *) (ty))
#define IS_TYPE_VOID(ty) ( (ty)->type == TYPEVOID )
#define IS_TYPE_INT(ty) ( (ty)->type == TYPEINT )
@@ -403,11 +412,14 @@ struct TypeList {
#define IS_TYPE_INT_OR_FLOAT(ty) ( IS_TYPE_INT(ty) || IS_TYPE_FLOAT(ty) )
#define IS_TYPE_STRUCT(ty) ( (ty)->type == TYPESTRUCT )
#define IS_TYPE_CLASS(ty) ( (ty)->type == TYPECLASS )
+#define IS_TYPE_OBJC_CLASS(ty) ( (ty)->type == TYPECLASS && TYPE_CLASS((ty))->objcinfo )
#define IS_TYPE_FUNC(ty) ( (ty)->type == TYPEFUNC )
#define IS_TYPEFUNC_METHOD(ty) ( (ty)->flags & FUNC_FLAGS_METHOD )
#define IS_TYPE_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) )
#define IS_TYPE_NONSTATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && !TYPE_METHOD(ty)->x26 )
#define IS_TYPE_STATIC_METHOD(ty) ( IS_TYPE_FUNC(ty) && IS_TYPEFUNC_METHOD(TYPE_FUNC(ty)) && TYPE_METHOD(ty)->x26 )
+#define IS_TYPEFUNC_NONSTATIC_METHOD(ty) ( IS_TYPEFUNC_METHOD(ty) && !TYPE_METHOD(ty)->x26 )
+#define IS_TYPEFUNC_STATIC_METHOD(ty) ( IS_TYPEFUNC_METHOD(ty) && TYPE_METHOD(ty)->x26 )
#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 )
diff --git a/includes/compiler/uDump.h b/includes/compiler/uDump.h
new file mode 100644
index 0000000..d39513c
--- /dev/null
+++ b/includes/compiler/uDump.h
@@ -0,0 +1,14 @@
+#ifndef COMPILER_UDUMP_H
+#define COMPILER_UDUMP_H
+
+#include "compiler/common.h"
+
+extern void SetupDumpIR(void);
+extern void CleanupDumpIR(void);
+extern void DumpIR(Statement *statements, Object *func);
+extern void DumpExpression(ENode *expr, int indent);
+extern void DumpSwitch(SwitchInfo *info);
+extern void DumpType(Type *type);
+extern void DumpStack(ExceptionAction *act);
+
+#endif