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/CFunc.h | |
parent | d0b9848c54e6f85ab713f059dcd1ddef7e57caa6 (diff) | |
download | MWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.tar.gz MWCC-9a46dd0e2e80790d9848c0bbd718932a27c23269.zip |
honk
Diffstat (limited to '')
-rw-r--r-- | includes/compiler/CFunc.h | 147 |
1 files changed, 147 insertions, 0 deletions
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 |