Skip to content

Commit 8aa59e4

Browse files
authored
Merge pull request cc65#2325 from acqn/Cleanup
[cc65] Cleanups
2 parents 773ed23 + acbd87b commit 8aa59e4

File tree

10 files changed

+32
-65
lines changed

10 files changed

+32
-65
lines changed

src/cc65/datatype.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,7 @@ unsigned BitSizeOf (const Type* T)
216216
unsigned SizeOf (const Type* T)
217217
/* Compute size (in bytes) of object represented by type array */
218218
{
219-
switch (GetUnqualTypeCode (T)) {
219+
switch (GetUnderlyingTypeCode (T)) {
220220

221221
case T_VOID:
222222
/* A void variable is a cc65 extension.
@@ -368,7 +368,7 @@ static unsigned GetMinimalTypeSizeByBitWidth (unsigned BitWidth)
368368

369369

370370

371-
TypeCode GetUnqualTypeCode (const Type* Type)
371+
TypeCode GetUnderlyingTypeCode (const Type* Type)
372372
/* Get the type code of the unqualified underlying type of Type.
373373
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
374374
*/
@@ -725,7 +725,7 @@ const Type* ArithmeticConvert (const Type* lhst, const Type* rhst)
725725
const Type* GetSignedType (const Type* T)
726726
/* Get signed counterpart of the integral type */
727727
{
728-
switch (GetUnqualTypeCode (T) & T_MASK_RANK) {
728+
switch (GetUnderlyingTypeCode (T) & T_MASK_RANK) {
729729
case T_RANK_CHAR:
730730
return type_schar;
731731

@@ -739,7 +739,7 @@ const Type* GetSignedType (const Type* T)
739739
return type_long;
740740

741741
default:
742-
Internal ("Unknown type code: %lX", GetUnqualTypeCode (T));
742+
Internal ("Unknown type code: %lX", GetUnderlyingTypeCode (T));
743743
return T;
744744
}
745745
}
@@ -749,7 +749,7 @@ const Type* GetSignedType (const Type* T)
749749
const Type* GetUnsignedType (const Type* T)
750750
/* Get unsigned counterpart of the integral type */
751751
{
752-
switch (GetUnqualTypeCode (T) & T_MASK_RANK) {
752+
switch (GetUnderlyingTypeCode (T) & T_MASK_RANK) {
753753
case T_RANK_CHAR:
754754
return type_uchar;
755755

@@ -763,7 +763,7 @@ const Type* GetUnsignedType (const Type* T)
763763
return type_ulong;
764764

765765
default:
766-
Internal ("Unknown type code: %lX", GetUnqualTypeCode (T));
766+
Internal ("Unknown type code: %lX", GetUnderlyingTypeCode (T));
767767
return T;
768768
}
769769
}

src/cc65/datatype.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,7 @@ INLINE TypeCode GetQualifier (const Type* T)
328328
# define GetQualifier(T) ((T)->C & T_MASK_QUAL)
329329
#endif
330330

331-
TypeCode GetUnqualTypeCode (const Type* Type);
331+
TypeCode GetUnderlyingTypeCode (const Type* Type);
332332
/* Get the type code of the unqualified underlying type of Type.
333333
** Return GetUnqualRawTypeCode (Type) if Type is not scalar.
334334
*/
@@ -359,30 +359,30 @@ INLINE TypeCode GetTypeClass (const Type* T)
359359
INLINE TypeCode GetTypeRank (const Type* T)
360360
/* Get the type rank of a type */
361361
{
362-
return (GetUnqualTypeCode (T) & T_MASK_RANK);
362+
return (GetUnderlyingTypeCode (T) & T_MASK_RANK);
363363
}
364364
#else
365-
# define GetTypeRank(T) (GetUnqualTypeCode (T) & T_MASK_RANK)
365+
# define GetTypeRank(T) (GetUnderlyingTypeCode (T) & T_MASK_RANK)
366366
#endif
367367

368368
#if defined(HAVE_INLINE)
369369
INLINE TypeCode GetSignedness (const Type* T)
370370
/* Get the signedness of a type */
371371
{
372-
return (GetUnqualTypeCode (T) & T_MASK_SIGN);
372+
return (GetUnderlyingTypeCode (T) & T_MASK_SIGN);
373373
}
374374
#else
375-
# define GetSignedness(T) (GetUnqualTypeCode (T) & T_MASK_SIGN)
375+
# define GetSignedness(T) (GetUnderlyingTypeCode (T) & T_MASK_SIGN)
376376
#endif
377377

378378
#if defined(HAVE_INLINE)
379379
INLINE TypeCode GetSizeModifier (const Type* T)
380380
/* Get the size modifier of a type */
381381
{
382-
return (GetUnqualTypeCode (T) & T_MASK_SIZE);
382+
return (GetUnderlyingTypeCode (T) & T_MASK_SIZE);
383383
}
384384
#else
385-
# define GetSizeModifier(T) (GetUnqualTypeCode (T) & T_MASK_SIZE)
385+
# define GetSizeModifier(T) (GetUnderlyingTypeCode (T) & T_MASK_SIZE)
386386
#endif
387387

388388
#if defined(HAVE_INLINE)

src/cc65/expr.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ unsigned CG_TypeOf (const Type* T)
129129
{
130130
unsigned CG_Type;
131131

132-
switch (GetUnqualTypeCode (T)) {
132+
switch (GetUnderlyingTypeCode (T)) {
133133

134134
case T_SCHAR:
135135
return CF_CHAR;
@@ -188,7 +188,7 @@ unsigned CG_TypeOf (const Type* T)
188188
unsigned CG_CallFlags (const Type* T)
189189
/* Get the code generator flags for calling the function */
190190
{
191-
if (GetUnqualTypeCode (T) == T_FUNC) {
191+
if (GetUnderlyingTypeCode (T) == T_FUNC) {
192192
return (T->A.F->Flags & FD_VARIADIC) ? 0 : CF_FIXARGC;
193193
} else {
194194
Error ("Illegal function type %04lX", T->C);
@@ -291,7 +291,7 @@ static unsigned typeadjust (ExprDesc* lhs, const ExprDesc* rhs, int NoPush)
291291
void LimitExprValue (ExprDesc* Expr, int WarnOverflow)
292292
/* Limit the constant value of the expression to the range of its type */
293293
{
294-
switch (GetUnqualTypeCode (Expr->Type)) {
294+
switch (GetUnderlyingTypeCode (Expr->Type)) {
295295
case T_INT:
296296
case T_SHORT:
297297
if (WarnOverflow && ((Expr->IVal < -0x8000) || (Expr->IVal > 0x7FFF))) {

src/cc65/exprdesc.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ ExprDesc* ED_FinalizeRValLoad (ExprDesc* Expr)
418418

419419

420420

421-
ExprDesc* ED_AddrExpr (ExprDesc* Expr)
421+
void ED_AddrExpr (ExprDesc* Expr)
422422
/* Take address of Expr. The result is always an rvalue */
423423
{
424424
switch (Expr->Flags & E_MASK_LOC) {
@@ -447,12 +447,11 @@ ExprDesc* ED_AddrExpr (ExprDesc* Expr)
447447
}
448448
break;
449449
}
450-
return Expr;
451450
}
452451

453452

454453

455-
ExprDesc* ED_IndExpr (ExprDesc* Expr)
454+
void ED_IndExpr (ExprDesc* Expr)
456455
/* Dereference Expr */
457456
{
458457
switch (Expr->Flags & E_MASK_LOC) {
@@ -486,7 +485,6 @@ ExprDesc* ED_IndExpr (ExprDesc* Expr)
486485
}
487486
break;
488487
}
489-
return Expr;
490488
}
491489

492490

src/cc65/exprdesc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -637,10 +637,10 @@ INLINE void ED_MarkExprAsRVal (ExprDesc* Expr)
637637
# define ED_MarkExprAsRVal(Expr) do { (Expr)->Flags &= ~E_RTYPE_LVAL; } while (0)
638638
#endif
639639

640-
ExprDesc* ED_AddrExpr (ExprDesc* Expr);
640+
void ED_AddrExpr (ExprDesc* Expr);
641641
/* Take address of Expr */
642642

643-
ExprDesc* ED_IndExpr (ExprDesc* Expr);
643+
void ED_IndExpr (ExprDesc* Expr);
644644
/* Dereference Expr */
645645

646646
#if defined(HAVE_INLINE)

src/cc65/initdata.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ static unsigned ParseVoidInit (Type* T)
679679
Size = 0;
680680
do {
681681
ExprDesc Expr = NoCodeConstExpr (hie1);
682-
switch (GetUnqualTypeCode (&Expr.Type[0])) {
682+
switch (GetUnderlyingTypeCode (&Expr.Type[0])) {
683683

684684
case T_SCHAR:
685685
case T_UCHAR:
@@ -747,7 +747,7 @@ static unsigned ParseVoidInit (Type* T)
747747
static unsigned ParseInitInternal (Type* T, int *Braces, int AllowFlexibleMembers)
748748
/* Parse initialization of variables. Return the number of data bytes. */
749749
{
750-
switch (GetUnqualTypeCode (T)) {
750+
switch (GetUnderlyingTypeCode (T)) {
751751

752752
case T_SCHAR:
753753
case T_UCHAR:

src/cc65/symtab.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -741,7 +741,7 @@ static int HandleSymRedefinition (SymEntry* Sym, const Type* T, unsigned Flags)
741741
/* Refine the existing composite prototype with this new
742742
** one.
743743
*/
744-
RefineFuncDesc (Sym->Type, T);
744+
TypeComposition (Sym->Type, T);
745745
}
746746
}
747747

src/cc65/typecmp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -259,8 +259,8 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
259259
}
260260

261261
/* Get the ranks of the left and right hands */
262-
LeftRank = (GetUnqualTypeCode (lhs) & T_MASK_RANK);
263-
RightRank = (GetUnqualTypeCode (rhs) & T_MASK_RANK);
262+
LeftRank = (GetUnderlyingTypeCode (lhs) & T_MASK_RANK);
263+
RightRank = (GetUnderlyingTypeCode (rhs) & T_MASK_RANK);
264264

265265
/* Bit-fields are considered compatible if they have the same
266266
** signedness, bit-offset and bit-width.
@@ -344,10 +344,10 @@ static void DoCompare (const Type* lhs, const Type* rhs, typecmp_t* Result)
344344
case T_RANK_PTR:
345345
++Result->Indirections;
346346
if (Result->Indirections == 1) {
347-
if ((GetUnqualTypeCode (lhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
347+
if ((GetUnderlyingTypeCode (lhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
348348
Result->F |= TCF_VOID_PTR_ON_LEFT;
349349
}
350-
if ((GetUnqualTypeCode (rhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
350+
if ((GetUnderlyingTypeCode (rhs + 1) & T_MASK_RANK) == T_RANK_VOID) {
351351
Result->F |= TCF_VOID_PTR_ON_RIGHT;
352352
}
353353
} else {

src/cc65/typeconv.c

Lines changed: 5 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -427,10 +427,6 @@ void TypeComposition (Type* lhs, const Type* rhs)
427427
** type or this fails with a critical check.
428428
*/
429429
{
430-
FuncDesc* F1;
431-
FuncDesc* F2;
432-
long LeftCount, RightCount;
433-
434430
/* Compose two types */
435431
while (lhs->C != T_END) {
436432

@@ -440,13 +436,13 @@ void TypeComposition (Type* lhs, const Type* rhs)
440436
}
441437

442438
/* Check for sanity */
443-
CHECK (GetUnqualTypeCode (lhs) == GetUnqualTypeCode (rhs));
439+
CHECK (GetUnderlyingTypeCode (lhs) == GetUnderlyingTypeCode (rhs));
444440

445441
/* Check for special type elements */
446442
if (IsTypeFunc (lhs)) {
447443
/* Compose the function descriptors */
448-
F1 = GetFuncDesc (lhs);
449-
F2 = GetFuncDesc (rhs);
444+
FuncDesc* F1 = GetFuncDesc (lhs);
445+
FuncDesc* F2 = GetFuncDesc (rhs);
450446

451447
/* If F1 has an empty parameter list (which does also mean, it is
452448
** not a function definition, because the flag is reset in this
@@ -470,8 +466,8 @@ void TypeComposition (Type* lhs, const Type* rhs)
470466
}
471467
} else if (IsTypeArray (lhs)) {
472468
/* Check member count */
473-
LeftCount = GetElementCount (lhs);
474-
RightCount = GetElementCount (rhs);
469+
long LeftCount = GetElementCount (lhs);
470+
long RightCount = GetElementCount (rhs);
475471

476472
/* Set composite type if it is requested */
477473
if (LeftCount != UNSPECIFIED) {
@@ -485,28 +481,4 @@ void TypeComposition (Type* lhs, const Type* rhs)
485481
++lhs;
486482
++rhs;
487483
}
488-
489-
return;
490-
}
491-
492-
493-
494-
FuncDesc* RefineFuncDesc (Type* OldType, const Type* NewType)
495-
/* Refine the existing function descriptor with a new one */
496-
{
497-
FuncDesc* Old = GetFuncDesc (OldType);
498-
FuncDesc* New = GetFuncDesc (NewType);
499-
500-
CHECK (Old != 0 && New != 0);
501-
502-
if ((New->Flags & FD_EMPTY) == 0) {
503-
if ((Old->Flags & FD_EMPTY) == 0) {
504-
TypeComposition (OldType, NewType);
505-
} else {
506-
TypeCopy (OldType, NewType);
507-
Old->Flags &= ~FD_EMPTY;
508-
}
509-
}
510-
511-
return Old;
512484
}

src/cc65/typeconv.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ void TypeComposition (Type* lhs, const Type* rhs);
6363
** type or this fails with a critical check.
6464
*/
6565

66-
FuncDesc* RefineFuncDesc (Type* OldType, const Type* NewType);
67-
/* Refine the existing function descriptor with a new one */
68-
6966

7067

7168
/* End of typeconv.h */

0 commit comments

Comments
 (0)