1 /*****************************************************************************/
5 /* Symbol table for the ca65 macroassembler */
9 /* (C) 1998-2003 Ullrich von Bassewitz */
11 /* D-70794 Filderstadt */
12 /* EMail: uz@cc65.org */
15 /* This software is provided 'as-is', without any expressed or implied */
16 /* warranty. In no event will the authors be held liable for any damages */
17 /* arising from the use of this software. */
19 /* Permission is granted to anyone to use this software for any purpose, */
20 /* including commercial applications, and to alter it and redistribute it */
21 /* freely, subject to the following restrictions: */
23 /* 1. The origin of this software must not be misrepresented; you must not */
24 /* claim that you wrote the original software. If you use this software */
25 /* in a product, an acknowledgment in the product documentation would be */
26 /* appreciated but is not required. */
27 /* 2. Altered source versions must be plainly marked as such, and must not */
28 /* be misrepresented as being the original software. */
29 /* 3. This notice may not be removed or altered from any source */
32 /*****************************************************************************/
51 /*****************************************************************************/
53 /*****************************************************************************/
57 /* Symbol table flags */
58 #define ST_NONE 0x00 /* No flags */
59 #define ST_DEFINED 0x01 /* Scope has been defined */
62 typedef struct SymTable SymTable;
64 SymTable* Left; /* Pointer to smaller entry */
65 SymTable* Right; /* Pointer to greater entry */
66 SymTable* Parent; /* Link to enclosing scope if any */
67 SymTable* Childs; /* Pointer to child scopes */
68 unsigned short Flags; /* Symbol table flags */
69 unsigned char AddrSize; /* Address size */
70 unsigned char Type; /* Type of the scope */
71 unsigned Level; /* Lexical level */
72 unsigned TableSlots; /* Number of hash table slots */
73 unsigned TableEntries; /* Number of entries in the table */
74 unsigned Name; /* Name of the scope */
75 SymEntry* Table[1]; /* Dynamic allocation */
79 SymTable* CurrentScope; /* Pointer to current symbol table */
80 SymTable* RootScope; /* Root symbol table */
84 /*****************************************************************************/
86 /*****************************************************************************/
90 void SymEnterLevel (const char* ScopeName, unsigned AddrSize);
91 /* Enter a new lexical level */
93 void SymLeaveLevel (void);
94 /* Leave the current lexical level */
96 SymTable* SymFindScope (SymTable* Parent, const char* Name, int AllocNew);
97 /* Find a scope in the given enclosing scope */
99 SymEntry* SymFind (SymTable* Scope, const char* Name, int AllocNew);
100 /* Find a new symbol table entry in the given table. If AllocNew is given and
101 * the entry is not found, create a new one. Return the entry found, or the
102 * new entry created, or - in case AllocNew is zero - return 0.
105 void SymConDes (const char* Name, unsigned Type, unsigned Prio);
106 /* Mark the given symbol as a module constructor/destructor. This will also
107 * mark the symbol as an export. Initializers may never be zero page symbols.
110 int SymIsZP (SymEntry* Sym);
111 /* Return true if the symbol is explicitly marked as zeropage symbol */
113 void SymCheck (void);
114 /* Run through all symbols and check for anomalies and errors */
116 void SymDump (FILE* F);
117 /* Dump the symbol table */
119 void WriteImports (void);
120 /* Write the imports list to the object file */
122 void WriteExports (void);
123 /* Write the exports list to the object file */
125 void WriteDbgSyms (void);
126 /* Write a list of all symbols to the object file */
130 /* End of symtab.h */