Add the label/equate bit to the exports and debug symbols

git-svn-id: svn://svn.cc65.org/cc65/trunk@876 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz 2001-09-08 21:08:20 +00:00
parent 522ddabc35
commit cd53882eed
4 changed files with 36 additions and 18 deletions

View file

@ -181,7 +181,7 @@ static void DefineSymbol (const char* Def)
} }
/* Define the symbol */ /* Define the symbol */
SymDef (SymName, LiteralExpr (Val), 0); SymDef (SymName, LiteralExpr (Val), 0, 0);
} }
@ -386,12 +386,12 @@ static void OneLine (void)
/* Skip the '=' */ /* Skip the '=' */
NextTok (); NextTok ();
/* Define the symbol with the expression following the '=' */ /* Define the symbol with the expression following the '=' */
SymDef (Ident, Expression (), 0); SymDef (Ident, Expression(), 0, 0);
/* Don't allow anything after a symbol definition */ /* Don't allow anything after a symbol definition */
Done = 1; Done = 1;
} else { } else {
/* Define a label */ /* Define a label */
SymDef (Ident, CurrentPC (), IsZPSeg ()); SymDef (Ident, CurrentPC(), IsZPSeg(), 1);
/* Skip the colon. If NoColonLabels is enabled, allow labels /* Skip the colon. If NoColonLabels is enabled, allow labels
* without a colon if there is no whitespace before the * without a colon if there is no whitespace before the
* identifier. * identifier.

View file

@ -1100,7 +1100,7 @@ static void DoProc (void)
{ {
if (Tok == TOK_IDENT) { if (Tok == TOK_IDENT) {
/* The new scope has a name */ /* The new scope has a name */
SymDef (SVal, CurrentPC (), IsZPSeg ()); SymDef (SVal, CurrentPC (), IsZPSeg (), 1);
NextTok (); NextTok ();
} }
SymEnterLevel (); SymEnterLevel ();

View file

@ -66,6 +66,7 @@
#define SF_GLOBAL 0x0010 /* Global symbol */ #define SF_GLOBAL 0x0010 /* Global symbol */
#define SF_ZP 0x0020 /* Declared as zeropage symbol */ #define SF_ZP 0x0020 /* Declared as zeropage symbol */
#define SF_ABS 0x0040 /* Declared as absolute symbol */ #define SF_ABS 0x0040 /* Declared as absolute symbol */
#define SF_LABEL 0x0080 /* Used as a label */
#define SF_INDEXED 0x0800 /* Index is valid */ #define SF_INDEXED 0x0800 /* Index is valid */
#define SF_CONST 0x1000 /* The symbol has a constant value */ #define SF_CONST 0x1000 /* The symbol has a constant value */
#define SF_MULTDEF 0x2000 /* Multiply defined symbol */ #define SF_MULTDEF 0x2000 /* Multiply defined symbol */
@ -399,7 +400,7 @@ void SymLeaveLevel (void)
void SymDef (const char* Name, ExprNode* Expr, int ZP) void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label)
/* Define a new symbol */ /* Define a new symbol */
{ {
/* Do we have such a symbol? */ /* Do we have such a symbol? */
@ -430,6 +431,9 @@ void SymDef (const char* Name, ExprNode* Expr, int ZP)
if (ZP) { if (ZP) {
S->Flags |= SF_ZP; S->Flags |= SF_ZP;
} }
if (Label) {
S->Flags |= SF_LABEL;
}
/* If the symbol is a ZP symbol, check if the value is in correct range */ /* If the symbol is a ZP symbol, check if the value is in correct range */
if (S->Flags & SF_ZP) { if (S->Flags & SF_ZP) {
@ -1062,6 +1066,26 @@ void WriteImports (void)
static unsigned char GetExprMask (SymEntry* S)
/* Return the expression bits for the given symbol table entry */
{
unsigned char ExprMask;
/* Check if the symbol is const */
ExprMask = (SymIsConst (S))? EXP_CONST : EXP_EXPR;
/* Add zeropage/abs bits */
ExprMask |= (S->Flags & SF_ZP)? EXP_ZP : EXP_ABS;
/* Add the label/equate bits */
ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE;
/* Return the mask */
return ExprMask;
}
void WriteExports (void) void WriteExports (void)
/* Write the exports list to the object file */ /* Write the exports list to the object file */
{ {
@ -1083,11 +1107,8 @@ void WriteExports (void)
/* Finalize an associated expression if we have one */ /* Finalize an associated expression if we have one */
SymFinalize (S); SymFinalize (S);
/* Check if the symbol is const */ /* Get the expression bits */
ExprMask = (SymIsConst (S))? EXP_CONST : EXP_EXPR; ExprMask = GetExprMask (S);
/* Add zeropage/abs bits */
ExprMask |= (S->Flags & SF_ZP)? EXP_ZP : EXP_ABS;
/* 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) {
@ -1104,7 +1125,7 @@ void WriteExports (void)
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));
} }
} }
} }
@ -1167,11 +1188,8 @@ void WriteDbgSyms (void)
/* Finalize an associated expression if we have one */ /* Finalize an associated expression if we have one */
SymFinalize (S); SymFinalize (S);
/* Check if the symbol is const */ /* Get the expression bits */
ExprMask = (SymIsConst (S))? EXP_CONST : EXP_EXPR; ExprMask = GetExprMask (S);
/* Add zeropage/abs bits */
ExprMask |= (S->Flags & SF_ZP)? EXP_ZP : EXP_ABS;
/* Write the type */ /* Write the type */
ObjWrite8 (ExprMask); ObjWrite8 (ExprMask);

View file

@ -49,7 +49,7 @@
/*****************************************************************************/ /*****************************************************************************/
/* Code */ /* Code */
/*****************************************************************************/ /*****************************************************************************/
@ -60,7 +60,7 @@ void SymEnterLevel (void);
void SymLeaveLevel (void); void SymLeaveLevel (void);
/* Leave the current lexical level */ /* Leave the current lexical level */
void SymDef (const char* Name, ExprNode* Expr, int ZP); void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
/* Define a new symbol */ /* Define a new symbol */
SymEntry* SymRef (const char* Name); SymEntry* SymRef (const char* Name);