mirror of https://git.wuffs.org/MWCC
201 lines
4.0 KiB
C
201 lines
4.0 KiB
C
#ifndef COMPILER_OBJECTS_H
|
|
#define COMPILER_OBJECTS_H
|
|
|
|
#include "compiler/common.h"
|
|
|
|
#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;
|
|
void *unk6;
|
|
};
|
|
|
|
|
|
/// 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;
|
|
void *any;
|
|
//char reg; // notsure?
|
|
//VarRecord *varptr; // notsure?
|
|
// union starts at 0x24 in v7
|
|
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;
|
|
} func;
|
|
struct {
|
|
char *data;
|
|
SInt32 size;
|
|
InlineXRef *xrefs;
|
|
} ifunc;
|
|
struct {
|
|
VarInfo *info;
|
|
SInt32 uid;
|
|
SInt32 offset;
|
|
Object *realObj;
|
|
} var;
|
|
struct {
|
|
Object *object;
|
|
//TypeClass *member;
|
|
BClassList *member; // ???
|
|
SInt32 offset;
|
|
} alias;
|
|
struct {
|
|
Object *function;
|
|
HashNameNode *labelname;
|
|
} label;
|
|
ENode *expr;
|
|
} u;
|
|
};
|
|
|
|
#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))
|
|
|
|
#endif
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=reset
|
|
#endif
|