From 872c2b445358e9f848c6f356a7b67d4edef98dd9 Mon Sep 17 00:00:00 2001 From: cuz Date: Thu, 10 Oct 2002 20:23:41 +0000 Subject: [PATCH] Made a lot of short functions inline git-svn-id: svn://svn.cc65.org/cc65/trunk@1456 b7a2c559-68d2-44c3-8de9-860c34a00d81 --- src/cc65/datatype.c | 84 +------------------------------- src/cc65/datatype.h | 115 +++++++++++++++++++++++++++++++++++++++----- 2 files changed, 105 insertions(+), 94 deletions(-) diff --git a/src/cc65/datatype.c b/src/cc65/datatype.c index bc3ae194f..6aad02ea3 100644 --- a/src/cc65/datatype.c +++ b/src/cc65/datatype.c @@ -488,7 +488,7 @@ unsigned PSizeOf (const type* T) /* Compute size of pointer object. */ { /* We are expecting a pointer expression */ - CHECK ((*T & T_CLASS_PTR) != 0); + CHECK ((T[0] & T_MASK_CLASS) == T_CLASS_PTR); /* Skip the pointer or array token itself */ if (IsTypeArray (T)) { @@ -585,7 +585,7 @@ type* Indirect (type* T) */ { /* We are expecting a pointer expression */ - CHECK ((*T & T_MASK_CLASS) == T_CLASS_PTR); + CHECK ((T[0] & T_MASK_CLASS) == T_CLASS_PTR); /* Skip the pointer or array token itself */ if (IsTypeArray (T)) { @@ -597,78 +597,6 @@ type* Indirect (type* T) -int IsTypeChar (const type* T) -/* Return true if this is a character type */ -{ - return (T[0] & T_MASK_TYPE) == T_TYPE_CHAR; -} - - - -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; -} - - - -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; -} - - - -int IsTypeFloat (const type* T) -/* Return true if this is a float type */ -{ - return (T[0] & T_MASK_TYPE) == T_TYPE_FLOAT; -} - - - -int IsTypeDouble (const type* T) -/* Return true if this is a double type */ -{ - return (T[0] & T_MASK_TYPE) == T_TYPE_DOUBLE; -} - - - -int IsTypePtr (const type* T) -/* Return true if this is a pointer type */ -{ - return ((T[0] & T_MASK_TYPE) == T_TYPE_PTR); -} - - - -int IsTypeArray (const type* T) -/* Return true if this is an array type */ -{ - return ((T[0] & T_MASK_TYPE) == T_TYPE_ARRAY); -} - - - -int IsTypeVoid (const type* T) -/* Return true if this is a void type */ -{ - return (T[0] & T_MASK_TYPE) == T_TYPE_VOID; -} - - - -int IsTypeFunc (const type* T) -/* Return true if this is a function class */ -{ - return ((T[0] & T_MASK_TYPE) == T_TYPE_FUNC); -} - - - int IsClassInt (const type* T) /* Return true if this is an integer type */ { @@ -747,14 +675,6 @@ int IsVariadicFunc (const type* T) -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); -} - - - type GetType (const type* T) /* Get the raw type */ { diff --git a/src/cc65/datatype.h b/src/cc65/datatype.h index 2d4ac21bb..75c84ef29 100644 --- a/src/cc65/datatype.h +++ b/src/cc65/datatype.h @@ -252,32 +252,126 @@ type* Indirect (type* Type); * given type points to. */ -int IsTypeChar (const type* T) attribute ((const)); +#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 -int IsTypeArray (const type* Type) attribute ((const)); +#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 + +#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 */ @@ -310,9 +404,6 @@ int IsVariadicFunc (const type* T) attribute ((const)); * 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)); /* Get the raw type */