/* */
/* */
/* */
-/* (C) 1998 Ullrich von Bassewitz */
-/* Wacholderweg 14 */
-/* D-70597 Stuttgart */
-/* EMail: uz@musoftware.de */
+/* (C) 1998-2002 Ullrich von Bassewitz */
+/* Wacholderweg 14 */
+/* D-70597 Stuttgart */
+/* EMail: uz@musoftware.de */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* common */
#include "attrib.h"
+#include "inline.h"
/* cc65 */
#include "funcdesc.h"
/* 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 [];
void TypeFree (type* Type);
/* Free a type string */
+int SignExtendChar (int C);
+/* Do correct sign extension of a character */
+
type GetDefaultChar (void);
/* Return the default char type (signed/unsigned) depending on the settings */
/* 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 */
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. */
* given type points to.
*/
-int IsTypeChar (const type* T) attribute ((const));
+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 */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_CHAR;
+}
+#else
+# define IsTypeChar(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_CHAR)
+#endif
-int IsTypeInt (const type* T) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeInt (const type* T)
/* Return true if this is an int type (signed or unsigned) */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_INT;
+}
+#else
+# define IsTypeInt(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_INT)
+#endif
-int IsTypeLong (const type* T) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeLong (const type* T)
/* Return true if this is a long type (signed or unsigned) */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_LONG;
+}
+#else
+# define IsTypeLong(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_LONG)
+#endif
-int IsTypeFloat (const type* T) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeFloat (const type* T)
/* Return true if this is a float type */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_FLOAT;
+}
+#else
+# define IsTypeFloat(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_FLOAT)
+#endif
-int IsTypeDouble (const type* T) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeDouble (const type* T)
/* Return true if this is a double type */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_DOUBLE;
+}
+#else
+# define IsTypeDouble(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_DOUBLE)
+#endif
-int IsTypePtr (const type* Type) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypePtr (const type* T)
/* Return true if this is a pointer type */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_PTR);
+}
+#else
+# define IsTypePtr(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_PTR)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int IsTypeStruct (const type* T)
+/* Return true if this is a struct type */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_STRUCT);
+}
+#else
+# define IsTypeStruct(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_STRUCT)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int IsTypeUnion (const type* T)
+/* Return true if this is a union type */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_UNION);
+}
+#else
+# define IsTypeUnion(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_UNION)
+#endif
-int IsTypeArray (const type* Type) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeArray (const type* T)
/* Return true if this is an array type */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_ARRAY);
+}
+#else
+# define IsTypeArray(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_ARRAY)
+#endif
-int IsTypeVoid (const type* Type) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeVoid (const type* T)
/* Return true if this is a void type */
+{
+ return (T[0] & T_MASK_TYPE) == T_TYPE_VOID;
+}
+#else
+# define IsTypeVoid(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_VOID)
+#endif
-int IsTypeFunc (const type* Type) attribute ((const));
+#if defined(HAVE_INLINE)
+INLINE int IsTypeFunc (const type* T)
/* Return true if this is a function class */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_FUNC);
+}
+#else
+# define IsTypeFunc(T) (((T)[0] & T_MASK_TYPE) == T_TYPE_FUNC)
+#endif
+
+#if defined(HAVE_INLINE)
+INLINE int IsTypeFuncPtr (const type* T)
+/* Return true if this is a function pointer */
+{
+ return ((T[0] & T_MASK_TYPE) == T_TYPE_PTR && (T[1] & T_MASK_TYPE) == T_TYPE_FUNC);
+}
+#else
+# define IsTypeFuncPtr(T) \
+ ((((T)[0] & T_MASK_TYPE) == T_TYPE_PTR) && (((T)[1] & T_MASK_TYPE) == T_TYPE_FUNC))
+#endif
int IsClassInt (const type* Type) attribute ((const));
/* Return true if this is an integer type */
* variable parameter list
*/
-int IsTypeFuncPtr (const type* T) attribute ((const));
-/* Return true if this is a function pointer */
-
-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 */
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 */