mirror of
https://github.com/cc65/cc65.git
synced 2025-01-16 13:31:16 +00:00
Minor fixes and improvements.
This commit is contained in:
parent
65081aebed
commit
18bd76bb90
@ -523,7 +523,7 @@ static void WrappedCallPragma (StrBuf* B)
|
||||
Entry = FindSym(Name);
|
||||
|
||||
/* Check if the name is valid */
|
||||
if (Entry && Entry->Flags & SC_FUNC) {
|
||||
if (Entry && (Entry->Flags & SC_FUNC) == SC_FUNC) {
|
||||
|
||||
PushWrappedCall(Entry, (unsigned char) Val);
|
||||
Entry->Flags |= SC_REF;
|
||||
|
@ -104,16 +104,21 @@ void FreeSymEntry (SymEntry* E)
|
||||
void DumpSymEntry (FILE* F, const SymEntry* E)
|
||||
/* Dump the given symbol table entry to the file in readable form */
|
||||
{
|
||||
static const struct {
|
||||
typedef const struct {
|
||||
const char* Name;
|
||||
unsigned Val;
|
||||
} Flags [] = {
|
||||
/* Beware: Order is important! */
|
||||
} SCFlagTable;
|
||||
|
||||
static SCFlagTable ESUTypes[] = {
|
||||
{ "SC_TYPEDEF", SC_TYPEDEF },
|
||||
{ "SC_BITFIELD", SC_BITFIELD },
|
||||
{ "SC_STRUCTFIELD", SC_STRUCTFIELD },
|
||||
{ "SC_UNION", SC_UNION },
|
||||
{ "SC_STRUCT", SC_STRUCT },
|
||||
};
|
||||
|
||||
static SCFlagTable Flags[] = {
|
||||
/* Beware: Order is important! */
|
||||
{ "SC_BITFIELD", SC_BITFIELD },
|
||||
{ "SC_STRUCTFIELD", SC_STRUCTFIELD },
|
||||
{ "SC_AUTO", SC_AUTO },
|
||||
{ "SC_REGISTER", SC_REGISTER },
|
||||
{ "SC_STATIC", SC_STATIC },
|
||||
@ -124,6 +129,7 @@ void DumpSymEntry (FILE* F, const SymEntry* E)
|
||||
{ "SC_PARAM", SC_PARAM },
|
||||
{ "SC_FUNC", SC_FUNC },
|
||||
{ "SC_STORAGE", SC_STORAGE },
|
||||
{ "SC_DECL", SC_DECL },
|
||||
{ "SC_DEF", SC_DEF },
|
||||
{ "SC_REF", SC_REF },
|
||||
{ "SC_ZEROPAGE", SC_ZEROPAGE },
|
||||
@ -143,6 +149,14 @@ void DumpSymEntry (FILE* F, const SymEntry* E)
|
||||
/* Print the flags */
|
||||
SymFlags = E->Flags;
|
||||
fprintf (F, " Flags:");
|
||||
if ((SymFlags & SC_ESUTYPEMASK) != 0) {
|
||||
for (I = 0; I < sizeof (ESUTypes) / sizeof (ESUTypes[0]); ++I) {
|
||||
if ((SymFlags & SC_ESUTYPEMASK) == ESUTypes[I].Val) {
|
||||
SymFlags &= ~SC_ESUTYPEMASK;
|
||||
fprintf (F, " %s", ESUTypes[I].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (I = 0; I < sizeof (Flags) / sizeof (Flags[0]) && SymFlags != 0; ++I) {
|
||||
if ((SymFlags & Flags[I].Val) == Flags[I].Val) {
|
||||
SymFlags &= ~Flags[I].Val;
|
||||
|
@ -74,24 +74,22 @@ struct CodeEntry;
|
||||
#define SC_UNION 0x0002U /* Union */
|
||||
#define SC_TYPEDEF 0x0004U /* A typedef */
|
||||
#define SC_ESUTYPEMASK 0x0007U /* Mask for above types */
|
||||
#define SC_ENUM 0x0008U /* An enum */
|
||||
#define SC_ENUM 0x0008U /* An enumerator */
|
||||
#define SC_BITFIELD 0x0010U /* A bit-field inside a struct or union */
|
||||
#define SC_TYPEMASK 0x001FU /* Mask for above types */
|
||||
|
||||
#define SC_CONST 0x0020U /* A numeric constant with a type */
|
||||
#define SC_FUNC 0x0020U /* A function */
|
||||
#define SC_LABEL 0x0040U /* A goto code label */
|
||||
#define SC_PARAM 0x0080U /* A function parameter */
|
||||
#define SC_FUNC 0x0100U /* A function */
|
||||
#define SC_CONST 0x0080U /* A numeric constant with a type */
|
||||
#define SC_PARAM 0x0100U /* A function parameter */
|
||||
#define SC_DEFTYPE 0x0200U /* Parameter has default type (=int, old style) */
|
||||
#define SC_STRUCTFIELD 0x0400U /* Struct or union field */
|
||||
|
||||
#define SC_DECL 0x0800U /* Symbol is declared in global scope */
|
||||
#define SC_ZEROPAGE 0x0800U /* Symbol marked as zeropage */
|
||||
|
||||
#define SC_DEF 0x1000U /* Symbol is defined */
|
||||
#define SC_REF 0x2000U /* Symbol is referenced */
|
||||
|
||||
#define SC_ZEROPAGE 0x4000U /* Symbol marked as zeropage */
|
||||
|
||||
#define SC_DECL 0x4000U /* Symbol is declared in global scope */
|
||||
#define SC_STORAGE 0x8000U /* Symbol with associated storage */
|
||||
|
||||
#define SC_AUTO 0x010000U /* Auto variable */
|
||||
@ -217,10 +215,10 @@ INLINE int SymIsBitField (const SymEntry* Sym)
|
||||
INLINE int SymIsTypeDef (const SymEntry* Sym)
|
||||
/* Return true if the given entry is a typedef entry */
|
||||
{
|
||||
return ((Sym->Flags & SC_TYPEDEF) == SC_TYPEDEF);
|
||||
return ((Sym->Flags & SC_TYPEMASK) == SC_TYPEDEF);
|
||||
}
|
||||
#else
|
||||
# define SymIsTypeDef(Sym) (((Sym)->Flags & SC_TYPEDEF) == SC_TYPEDEF)
|
||||
# define SymIsTypeDef(Sym) (((Sym)->Flags & SC_TYPEMASK) == SC_TYPEDEF)
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_INLINE)
|
||||
@ -251,7 +249,7 @@ INLINE int SymIsRegVar (const SymEntry* Sym)
|
||||
return ((Sym->Flags & (SC_REGISTER|SC_TYPEMASK)) == SC_REGISTER);
|
||||
}
|
||||
#else
|
||||
# define SymIsRegVar(Sym) (((Sym)->Flags & (SC_REGISTER|SC_ESUTYPEMASK)) == SC_REGISTER)
|
||||
# define SymIsRegVar(Sym) (((Sym)->Flags & (SC_REGISTER|SC_TYPEMASK)) == SC_REGISTER)
|
||||
#endif
|
||||
|
||||
int SymIsOutputFunc (const SymEntry* Sym);
|
||||
|
@ -821,7 +821,7 @@ SymEntry* AddLocalSym (const char* Name, const Type* T, unsigned Flags, int Offs
|
||||
|
||||
/* Set the symbol attributes */
|
||||
Entry->Type = TypeDup (T);
|
||||
if ((Flags & SC_AUTO) == SC_AUTO || (Flags & SC_TYPEDEF) == SC_TYPEDEF) {
|
||||
if ((Flags & SC_AUTO) == SC_AUTO || (Flags & SC_TYPEMASK) == SC_TYPEDEF) {
|
||||
Entry->V.Offs = Offs;
|
||||
} else if ((Flags & SC_REGISTER) == SC_REGISTER) {
|
||||
Entry->V.R.RegOffs = Offs;
|
||||
|
Loading…
x
Reference in New Issue
Block a user