X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fdatatype.h;h=76bd018e1bf10989c7a772af45393a5c0b272470;hb=aef8789873bd008d42aa50330ca98488fad91b31;hp=75c84ef297015642ce9117c5c4234fa6139b9aa7;hpb=872c2b445358e9f848c6f356a7b67d4edef98dd9;p=cc65 diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index 75c84ef29..76bd018e1 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -42,6 +42,7 @@ /* common */ #include "attrib.h" +#include "inline.h" /* cc65 */ #include "funcdesc.h" @@ -143,6 +144,20 @@ typedef unsigned short type; /* Type elements needed for Encode/Decode */ #define DECODE_SIZE 5 +/* Special encodings for element counts of an array */ +#define UNSPECIFIED -1L /* Element count was not specified */ +#define FLEXIBLE 0L /* Flexible array struct member */ + +/* Sizes */ +#define SIZEOF_CHAR 1 +#define SIZEOF_SHORT 2 +#define SIZEOF_INT 2 +#define SIZEOF_LONG 4 +#define SIZEOF_LONGLONG 8 +#define SIZEOF_FLOAT 4 +#define SIZEOF_DOUBLE 4 +#define SIZEOF_PTR 2 + /* Predefined type strings */ extern type type_uchar []; extern type type_int []; @@ -207,7 +222,7 @@ void PrintFuncSig (FILE* F, const char* Name, type* Type); /* Print a function signature. */ void Encode (type* Type, unsigned long Val); -/* Encode an unsigned long into a type array */ +/* Encode Val into the given type string */ void EncodePtr (type* Type, void* P); /* Encode a pointer into a type array */ @@ -224,8 +239,15 @@ int HasEncode (const type* Type); void CopyEncode (const type* Source, type* Target); /* Copy encoded data from Source to Target */ -type UnqualifiedType (type T); +#if defined(HAVE_INLINE) +INLINE type UnqualifiedType (type T) /* Return the unqalified type */ +{ + return (T & ~T_MASK_QUAL); +} +#else +# define UnqualifiedType(T) ((T) & ~T_MASK_QUAL) +#endif unsigned SizeOf (const type* Type); /* Compute size of object represented by type array. */ @@ -252,6 +274,9 @@ type* Indirect (type* Type); * given type points to. */ +type* ArrayToPtr (const type* Type); +/* Convert an array to a pointer to it's first element */ + #if defined(HAVE_INLINE) INLINE int IsTypeChar (const type* T) /* Return true if this is a character type */ @@ -404,17 +429,45 @@ int IsVariadicFunc (const type* T) attribute ((const)); * variable parameter list */ -type GetType (const type* T) attribute ((const)); +#if defined(HAVE_INLINE) +INLINE type GetType (const type* T) /* Get the raw type */ +{ + return (T[0] & T_MASK_TYPE); +} +#else +# define GetType(T) ((T)[0] & T_MASK_TYPE) +#endif -type GetClass (const type* T) attribute ((const)); +#if defined(HAVE_INLINE) +INLINE type GetClass (const type* T) /* Get the class of a type string */ +{ + return (T[0] & T_MASK_CLASS); +} +#else +# define GetClass(T) ((T)[0] & T_MASK_CLASS) +#endif -type GetSignedness (const type* T) attribute ((const)); +#if defined(HAVE_INLINE) +INLINE type GetSignedness (const type* T) /* Get the sign of a type */ +{ + return (T[0] & T_MASK_SIGN); +} +#else +# define GetSignedness(T) ((T)[0] & T_MASK_SIGN) +#endif -type GetSizeModifier (const type* T) attribute ((const)); +#if defined(HAVE_INLINE) +INLINE type GetSizeModifier (const type* T) /* Get the size modifier of a type */ +{ + return (T[0] & T_MASK_SIZE); +} +#else +# define GetSizeModifier(T) ((T)[0] & T_MASK_SIZE) +#endif type GetQualifier (const type* T) attribute ((const)); /* Get the qualifier from the given type string */ @@ -425,6 +478,14 @@ FuncDesc* GetFuncDesc (const type* T) attribute ((const)); type* GetFuncReturn (type* T) attribute ((const)); /* Return a pointer to the return type of a function or pointer-to-function type */ +long GetElementCount (const type* T); +/* Get the element count of the array specified in T (which must be of + * array type). + */ + +type* GetElementType (type* T); +/* Return the element type of the given array type. */ + /* End of datatype.h */