X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=src%2Fcc65%2Fsymentry.h;h=b1f8647035d0de46ebe2f0c7d269d708e86f1de5;hb=923ae328a53d95390815c73b390165e85c06af01;hp=610a06ee37630c28a1cab25c293ef043a32c0b33;hpb=594a941ee94d1cd7369256ac6ffa9ebf26e33a64;p=cc65 diff --git a/src/cc65/symentry.h b/src/cc65/symentry.h index 610a06ee3..b1f864703 100644 --- a/src/cc65/symentry.h +++ b/src/cc65/symentry.h @@ -6,10 +6,10 @@ /* */ /* */ /* */ -/* (C) 2000 Ullrich von Bassewitz */ -/* Wacholderweg 14 */ -/* D-70597 Stuttgart */ -/* EMail: uz@musoftware.de */ +/* (C) 2000-2002 Ullrich von Bassewitz */ +/* Wacholderweg 14 */ +/* D-70597 Stuttgart */ +/* EMail: uz@cc65.org */ /* */ /* */ /* This software is provided 'as-is', without any expressed or implied */ @@ -40,27 +40,41 @@ #include +/* common */ +#include "inline.h" + +/* cc65 */ #include "datatype.h" /*****************************************************************************/ -/* struct SymEntry */ +/* Forwards */ +/*****************************************************************************/ + + + +struct Segments; + + + +/*****************************************************************************/ +/* struct SymEntry */ /*****************************************************************************/ /* Storage classes and flags */ -#define SC_AUTO 0x0001U +#define SC_AUTO 0x0001U #define SC_REGISTER 0x0002U /* Register variable, is in static storage */ #define SC_STATIC 0x0004U #define SC_EXTERN 0x0008U -#define SC_ENUM 0x0030U /* An enum (numeric constant) */ -#define SC_CONST 0x0020U /* A numeric constant with a type */ +#define SC_ENUM 0x0030U /* An enum (numeric constant) */ +#define SC_CONST 0x0020U /* A numeric constant with a type */ #define SC_LABEL 0x0040U /* A goto label */ #define SC_PARAM 0x0080U /* This is a function parameter */ -#define SC_FUNC 0x0100U /* Function entry */ +#define SC_FUNC 0x0100U /* Function entry */ #define SC_STORAGE 0x0400U /* Symbol with associated storage */ #define SC_DEFAULT 0x0800U /* Flag: default storage class was used */ @@ -70,7 +84,7 @@ #define SC_TYPE 0x4000U /* This is a type, struct, typedef, etc. */ #define SC_STRUCT 0x4001U /* Struct or union */ -#define SC_SFLD 0x4002U /* Struct or union field */ +#define SC_STRUCTFIELD 0x4002U /* Struct or union field */ #define SC_TYPEDEF 0x4003U /* A typedef */ #define SC_ZEROPAGE 0x8000U /* Symbol marked as zeropage */ @@ -83,22 +97,31 @@ struct SymEntry { SymEntry* NextHash; /* Next entry in hash list */ SymEntry* PrevSym; /* Previous symbol in dl list */ SymEntry* NextSym; /* Next symbol double linked list */ - SymEntry* Link; /* General purpose single linked list */ + SymEntry* Link; /* General purpose single linked list */ struct SymTable* Owner; /* Symbol table the symbol is in */ unsigned Flags; /* Symbol flags */ type* Type; /* Symbol type */ + char* AsmName; /* Assembler name if any */ /* Data that differs for the different symbol types */ union { - /* Offset for locals or struct members */ - int Offs; + /* Offset for locals or struct members */ + int Offs; - /* Label name for static symbols */ - unsigned Label; + /* Label name for static symbols */ + unsigned Label; - /* Value for enums */ - int EnumVal; + /* Register bank offset and offset of the saved copy on stack for + * register variables. + */ + struct { + int RegOffs; + int SaveOffs; + } R; + + /* Value for constants (including enums) */ + long ConstVal; /* Data for structs/unions */ struct { @@ -107,16 +130,19 @@ struct SymEntry { } S; /* Data for functions */ - struct FuncDesc* Func; /* Function descriptor */ + struct { + struct FuncDesc* Func; /* Function descriptor */ + struct Segments* Seg; /* Segments for this function */ + } F; } V; - char Name[1]; /* Name, dynamically allocated */ + char Name[1]; /* Name, dynamically allocated */ }; /*****************************************************************************/ -/* Code */ +/* Code */ /*****************************************************************************/ @@ -130,12 +156,58 @@ void FreeSymEntry (SymEntry* E); void DumpSymEntry (FILE* F, const SymEntry* E); /* Dump the given symbol table entry to the file in readable form */ -int IsTypeDef (const SymEntry* E); +#if defined(HAVE_INLINE) +INLINE int SymIsTypeDef (const SymEntry* Sym) /* Return true if the given entry is a typedef entry */ +{ + return ((Sym->Flags & SC_TYPEDEF) == SC_TYPEDEF); +} +#else +# define SymIsTypeDef(Sym) (((Sym)->Flags & SC_TYPEDEF) == SC_TYPEDEF) +#endif + +#if defined(HAVE_INLINE) +INLINE int SymIsDef (const SymEntry* Sym) +/* Return true if the given entry is defined */ +{ + return ((Sym->Flags & SC_DEF) == SC_DEF); +} +#else +# define SymIsDef(Sym) (((Sym)->Flags & SC_DEF) == SC_DEF) +#endif + +#if defined(HAVE_INLINE) +INLINE int SymIsRef (const SymEntry* Sym) +/* Return true if the given entry is referenced */ +{ + return ((Sym->Flags & SC_REF) == SC_REF); +} +#else +# define SymIsRef(Sym) (((Sym)->Flags & SC_REF) == SC_REF) +#endif + +#if defined(HAVE_INLINE) +INLINE int SymIsRegVar (const SymEntry* Sym) +/* Return true if the given entry is a register variable */ +{ + return ((Sym->Flags & SC_REGISTER) == SC_REGISTER); +} +#else +# define SymIsRegVar(Sym) (((Sym)->Flags & SC_REGISTER) == SC_REGISTER) +#endif + +void CvtRegVarToAuto (SymEntry* Sym); +/* Convert a register variable to an auto variable */ void ChangeSymType (SymEntry* Entry, type* Type); /* Change the type of the given symbol */ +void ChangeAsmName (SymEntry* Entry, const char* NewAsmName); +/* Change the assembler name of the symbol */ + +int HasAnonName (const SymEntry* Entry); +/* Return true if the symbol entry has an anonymous name */ + /* End of symentry.h */