1
0
mirror of https://github.com/cc65/cc65.git synced 2024-11-17 09:07:32 +00:00

Renamed the defines in symdefs.h to something more meaningful. They were named

EXP_xxx for historic reasons, but SYM_ does make much more sense now.


git-svn-id: svn://svn.cc65.org/cc65/trunk@4812 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
uz 2010-08-17 20:47:27 +00:00
parent d62af9de80
commit 112ae0e3db
8 changed files with 99 additions and 77 deletions

View File

@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2010, Ullrich von Bassewitz */
/* Römerstraße 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@ -411,17 +411,17 @@ static void LibCheckExports (ObjData* O)
const char* Name; const char* Name;
/* Get the export tag and skip the address size */ /* Get the export tag and skip the address size */
unsigned char Type = *Exports++; unsigned Type = GetVar (&Exports);
++Exports; ++Exports;
/* condes decls may follow */ /* condes decls may follow */
Exports += GET_EXP_CONDES_COUNT (Type); Exports += SYM_GET_CONDES_COUNT (Type);
/* Next thing is index of name of symbol */ /* Next thing is index of name of symbol */
Name = GetObjString (O, GetVar (&Exports)); Name = GetObjString (O, GetVar (&Exports));
/* Skip value of symbol */ /* Skip value of symbol */
if (Type & EXP_EXPR) { if (SYM_IS_EXPR (Type)) {
/* Expression tree */ /* Expression tree */
SkipExpr (&Exports); SkipExpr (&Exports);
} else { } else {

View File

@ -37,6 +37,7 @@
/* common */ /* common */
#include "addrsize.h" #include "addrsize.h"
#include "symdefs.h"
#include "xmalloc.h" #include "xmalloc.h"
/* ca65 */ /* ca65 */
@ -606,7 +607,7 @@ void SymImportFromGlobal (SymEntry* S)
int SymIsConst (SymEntry* S, long* Val) int SymIsConst (const SymEntry* S, long* Val)
/* Return true if the given symbol has a constant value. If Val is not NULL /* Return true if the given symbol has a constant value. If Val is not NULL
* and the symbol has a constant value, store it's value there. * and the symbol has a constant value, store it's value there.
*/ */
@ -673,3 +674,21 @@ unsigned GetSymImportId (const SymEntry* S)
unsigned GetSymInfoFlags (const SymEntry* S, long* ConstVal)
/* Return a set of flags used when writing symbol information into a file.
* If the SYM_CONST bit is set, ConstVal will contain the constant value
* of the symbol. The result does not include the condes count.
* See common/symdefs.h for more information.
*/
{
/* Setup info flags */
unsigned Flags = 0;
Flags |= SymIsConst (S, ConstVal)? SYM_CONST : SYM_EXPR;
Flags |= (S->Flags & SF_LABEL)? SYM_LABEL : SYM_EQUATE;
/* Return the result */
return Flags;
}

View File

@ -246,7 +246,7 @@ INLINE int SymIsVar (const SymEntry* S)
# define SymIsVar(S) (((S)->Flags & SF_VAR) != 0) # define SymIsVar(S) (((S)->Flags & SF_VAR) != 0)
#endif #endif
int SymIsConst (SymEntry* Sym, long* Val); int SymIsConst (const SymEntry* Sym, long* Val);
/* Return true if the given symbol has a constant value. If Val is not NULL /* Return true if the given symbol has a constant value. If Val is not NULL
* and the symbol has a constant value, store it's value there. * and the symbol has a constant value, store it's value there.
*/ */
@ -338,6 +338,13 @@ long GetSymVal (SymEntry* Sym);
unsigned GetSymImportId (const SymEntry* Sym); unsigned GetSymImportId (const SymEntry* Sym);
/* Return the import id for the given symbol */ /* Return the import id for the given symbol */
unsigned GetSymInfoFlags (const SymEntry* Sym, long* ConstVal);
/* Return a set of flags used when writing symbol information into a file.
* If the SYM_CONST bit is set, ConstVal will contain the constant value
* of the symbol. The result does not include the condes count.
* See common/symdefs.h for more information.
*/
#if defined(HAVE_INLINE) #if defined(HAVE_INLINE)
INLINE const FilePos* GetSymPos (const SymEntry* S) INLINE const FilePos* GetSymPos (const SymEntry* S)
/* Return the position of first occurence in the source for the given symbol */ /* Return the position of first occurence in the source for the given symbol */

View File

@ -717,38 +717,36 @@ void WriteExports (void)
while (S) { while (S) {
if ((S->Flags & (SF_UNUSED | SF_EXPORT)) == SF_EXPORT) { if ((S->Flags & (SF_UNUSED | SF_EXPORT)) == SF_EXPORT) {
/* Get the expression bits and the value */
long ConstVal; long ConstVal;
unsigned ExprMask = GetSymInfoFlags (S, &ConstVal);
/* Get the expression bits */
unsigned char ExprMask = SymIsConst (S, &ConstVal)? EXP_CONST : EXP_EXPR;
ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE;
/* Count the number of ConDes types */ /* Count the number of ConDes types */
for (Type = 0; Type < CD_TYPE_COUNT; ++Type) { for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
if (S->ConDesPrio[Type] != CD_PRIO_NONE) { if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
INC_EXP_CONDES_COUNT (ExprMask); SYM_INC_CONDES_COUNT (ExprMask);
} }
} }
/* Write the type and the export size */ /* Write the type and the export size */
ObjWrite8 (ExprMask); ObjWriteVar (ExprMask);
ObjWrite8 (S->ExportSize); ObjWrite8 (S->ExportSize);
/* Write any ConDes declarations */ /* Write any ConDes declarations */
if (GET_EXP_CONDES_COUNT (ExprMask) > 0) { if (SYM_GET_CONDES_COUNT (ExprMask) > 0) {
for (Type = 0; Type < CD_TYPE_COUNT; ++Type) { for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
unsigned char Prio = S->ConDesPrio[Type]; unsigned char Prio = S->ConDesPrio[Type];
if (Prio != CD_PRIO_NONE) { if (Prio != CD_PRIO_NONE) {
ObjWrite8 (CD_BUILD (Type, Prio)); ObjWrite8 (CD_BUILD (Type, Prio));
} }
} }
} }
/* Write the name */ /* Write the name */
ObjWriteVar (S->Name); ObjWriteVar (S->Name);
/* Write the value */ /* Write the value */
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) { if (SYM_IS_CONST (ExprMask)) {
/* Constant value */ /* Constant value */
ObjWrite32 (ConstVal); ObjWrite32 (ConstVal);
} else { } else {
@ -798,14 +796,12 @@ void WriteDbgSyms (void)
while (S) { while (S) {
if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL) { if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL) {
/* Get the expression bits and the value */
long ConstVal; long ConstVal;
unsigned ExprMask = GetSymInfoFlags (S, &ConstVal);
/* Get the expression bits */
unsigned char ExprMask = (SymIsConst (S, &ConstVal))? EXP_CONST : EXP_EXPR;
ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE;
/* Write the type */ /* Write the type */
ObjWrite8 (ExprMask); ObjWriteVar (ExprMask);
/* Write the address size */ /* Write the address size */
ObjWrite8 (S->AddrSize); ObjWrite8 (S->AddrSize);
@ -814,7 +810,7 @@ void WriteDbgSyms (void)
ObjWriteVar (S->Name); ObjWriteVar (S->Name);
/* Write the value */ /* Write the value */
if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) { if (SYM_IS_CONST (ExprMask)) {
/* Constant value */ /* Constant value */
ObjWrite32 (ConstVal); ObjWrite32 (ConstVal);
} else { } else {

View File

@ -6,10 +6,10 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2003 Ullrich von Bassewitz */ /* (C) 1998-2010, Ullrich von Bassewitz */
/* Römerstraße 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
/* */ /* */
/* */ /* */
/* This software is provided 'as-is', without any expressed or implied */ /* This software is provided 'as-is', without any expressed or implied */
@ -49,27 +49,27 @@
/* Number of module constructor/destructor declarations for an export */ /* Number of module constructor/destructor declarations for an export */
#define EXP_CONDES_MASK 0x07 #define SYM_CONDES_MASK 0x07U
#define IS_EXP_CONDES(x) (((x) & EXP_CONDES_MASK) != 0) #define SYM_IS_CONDES(x) (((x) & SYM_CONDES_MASK) != 0)
#define GET_EXP_CONDES_COUNT(x) ((x) & EXP_CONDES_MASK) #define SYM_GET_CONDES_COUNT(x) ((x) & SYM_CONDES_MASK)
#define INC_EXP_CONDES_COUNT(x) ((x)++) #define SYM_INC_CONDES_COUNT(x) ((x)++)
/* Export value type */ /* Symbol value type */
#define EXP_CONST 0x00 /* Mask bit for const values */ #define SYM_CONST 0x00U /* Mask bit for const values */
#define EXP_EXPR 0x10 /* Mask bit for expr values */ #define SYM_EXPR 0x10U /* Mask bit for expr values */
#define EXP_MASK_VAL 0x10 /* Value mask */ #define SYM_MASK_VAL 0x10U /* Value mask */
#define IS_EXP_CONST(x) (((x) & EXP_MASK_VAL) == EXP_CONST) #define SYM_IS_CONST(x) (((x) & SYM_MASK_VAL) == SYM_CONST)
#define IS_EXP_EXPR(x) (((x) & EXP_MASK_VAL) == EXP_EXPR) #define SYM_IS_EXPR(x) (((x) & SYM_MASK_VAL) == SYM_EXPR)
/* Export usage */ /* Symbol usage */
#define EXP_EQUATE 0x00 /* Mask bit for an equate */ #define SYM_EQUATE 0x00U /* Mask bit for an equate */
#define EXP_LABEL 0x20 /* Mask bit for a label */ #define SYM_LABEL 0x20U /* Mask bit for a label */
#define EXP_MASK_LABEL 0x20 /* Value mask */ #define SYM_MASK_LABEL 0x20U /* Value mask */
#define IS_EXP_EQUATE(x) (((x) & EXP_MASK_LABEL) == EXP_EQUATE) #define SYM_IS_EQUATE(x) (((x) & SYM_MASK_LABEL) == SYM_EQUATE)
#define IS_EXP_LABEL(x) (((x) & EXP_MASK_LABEL) == EXP_LABEL) #define SYM_IS_LABEL(x) (((x) & SYM_MASK_LABEL) == SYM_LABEL)

View File

@ -142,7 +142,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O)
/* Read a debug symbol from a file, insert and return it */ /* Read a debug symbol from a file, insert and return it */
{ {
/* Read the type and address size */ /* Read the type and address size */
unsigned char Type = Read8 (F); unsigned char Type = ReadVar (F);
unsigned char AddrSize = Read8 (F); unsigned char AddrSize = Read8 (F);
/* Create a new debug symbol */ /* Create a new debug symbol */
@ -152,7 +152,7 @@ DbgSym* ReadDbgSym (FILE* F, ObjData* O)
D->Name = MakeGlobalStringId (O, ReadVar (F)); D->Name = MakeGlobalStringId (O, ReadVar (F));
/* Read the value */ /* Read the value */
if (IS_EXP_EXPR (D->Type)) { if (SYM_IS_EXPR (D->Type)) {
D->Expr = ReadExpr (F, O); D->Expr = ReadExpr (F, O);
} else { } else {
D->Expr = LiteralExpr (Read32 (F), O); D->Expr = LiteralExpr (Read32 (F), O);
@ -221,7 +221,7 @@ void PrintDbgSyms (ObjData* O, FILE* F)
GetString (D->Name), GetString (D->Name),
Val, Val,
AddrSizeToStr (D->AddrSize), AddrSizeToStr (D->AddrSize),
IS_EXP_LABEL (D->Type)? "label" : "equate"); SYM_IS_LABEL (D->Type)? "label" : "equate");
/* Insert the symbol into the table */ /* Insert the symbol into the table */
InsertDbgSym (D, Val); InsertDbgSym (D, Val);
@ -245,7 +245,7 @@ void PrintDbgSymLabels (ObjData* O, FILE* F)
DbgSym* D = CollAt (&O->DbgSyms, I); DbgSym* D = CollAt (&O->DbgSyms, I);
/* Emit this symbol only if it is a label (ignore equates) */ /* Emit this symbol only if it is a label (ignore equates) */
if (IS_EXP_EQUATE (D->Type)) { if (SYM_IS_EQUATE (D->Type)) {
continue; continue;
} }

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 1998-2009, Ullrich von Bassewitz */ /* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -326,7 +326,7 @@ void InsertExport (Export* E)
E->Flags |= EXP_INLIST; E->Flags |= EXP_INLIST;
/* Insert the export into any condes tables if needed */ /* Insert the export into any condes tables if needed */
if (IS_EXP_CONDES (E->Type)) { if (SYM_IS_CONDES (E->Type)) {
ConDesAddExport (E); ConDesAddExport (E);
} }
@ -395,7 +395,7 @@ Export* ReadExport (FILE* F, ObjData* O)
Export* E; Export* E;
/* Read the type */ /* Read the type */
unsigned char Type = Read8 (F); unsigned char Type = ReadVar (F);
/* Read the address size */ /* Read the address size */
unsigned char AddrSize = Read8 (F); unsigned char AddrSize = Read8 (F);
@ -404,7 +404,7 @@ Export* ReadExport (FILE* F, ObjData* O)
E = NewExport (Type, AddrSize, INVALID_STRING_ID, O); E = NewExport (Type, AddrSize, INVALID_STRING_ID, O);
/* Read the constructor/destructor decls if we have any */ /* Read the constructor/destructor decls if we have any */
ConDesCount = GET_EXP_CONDES_COUNT (Type); ConDesCount = SYM_GET_CONDES_COUNT (Type);
if (ConDesCount > 0) { if (ConDesCount > 0) {
unsigned char ConDes[CD_TYPE_COUNT]; unsigned char ConDes[CD_TYPE_COUNT];
@ -430,7 +430,7 @@ Export* ReadExport (FILE* F, ObjData* O)
E->Name = MakeGlobalStringId (O, ReadVar (F)); E->Name = MakeGlobalStringId (O, ReadVar (F));
/* Read the value */ /* Read the value */
if (IS_EXP_EXPR (Type)) { if (SYM_IS_EXPR (Type)) {
E->Expr = ReadExpr (F, O); E->Expr = ReadExpr (F, O);
} else { } else {
E->Expr = LiteralExpr (Read32 (F), O); E->Expr = LiteralExpr (Read32 (F), O);
@ -449,7 +449,7 @@ Export* CreateConstExport (unsigned Name, long Value)
/* Create an export for a literal date */ /* Create an export for a literal date */
{ {
/* Create a new export */ /* Create a new export */
Export* E = NewExport (EXP_CONST | EXP_EQUATE, ADDR_SIZE_ABS, Name, 0); Export* E = NewExport (SYM_CONST | SYM_EQUATE, ADDR_SIZE_ABS, Name, 0);
/* Assign the value */ /* Assign the value */
E->Expr = LiteralExpr (Value, 0); E->Expr = LiteralExpr (Value, 0);
@ -467,7 +467,7 @@ Export* CreateMemoryExport (unsigned Name, Memory* Mem, unsigned long Offs)
/* Create an relative export for a memory area offset */ /* Create an relative export for a memory area offset */
{ {
/* Create a new export */ /* Create a new export */
Export* E = NewExport (EXP_EXPR | EXP_LABEL, ADDR_SIZE_ABS, Name, 0); Export* E = NewExport (SYM_EXPR | SYM_LABEL, ADDR_SIZE_ABS, Name, 0);
/* Assign the value */ /* Assign the value */
E->Expr = MemoryExpr (Mem, Offs, 0); E->Expr = MemoryExpr (Mem, Offs, 0);
@ -485,7 +485,7 @@ Export* CreateSegmentExport (unsigned Name, Segment* Seg, unsigned long Offs)
/* Create a relative export to a segment */ /* Create a relative export to a segment */
{ {
/* Create a new export */ /* Create a new export */
Export* E = NewExport (EXP_EXPR | EXP_LABEL, Seg->AddrSize, Name, 0); Export* E = NewExport (SYM_EXPR | SYM_LABEL, Seg->AddrSize, Name, 0);
/* Assign the value */ /* Assign the value */
E->Expr = SegmentExpr (Seg, Offs, 0); E->Expr = SegmentExpr (Seg, Offs, 0);
@ -503,7 +503,7 @@ Export* CreateSectionExport (unsigned Name, Section* Sec, unsigned long Offs)
/* Create a relative export to a section */ /* Create a relative export to a section */
{ {
/* Create a new export */ /* Create a new export */
Export* E = NewExport (EXP_EXPR | EXP_LABEL, Sec->AddrSize, Name, 0); Export* E = NewExport (SYM_EXPR | SYM_LABEL, Sec->AddrSize, Name, 0);
/* Assign the value */ /* Assign the value */
E->Expr = SectionExpr (Sec, Offs, 0); E->Expr = SectionExpr (Sec, Offs, 0);
@ -762,15 +762,15 @@ void PrintExportMap (FILE* F)
const Export* E = ExpPool [I]; const Export* E = ExpPool [I];
/* Print unreferenced symbols only if explictly requested */ /* Print unreferenced symbols only if explictly requested */
if (VerboseMap || E->ImpCount > 0 || IS_EXP_CONDES (E->Type)) { if (VerboseMap || E->ImpCount > 0 || SYM_IS_CONDES (E->Type)) {
fprintf (F, fprintf (F,
"%-25s %06lX %c%c%c%c ", "%-25s %06lX %c%c%c%c ",
GetString (E->Name), GetString (E->Name),
GetExportVal (E), GetExportVal (E),
E->ImpCount? 'R' : ' ', E->ImpCount? 'R' : ' ',
IS_EXP_LABEL (E->Type)? 'L' : 'E', SYM_IS_LABEL (E->Type)? 'L' : 'E',
GetAddrSizeCode (E->AddrSize), GetAddrSizeCode (E->AddrSize),
IS_EXP_CONDES (E->Type)? 'I' : ' '); SYM_IS_CONDES (E->Type)? 'I' : ' ');
if (++Count == 2) { if (++Count == 2) {
Count = 0; Count = 0;
fprintf (F, "\n"); fprintf (F, "\n");

View File

@ -6,7 +6,7 @@
/* */ /* */
/* */ /* */
/* */ /* */
/* (C) 2002-2009, Ullrich von Bassewitz */ /* (C) 2002-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */ /* Roemerstrasse 52 */
/* D-70794 Filderstadt */ /* D-70794 Filderstadt */
/* EMail: uz@cc65.org */ /* EMail: uz@cc65.org */
@ -174,16 +174,16 @@ static const char* GetExportFlags (unsigned Flags, const unsigned char* ConDes)
/* Type of expression */ /* Type of expression */
TypeDesc[0] = '\0'; TypeDesc[0] = '\0';
switch (Flags & EXP_MASK_VAL) { switch (Flags & SYM_MASK_VAL) {
case EXP_CONST: strcat (TypeDesc, "EXP_CONST"); break; case SYM_CONST: strcat (TypeDesc, "SYM_CONST"); break;
case EXP_EXPR: strcat (TypeDesc, "EXP_EXPR"); break; case SYM_EXPR: strcat (TypeDesc, "SYM_EXPR"); break;
} }
/* Constructor/destructor declarations */ /* Constructor/destructor declarations */
T = TypeDesc + strlen (TypeDesc); T = TypeDesc + strlen (TypeDesc);
Count = GET_EXP_CONDES_COUNT (Flags); Count = SYM_GET_CONDES_COUNT (Flags);
if (Count > 0 && ConDes) { if (Count > 0 && ConDes) {
T += sprintf (T, ",EXP_CONDES="); T += sprintf (T, ",SYM_CONDES=");
for (I = 0; I < Count; ++I) { for (I = 0; I < Count; ++I) {
unsigned Type = CD_GET_TYPE (ConDes[I]); unsigned Type = CD_GET_TYPE (ConDes[I]);
unsigned Prio = CD_GET_PRIO (ConDes[I]); unsigned Prio = CD_GET_PRIO (ConDes[I]);
@ -545,10 +545,10 @@ void DumpObjExports (FILE* F, unsigned long Offset)
/* Read the data for one export */ /* Read the data for one export */
unsigned char Type = Read8 (F); unsigned char Type = Read8 (F);
unsigned char AddrSize = Read8 (F); unsigned char AddrSize = Read8 (F);
ReadData (F, ConDes, GET_EXP_CONDES_COUNT (Type)); ReadData (F, ConDes, SYM_GET_CONDES_COUNT (Type));
Name = GetString (&StrPool, ReadVar (F)); Name = GetString (&StrPool, ReadVar (F));
Len = strlen (Name); Len = strlen (Name);
if (IS_EXP_EXPR (Type)) { if (SYM_IS_EXPR (Type)) {
SkipExpr (F); SkipExpr (F);
HaveValue = 0; HaveValue = 0;
} else { } else {
@ -621,7 +621,7 @@ void DumpObjDbgSyms (FILE* F, unsigned long Offset)
unsigned char AddrSize = Read8 (F); unsigned char AddrSize = Read8 (F);
const char* Name = GetString (&StrPool, ReadVar (F)); const char* Name = GetString (&StrPool, ReadVar (F));
unsigned Len = strlen (Name); unsigned Len = strlen (Name);
if (IS_EXP_EXPR (Type)) { if (SYM_IS_EXPR (Type)) {
SkipExpr (F); SkipExpr (F);
HaveValue = 0; HaveValue = 0;
} else { } else {