1 /*****************************************************************************/
5 /* Symbol table for the ca65 macroassembler */
9 /* (C) 1998-2003 Ullrich von Bassewitz */
10 /* Römerstrasse 52 */
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 /* Scope identifiers */
59 #define SCOPE_GLOBAL 1
62 /* Flags used in SymDef */
63 #define SYM_DEFAULT 0x00
65 #define SYM_LABEL 0x02
69 /*****************************************************************************/
71 /*****************************************************************************/
75 void SymEnterLevel (const char* ScopeName);
76 /* Enter a new lexical level */
78 void SymLeaveLevel (void);
79 /* Leave the current lexical level */
81 int SymIsLocalLevel (void);
82 /* Return true if we are on a local symbol table level. */
84 void SymDef (const char* Name, ExprNode* Expr, unsigned Flags);
85 /* Define a new symbol */
87 SymEntry* SymRef (const char* Name, int Scope);
88 /* Search for the symbol and return it */
90 int SymIsDef (const char* Name, int Scope);
91 /* Return true if the given symbol is already defined */
93 int SymIsRef (const char* Name, int Scope);
94 /* Return true if the given symbol has been referenced */
96 void SymImport (const char* Name);
97 /* Mark the given symbol as an imported symbol */
99 void SymImportZP (const char* Name);
100 /* Mark the given symbol as a imported zeropage symbol */
102 void SymImportForced (const char* Name);
103 /* Mark the given symbol as a forced imported symbol */
105 void SymExport (const char* Name);
106 /* Mark the given symbol as an exported symbol */
108 void SymExportZP (const char* Name);
109 /* Mark the given symbol as an exported zeropage symbol */
111 void SymGlobal (const char* Name);
112 /* Mark the given symbol as a global symbol, that is, as a symbol that is
113 * either imported or exported.
116 void SymGlobalZP (const char* Name);
117 /* Mark the given symbol as a global zeropage symbol, that is, as a symbol
118 * that is either imported or exported.
121 void SymConDes (const char* Name, unsigned Type, unsigned Prio);
122 /* Mark the given symbol as a module constructor/destructor. This will also
123 * mark the symbol as an export. Initializers may never be zero page symbols.
126 int SymIsConst (SymEntry* Sym);
127 /* Return true if the given symbol has a constant value */
129 int SymIsZP (SymEntry* Sym);
130 /* Return true if the symbol is explicitly marked as zeropage symbol */
132 int SymIsImport (SymEntry* Sym);
133 /* Return true if the given symbol is marked as import */
135 int SymHasExpr (SymEntry* Sym);
136 /* Return true if the given symbol has an associated expression */
138 void SymMarkUser (SymEntry* Sym);
139 /* Set a user mark on the specified symbol */
141 void SymUnmarkUser (SymEntry* Sym);
142 /* Remove a user mark from the specified symbol */
144 int SymHasUserMark (SymEntry* Sym);
145 /* Return the state of the user mark for the specified symbol */
147 long GetSymVal (SymEntry* Sym);
148 /* Return the symbol value */
150 ExprNode* GetSymExpr (SymEntry* Sym);
151 /* Get the expression for a non-const symbol */
153 const char* GetSymName (SymEntry* Sym);
154 /* Return the name of the symbol */
156 unsigned GetSymIndex (SymEntry* Sym);
157 /* Return the symbol index for the given symbol */
159 const FilePos* GetSymPos (SymEntry* Sym);
160 /* Return the position of first occurence in the source for the given symbol */
162 void SymCheck (void);
163 /* Run through all symbols and check for anomalies and errors */
165 void SymDump (FILE* F);
166 /* Dump the symbol table */
168 void WriteImports (void);
169 /* Write the imports list to the object file */
171 void WriteExports (void);
172 /* Write the exports list to the object file */
174 void WriteDbgSyms (void);
175 /* Write a list of all symbols to the object file */
179 /* End of symtab.h */