mirror of
https://github.com/cc65/cc65.git
synced 2024-12-27 15:29:46 +00:00
commit
8aa59e4af3
@ -216,7 +216,7 @@ unsigned BitSizeOf (const Type* T)
|
|||||||
unsigned SizeOf (const Type* T)
|
unsigned SizeOf (const Type* T)
|
||||||
/* Compute size (in bytes) of object represented by type array */
|
/* Compute size (in bytes) of object represented by type array */
|
||||||
{
|
{
|
||||||
switch (GetUnqualTypeCode (T)) {
|
switch (GetUnderlyingTypeCode (T)) {
|
||||||
|
|
||||||
case T_VOID:
|
case T_VOID:
|
||||||
/* A void variable is a cc65 extension.
|
/* A void variable is a cc65 extension.
|
||||||
@ -368,7 +368,7 @@ static unsigned GetMinimalTypeSizeByBitWidth (unsigned BitWidth)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
TypeCode GetUnqualTypeCode (const Type* Type)
|
TypeCode GetUnderlyingTypeCode (const Type* Type)
|
||||||
/* Get the type code of the unqualified underlying type of Type.
|
/* Get the type code of the unqualified underlying type of Type.
|
||||||
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
|
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
|
||||||
*/
|
*/
|
||||||
@ -725,7 +725,7 @@ const Type* ArithmeticConvert (const Type* lhst, const Type* rhst)
|
|||||||
const Type* GetSignedType (const Type* T)
|
const Type* GetSignedType (const Type* T)
|
||||||
/* Get signed counterpart of the integral type */
|
/* Get signed counterpart of the integral type */
|
||||||
{
|
{
|
||||||
switch (GetUnqualTypeCode (T) & T_MASK_RANK) {
|
switch (GetUnderlyingTypeCode (T) & T_MASK_RANK) {
|
||||||
case T_RANK_CHAR:
|
case T_RANK_CHAR:
|
||||||
return type_schar;
|
return type_schar;
|
||||||
|
|
||||||
@ -739,7 +739,7 @@ const Type* GetSignedType (const Type* T)
|
|||||||
return type_long;
|
return type_long;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Internal ("Unknown type code: %lX", GetUnqualTypeCode (T));
|
Internal ("Unknown type code: %lX", GetUnderlyingTypeCode (T));
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -749,7 +749,7 @@ const Type* GetSignedType (const Type* T)
|
|||||||
const Type* GetUnsignedType (const Type* T)
|
const Type* GetUnsignedType (const Type* T)
|
||||||
/* Get unsigned counterpart of the integral type */
|
/* Get unsigned counterpart of the integral type */
|
||||||
{
|
{
|
||||||
switch (GetUnqualTypeCode (T) & T_MASK_RANK) {
|
switch (GetUnderlyingTypeCode (T) & T_MASK_RANK) {
|
||||||
case T_RANK_CHAR:
|
case T_RANK_CHAR:
|
||||||
return type_uchar;
|
return type_uchar;
|
||||||
|
|
||||||
@ -763,7 +763,7 @@ const Type* GetUnsignedType (const Type* T)
|
|||||||
return type_ulong;
|
return type_ulong;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
Internal ("Unknown type code: %lX", GetUnqualTypeCode (T));
|
Internal ("Unknown type code: %lX", GetUnderlyingTypeCode (T));
|
||||||
return T;
|
return T;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -328,7 +328,7 @@ INLINE TypeCode GetQualifier (const Type* T)
|
|||||||
# define GetQualifier(T) ((T)->C & T_MASK_QUAL)
|
# define GetQualifier(T) ((T)->C & T_MASK_QUAL)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TypeCode GetUnqualTypeCode (const Type* Type);
|
TypeCode GetUnderlyingTypeCode (const Type* Type);
|
||||||
/* Get the type code of the unqualified underlying type of Type.
|
/* Get the type code of the unqualified underlying type of Type.
|
||||||
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
|
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
|
||||||
*/
|
*/
|
||||||
@ -359,30 +359,30 @@ INLINE TypeCode GetTypeClass (const Type* T)
|
|||||||
INLINE TypeCode GetTypeRank (const Type* T)
|
INLINE TypeCode GetTypeRank (const Type* T)
|
||||||
/* Get the type rank of a type */
|
/* Get the type rank of a type */
|
||||||
{
|
{
|
||||||
return (GetUnqualTypeCode (T) & T_MASK_RANK);
|
return (GetUnderlyingTypeCode (T) & T_MASK_RANK);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetTypeRank(T) (GetUnqualTypeCode (T) & T_MASK_RANK)
|
# define GetTypeRank(T) (GetUnderlyingTypeCode (T) & T_MASK_RANK)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE TypeCode GetSignedness (const Type* T)
|
INLINE TypeCode GetSignedness (const Type* T)
|
||||||
/* Get the signedness of a type */
|
/* Get the signedness of a type */
|
||||||
{
|
{
|
||||||
return (GetUnqualTypeCode (T) & T_MASK_SIGN);
|
return (GetUnderlyingTypeCode (T) & T_MASK_SIGN);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetSignedness(T) (GetUnqualTypeCode (T) & T_MASK_SIGN)
|
# define GetSignedness(T) (GetUnderlyingTypeCode (T) & T_MASK_SIGN)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
INLINE TypeCode GetSizeModifier (const Type* T)
|
INLINE TypeCode GetSizeModifier (const Type* T)
|
||||||
/* Get the size modifier of a type */
|
/* Get the size modifier of a type */
|
||||||
{
|
{
|
||||||
return (GetUnqualTypeCode (T) & T_MASK_SIZE);
|
return (GetUnderlyingTypeCode (T) & T_MASK_SIZE);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
# define GetSizeModifier(T) (GetUnqualTypeCode (T) & T_MASK_SIZE)
|
# define GetSizeModifier(T) (GetUnderlyingTypeCode (T) & T_MASK_SIZE)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
|
@ -129,7 +129,7 @@ unsigned CG_TypeOf (const Type* T)
|
|||||||
{
|
{
|
||||||
unsigned CG_Type;
|
unsigned CG_Type;
|
||||||
|
|
||||||
switch (GetUnqualTypeCode (T)) {
|
switch (GetUnderlyingTypeCode (T)) {
|
||||||
|
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
return CF_CHAR;
|
return CF_CHAR;
|
||||||
@ -188,7 +188,7 @@ unsigned CG_TypeOf (const Type* T)
|
|||||||
unsigned CG_CallFlags (const Type* T)
|
unsigned CG_CallFlags (const Type* T)
|
||||||
/* Get the code generator flags for calling the function */
|
/* Get the code generator flags for calling the function */
|
||||||
{
|
{
|
||||||
if (GetUnqualTypeCode (T) == T_FUNC) {
|
if (GetUnderlyingTypeCode (T) == T_FUNC) {
|
||||||
return (T->A.F->Flags & FD_VARIADIC) ? 0 : CF_FIXARGC;
|
return (T->A.F->Flags & FD_VARIADIC) ? 0 : CF_FIXARGC;
|
||||||
} else {
|
} else {
|
||||||
Error ("Illegal function type %04lX", T->C);
|
Error ("Illegal function type %04lX", T->C);
|
||||||
@ -291,7 +291,7 @@ static unsigned typeadjust (ExprDesc* lhs, const ExprDesc* rhs, int NoPush)
|
|||||||
void LimitExprValue (ExprDesc* Expr, int WarnOverflow)
|
void LimitExprValue (ExprDesc* Expr, int WarnOverflow)
|
||||||
/* Limit the constant value of the expression to the range of its type */
|
/* Limit the constant value of the expression to the range of its type */
|
||||||
{
|
{
|
||||||
switch (GetUnqualTypeCode (Expr->Type)) {
|
switch (GetUnderlyingTypeCode (Expr->Type)) {
|
||||||
case T_INT:
|
case T_INT:
|
||||||
case T_SHORT:
|
case T_SHORT:
|
||||||
if (WarnOverflow && ((Expr->IVal < -0x8000) || (Expr->IVal > 0x7FFF))) {
|
if (WarnOverflow && ((Expr->IVal < -0x8000) || (Expr->IVal > 0x7FFF))) {
|
||||||
|
@ -418,7 +418,7 @@ ExprDesc* ED_FinalizeRValLoad (ExprDesc* Expr)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExprDesc* ED_AddrExpr (ExprDesc* Expr)
|
void ED_AddrExpr (ExprDesc* Expr)
|
||||||
/* Take address of Expr. The result is always an rvalue */
|
/* Take address of Expr. The result is always an rvalue */
|
||||||
{
|
{
|
||||||
switch (Expr->Flags & E_MASK_LOC) {
|
switch (Expr->Flags & E_MASK_LOC) {
|
||||||
@ -447,12 +447,11 @@ ExprDesc* ED_AddrExpr (ExprDesc* Expr)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
ExprDesc* ED_IndExpr (ExprDesc* Expr)
|
void ED_IndExpr (ExprDesc* Expr)
|
||||||
/* Dereference Expr */
|
/* Dereference Expr */
|
||||||
{
|
{
|
||||||
switch (Expr->Flags & E_MASK_LOC) {
|
switch (Expr->Flags & E_MASK_LOC) {
|
||||||
@ -486,7 +485,6 @@ ExprDesc* ED_IndExpr (ExprDesc* Expr)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return Expr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -637,10 +637,10 @@ INLINE void ED_MarkExprAsRVal (ExprDesc* Expr)
|
|||||||
# define ED_MarkExprAsRVal(Expr) do { (Expr)->Flags &= ~E_RTYPE_LVAL; } while (0)
|
# define ED_MarkExprAsRVal(Expr) do { (Expr)->Flags &= ~E_RTYPE_LVAL; } while (0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ExprDesc* ED_AddrExpr (ExprDesc* Expr);
|
void ED_AddrExpr (ExprDesc* Expr);
|
||||||
/* Take address of Expr */
|
/* Take address of Expr */
|
||||||
|
|
||||||
ExprDesc* ED_IndExpr (ExprDesc* Expr);
|
void ED_IndExpr (ExprDesc* Expr);
|
||||||
/* Dereference Expr */
|
/* Dereference Expr */
|
||||||
|
|
||||||
#if defined(HAVE_INLINE)
|
#if defined(HAVE_INLINE)
|
||||||
|
@ -679,7 +679,7 @@ static unsigned ParseVoidInit (Type* T)
|
|||||||
Size = 0;
|
Size = 0;
|
||||||
do {
|
do {
|
||||||
ExprDesc Expr = NoCodeConstExpr (hie1);
|
ExprDesc Expr = NoCodeConstExpr (hie1);
|
||||||
switch (GetUnqualTypeCode (&Expr.Type[0])) {
|
switch (GetUnderlyingTypeCode (&Expr.Type[0])) {
|
||||||
|
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
case T_UCHAR:
|
case T_UCHAR:
|
||||||
@ -747,7 +747,7 @@ static unsigned ParseVoidInit (Type* T)
|
|||||||
static unsigned ParseInitInternal (Type* T, int *Braces, int AllowFlexibleMembers)
|
static unsigned ParseInitInternal (Type* T, int *Braces, int AllowFlexibleMembers)
|
||||||
/* Parse initialization of variables. Return the number of data bytes. */
|
/* Parse initialization of variables. Return the number of data bytes. */
|
||||||
{
|
{
|
||||||
switch (GetUnqualTypeCode (T)) {
|
switch (GetUnderlyingTypeCode (T)) {
|
||||||
|
|
||||||
case T_SCHAR:
|
case T_SCHAR:
|
||||||
case T_UCHAR:
|
case T_UCHAR:
|
||||||
|
@ -741,7 +741,7 @@ static int HandleSymRedefinition (SymEntry* Sym, const Type* T, unsigned Flags)
|
|||||||
/* Refine the existing composite prototype with this new
|
/* Refine the existing composite prototype with this new
|
||||||
** one.
|
** one.
|
||||||
*/
|
*/
|
||||||
RefineFuncDesc (Sym->Type, T);
|
TypeComposition (Sym->Type, T);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -259,8 +259,8 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get the ranks of the left and right hands */
|
/* Get the ranks of the left and right hands */
|
||||||
LeftRank = (GetUnqualTypeCode (lhs) & T_MASK_RANK);
|
LeftRank = (GetUnderlyingTypeCode (lhs) & T_MASK_RANK);
|
||||||
RightRank = (GetUnqualTypeCode (rhs) & T_MASK_RANK);
|
RightRank = (GetUnderlyingTypeCode (rhs) & T_MASK_RANK);
|
||||||
|
|
||||||
/* Bit-fields are considered compatible if they have the same
|
/* Bit-fields are considered compatible if they have the same
|
||||||
** signedness, bit-offset and bit-width.
|
** signedness, bit-offset and bit-width.
|
||||||
@ -344,10 +344,10 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
|
|||||||
case T_RANK_PTR:
|
case T_RANK_PTR:
|
||||||
++Result->Indirections;
|
++Result->Indirections;
|
||||||
if (Result->Indirections == 1) {
|
if (Result->Indirections == 1) {
|
||||||
if ((GetUnqualTypeCode (lhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
|
if ((GetUnderlyingTypeCode (lhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
|
||||||
Result->F |= TCF_VOID_PTR_ON_LEFT;
|
Result->F |= TCF_VOID_PTR_ON_LEFT;
|
||||||
}
|
}
|
||||||
if ((GetUnqualTypeCode (rhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
|
if ((GetUnderlyingTypeCode (rhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
|
||||||
Result->F |= TCF_VOID_PTR_ON_RIGHT;
|
Result->F |= TCF_VOID_PTR_ON_RIGHT;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -427,10 +427,6 @@ void TypeComposition (Type* lhs, const Type* rhs)
|
|||||||
** type or this fails with a critical check.
|
** type or this fails with a critical check.
|
||||||
*/
|
*/
|
||||||
{
|
{
|
||||||
FuncDesc* F1;
|
|
||||||
FuncDesc* F2;
|
|
||||||
long LeftCount, RightCount;
|
|
||||||
|
|
||||||
/* Compose two types */
|
/* Compose two types */
|
||||||
while (lhs->C != T_END) {
|
while (lhs->C != T_END) {
|
||||||
|
|
||||||
@ -440,13 +436,13 @@ void TypeComposition (Type* lhs, const Type* rhs)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Check for sanity */
|
/* Check for sanity */
|
||||||
CHECK (GetUnqualTypeCode (lhs) == GetUnqualTypeCode (rhs));
|
CHECK (GetUnderlyingTypeCode (lhs) == GetUnderlyingTypeCode (rhs));
|
||||||
|
|
||||||
/* Check for special type elements */
|
/* Check for special type elements */
|
||||||
if (IsTypeFunc (lhs)) {
|
if (IsTypeFunc (lhs)) {
|
||||||
/* Compose the function descriptors */
|
/* Compose the function descriptors */
|
||||||
F1 = GetFuncDesc (lhs);
|
FuncDesc* F1 = GetFuncDesc (lhs);
|
||||||
F2 = GetFuncDesc (rhs);
|
FuncDesc* F2 = GetFuncDesc (rhs);
|
||||||
|
|
||||||
/* If F1 has an empty parameter list (which does also mean, it is
|
/* If F1 has an empty parameter list (which does also mean, it is
|
||||||
** not a function definition, because the flag is reset in this
|
** not a function definition, because the flag is reset in this
|
||||||
@ -470,8 +466,8 @@ void TypeComposition (Type* lhs, const Type* rhs)
|
|||||||
}
|
}
|
||||||
} else if (IsTypeArray (lhs)) {
|
} else if (IsTypeArray (lhs)) {
|
||||||
/* Check member count */
|
/* Check member count */
|
||||||
LeftCount = GetElementCount (lhs);
|
long LeftCount = GetElementCount (lhs);
|
||||||
RightCount = GetElementCount (rhs);
|
long RightCount = GetElementCount (rhs);
|
||||||
|
|
||||||
/* Set composite type if it is requested */
|
/* Set composite type if it is requested */
|
||||||
if (LeftCount != UNSPECIFIED) {
|
if (LeftCount != UNSPECIFIED) {
|
||||||
@ -485,28 +481,4 @@ void TypeComposition (Type* lhs, const Type* rhs)
|
|||||||
++lhs;
|
++lhs;
|
||||||
++rhs;
|
++rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
FuncDesc* RefineFuncDesc (Type* OldType, const Type* NewType)
|
|
||||||
/* Refine the existing function descriptor with a new one */
|
|
||||||
{
|
|
||||||
FuncDesc* Old = GetFuncDesc (OldType);
|
|
||||||
FuncDesc* New = GetFuncDesc (NewType);
|
|
||||||
|
|
||||||
CHECK (Old != 0 && New != 0);
|
|
||||||
|
|
||||||
if ((New->Flags & FD_EMPTY) == 0) {
|
|
||||||
if ((Old->Flags & FD_EMPTY) == 0) {
|
|
||||||
TypeComposition (OldType, NewType);
|
|
||||||
} else {
|
|
||||||
TypeCopy (OldType, NewType);
|
|
||||||
Old->Flags &= ~FD_EMPTY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return Old;
|
|
||||||
}
|
}
|
||||||
|
@ -63,9 +63,6 @@ void TypeComposition (Type* lhs, const Type* rhs);
|
|||||||
** type or this fails with a critical check.
|
** type or this fails with a critical check.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
FuncDesc* RefineFuncDesc (Type* OldType, const Type* NewType);
|
|
||||||
/* Refine the existing function descriptor with a new one */
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* End of typeconv.h */
|
/* End of typeconv.h */
|
||||||
|
Loading…
Reference in New Issue
Block a user