]> git.sur5r.net Git - cc65/blob - src/ca65/symtab.h
71cc42977f50436960875989b43e4b307f3e9ef4
[cc65] / src / ca65 / symtab.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                 symtab.h                                  */
4 /*                                                                           */
5 /*                 Symbol table for the ca65 macroassembler                  */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 1998-2003 Ullrich von Bassewitz                                       */
10 /*               Römerstrasse 52                                             */
11 /*               D-70794 Filderstadt                                         */
12 /* EMail:        uz@cc65.org                                                 */
13 /*                                                                           */
14 /*                                                                           */
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.                                    */
18 /*                                                                           */
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:                            */
22 /*                                                                           */
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              */
30 /*    distribution.                                                          */
31 /*                                                                           */
32 /*****************************************************************************/
33
34
35
36 #ifndef SYMTAB_H
37 #define SYMTAB_H
38
39
40
41 #include <stdio.h>
42
43 /* common */
44 #include "exprdefs.h"
45
46 /* ca65 */
47 #include "symentry.h"
48
49
50
51 /*****************************************************************************/
52 /*                                   Data                                    */
53 /*****************************************************************************/
54
55
56
57 /* Scope identifiers */
58 #define SCOPE_ANY       0
59 #define SCOPE_GLOBAL    1
60 #define SCOPE_LOCAL     2
61
62
63
64 /*****************************************************************************/
65 /*                                   Code                                    */
66 /*****************************************************************************/
67
68
69
70 void SymEnterLevel (void);
71 /* Enter a new lexical level */
72
73 void SymLeaveLevel (void);
74 /* Leave the current lexical level */
75
76 int SymIsLocalLevel (void);
77 /* Return true if we are on a local symbol table level. */
78
79 void SymDef (const char* Name, ExprNode* Expr, int ZP, int Label);
80 /* Define a new symbol */
81
82 SymEntry* SymRef (const char* Name, int Scope);
83 /* Search for the symbol and return it */
84
85 int SymIsDef (const char* Name, int Scope);
86 /* Return true if the given symbol is already defined */
87
88 int SymIsRef (const char* Name, int Scope);
89 /* Return true if the given symbol has been referenced */
90
91 void SymImport (const char* Name);
92 /* Mark the given symbol as an imported symbol */
93
94 void SymImportZP (const char* Name);
95 /* Mark the given symbol as a imported zeropage symbol */
96
97 void SymImportForced (const char* Name);
98 /* Mark the given symbol as a forced imported symbol */
99
100 void SymExport (const char* Name);
101 /* Mark the given symbol as an exported symbol */
102
103 void SymExportZP (const char* Name);
104 /* Mark the given symbol as an exported zeropage symbol */
105
106 void SymGlobal (const char* Name);
107 /* Mark the given symbol as a global symbol, that is, as a symbol that is
108  * either imported or exported.
109  */
110
111 void SymGlobalZP (const char* Name);
112 /* Mark the given symbol as a global zeropage symbol, that is, as a symbol
113  * that is either imported or exported.
114  */
115
116 void SymConDes (const char* Name, unsigned Type, unsigned Prio);
117 /* Mark the given symbol as a module constructor/destructor. This will also
118  * mark the symbol as an export. Initializers may never be zero page symbols.
119  */
120
121 int SymIsConst (SymEntry* Sym);
122 /* Return true if the given symbol has a constant value */
123
124 int SymIsZP (SymEntry* Sym);
125 /* Return true if the symbol is explicitly marked as zeropage symbol */
126
127 int SymIsImport (SymEntry* Sym);
128 /* Return true if the given symbol is marked as import */
129
130 int SymHasExpr (SymEntry* Sym);
131 /* Return true if the given symbol has an associated expression */
132
133 void SymMarkUser (SymEntry* Sym);
134 /* Set a user mark on the specified symbol */
135
136 void SymUnmarkUser (SymEntry* Sym);
137 /* Remove a user mark from the specified symbol */
138
139 int SymHasUserMark (SymEntry* Sym);
140 /* Return the state of the user mark for the specified symbol */
141
142 long GetSymVal (SymEntry* Sym);
143 /* Return the symbol value */
144
145 ExprNode* GetSymExpr (SymEntry* Sym);
146 /* Get the expression for a non-const symbol */
147
148 const char* GetSymName (SymEntry* Sym);
149 /* Return the name of the symbol */
150
151 unsigned GetSymIndex (SymEntry* Sym);
152 /* Return the symbol index for the given symbol */
153
154 const FilePos* GetSymPos (SymEntry* Sym);
155 /* Return the position of first occurence in the source for the given symbol */
156
157 void SymCheck (void);
158 /* Run through all symbols and check for anomalies and errors */
159
160 void SymDump (FILE* F);
161 /* Dump the symbol table */
162
163 void WriteImports (void);
164 /* Write the imports list to the object file */
165
166 void WriteExports (void);
167 /* Write the exports list to the object file */
168
169 void WriteDbgSyms (void);
170 /* Write a list of all symbols to the object file */
171
172
173
174 /* End of symtab.h */
175
176 #endif
177
178
179
180