1
0
mirror of https://github.com/cc65/cc65.git synced 2024-06-07 23:29:39 +00:00

Utility for checking general datatype categories, incomplete ESU types and arrays of unknown sizes.

This commit is contained in:
acqn 2020-08-12 21:50:34 +08:00 committed by Oliver Schmidt
parent 7e61b11f23
commit 11cd3e5cbd
2 changed files with 132 additions and 3 deletions

View File

@ -1037,18 +1037,114 @@ Type* ArrayToPtr (Type* T)
int IsClassObject (const Type* T)
/* Return true if this is a fully described object type */
{
return !IsTypeFunc (T) && !IsClassIncomplete (T);
}
int IsClassIncomplete (const Type* T)
/* Return true if this is an object type lacking size info */
{
if (IsTypeArray (T)) {
return GetElementCount (T) == UNSPECIFIED;
}
return IsTypeVoid (T) || IsIncompleteESUType (T);
}
int IsClassArithmetic (const Type* T)
/* Return true if this is an arithmetic type */
/* Return true if this is an integer or real floating type */
{
return IsClassInt (T) || IsClassFloat (T);
}
int IsClassBasic (const Type* T)
/* Return true if this is a char, integer or floating type */
{
return IsRawTypeChar (T) || IsClassInt (T) || IsClassFloat (T);
}
int IsClassScalar (const Type* T)
/* Return true if this is an arithmetic or pointer type */
{
return IsClassArithmetic (T) || IsTypePtr (T);
}
int IsClassDerived (const Type* T)
/* Return true if this is an array, struct, union, function or pointer type */
{
return IsTypeArray (T) || IsClassStruct (T) || IsClassFunc (T) || IsTypePtr (T);
}
int IsClassAggregate (const Type* T)
/* Return true if this is an array or struct type */
{
return IsTypeArray (T) || IsTypeStruct (T);
}
int IsRelationType (const Type* T)
/* Return true if this is an arithmetic, array or pointer type */
{
return IsClassArithmetic (T) || IsClassPtr (T);
}
int IsCastType (const Type* T)
/* Return true if this type can be used for casting */
{
return IsClassArithmetic (T) || IsClassPtr (T) || IsTypeVoid (T);
return IsClassScalar (T) || IsTypeVoid (T);
}
int IsESUType (const Type* T)
/* Return true if this is an enum/struct/union type */
{
return IsClassStruct (T) || IsTypeEnum (T);
}
int IsIncompleteESUType (const Type* T)
/* Return true if this is an incomplete ESU type */
{
SymEntry* Sym = GetSymType (T);
return Sym != 0 && !SymIsDef (Sym);
}
int IsEmptiableObjectType (const Type* T)
/* Return true if this is a struct/union/void type that can have zero size */
{
return IsClassStruct (T) || IsTypeVoid (T);
}
int HasUnknownSize (const Type* T)
/* Return true if this is an incomplete ESU type or an array of unknown size */
{
if (IsTypeArray (T)) {
return GetElementCount (T) == UNSPECIFIED;
}
return IsIncompleteESUType (T);
}

View File

@ -593,12 +593,45 @@ INLINE int IsClassFunc (const Type* T)
# define IsClassFunc(T) (GetClass (T) == T_CLASS_FUNC)
#endif
int IsClassObject (const Type* T);
/* Return true if this is a fully described object type */
int IsClassIncomplete (const Type* T);
/* Return true if this is an object type lacking size info */
int IsClassArithmetic (const Type* T);
/* Return true if this is an arithmetic type */
/* Return true if this is an integer or real floating type */
int IsClassBasic (const Type* T);
/* Return true if this is a char, integer or floating type */
int IsClassScalar (const Type* T);
/* Return true if this is an arithmetic or pointer type */
int IsClassDerived (const Type* T);
/* Return true if this is an array, struct, union, function or pointer type */
int IsClassAggregate (const Type* T);
/* Return true if this is an array or struct type */
int IsRelationType (const Type* T);
/* Return true if this is an arithmetic, array or pointer type */
int IsCastType (const Type* T);
/* Return true if this type can be used for casting */
int IsESUType (const Type* T);
/* Return true if this is an enum/struct/union type */
int IsIncompleteESUType (const Type* T);
/* Return true if this is an incomplete ESU type */
int IsEmptiableObjectType (const Type* T);
/* Return true if this is a struct/union/void type that can have zero size */
int HasUnknownSize (const Type* T);
/* Return true if this is an incomplete ESU type or an array of unknown size */
#if defined(HAVE_INLINE)
INLINE TypeCode GetRawSignedness (const Type* T)
/* Get the raw signedness of a type */