]> git.sur5r.net Git - cc65/blob - src/ca65/symtab.h
Replace error/warning numbers by strings.
[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 /* Symbol table flags */                                        
58 #define ST_NONE         0x00            /* No flags */
59 #define ST_DEFINED      0x01            /* Scope has been defined */
60
61 /* A symbol table */
62 typedef struct SymTable SymTable;
63 struct 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 */
76 };
77
78 /* Symbol tables */
79 SymTable*       CurrentScope;   /* Pointer to current symbol table */
80 SymTable*       RootScope;      /* Root symbol table */
81
82
83
84 /*****************************************************************************/
85 /*                                   Code                                    */
86 /*****************************************************************************/
87
88
89
90 void SymEnterLevel (const char* ScopeName, unsigned AddrSize);
91 /* Enter a new lexical level */
92
93 void SymLeaveLevel (void);
94 /* Leave the current lexical level */
95
96 SymTable* SymFindScope (SymTable* Parent, const char* Name, int AllocNew);
97 /* Find a scope in the given enclosing scope */
98
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.
103  */
104
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.
108  */
109
110 int SymIsConst (SymEntry* Sym);
111 /* Return true if the given symbol has a constant value */
112
113 int SymIsZP (SymEntry* Sym);
114 /* Return true if the symbol is explicitly marked as zeropage symbol */
115
116 void SymCheck (void);
117 /* Run through all symbols and check for anomalies and errors */
118
119 void SymDump (FILE* F);
120 /* Dump the symbol table */
121
122 void WriteImports (void);
123 /* Write the imports list to the object file */
124
125 void WriteExports (void);
126 /* Write the exports list to the object file */
127
128 void WriteDbgSyms (void);
129 /* Write a list of all symbols to the object file */
130
131
132
133 /* End of symtab.h */
134
135 #endif
136
137
138
139