1 /*****************************************************************************/
5 /* Symbol table for the ca65 macroassembler */
9 /* (C) 1998 Ullrich von Bassewitz */
11 /* D-70597 Stuttgart */
12 /* EMail: uz@musoftware.de */
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
64 /*****************************************************************************/
66 /*****************************************************************************/
70 void SymEnterLevel (void);
71 /* Enter a new lexical level */
73 void SymLeaveLevel (void);
74 /* Leave the current lexical level */
76 void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
77 /* Define a new symbol */
79 SymEntry* SymRef (const char* Name, int Scope);
80 /* Search for the symbol and return it */
82 int SymIsDef (const char* Name, int Scope);
83 /* Return true if the given symbol is already defined */
85 int SymIsRef (const char* Name, int Scope);
86 /* Return true if the given symbol has been referenced */
88 void SymImport (const char* Name, int ZP);
89 /* Mark the given symbol as an imported symbol */
91 void SymExport (const char* Name, int ZP);
92 /* Mark the given symbol as an exported symbol */
94 void SymGlobal (const char* Name, int ZP);
95 /* Mark the given symbol as a global symbol, that is, as a symbol that is
96 * either imported or exported.
99 void SymConDes (const char* Name, unsigned Type, unsigned Prio);
100 /* Mark the given symbol as a module constructor/destructor. This will also
101 * mark the symbol as an export. Initializers may never be zero page symbols.
104 int SymIsConst (SymEntry* Sym);
105 /* Return true if the given symbol has a constant value */
107 int SymIsZP (SymEntry* Sym);
108 /* Return true if the symbol is explicitly marked as zeropage symbol */
110 int SymIsImport (SymEntry* Sym);
111 /* Return true if the given symbol is marked as import */
113 int SymHasExpr (SymEntry* Sym);
114 /* Return true if the given symbol has an associated expression */
116 void SymMarkUser (SymEntry* Sym);
117 /* Set a user mark on the specified symbol */
119 void SymUnmarkUser (SymEntry* Sym);
120 /* Remove a user mark from the specified symbol */
122 int SymHasUserMark (SymEntry* Sym);
123 /* Return the state of the user mark for the specified symbol */
125 long GetSymVal (SymEntry* Sym);
126 /* Return the symbol value */
128 ExprNode* GetSymExpr (SymEntry* Sym);
129 /* Get the expression for a non-const symbol */
131 const char* GetSymName (SymEntry* Sym);
132 /* Return the name of the symbol */
134 unsigned GetSymIndex (SymEntry* Sym);
135 /* Return the symbol index for the given symbol */
137 const FilePos* GetSymPos (SymEntry* Sym);
138 /* Return the position of first occurence in the source for the given symbol */
140 void SymCheck (void);
141 /* Run through all symbols and check for anomalies and errors */
143 void SymDump (FILE* F);
144 /* Dump the symbol table */
146 void WriteImports (void);
147 /* Write the imports list to the object file */
149 void WriteExports (void);
150 /* Write the exports list to the object file */
152 void WriteDbgSyms (void);
153 /* Write a list of all symbols to the object file */
157 /* End of symtab.h */