#ifndef COMPILER_OBJECTS_H #define COMPILER_OBJECTS_H #include "compiler/common.h" #include "compiler/tokens.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; UInt32 qual; }; /// 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; VarRecord *varptr; 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; }; struct ObjectTemplated { Object object; Object *parent; }; enum { OBJECT_FLAGS_UNUSED = 1, OBJECT_FLAGS_2 = 2, OBJECT_FLAGS_4 = 4, OBJECT_FLAGS_8 = 8, OBJECT_FLAGS_10 = 0x10, // internal OBJECT_FLAGS_20 = 0x20, // import OBJECT_FLAGS_40 = 0x40, // export OBJECT_FLAGS_60 = 0x60 // lib export }; enum { OBJECT_SCLASS_101 = 0x101, OBJECT_SCLASS_102 = 0x102, OBJECT_SCLASS_103 = 0x103, OBJECT_SCLASS_104 = 0x104, OBJECT_SCLASS_12B = 0x12B }; #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)) #define OBJECT_TEMPL(obj) ((ObjectTemplated *) (obj)) struct VarInfo { // OK! 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? VarInfoFlag40 = 0x40, VarInfoFlag80 = 0x80 }; // placing these here until further notice // unknown name, mwcppc.exe 7.0: 484870 inline Boolean Inline_IsObjectData(Object *object) { return object->datatype == DDATA; } #ifdef __MWERKS__ #pragma options align=reset #endif #endif