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 void SymEnterLevel (void);
58 /* Enter a new lexical level */
60 void SymLeaveLevel (void);
61 /* Leave the current lexical level */
63 void SymDef (const char* Name, ExprNode* Expr, int ZP);
64 /* Define a new symbol */
66 SymEntry* SymRef (const char* Name);
67 /* Search for the symbol and return it */
69 SymEntry* SymRefGlobal (const char* Name);
70 /* Search for the symbol in the global namespace and return it */
72 int SymIsDef (const char* Name);
73 /* Return true if the given symbol is already defined */
75 int SymIsRef (const char* Name);
76 /* Return true if the given symbol has been referenced */
78 void SymImport (const char* Name, int ZP);
79 /* Mark the given symbol as an imported symbol */
81 void SymExport (const char* Name, int ZP);
82 /* Mark the given symbol as an exported symbol */
84 void SymGlobal (const char* Name, int ZP);
85 /* Mark the given symbol as a global symbol, that is, as a symbol that is
86 * either imported or exported.
89 void SymInitializer (const char* Name, int ZP);
90 /* Mark the given symbol as an initializer. This will also mark the symbol as
91 * an export. Initializers may never be zero page symbols, the ZP parameter
92 * is supplied to make the prototype the same as the other functions (this
93 * is used in pseudo.c). Passing something else but zero as ZP argument will
94 * trigger an internal error.
97 int SymIsConst (SymEntry* Sym);
98 /* Return true if the given symbol has a constant value */
100 int SymIsZP (SymEntry* Sym);
101 /* Return true if the symbol is explicitly marked as zeropage symbol */
103 int SymIsImport (SymEntry* Sym);
104 /* Return true if the given symbol is marked as import */
106 int SymHasExpr (SymEntry* Sym);
107 /* Return true if the given symbol has an associated expression */
109 void SymMarkUser (SymEntry* Sym);
110 /* Set a user mark on the specified symbol */
112 void SymUnmarkUser (SymEntry* Sym);
113 /* Remove a user mark from the specified symbol */
115 int SymHasUserMark (SymEntry* Sym);
116 /* Return the state of the user mark for the specified symbol */
118 long GetSymVal (SymEntry* Sym);
119 /* Return the symbol value */
121 ExprNode* GetSymExpr (SymEntry* Sym);
122 /* Get the expression for a non-const symbol */
124 const char* GetSymName (SymEntry* Sym);
125 /* Return the name of the symbol */
127 unsigned GetSymIndex (SymEntry* Sym);
128 /* Return the symbol index for the given symbol */
130 const FilePos* GetSymPos (SymEntry* Sym);
131 /* Return the position of first occurence in the source for the given symbol */
133 void SymCheck (void);
134 /* Run through all symbols and check for anomalies and errors */
136 void SymDump (FILE* F);
137 /* Dump the symbol table */
139 void WriteImports (void);
140 /* Write the imports list to the object file */
142 void WriteExports (void);
143 /* Write the exports list to the object file */
145 void WriteDbgSyms (void);
146 /* Write a list of all symbols to the object file */
150 /* End of symtab.h */