#ifndef _datatype_h_ #define _datatype_h_ #include "pre.h" enum DataTypeKind { DtkInvalid = 0, DtkVoid, DtkBasic, DtkStruct, DtkUnion, DtkProc, DtkArray, DtkBool, }; typedef struct DataType DataType; typedef struct { bool packed; Vec(DataType *) fields; } DataTypeCompound; struct DataType { enum DataTypeKind kind; u16 size; /* size in bytes of the data type */ bool builtin; /* if this type is defined in compilerland */ bool sign; /* if the type is numerical and has a sign or not */ Str name; union { DataTypeCompound compound; /* Represents either a struct or union type */ struct { DataType *rettype; Vec(DataType *) argtypes; bool public; bool extern_lnk; /* external linkage */ bool c_varargs; /* C-style varargs (for FFI) */ } proc; struct { DataType *base; isize len; } array; }; }; typedef struct { bool ok; /* whether the type checking succeeded */ Str msg; /* message describing the type error */ } DataTypeCheck; #endif