MWCC/includes/compiler/objects.h

247 lines
5.1 KiB
C
Raw Normal View History

2022-10-25 19:30:28 +00:00
#ifndef COMPILER_OBJECTS_H
#define COMPILER_OBJECTS_H
#include "compiler/common.h"
#include "compiler/tokens.h"
2022-10-25 19:30:28 +00:00
#ifdef __MWERKS__
#pragma options align=mac68k
#endif
typedef enum ObjectType {
OT_ENUMCONST,
OT_TYPE,
OT_TYPETAG,
OT_NAMESPACE,
OT_MEMBERVAR,
OT_OBJECT,
OT_ILLEGAL
} ObjectType;
struct ObjectList {
ObjectList *next;
Object *object;
};
/// General structure with all shared fields for all kinds of objects
struct ObjBase {
ObjectType otype;
AccessType access;
};
/// Type 0 (OT_ENUMCONST)
struct ObjEnumConst {
ObjectType otype;
AccessType access;
ObjEnumConst *next;
HashNameNode *name;
Type *type;
CInt64 val;
};
/// Type 1 (OT_TYPE)
struct ObjType {
ObjectType otype;
AccessType access;
Type *type;
2022-11-07 03:06:21 +00:00
UInt32 qual;
2022-10-25 19:30:28 +00:00
};
/// Type 2 (OT_TYPETAG)
struct ObjTypeTag {
ObjectType otype;
AccessType access;
Type *type;
};
/// Type 3 (OT_NAMESPACE)
struct ObjNameSpace {
ObjectType otype;
AccessType access;
NameSpace *nspace;
};
/// Type 4 (OT_MEMBERVAR)
struct ObjMemberVar {
ObjectType otype;
AccessType access;
Boolean anonunion;
Boolean has_path;
struct ObjMemberVar *next;
HashNameNode *name;
Type *type;
UInt32 qual;
UInt32 offset;
};
struct ObjMemberVarPath {
ObjectType otype;
AccessType access;
Boolean anonunion;
Boolean has_path;
struct ObjMemberVar *next;
HashNameNode *name;
Type *type;
UInt32 qual;
UInt32 offset;
BClassList *path;
};
typedef enum DataType {
DDATA,
DLOCAL,
DABSOLUTE,
DFUNC,
DVFUNC,
DINLINEFUNC,
DALIAS,
DEXPR,
DNONLAZYPTR,
DLABEL,
DUNUSED
} DataType;
/// Type 5 (OT_OBJECT)
struct Object {
ObjectType otype;
AccessType access;
DataType datatype;
Section section;
NameSpace *nspace;
HashNameNode *name;
Type *type;
UInt32 qual;
SInt16 sclass;
UInt8 flags;
ExtendedParam *extParam;
Object *toc;
2022-12-29 12:32:55 +00:00
VarRecord *varptr;
2022-10-25 19:30:28 +00:00
union {
struct {
union {
CInt64 intconst;
Float *floatconst;
MWVector128 *vector128const;
char *string;
struct {
char *data;
SInt32 size;
} switchtable;
} u;
VarInfo *info;
HashNameNode *linkname;
Boolean islocalstatic;
} data;
UInt32 address;
struct {
VarInfo *info;
HashNameNode *linkname;
Object *over_load;
} toc;
struct {
union {
TemplateFunction *templ;
CI_FuncData *ifuncdata;
SInt32 intrinsicid;
} u;
DefArgCtorInfo *defargdata;
HashNameNode *linkname;
TemplFuncInstance *inst;
PTFList *ptfList;
ObjectList *argList;
2023-01-10 11:05:21 +00:00
} func; // Used with DFUNC and DVFUNC
2022-10-25 19:30:28 +00:00
struct {
char *data;
SInt32 size;
InlineXRef *xrefs;
2023-01-10 11:05:21 +00:00
} ifunc; // Used with DINLINEFUNC
2022-10-25 19:30:28 +00:00
struct {
VarInfo *info;
SInt32 uid;
// SInt32 offset; // ???
2022-10-25 19:30:28 +00:00
Object *realObj;
} var;
struct {
Object *object;
//TypeClass *member;
BClassList *member; // ???
SInt32 offset;
} alias;
struct {
Object *function;
HashNameNode *labelname;
} label;
ENode *expr;
} u;
};
2022-12-29 12:32:55 +00:00
struct ObjectTemplated {
Object object;
Object *parent;
};
2022-11-07 03:06:21 +00:00
enum {
2023-01-20 11:56:38 +00:00
OBJECT_USED = 1,
OBJECT_FLAGS_2 = 2, // this object has been used in certain contexts (figure me out?)
OBJECT_DEFINED = 4,
OBJECT_LAZY = 8, // this object will be created by a CParser callback action only if referenced
OBJECT_INTERNAL = 0x10,
OBJECT_IMPORT = 0x20,
OBJECT_EXPORT = 0x40,
OBJECT_LIB_EXPORT = 0x60
2022-11-07 03:06:21 +00:00
};
2022-10-25 19:30:28 +00:00
#define OBJ_BASE(obj) ((ObjBase *) (obj))
#define OBJ_ENUM_CONST(obj) ((ObjEnumConst *) (obj))
#define OBJ_TYPE(obj) ((ObjType *) (obj))
#define OBJ_TYPE_TAG(obj) ((ObjTypeTag *) (obj))
#define OBJ_NAMESPACE(obj) ((ObjNameSpace *) (obj))
#define OBJ_MEMBER_VAR(obj) ((ObjMemberVar *) (obj))
#define OBJ_MEMBER_VAR_PATH(obj) ((ObjMemberVarPath *) (obj))
#define OBJECT(obj) ((Object *) (obj))
2022-12-29 12:32:55 +00:00
#define OBJECT_TEMPL(obj) ((ObjectTemplated *) (obj))
2022-10-25 19:30:28 +00:00
2022-11-07 03:06:21 +00:00
2023-01-20 11:56:38 +00:00
struct VarInfo {
2022-11-07 03:06:21 +00:00
Object *func;
SInt32 usage;
TStreamElement deftoken;
SInt16 varnumber;
Boolean noregister;
Boolean used;
UInt8 flags;
UInt8 rclass;
SInt16 reg;
SInt16 regHi;
};
enum {
VarInfoFlag1 = 1, // is parameter?
VarInfoFlag2 = 2, // spill related?
VarInfoFlag4 = 4, // 64-bit spill related?
2022-11-07 03:06:21 +00:00
VarInfoFlag40 = 0x40,
VarInfoFlag80 = 0x80
};
2022-10-25 19:30:28 +00:00
2023-01-10 11:05:21 +00:00
#define OBJECT_OR_ALIAS(_object) ( ((_object)->datatype == DALIAS) ? ((_object)->u.alias.object) : (_object) )
// placing these here until further notice
// unknown name, mwcppc.exe 7.0: 484870
2023-01-11 23:26:04 +00:00
CW_INLINE Boolean Inline_IsObjectData(Object *object) {
return object->datatype == DDATA;
}
2022-10-25 19:30:28 +00:00
#ifdef __MWERKS__
#pragma options align=reset
#endif
2022-11-07 03:06:21 +00:00
#endif