2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* datatype.h */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Type string handling for the cc65 C compiler */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* */
|
2015-03-09 22:53:45 +00:00
|
|
|
/* (C) 1998-2015, Ullrich von Bassewitz */
|
2010-04-29 20:30:49 +00:00
|
|
|
/* Roemerstrasse 52 */
|
|
|
|
/* D-70794 Filderstadt */
|
|
|
|
/* EMail: uz@cc65.org */
|
2000-05-28 13:40:48 +00:00
|
|
|
/* */
|
|
|
|
/* */
|
|
|
|
/* This software is provided 'as-is', without any expressed or implied */
|
|
|
|
/* warranty. In no event will the authors be held liable for any damages */
|
|
|
|
/* arising from the use of this software. */
|
|
|
|
/* */
|
|
|
|
/* Permission is granted to anyone to use this software for any purpose, */
|
|
|
|
/* including commercial applications, and to alter it and redistribute it */
|
|
|
|
/* freely, subject to the following restrictions: */
|
|
|
|
/* */
|
|
|
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
|
|
|
/* claim that you wrote the original software. If you use this software */
|
|
|
|
/* in a product, an acknowledgment in the product documentation would be */
|
|
|
|
/* appreciated but is not required. */
|
|
|
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
|
|
|
/* be misrepresented as being the original software. */
|
|
|
|
/* 3. This notice may not be removed or altered from any source */
|
|
|
|
/* distribution. */
|
|
|
|
/* */
|
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef DATATYPE_H
|
|
|
|
#define DATATYPE_H
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
2000-08-19 21:55:06 +00:00
|
|
|
/* common */
|
|
|
|
#include "attrib.h"
|
2002-11-24 23:31:54 +00:00
|
|
|
#include "inline.h"
|
2008-08-31 18:24:33 +00:00
|
|
|
#include "mmodel.h"
|
2000-08-19 21:55:06 +00:00
|
|
|
|
2001-03-23 19:17:04 +00:00
|
|
|
/* cc65 */
|
|
|
|
#include "funcdesc.h"
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Data */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Basic data types */
|
2000-08-01 15:04:35 +00:00
|
|
|
enum {
|
2013-05-09 11:56:54 +00:00
|
|
|
T_END = 0x000000,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Basic types */
|
2013-05-09 11:56:54 +00:00
|
|
|
T_TYPE_NONE = 0x000000,
|
|
|
|
T_TYPE_CHAR = 0x000001,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_TYPE_SHORT = 0x000002,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_TYPE_INT = 0x000003,
|
|
|
|
T_TYPE_LONG = 0x000004,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_TYPE_LONGLONG = 0x000005,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_TYPE_ENUM = 0x000006,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_TYPE_FLOAT = 0x000007,
|
|
|
|
T_TYPE_DOUBLE = 0x000008,
|
|
|
|
T_TYPE_VOID = 0x000009,
|
|
|
|
T_TYPE_STRUCT = 0x00000A,
|
|
|
|
T_TYPE_UNION = 0x00000B,
|
|
|
|
T_TYPE_ARRAY = 0x00000C,
|
|
|
|
T_TYPE_PTR = 0x00000D,
|
|
|
|
T_TYPE_FUNC = 0x00000E,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_MASK_TYPE = 0x00000F,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Type classes */
|
2008-08-24 17:33:30 +00:00
|
|
|
T_CLASS_NONE = 0x000000,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_CLASS_INT = 0x000010,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_CLASS_FLOAT = 0x000020,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_CLASS_PTR = 0x000030,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_CLASS_STRUCT = 0x000040,
|
|
|
|
T_CLASS_FUNC = 0x000050,
|
|
|
|
T_MASK_CLASS = 0x000070,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Type signedness */
|
2013-05-09 11:56:54 +00:00
|
|
|
T_SIGN_NONE = 0x000000,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_SIGN_UNSIGNED = 0x000080,
|
|
|
|
T_SIGN_SIGNED = 0x000100,
|
|
|
|
T_MASK_SIGN = 0x000180,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Type size modifiers */
|
2013-05-09 11:56:54 +00:00
|
|
|
T_SIZE_NONE = 0x000000,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_SIZE_CHAR = 0x000200,
|
|
|
|
T_SIZE_SHORT = 0x000400,
|
|
|
|
T_SIZE_INT = 0x000600,
|
|
|
|
T_SIZE_LONG = 0x000800,
|
|
|
|
T_SIZE_LONGLONG = 0x000A00,
|
|
|
|
T_MASK_SIZE = 0x000E00,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Type qualifiers */
|
2008-08-24 17:33:30 +00:00
|
|
|
T_QUAL_NONE = 0x000000,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_QUAL_CONST = 0x001000,
|
|
|
|
T_QUAL_VOLATILE = 0x002000,
|
|
|
|
T_QUAL_RESTRICT = 0x004000,
|
|
|
|
T_QUAL_NEAR = 0x008000,
|
|
|
|
T_QUAL_FAR = 0x010000,
|
2008-08-24 17:33:30 +00:00
|
|
|
T_QUAL_ADDRSIZE = T_QUAL_NEAR | T_QUAL_FAR,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_QUAL_FASTCALL = 0x020000,
|
|
|
|
T_QUAL_CDECL = 0x040000,
|
2010-04-29 20:30:49 +00:00
|
|
|
T_QUAL_CCONV = T_QUAL_FASTCALL | T_QUAL_CDECL,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_MASK_QUAL = 0x07F000,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2000-12-20 17:44:12 +00:00
|
|
|
/* Types */
|
2020-07-26 12:12:55 +00:00
|
|
|
T_CHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_CHAR,
|
|
|
|
T_SCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_CHAR,
|
|
|
|
T_UCHAR = T_TYPE_CHAR | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_CHAR,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_SHORT = T_TYPE_SHORT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_SHORT,
|
2000-08-01 18:45:08 +00:00
|
|
|
T_USHORT = T_TYPE_SHORT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_SHORT,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_INT = T_TYPE_INT | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_INT,
|
|
|
|
T_UINT = T_TYPE_INT | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_INT,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_LONG = T_TYPE_LONG | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONG,
|
|
|
|
T_ULONG = T_TYPE_LONG | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONG,
|
|
|
|
T_LONGLONG = T_TYPE_LONGLONG | T_CLASS_INT | T_SIGN_SIGNED | T_SIZE_LONGLONG,
|
|
|
|
T_ULONGLONG = T_TYPE_LONGLONG | T_CLASS_INT | T_SIGN_UNSIGNED | T_SIZE_LONGLONG,
|
2020-07-26 12:12:55 +00:00
|
|
|
T_ENUM = T_TYPE_ENUM | T_CLASS_INT | T_SIGN_NONE | T_SIZE_NONE,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_FLOAT = T_TYPE_FLOAT | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE,
|
|
|
|
T_DOUBLE = T_TYPE_DOUBLE | T_CLASS_FLOAT | T_SIGN_NONE | T_SIZE_NONE,
|
|
|
|
T_VOID = T_TYPE_VOID | T_CLASS_NONE | T_SIGN_NONE | T_SIZE_NONE,
|
2000-08-01 18:45:08 +00:00
|
|
|
T_STRUCT = T_TYPE_STRUCT | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE,
|
|
|
|
T_UNION = T_TYPE_UNION | T_CLASS_STRUCT | T_SIGN_NONE | T_SIZE_NONE,
|
2013-05-09 11:56:54 +00:00
|
|
|
T_ARRAY = T_TYPE_ARRAY | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE,
|
|
|
|
T_PTR = T_TYPE_PTR | T_CLASS_PTR | T_SIGN_NONE | T_SIZE_NONE,
|
|
|
|
T_FUNC = T_TYPE_FUNC | T_CLASS_FUNC | T_SIGN_NONE | T_SIZE_NONE,
|
2000-07-27 21:08:52 +00:00
|
|
|
|
2004-06-04 17:52:19 +00:00
|
|
|
/* Aliases */
|
|
|
|
T_SIZE_T = T_UINT,
|
2000-07-27 21:08:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
/* Type code entry */
|
|
|
|
typedef unsigned long TypeCode;
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Type entry */
|
2006-02-19 12:29:37 +00:00
|
|
|
typedef struct Type Type;
|
|
|
|
struct Type {
|
|
|
|
TypeCode C; /* Code for this entry */
|
|
|
|
union {
|
|
|
|
void* P; /* Arbitrary attribute pointer */
|
|
|
|
long L; /* Numeric attribute value */
|
|
|
|
unsigned long U; /* Dito, unsigned */
|
|
|
|
} A; /* Type attribute if necessary */
|
|
|
|
};
|
|
|
|
|
|
|
|
/* A macro that expands to a full initializer for struct Type */
|
|
|
|
#define TYPE(T) { (T), { 0 } }
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
/* Maximum length of a type string */
|
2013-05-09 11:56:54 +00:00
|
|
|
#define MAXTYPELEN 30
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2003-02-05 22:02:48 +00:00
|
|
|
/* Special encodings for element counts of an array */
|
|
|
|
#define UNSPECIFIED -1L /* Element count was not specified */
|
|
|
|
#define FLEXIBLE 0L /* Flexible array struct member */
|
2003-02-03 22:14:20 +00:00
|
|
|
|
2008-08-11 17:51:00 +00:00
|
|
|
/* Sizes. Floating point sizes come from fp.h */
|
2009-08-30 08:36:56 +00:00
|
|
|
#define SIZEOF_CHAR 1U
|
|
|
|
#define SIZEOF_SHORT 2U
|
|
|
|
#define SIZEOF_INT 2U
|
|
|
|
#define SIZEOF_LONG 4U
|
|
|
|
#define SIZEOF_LONGLONG 8U
|
2008-08-11 17:51:00 +00:00
|
|
|
#define SIZEOF_FLOAT (FP_F_Size())
|
|
|
|
#define SIZEOF_DOUBLE (FP_D_Size())
|
2009-08-30 08:36:56 +00:00
|
|
|
#define SIZEOF_PTR SIZEOF_INT
|
2002-11-01 21:27:31 +00:00
|
|
|
|
2009-08-29 17:38:53 +00:00
|
|
|
/* Bit sizes */
|
|
|
|
#define CHAR_BITS (8 * SIZEOF_CHAR)
|
|
|
|
#define SHORT_BITS (8 * SIZEOF_SHORT)
|
|
|
|
#define INT_BITS (8 * SIZEOF_INT)
|
|
|
|
#define LONG_BITS (8 * SIZEOF_LONG)
|
|
|
|
#define LONGLONG_BITS (8 * SIZEOF_LONGLONG)
|
|
|
|
#define FLOAT_BITS (8 * SIZEOF_FLOAT)
|
|
|
|
#define DOUBLE_BITS (8 * SIZEOF_DOUBLE)
|
|
|
|
#define PTR_BITS (8 * SIZEOF_PTR)
|
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Predefined type strings */
|
2006-02-19 12:29:37 +00:00
|
|
|
extern Type type_schar[];
|
|
|
|
extern Type type_uchar[];
|
|
|
|
extern Type type_int[];
|
|
|
|
extern Type type_uint[];
|
|
|
|
extern Type type_long[];
|
|
|
|
extern Type type_ulong[];
|
|
|
|
extern Type type_void[];
|
|
|
|
extern Type type_size_t[];
|
|
|
|
extern Type type_float[];
|
|
|
|
extern Type type_double[];
|
|
|
|
|
|
|
|
/* Forward for the SymEntry struct */
|
|
|
|
struct SymEntry;
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2020-08-02 13:51:26 +00:00
|
|
|
/* Forward for the StrBuf struct */
|
|
|
|
struct StrBuf;
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2013-05-09 11:56:54 +00:00
|
|
|
/* Code */
|
2000-05-28 13:40:48 +00:00
|
|
|
/*****************************************************************************/
|
|
|
|
|
|
|
|
|
|
|
|
|
2020-07-18 15:30:09 +00:00
|
|
|
const char* GetBasicTypeName (const Type* T);
|
|
|
|
/* Return a const name string of the basic type.
|
|
|
|
** Return "type" for unknown basic types.
|
|
|
|
*/
|
|
|
|
|
2020-08-02 13:51:26 +00:00
|
|
|
const char* GetFullTypeName (const Type* T);
|
|
|
|
/* Return the full name string of the given type.
|
|
|
|
** Note: This may use a static buffer that could be overwritten by other calls.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct StrBuf* GetFullTypeNameBuf (struct StrBuf* S, const Type* T);
|
|
|
|
/* Return the full name string of the given type */
|
|
|
|
|
|
|
|
int GetQualifierTypeCodeNameBuf (struct StrBuf* S, TypeCode Qual, TypeCode IgnoredQual);
|
|
|
|
/* Return the names of the qualifiers of the type.
|
|
|
|
** Qualifiers to be ignored can be specified with the IgnoredQual flags.
|
|
|
|
** Return the count of added qualifier names.
|
|
|
|
*/
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned TypeLen (const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return the length of the type string */
|
|
|
|
|
2008-08-31 18:24:33 +00:00
|
|
|
Type* TypeCopy (Type* Dest, const Type* Src);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Copy a type string */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* TypeDup (const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Create a copy of the given type on the heap */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* TypeAlloc (unsigned Len);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Allocate memory for a type string of length Len. Len *must* include the
|
2014-06-30 09:10:35 +00:00
|
|
|
** trailing T_END.
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void TypeFree (Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Free a type string */
|
|
|
|
|
2002-09-30 18:46:08 +00:00
|
|
|
int SignExtendChar (int C);
|
|
|
|
/* Do correct sign extension of a character */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
TypeCode GetDefaultChar (void);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return the default char type (signed/unsigned) depending on the settings */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* GetCharArrayType (unsigned Len);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return the type for a char array of the given length */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* GetImplicitFuncType (void);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return a type string for an inplicitly declared function */
|
|
|
|
|
2020-07-19 05:47:48 +00:00
|
|
|
const Type* GetStructReplacementType (const Type* SType);
|
2020-07-18 15:30:09 +00:00
|
|
|
/* Get a replacement type for passing a struct/union in the primary register */
|
|
|
|
|
2020-07-26 12:12:55 +00:00
|
|
|
long GetIntegerTypeMin (const Type* Type);
|
2020-07-27 11:20:07 +00:00
|
|
|
/* Get the smallest possible value of the integer type.
|
|
|
|
** The type must have a known size.
|
|
|
|
*/
|
2020-07-26 12:12:55 +00:00
|
|
|
|
|
|
|
unsigned long GetIntegerTypeMax (const Type* Type);
|
2020-07-27 11:20:07 +00:00
|
|
|
/* Get the largest possible value of the integer type.
|
|
|
|
** The type must have a known size.
|
|
|
|
*/
|
2020-07-26 12:12:55 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* PointerTo (const Type* T);
|
2000-08-20 09:25:47 +00:00
|
|
|
/* Return a type string that is "pointer to T". The type string is allocated
|
2014-06-30 09:10:35 +00:00
|
|
|
** on the heap and may be freed after use.
|
|
|
|
*/
|
2000-08-20 09:25:47 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void PrintType (FILE* F, const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Output translation of type array. */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void PrintRawType (FILE* F, const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Print a type string in raw format (for debugging) */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void PrintFuncSig (FILE* F, const char* Name, Type* T);
|
2001-05-03 17:34:54 +00:00
|
|
|
/* Print a function signature. */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
int TypeHasAttr (const Type* T);
|
|
|
|
/* Return true if the given type has attribute data */
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE void CopyTypeAttr (const Type* Src, Type* Dest)
|
|
|
|
/* Copy attribute data from Src to Dest */
|
|
|
|
{
|
|
|
|
Dest->A = Src->A;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define CopyTypeAttr(Src, Dest) ((Dest)->A = (Src)->A)
|
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2002-11-14 22:51:39 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE TypeCode UnqualifiedType (TypeCode T)
|
|
|
|
/* Return the unqalified type code */
|
2002-11-14 22:51:39 +00:00
|
|
|
{
|
|
|
|
return (T & ~T_MASK_QUAL);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define UnqualifiedType(T) ((T) & ~T_MASK_QUAL)
|
|
|
|
#endif
|
2000-08-01 18:45:08 +00:00
|
|
|
|
2020-07-26 12:12:55 +00:00
|
|
|
const Type* GetUnderlyingType (const Type* Type);
|
|
|
|
/* Get the underlying type of an enum or other integer class type */
|
|
|
|
|
|
|
|
TypeCode GetUnderlyingTypeCode (const Type* Type);
|
|
|
|
/* Get the type code of the unqualified underlying type of TCode.
|
|
|
|
** Return TCode if it is not scalar.
|
|
|
|
*/
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned SizeOf (const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Compute size of object represented by type array. */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned PSizeOf (const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Compute size of pointer object. */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned CheckedSizeOf (const Type* T);
|
2002-03-10 20:44:58 +00:00
|
|
|
/* Return the size of a data type. If the size is zero, emit an error and
|
2014-06-30 09:10:35 +00:00
|
|
|
** return some valid size instead (so the rest of the compiler doesn't have
|
|
|
|
** to work with invalid sizes).
|
|
|
|
*/
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned CheckedPSizeOf (const Type* T);
|
2002-03-10 20:44:58 +00:00
|
|
|
/* Return the size of a data type that is pointed to by a pointer. If the
|
2014-06-30 09:10:35 +00:00
|
|
|
** size is zero, emit an error and return some valid size instead (so the
|
|
|
|
** rest of the compiler doesn't have to work with invalid sizes).
|
|
|
|
*/
|
2002-03-10 20:44:58 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
unsigned TypeOf (const Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Get the code generator base type of the object */
|
|
|
|
|
2020-08-01 14:06:14 +00:00
|
|
|
unsigned FuncTypeOf (const Type* T);
|
|
|
|
/* Get the code generator flag for calling the function */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* Indirect (Type* T);
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Do one indirection for the given type, that is, return the type where the
|
2014-06-30 09:10:35 +00:00
|
|
|
** given type points to.
|
|
|
|
*/
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2009-07-28 18:56:16 +00:00
|
|
|
Type* ArrayToPtr (Type* T);
|
2002-12-17 12:12:44 +00:00
|
|
|
/* Convert an array to a pointer to it's first element */
|
|
|
|
|
2006-02-19 15:53:11 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2020-07-26 12:12:55 +00:00
|
|
|
INLINE TypeCode GetRawType (const Type* T)
|
2006-02-19 15:53:11 +00:00
|
|
|
/* Get the raw type */
|
|
|
|
{
|
|
|
|
return (T->C & T_MASK_TYPE);
|
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define GetRawType(T) ((T)->C & T_MASK_TYPE)
|
2006-02-19 15:53:11 +00:00
|
|
|
#endif
|
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeChar (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is a character type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (GetUnderlyingType (T)) == T_TYPE_CHAR);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeChar(T) (GetRawType (GetUnderlyingType (T)) == T_TYPE_CHAR)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-01 18:45:08 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeInt (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is an int type (signed or unsigned) */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (GetUnderlyingType (T)) == T_TYPE_INT);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeInt(T) (GetRawType (GetUnderlyingType (T)) == T_TYPE_INT)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeLong (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is a long type (signed or unsigned) */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (GetUnderlyingType (T)) == T_TYPE_LONG);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsTypeLong(T) (GetRawType (GetUnderlyingType (T)) == T_TYPE_LONG)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsRawTypeChar (const Type* T)
|
|
|
|
/* Return true if this is a character raw type */
|
|
|
|
{
|
|
|
|
return (GetRawType (T) == T_TYPE_CHAR);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsRawTypeChar(T) (GetRawType (T) == T_TYPE_CHAR)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsRawTypeInt (const Type* T)
|
|
|
|
/* Return true if this is an int raw type (signed or unsigned) */
|
|
|
|
{
|
|
|
|
return (GetRawType (T) == T_TYPE_INT);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsRawTypeInt(T) (GetRawType (T) == T_TYPE_INT)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsRawTypeLong (const Type* T)
|
|
|
|
/* Return true if this is a long raw type (signed or unsigned) */
|
|
|
|
{
|
|
|
|
return (GetRawType (T) == T_TYPE_LONG);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsRawTypeLong(T) (GetRawType (T) == T_TYPE_LONG)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-14 22:18:26 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeFloat (const Type* T)
|
2000-08-19 21:55:06 +00:00
|
|
|
/* Return true if this is a float type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_FLOAT);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeFloat(T) (GetRawType (T) == T_TYPE_FLOAT)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-19 21:55:06 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeDouble (const Type* T)
|
2000-08-19 21:55:06 +00:00
|
|
|
/* Return true if this is a double type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_DOUBLE);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeDouble(T) (GetRawType (T) == T_TYPE_DOUBLE)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-19 21:55:06 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypePtr (const Type* T)
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return true if this is a pointer type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_PTR);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypePtr(T) (GetRawType (T) == T_TYPE_PTR)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsTypeEnum (const Type* T)
|
|
|
|
/* Return true if this is an enum type */
|
|
|
|
{
|
|
|
|
return (GetRawType (T) == T_TYPE_ENUM);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsTypeEnum(T) (GetRawType (T) == T_TYPE_ENUM)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeStruct (const Type* T)
|
2002-10-10 20:23:41 +00:00
|
|
|
/* Return true if this is a struct type */
|
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_STRUCT);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeStruct(T) (GetRawType (T) == T_TYPE_STRUCT)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeUnion (const Type* T)
|
2002-10-10 20:23:41 +00:00
|
|
|
/* Return true if this is a union type */
|
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_UNION);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeUnion(T) (GetRawType (T) == T_TYPE_UNION)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeArray (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is an array type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_ARRAY);
|
2007-08-26 18:53:46 +00:00
|
|
|
}
|
2002-10-10 20:23:41 +00:00
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeArray(T) (GetRawType (T) == T_TYPE_ARRAY)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-14 22:18:26 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeVoid (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is a void type */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_VOID);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeVoid(T) (GetRawType (T) == T_TYPE_VOID)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-08-14 22:18:26 +00:00
|
|
|
|
2002-10-10 20:23:41 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeFunc (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is a function class */
|
2002-10-10 20:23:41 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetRawType (T) == T_TYPE_FUNC);
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define IsTypeFunc(T) (GetRawType (T) == T_TYPE_FUNC)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
2006-02-19 12:29:37 +00:00
|
|
|
INLINE int IsTypeFuncPtr (const Type* T)
|
2002-10-10 20:23:41 +00:00
|
|
|
/* Return true if this is a function pointer */
|
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (IsTypePtr (T) && IsTypeFunc (T+1));
|
2002-10-10 20:23:41 +00:00
|
|
|
}
|
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsTypeFuncPtr(T) (IsTypePtr (T) && IsTypeFunc (T+1))
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetClass (const Type* T)
|
|
|
|
/* Get the class of a type string */
|
|
|
|
{
|
|
|
|
return (T->C & T_MASK_CLASS);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetClass(T) ((T)->C & T_MASK_CLASS)
|
2002-10-10 20:23:41 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsClassInt (const Type* T)
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Return true if this is an integer type */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetClass (T) == T_CLASS_INT);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsClassInt(T) (GetClass (T) == T_CLASS_INT)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsClassFloat (const Type* T)
|
2000-08-19 21:55:06 +00:00
|
|
|
/* Return true if this is a float type */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetClass (T) == T_CLASS_FLOAT);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsClassFloat(T) (GetClass (T) == T_CLASS_FLOAT)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-08-19 21:55:06 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsClassPtr (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is a pointer type */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetClass (T) == T_CLASS_PTR);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsClassPtr(T) (GetClass (T) == T_CLASS_PTR)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsClassStruct (const Type* T)
|
2020-07-19 05:47:48 +00:00
|
|
|
/* Return true if this is a struct or union type */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetClass (T) == T_CLASS_STRUCT);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
2009-07-28 18:56:16 +00:00
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsClassStruct(T) (GetClass (T) == T_CLASS_STRUCT)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsClassFunc (const Type* T)
|
|
|
|
/* Return true if this is a function type */
|
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetClass (T) == T_CLASS_FUNC);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsClassFunc(T) (GetClass (T) == T_CLASS_FUNC)
|
|
|
|
#endif
|
|
|
|
|
2020-07-26 12:12:55 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetRawSignedness (const Type* T)
|
|
|
|
/* Get the raw signedness of a type */
|
|
|
|
{
|
|
|
|
return ((T)->C & T_MASK_SIGN);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetRawSignedness(T) ((T)->C & T_MASK_SIGN)
|
|
|
|
#endif
|
|
|
|
|
2006-02-19 15:53:11 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetSignedness (const Type* T)
|
2020-07-26 12:12:55 +00:00
|
|
|
/* Get the signedness of a type */
|
2006-02-19 15:53:11 +00:00
|
|
|
{
|
2020-07-26 12:12:55 +00:00
|
|
|
return (GetUnderlyingTypeCode (T) & T_MASK_SIGN);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2020-07-26 12:12:55 +00:00
|
|
|
# define GetSignedness(T) (GetUnderlyingTypeCode (T) & T_MASK_SIGN)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsSignUnsigned (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if this is an unsigned type */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2006-02-19 15:53:11 +00:00
|
|
|
return (GetSignedness (T) == T_SIGN_UNSIGNED);
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2006-02-19 15:53:11 +00:00
|
|
|
# define IsSignUnsigned(T) (GetSignedness (T) == T_SIGN_UNSIGNED)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2007-08-26 18:53:46 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsSignSigned (const Type* T)
|
|
|
|
/* Return true if this is a signed type */
|
|
|
|
{
|
|
|
|
return (GetSignedness (T) == T_SIGN_SIGNED);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsSignSigned(T) (GetSignedness (T) == T_SIGN_SIGNED)
|
|
|
|
#endif
|
|
|
|
|
2020-07-28 03:17:17 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetRawSizeModifier(const Type* T)
|
|
|
|
/* Get the size modifier of a raw type */
|
|
|
|
{
|
|
|
|
return (T->C & T_MASK_SIZE);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetRawSizeModifier(T) ((T)->C & T_MASK_SIZE)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetSizeModifier (const Type* T)
|
|
|
|
/* Get the size modifier of a type */
|
|
|
|
{
|
|
|
|
return (GetUnderlyingTypeCode (T) & T_MASK_SIZE);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetSizeModifier(T) (GetUnderlyingTypeCode (T) & T_MASK_SIZE)
|
|
|
|
#endif
|
|
|
|
|
2008-08-24 17:33:30 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode GetQualifier (const Type* T)
|
2008-08-11 17:51:00 +00:00
|
|
|
/* Get the qualifier from the given type string */
|
2008-08-24 17:33:30 +00:00
|
|
|
{
|
|
|
|
return (T->C & T_MASK_QUAL);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define GetQualifier(T) ((T)->C & T_MASK_QUAL)
|
|
|
|
#endif
|
2006-02-19 12:29:37 +00:00
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualConst (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if the given type has a const memory image */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2008-08-24 17:33:30 +00:00
|
|
|
return (T->C & T_QUAL_CONST) != 0;
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualConst(T) (((T)->C & T_QUAL_CONST) != 0)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-08-14 22:18:26 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualVolatile (const Type* T)
|
2000-08-14 22:18:26 +00:00
|
|
|
/* Return true if the given type has a volatile type qualifier */
|
2006-02-19 12:29:37 +00:00
|
|
|
{
|
2008-08-24 17:33:30 +00:00
|
|
|
return (T->C & T_QUAL_VOLATILE) != 0;
|
2006-02-19 12:29:37 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualVolatile(T) (((T)->C & T_QUAL_VOLATILE) != 0)
|
2006-02-19 15:53:11 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualRestrict (const Type* T)
|
|
|
|
/* Return true if the given type has a restrict qualifier */
|
|
|
|
{
|
2008-08-24 17:33:30 +00:00
|
|
|
return (T->C & T_QUAL_RESTRICT) != 0;
|
2006-02-19 15:53:11 +00:00
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualRestrict(T) (((T)->C & T_QUAL_RESTRICT) != 0)
|
2006-02-19 12:29:37 +00:00
|
|
|
#endif
|
2000-08-14 22:18:26 +00:00
|
|
|
|
2008-08-24 17:33:30 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualNear (const Type* T)
|
|
|
|
/* Return true if the given type has a near qualifier */
|
|
|
|
{
|
|
|
|
return (T->C & T_QUAL_NEAR) != 0;
|
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualNear(T) (((T)->C & T_QUAL_NEAR) != 0)
|
2008-08-24 17:33:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualFar (const Type* T)
|
|
|
|
/* Return true if the given type has a far qualifier */
|
|
|
|
{
|
|
|
|
return (T->C & T_QUAL_FAR) != 0;
|
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualFar(T) (((T)->C & T_QUAL_FAR) != 0)
|
2008-08-24 17:33:30 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualFastcall (const Type* T)
|
|
|
|
/* Return true if the given type has a fastcall qualifier */
|
|
|
|
{
|
|
|
|
return (T->C & T_QUAL_FASTCALL) != 0;
|
|
|
|
}
|
|
|
|
#else
|
2008-08-31 18:31:18 +00:00
|
|
|
# define IsQualFastcall(T) (((T)->C & T_QUAL_FASTCALL) != 0)
|
2008-08-24 17:33:30 +00:00
|
|
|
#endif
|
2000-05-28 13:40:48 +00:00
|
|
|
|
2010-04-29 20:30:49 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualCDecl (const Type* T)
|
|
|
|
/* Return true if the given type has a cdecl qualifier */
|
|
|
|
{
|
|
|
|
return (T->C & T_QUAL_CDECL) != 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsQualCDecl(T) (((T)->C & T_QUAL_CDECL) != 0)
|
|
|
|
#endif
|
|
|
|
|
2015-03-09 22:53:45 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE int IsQualCConv (const Type* T)
|
|
|
|
/* Return true if the given type has a calling convention qualifier */
|
|
|
|
{
|
|
|
|
return (T->C & T_QUAL_CCONV) != 0;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define IsQualCConv(T) (((T)->C & T_QUAL_CCONV) != 0)
|
|
|
|
#endif
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
int IsVariadicFunc (const Type* T) attribute ((const));
|
2001-09-24 22:36:35 +00:00
|
|
|
/* Return true if this is a function type or pointer to function type with
|
2014-06-30 09:10:35 +00:00
|
|
|
** variable parameter list
|
|
|
|
*/
|
2001-03-22 21:02:01 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
FuncDesc* GetFuncDesc (const Type* T) attribute ((const));
|
2000-05-28 13:40:48 +00:00
|
|
|
/* Get the FuncDesc pointer from a function or pointer-to-function type */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void SetFuncDesc (Type* T, FuncDesc* F);
|
|
|
|
/* Set the FuncDesc pointer in a function or pointer-to-function type */
|
|
|
|
|
|
|
|
Type* GetFuncReturn (Type* T) attribute ((const));
|
2001-05-03 17:34:54 +00:00
|
|
|
/* Return a pointer to the return type of a function or pointer-to-function type */
|
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
long GetElementCount (const Type* T);
|
2003-02-03 22:14:20 +00:00
|
|
|
/* Get the element count of the array specified in T (which must be of
|
2014-06-30 09:10:35 +00:00
|
|
|
** array type).
|
|
|
|
*/
|
2003-02-03 22:14:20 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
void SetElementCount (Type* T, long Count);
|
|
|
|
/* Set the element count of the array specified in T (which must be of
|
2014-06-30 09:10:35 +00:00
|
|
|
** array type).
|
|
|
|
*/
|
2006-02-19 12:29:37 +00:00
|
|
|
|
|
|
|
Type* GetElementType (Type* T);
|
2003-02-05 22:02:48 +00:00
|
|
|
/* Return the element type of the given array type. */
|
|
|
|
|
2012-03-24 14:28:59 +00:00
|
|
|
Type* GetBaseElementType (Type* T);
|
|
|
|
/* Return the base element type of a given type. If T is not an array, this
|
2014-06-30 09:10:35 +00:00
|
|
|
** will return. Otherwise it will return the base element type, which means
|
|
|
|
** the element type that is not an array.
|
|
|
|
*/
|
2012-03-24 14:28:59 +00:00
|
|
|
|
2020-08-02 13:08:50 +00:00
|
|
|
struct SymEntry* GetESUSymEntry (const Type* T) attribute ((const));
|
|
|
|
/* Return a SymEntry pointer from an enum/struct/union type */
|
2006-02-19 12:29:37 +00:00
|
|
|
|
2020-08-02 13:08:50 +00:00
|
|
|
void SetESUSymEntry (Type* T, struct SymEntry* S);
|
|
|
|
/* Set the SymEntry pointer for an enum/struct/union type */
|
2006-02-19 12:29:37 +00:00
|
|
|
|
|
|
|
Type* IntPromotion (Type* T);
|
2004-06-29 20:26:27 +00:00
|
|
|
/* Apply the integer promotions to T and return the result. The returned type
|
2014-06-30 09:10:35 +00:00
|
|
|
** string may be T if there is no need to change it.
|
|
|
|
*/
|
2004-06-29 20:26:27 +00:00
|
|
|
|
2006-02-19 12:29:37 +00:00
|
|
|
Type* PtrConversion (Type* T);
|
2004-08-02 16:37:00 +00:00
|
|
|
/* If the type is a function, convert it to pointer to function. If the
|
2014-06-30 09:10:35 +00:00
|
|
|
** expression is an array, convert it to pointer to first element. Otherwise
|
|
|
|
** return T.
|
|
|
|
*/
|
2004-08-02 16:37:00 +00:00
|
|
|
|
2008-08-31 18:24:33 +00:00
|
|
|
TypeCode AddrSizeQualifier (unsigned AddrSize);
|
|
|
|
/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the address size */
|
|
|
|
|
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode CodeAddrSizeQualifier (void)
|
2008-08-24 17:33:30 +00:00
|
|
|
/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the code address size */
|
2008-08-31 18:24:33 +00:00
|
|
|
{
|
|
|
|
return AddrSizeQualifier (CodeAddrSize);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define CodeAddrSizeQualifier() (AddrSizeQualifier (CodeAddrSize))
|
|
|
|
#endif
|
2008-08-24 17:33:30 +00:00
|
|
|
|
2008-08-31 18:24:33 +00:00
|
|
|
#if defined(HAVE_INLINE)
|
|
|
|
INLINE TypeCode DataAddrSizeQualifier (void)
|
2008-08-24 17:33:30 +00:00
|
|
|
/* Return T_QUAL_NEAR or T_QUAL_FAR depending on the data address size */
|
2008-08-31 18:24:33 +00:00
|
|
|
{
|
|
|
|
return AddrSizeQualifier (DataAddrSize);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
# define DataAddrSizeQualifier() (AddrSizeQualifier (DataAddrSize))
|
|
|
|
#endif
|
2008-08-24 17:33:30 +00:00
|
|
|
|
2000-05-28 13:40:48 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* End of datatype.h */
|
|
|
|
|
|
|
|
#endif
|