diff options
author | Ash Wolf <ninji@wuffs.org> | 2022-11-07 03:06:21 +0000 |
---|---|---|
committer | Ash Wolf <ninji@wuffs.org> | 2022-11-07 03:06:21 +0000 |
commit | 9a46dd0e2e80790d9848c0bbd718932a27c23269 (patch) | |
tree | e7a8e976c7138d50a69ff4778c4e8572efd94452 /includes/compiler/CInline.h | |
parent | d0b9848c54e6f85ab713f059dcd1ddef7e57caa6 (diff) | |
download | MWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.tar.gz MWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.zip |
honk
Diffstat (limited to '')
-rw-r--r-- | includes/compiler/CInline.h | 121 |
1 files changed, 121 insertions, 0 deletions
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 |