]> git.sur5r.net Git - cc65/blob - src/cc65/symentry.h
Added the io module
[cc65] / src / cc65 / symentry.h
1 /*****************************************************************************/
2 /*                                                                           */
3 /*                                symentry.h                                 */
4 /*                                                                           */
5 /*               Symbol table entries for the cc65 C compiler                */
6 /*                                                                           */
7 /*                                                                           */
8 /*                                                                           */
9 /* (C) 2000     Ullrich von Bassewitz                                        */
10 /*              Wacholderweg 14                                              */
11 /*              D-70597 Stuttgart                                            */
12 /* EMail:       uz@musoftware.de                                             */
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 SYMENTRY_H
37 #define SYMENTRY_H
38
39
40
41 #include <stdio.h>
42
43 #include "datatype.h"
44
45
46
47 /*****************************************************************************/
48 /*                              struct SymEntry                              */
49 /*****************************************************************************/
50
51
52
53 /* Storage classes and flags */
54 #define SC_AUTO         0x0001U
55 #define SC_REGISTER     0x0002U /* Register variable, is in static storage */
56 #define SC_STATIC       0x0004U
57 #define SC_EXTERN       0x0008U
58
59 #define SC_ENUM         0x0010U /* An enum (numeric constant) */
60 #define SC_LABEL        0x0020U /* A goto label */
61 #define SC_PARAM        0x0040U /* This is a function parameter */
62 #define SC_FUNC         0x0080U /* Function entry */
63
64 #define SC_STORAGE      0x0100U /* Symbol with associated storage */
65 #define SC_DEFAULT      0x0200U /* Flag: default storage class was used */
66
67 #define SC_DEF          0x0400U /* Symbol is defined */
68 #define SC_REF          0x0800U /* Symbol is referenced */
69
70 #define SC_TYPE         0x1000U /* This is a type, struct, typedef, etc. */
71 #define SC_STRUCT       0x1001U /* Struct or union */
72 #define SC_SFLD         0x1002U /* Struct or union field */
73 #define SC_TYPEDEF      0x1003U /* A typedef */
74
75 #define SC_ZEROPAGE     0x8000U /* Symbol marked as zeropage */
76
77
78
79 /* Symbol table entry */
80 typedef struct SymEntry SymEntry;
81 struct SymEntry {
82     SymEntry*                   NextHash; /* Next entry in hash list */
83     SymEntry*                   PrevSym;  /* Previous symbol in dl list */
84     SymEntry*                   NextSym;  /* Next symbol double linked list */
85     SymEntry*                   Link;     /* General purpose single linked list */
86     struct SymTable*            Owner;    /* Symbol table the symbol is in */
87     unsigned                    Flags;    /* Symbol flags */
88     type*                       Type;     /* Symbol type */
89
90     /* Data that differs for the different symbol types */
91     union {
92
93         /* Offset for locals or struct members */
94         int                     Offs;
95
96         /* Label name for static symbols */
97         unsigned                Label;
98
99         /* Value for enums */
100         int                     EnumVal;
101
102         /* Data for structs/unions */
103         struct {
104             struct SymTable*    SymTab;   /* Member symbol table */
105             unsigned            Size;     /* Size of the union/struct */
106         } S;
107
108         /* Data for functions */
109         struct FuncDesc*        Func;     /* Function descriptor */
110
111     } V;
112     char                       Name[1]; /* Name, dynamically allocated */
113 };
114
115
116
117 /*****************************************************************************/
118 /*                                   Code                                    */
119 /*****************************************************************************/
120
121
122
123 SymEntry* NewSymEntry (const char* Name, unsigned Flags);
124 /* Create a new symbol table with the given name */
125
126 void FreeSymEntry (SymEntry* E);
127 /* Free a symbol entry */
128
129 void DumpSymEntry (FILE* F, const SymEntry* E);
130 /* Dump the given symbol table entry to the file in readable form */
131
132 int IsTypeDef (const SymEntry* E);
133 /* Return true if the given entry is a typedef entry */
134
135 void ChangeSymType (SymEntry* Entry, type* Type);
136 /* Change the type of the given symbol */
137
138
139
140 /* End of symentry.h */
141 #endif
142
143
144