Move SymEntry stuff into its own module

git-svn-id: svn://svn.cc65.org/cc65/trunk@2563 b7a2c559-68d2-44c3-8de9-860c34a00d81
This commit is contained in:
cuz
2003-10-22 21:24:37 +00:00
parent 2c7218b5d9
commit 48c122e478
5 changed files with 159 additions and 85 deletions

View File

@@ -6,10 +6,10 @@
/* */
/* */
/* */
/* (C) 1998 Ullrich von Bassewitz */
/* Wacholderweg 14 */
/* D-70597 Stuttgart */
/* EMail: uz@musoftware.de */
/* (C) 1998-2003 Ullrich von Bassewitz */
/* R<>merstrasse 52 */
/* D-70794 Filderstadt */
/* EMail: uz@cc65.org */
/* */
/* */
/* This software is provided 'as-is', without any expressed or implied */
@@ -38,14 +38,70 @@
/* common */
#include "cddefs.h"
#include "filepos.h"
/*****************************************************************************/
/* Data */
/*****************************************************************************/
/* Forward declaration for struct SymEntry */
/* Bits for the Flags value in SymEntry */
#define SF_NONE 0x0000 /* Empty flag set */
#define SF_USER 0x0001 /* User bit */
#define SF_TRAMPOLINE 0x0002 /* Trampoline entry */
#define SF_EXPORT 0x0004 /* Export this symbol */
#define SF_IMPORT 0x0008 /* Import this symbol */
#define SF_GLOBAL 0x0010 /* Global symbol */
#define SF_ZP 0x0020 /* Declared as zeropage symbol */
#define SF_ABS 0x0040 /* Declared as absolute symbol */
#define SF_LABEL 0x0080 /* Used as a label */
#define SF_FORCED 0x0100 /* Forced import, SF_IMPORT also set */
#define SF_FINALIZED 0x0200 /* Symbol is finalized */
#define SF_INDEXED 0x0800 /* Index is valid */
#define SF_CONST 0x1000 /* The symbol has a constant value */
#define SF_MULTDEF 0x2000 /* Multiply defined symbol */
#define SF_DEFINED 0x4000 /* Defined */
#define SF_REFERENCED 0x8000 /* Referenced */
/* Structure of a symbol table entry */
typedef struct SymEntry SymEntry;
struct SymEntry {
SymEntry* Left; /* Lexically smaller entry */
SymEntry* Right; /* Lexically larger entry */
SymEntry* List; /* List of all entries */
SymEntry* Locals; /* Root of subtree for local symbols */
struct SymTable* SymTab; /* Table this symbol is in, 0 for locals */
FilePos Pos; /* File position for this symbol */
unsigned Flags; /* Symbol flags */
unsigned Index; /* Index of import/export entries */
union {
struct ExprNode* Expr; /* Expression if CONST not set */
long Val; /* Value (if CONST set) */
SymEntry* Sym; /* Symbol (if trampoline entry) */
} V;
unsigned char ConDesPrio[CD_TYPE_COUNT]; /* ConDes priorities... */
/* ...actually value+1 (used as flag) */
char Name [1]; /* Dynamic allocation */
};
/* List of all symbol table entries */
extern SymEntry* SymList;
/*****************************************************************************/
/* Code */
/*****************************************************************************/
SymEntry* NewSymEntry (const char* Name);
/* Allocate a symbol table entry, initialize and return it */