/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
const char* Name;
/* Get the export tag and skip the address size */
- unsigned char Type = *Exports++;
+ unsigned Type = GetVar (&Exports);
++Exports;
/* condes decls may follow */
- Exports += GET_EXP_CONDES_COUNT (Type);
+ Exports += SYM_GET_CONDES_COUNT (Type);
/* Next thing is index of name of symbol */
Name = GetObjString (O, GetVar (&Exports));
/* Skip value of symbol */
- if (Type & EXP_EXPR) {
+ if (SYM_IS_EXPR (Type)) {
/* Expression tree */
SkipExpr (&Exports);
} else {
/* common */
#include "addrsize.h"
+#include "symdefs.h"
#include "xmalloc.h"
/* ca65 */
-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
* and the symbol has a constant value, store it's value there.
*/
+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;
+}
+
+
+
# define SymIsVar(S) (((S)->Flags & SF_VAR) != 0)
#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
* and the symbol has a constant value, store it's value there.
*/
unsigned GetSymImportId (const SymEntry* Sym);
/* 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)
INLINE const FilePos* GetSymPos (const SymEntry* S)
/* Return the position of first occurence in the source for the given symbol */
while (S) {
if ((S->Flags & (SF_UNUSED | SF_EXPORT)) == SF_EXPORT) {
+ /* Get the expression bits and the value */
long ConstVal;
-
- /* Get the expression bits */
- unsigned char ExprMask = SymIsConst (S, &ConstVal)? EXP_CONST : EXP_EXPR;
- ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE;
+ unsigned ExprMask = GetSymInfoFlags (S, &ConstVal);
/* Count the number of ConDes types */
for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
- if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
- INC_EXP_CONDES_COUNT (ExprMask);
- }
+ if (S->ConDesPrio[Type] != CD_PRIO_NONE) {
+ SYM_INC_CONDES_COUNT (ExprMask);
+ }
}
/* Write the type and the export size */
- ObjWrite8 (ExprMask);
+ ObjWriteVar (ExprMask);
ObjWrite8 (S->ExportSize);
/* Write any ConDes declarations */
- if (GET_EXP_CONDES_COUNT (ExprMask) > 0) {
- for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
- unsigned char Prio = S->ConDesPrio[Type];
- if (Prio != CD_PRIO_NONE) {
- ObjWrite8 (CD_BUILD (Type, Prio));
- }
- }
+ if (SYM_GET_CONDES_COUNT (ExprMask) > 0) {
+ for (Type = 0; Type < CD_TYPE_COUNT; ++Type) {
+ unsigned char Prio = S->ConDesPrio[Type];
+ if (Prio != CD_PRIO_NONE) {
+ ObjWrite8 (CD_BUILD (Type, Prio));
+ }
+ }
}
/* Write the name */
ObjWriteVar (S->Name);
/* Write the value */
- if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
+ if (SYM_IS_CONST (ExprMask)) {
/* Constant value */
ObjWrite32 (ConstVal);
} else {
while (S) {
if ((S->Flags & SF_DBGINFOMASK) == SF_DBGINFOVAL) {
+ /* Get the expression bits and the value */
long ConstVal;
-
- /* Get the expression bits */
- unsigned char ExprMask = (SymIsConst (S, &ConstVal))? EXP_CONST : EXP_EXPR;
- ExprMask |= (S->Flags & SF_LABEL)? EXP_LABEL : EXP_EQUATE;
+ unsigned ExprMask = GetSymInfoFlags (S, &ConstVal);
/* Write the type */
- ObjWrite8 (ExprMask);
+ ObjWriteVar (ExprMask);
/* Write the address size */
ObjWrite8 (S->AddrSize);
ObjWriteVar (S->Name);
/* Write the value */
- if ((ExprMask & EXP_MASK_VAL) == EXP_CONST) {
+ if (SYM_IS_CONST (ExprMask)) {
/* Constant value */
ObjWrite32 (ConstVal);
} else {
/* */
/* */
/* */
-/* (C) 1998-2003 Ullrich von Bassewitz */
-/* Römerstraße 52 */
-/* D-70794 Filderstadt */
-/* EMail: uz@cc65.org */
+/* (C) 1998-2010, Ullrich von Bassewitz */
+/* Roemerstrasse 52 */
+/* D-70794 Filderstadt */
+/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
/* 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 GET_EXP_CONDES_COUNT(x) ((x) & EXP_CONDES_MASK)
-#define INC_EXP_CONDES_COUNT(x) ((x)++)
+#define SYM_IS_CONDES(x) (((x) & SYM_CONDES_MASK) != 0)
+#define SYM_GET_CONDES_COUNT(x) ((x) & SYM_CONDES_MASK)
+#define SYM_INC_CONDES_COUNT(x) ((x)++)
-/* Export value type */
-#define EXP_CONST 0x00 /* Mask bit for const values */
-#define EXP_EXPR 0x10 /* Mask bit for expr values */
-#define EXP_MASK_VAL 0x10 /* Value mask */
+/* Symbol value type */
+#define SYM_CONST 0x00U /* Mask bit for const values */
+#define SYM_EXPR 0x10U /* Mask bit for expr values */
+#define SYM_MASK_VAL 0x10U /* Value mask */
-#define IS_EXP_CONST(x) (((x) & EXP_MASK_VAL) == EXP_CONST)
-#define IS_EXP_EXPR(x) (((x) & EXP_MASK_VAL) == EXP_EXPR)
+#define SYM_IS_CONST(x) (((x) & SYM_MASK_VAL) == SYM_CONST)
+#define SYM_IS_EXPR(x) (((x) & SYM_MASK_VAL) == SYM_EXPR)
-/* Export usage */
-#define EXP_EQUATE 0x00 /* Mask bit for an equate */
-#define EXP_LABEL 0x20 /* Mask bit for a label */
-#define EXP_MASK_LABEL 0x20 /* Value mask */
+/* Symbol usage */
+#define SYM_EQUATE 0x00U /* Mask bit for an equate */
+#define SYM_LABEL 0x20U /* Mask bit for a label */
+#define SYM_MASK_LABEL 0x20U /* Value mask */
-#define IS_EXP_EQUATE(x) (((x) & EXP_MASK_LABEL) == EXP_EQUATE)
-#define IS_EXP_LABEL(x) (((x) & EXP_MASK_LABEL) == EXP_LABEL)
+#define SYM_IS_EQUATE(x) (((x) & SYM_MASK_LABEL) == SYM_EQUATE)
+#define SYM_IS_LABEL(x) (((x) & SYM_MASK_LABEL) == SYM_LABEL)
/* End of symdefs.h */
#endif
-
+
/* Read a debug symbol from a file, insert and return it */
{
/* Read the type and address size */
- unsigned char Type = Read8 (F);
+ unsigned char Type = ReadVar (F);
unsigned char AddrSize = Read8 (F);
/* Create a new debug symbol */
D->Name = MakeGlobalStringId (O, ReadVar (F));
/* Read the value */
- if (IS_EXP_EXPR (D->Type)) {
+ if (SYM_IS_EXPR (D->Type)) {
D->Expr = ReadExpr (F, O);
} else {
D->Expr = LiteralExpr (Read32 (F), O);
GetString (D->Name),
Val,
AddrSizeToStr (D->AddrSize),
- IS_EXP_LABEL (D->Type)? "label" : "equate");
+ SYM_IS_LABEL (D->Type)? "label" : "equate");
/* Insert the symbol into the table */
InsertDbgSym (D, Val);
DbgSym* D = CollAt (&O->DbgSyms, I);
/* Emit this symbol only if it is a label (ignore equates) */
- if (IS_EXP_EQUATE (D->Type)) {
+ if (SYM_IS_EQUATE (D->Type)) {
continue;
}
/* */
/* */
/* */
-/* (C) 1998-2009, Ullrich von Bassewitz */
+/* (C) 1998-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
E->Flags |= EXP_INLIST;
/* Insert the export into any condes tables if needed */
- if (IS_EXP_CONDES (E->Type)) {
+ if (SYM_IS_CONDES (E->Type)) {
ConDesAddExport (E);
}
Export* E;
/* Read the type */
- unsigned char Type = Read8 (F);
+ unsigned char Type = ReadVar (F);
/* Read the address size */
unsigned char AddrSize = Read8 (F);
E = NewExport (Type, AddrSize, INVALID_STRING_ID, O);
/* Read the constructor/destructor decls if we have any */
- ConDesCount = GET_EXP_CONDES_COUNT (Type);
+ ConDesCount = SYM_GET_CONDES_COUNT (Type);
if (ConDesCount > 0) {
unsigned char ConDes[CD_TYPE_COUNT];
E->Name = MakeGlobalStringId (O, ReadVar (F));
/* Read the value */
- if (IS_EXP_EXPR (Type)) {
+ if (SYM_IS_EXPR (Type)) {
E->Expr = ReadExpr (F, O);
} else {
E->Expr = LiteralExpr (Read32 (F), O);
/* Create an export for a literal date */
{
/* 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 */
E->Expr = LiteralExpr (Value, 0);
/* Create an relative export for a memory area offset */
{
/* 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 */
E->Expr = MemoryExpr (Mem, Offs, 0);
/* Create a relative export to a segment */
{
/* 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 */
E->Expr = SegmentExpr (Seg, Offs, 0);
/* Create a relative export to a section */
{
/* 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 */
E->Expr = SectionExpr (Sec, Offs, 0);
const Export* E = ExpPool [I];
/* 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,
"%-25s %06lX %c%c%c%c ",
GetString (E->Name),
GetExportVal (E),
E->ImpCount? 'R' : ' ',
- IS_EXP_LABEL (E->Type)? 'L' : 'E',
+ SYM_IS_LABEL (E->Type)? 'L' : 'E',
GetAddrSizeCode (E->AddrSize),
- IS_EXP_CONDES (E->Type)? 'I' : ' ');
+ SYM_IS_CONDES (E->Type)? 'I' : ' ');
if (++Count == 2) {
Count = 0;
fprintf (F, "\n");
/* */
/* */
/* */
-/* (C) 2002-2009, Ullrich von Bassewitz */
+/* (C) 2002-2010, Ullrich von Bassewitz */
/* Roemerstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* Type of expression */
TypeDesc[0] = '\0';
- switch (Flags & EXP_MASK_VAL) {
- case EXP_CONST: strcat (TypeDesc, "EXP_CONST"); break;
- case EXP_EXPR: strcat (TypeDesc, "EXP_EXPR"); break;
+ switch (Flags & SYM_MASK_VAL) {
+ case SYM_CONST: strcat (TypeDesc, "SYM_CONST"); break;
+ case SYM_EXPR: strcat (TypeDesc, "SYM_EXPR"); break;
}
/* Constructor/destructor declarations */
T = TypeDesc + strlen (TypeDesc);
- Count = GET_EXP_CONDES_COUNT (Flags);
+ Count = SYM_GET_CONDES_COUNT (Flags);
if (Count > 0 && ConDes) {
- T += sprintf (T, ",EXP_CONDES=");
+ T += sprintf (T, ",SYM_CONDES=");
for (I = 0; I < Count; ++I) {
unsigned Type = CD_GET_TYPE (ConDes[I]);
unsigned Prio = CD_GET_PRIO (ConDes[I]);
/* Read the data for one export */
unsigned char Type = 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));
Len = strlen (Name);
- if (IS_EXP_EXPR (Type)) {
+ if (SYM_IS_EXPR (Type)) {
SkipExpr (F);
HaveValue = 0;
} else {
unsigned char AddrSize = Read8 (F);
const char* Name = GetString (&StrPool, ReadVar (F));
unsigned Len = strlen (Name);
- if (IS_EXP_EXPR (Type)) {
+ if (SYM_IS_EXPR (Type)) {
SkipExpr (F);
HaveValue = 0;
} else {