mirror of https://git.wuffs.org/MWCC
325 lines
6.1 KiB
C
325 lines
6.1 KiB
C
#ifndef COMPILER_TYPES_H
|
|
#define COMPILER_TYPES_H
|
|
|
|
#include "compiler/common.h"
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=mac68k
|
|
#endif
|
|
|
|
typedef enum TypeType {
|
|
TYPEVOID = 0,
|
|
TYPEINT,
|
|
TYPEFLOAT,
|
|
TYPEENUM,
|
|
TYPESTRUCT,
|
|
TYPECLASS,
|
|
TYPEFUNC,
|
|
TYPEBITFIELD,
|
|
TYPELABEL,
|
|
TYPETEMPLATE,
|
|
TYPEMEMBERPOINTER,
|
|
TYPEPOINTER,
|
|
TYPEARRAY,
|
|
TYPEOBJCID,
|
|
TYPETEMPLDEPEXPR,
|
|
TYPEILLEGAL = -1
|
|
} TypeType;
|
|
|
|
|
|
/// Common fields across all kinds of types
|
|
struct Type {
|
|
TypeType type;
|
|
SInt32 size;
|
|
};
|
|
|
|
|
|
typedef enum IntegralType {
|
|
IT_BOOL = 0,
|
|
IT_CHAR = 1,
|
|
IT_SCHAR = 2,
|
|
IT_UCHAR = 3,
|
|
IT_WCHAR_T = 4,
|
|
IT_SHORT = 5,
|
|
IT_USHORT = 6,
|
|
IT_INT = 7,
|
|
IT_UINT = 8,
|
|
IT_LONG = 9,
|
|
IT_ULONG = 10,
|
|
IT_LONGLONG = 11,
|
|
IT_ULONGLONG = 12,
|
|
IT_FLOAT = 13,
|
|
IT_SHORTDOUBLE = 14,
|
|
IT_DOUBLE = 15,
|
|
IT_LONGDOUBLE = 16
|
|
} IntegralType;
|
|
|
|
struct TypeIntegral {
|
|
TypeType type;
|
|
SInt32 size;
|
|
unsigned char integral;
|
|
};
|
|
|
|
|
|
struct TypeEnum { // checked via CPrec
|
|
TypeType type;
|
|
SInt32 size;
|
|
NameSpace *nspace;
|
|
ObjEnumConst *enumlist;
|
|
Type *enumtype;
|
|
HashNameNode *enumname;
|
|
};
|
|
|
|
|
|
struct TypeStruct {
|
|
TypeType type;
|
|
SInt32 size;
|
|
HashNameNode *name;
|
|
StructMember *members;
|
|
char stype;
|
|
SInt16 align;
|
|
};
|
|
struct StructMember {
|
|
StructMember *next;
|
|
Type *type;
|
|
HashNameNode *name;
|
|
SInt32 offset;
|
|
UInt32 qual;
|
|
};
|
|
|
|
enum {
|
|
STRUCT_TYPE_STRUCT = 0,
|
|
STRUCT_TYPE_UNION = 1,
|
|
STRUCT_TYPE_4 = 4,
|
|
STRUCT_TYPE_5 = 5,
|
|
STRUCT_TYPE_6 = 6,
|
|
STRUCT_TYPE_7 = 7,
|
|
STRUCT_TYPE_8 = 8,
|
|
STRUCT_TYPE_9 = 9,
|
|
STRUCT_TYPE_A = 10,
|
|
STRUCT_TYPE_B = 11,
|
|
STRUCT_TYPE_C = 12,
|
|
STRUCT_TYPE_D = 13,
|
|
STRUCT_TYPE_E = 14
|
|
};
|
|
|
|
|
|
typedef struct ClassList { // checked via CPrec
|
|
struct ClassList *next;
|
|
TypeClass *base;
|
|
SInt32 offset;
|
|
SInt32 voffset;
|
|
AccessType access;
|
|
Boolean is_virtual;
|
|
} ClassList;
|
|
|
|
typedef struct VClassList { // checked via CPrec
|
|
struct VClassList *next;
|
|
TypeClass *base;
|
|
SInt32 offset;
|
|
SInt32 voffset;
|
|
Boolean has_override;
|
|
char alignsave;
|
|
} VClassList;
|
|
|
|
typedef struct ClassFriend { // checked via CPrec
|
|
struct ClassFriend *next;
|
|
union {
|
|
TypeClass *theclass;
|
|
Object *obj;
|
|
} u;
|
|
Boolean isclass;
|
|
} ClassFriend;
|
|
|
|
struct BClassList { // checked via CPrec
|
|
struct BClassList *next;
|
|
Type *type;
|
|
};
|
|
|
|
typedef struct VTable { // checked via CPrec
|
|
Object *object;
|
|
TypeClass *owner;
|
|
SInt32 offset;
|
|
SInt32 size;
|
|
} VTable;
|
|
|
|
struct TypeClass {
|
|
TypeType type;
|
|
SInt32 size;
|
|
NameSpace *nspace;
|
|
HashNameNode *classname;
|
|
ClassList *bases;
|
|
VClassList *vbases;
|
|
ObjMemberVar *ivars;
|
|
ClassFriend *friends;
|
|
VTable *vtable;
|
|
SOMInfo *sominfo;
|
|
ObjCInfo *objcinfo;
|
|
UInt16 flags;
|
|
SInt8 mode;
|
|
SInt8 action;
|
|
SInt16 align;
|
|
UInt8 eflags;
|
|
};
|
|
|
|
enum {
|
|
CLASS_FLAGS_2 = 2,
|
|
CLASS_FLAGS_20 = 0x20,
|
|
CLASS_FLAGS_100 = 0x100, // is TemplClass
|
|
CLASS_FLAGS_800 = 0x800, // is TemplClassInst
|
|
CLASS_FLAGS_900 = 0x900
|
|
};
|
|
|
|
|
|
typedef struct ExceptSpecList {
|
|
struct ExceptSpecList *next;
|
|
Type *type;
|
|
UInt32 qual;
|
|
} ExceptSpecList;
|
|
|
|
struct FuncArg { // ok
|
|
struct FuncArg *next;
|
|
HashNameNode *name;
|
|
ENode *dexpr;
|
|
Type *type;
|
|
UInt32 qual;
|
|
SInt16 sclass;
|
|
Boolean is_array;
|
|
Boolean has_defdefarg;
|
|
};
|
|
|
|
struct TypeFunc {
|
|
TypeType type;
|
|
SInt32 size;
|
|
FuncArg *args;
|
|
ExceptSpecList *exspecs;
|
|
Type *functype;
|
|
UInt32 qual;
|
|
UInt32 flags;
|
|
};
|
|
enum {
|
|
FUNC_FLAGS_PASCAL = 1, // on TypeFunc::flags
|
|
FUNC_FLAGS_METHOD = 0x10,
|
|
FUNC_FLAGS_40 = 0x40, // func that's like "operator SomeOtherType()"
|
|
FUNC_FLAGS_1000 = 0x1000,
|
|
FUNC_FLAGS_2000 = 0x2000,
|
|
FUNC_FLAGS_100000 = 0x100000,
|
|
FUNC_FLAGS_900000 = 0x900000
|
|
};
|
|
|
|
// There seems to be a version of this which adds a class pointer at the end
|
|
struct TypeMethod {
|
|
TypeType type;
|
|
SInt32 size;
|
|
FuncArg *args;
|
|
ExceptSpecList *exspecs;
|
|
Type *functype;
|
|
UInt32 qual;
|
|
UInt32 flags;
|
|
TypeClass *theclass;
|
|
void *x1E;
|
|
void *x22;
|
|
Boolean x26;
|
|
};
|
|
|
|
|
|
struct TypeBitfield {
|
|
TypeType type;
|
|
SInt32 size;
|
|
Type *bitfieldtype;
|
|
unsigned char unkA;
|
|
char unkB;
|
|
};
|
|
|
|
|
|
// Label
|
|
|
|
|
|
typedef enum TypeTemplDepType {
|
|
TEMPLDEP_ARGUMENT,
|
|
TEMPLDEP_QUALNAME,
|
|
TEMPLDEP_TEMPLATE,
|
|
TEMPLDEP_ARRAY,
|
|
TEMPLDEP_QUALTEMPL,
|
|
TEMPLDEP_BITFIELD,
|
|
TEMPLDEP_VALUEDEP, // not in v7?
|
|
TEMPLDEP_ENUMVAL, // not in v7?
|
|
TEMPLDEP_TYPEOF // not in v7?
|
|
} TypeTemplDepType;
|
|
|
|
struct TypeTemplDep {
|
|
TypeType type;
|
|
SInt32 size;
|
|
TypeTemplDepType dtype;
|
|
union {
|
|
TemplParamID pid;
|
|
struct {
|
|
TypeTemplDep *type;
|
|
HashNameNode *name;
|
|
} qual;
|
|
struct {
|
|
TemplClass *templ;
|
|
TemplArg *args;
|
|
} templ;
|
|
struct {
|
|
Type *type;
|
|
ENode *index;
|
|
} array;
|
|
struct {
|
|
TypeTemplDep *type;
|
|
TemplArg *args;
|
|
} qualtempl;
|
|
struct {
|
|
Type *type;
|
|
ENode *size;
|
|
} bitfield;
|
|
// the following ones may not be in v7
|
|
Type *vdep;
|
|
ENode *tof;
|
|
struct {
|
|
TypeEnum *etype;
|
|
ENode *expr;
|
|
} enumval;
|
|
} u;
|
|
};
|
|
|
|
|
|
struct TypeMemberPointer {
|
|
TypeType type;
|
|
SInt32 size;
|
|
Type *ty1;
|
|
Type *ty2;
|
|
UInt32 qual;
|
|
};
|
|
|
|
|
|
/// Used for TYPEPOINTER and TYPEARRAY
|
|
struct TypePointer {
|
|
TypeType type;
|
|
SInt32 size;
|
|
Type *target;
|
|
UInt32 qual;
|
|
};
|
|
|
|
|
|
// ObjCID
|
|
|
|
|
|
// Not sure if these existed originally, but they'll help
|
|
#define TYPE_INTEGRAL(ty) ((TypeIntegral *) (ty))
|
|
#define TYPE_ENUM(ty) ((TypeEnum *) (ty))
|
|
#define TYPE_STRUCT(ty) ((TypeStruct *) (ty))
|
|
#define TYPE_CLASS(ty) ((TypeClass *) (ty))
|
|
#define TYPE_FUNC(ty) ((TypeFunc *) (ty))
|
|
#define TYPE_METHOD(ty) ((TypeMethod *) (ty))
|
|
#define TYPE_BITFIELD(ty) ((TypeBitfield *) (ty))
|
|
#define TYPE_TEMPLATE(ty) ((TypeTemplDep *) (ty))
|
|
#define TYPE_MEMBER_POINTER(ty) ((TypeMemberPointer *) (ty))
|
|
#define TYPE_POINTER(ty) ((TypePointer *) (ty))
|
|
|
|
#ifdef __MWERKS__
|
|
#pragma options align=reset
|
|
#endif
|
|
|
|
#endif
|