Pristine Ack-5.5
[Ack-5.5.git] / util / grind / symbol.hh
1 /* $Id: symbol.hh,v 1.6 1994/06/24 11:01:19 ceriel Exp $ */
2
3 /* Symbol table data structure.
4    Each identifier structure refers to a list of possible meanings of this
5    identifier. Each of these meanings is represented by a "symbol" structure.
6 */
7
8 typedef union constant {        /* depends on type */
9   long  co_ival;
10   double co_rval;
11   char *co_sval;
12   char *co_setval;
13 } t_const, *p_const;
14
15 typedef struct name {
16   long  nm_value;               /* address or offset */
17   struct scope *nm_scope;       /* for names that define a scope */
18 } t_name, *p_name;
19
20 typedef struct symbol {
21   struct symbol *sy_next;       /* link to next meaning */
22   struct symbol *sy_prev_sc;    /* link to previous decl in scope */
23   struct type   *sy_type;       /* type of symbol */
24   int           sy_class;
25 #define CONST           0x0001
26 #define TYPE            0x0002
27 #define TAG             0x0004
28 #define MODULE          0x0008
29 #define PROC            0x0010
30 #define FUNCTION        0x0020
31 #define VAR             0x0040
32 #define REGVAR          0x0080
33 #define LOCVAR          0x0100
34 #define VARPAR          0x0200
35 #define FIELD           0x0400
36 #define FILESYM         0x0800  /* a filename */
37 #define FILELINK        0x1000  /* a filename without its suffix */
38 #define LBOUND          0x2000  /* lower bound of array descriptor */
39 #define UBOUND          0x4000  /* upper bound of array descriptor */
40   struct idf    *sy_idf;        /* reference back to its idf structure */
41   struct scope  *sy_scope;      /* scope in which this symbol resides */
42   union {
43         t_const syv_const;      /* CONST */
44         t_name  syv_name;
45         struct file *syv_file;          /* for FILESYM */
46         struct symbol *syv_fllink;      /* for FILELINK */
47         struct symbol *syv_descr;       /* for LBOUND and UBOUND */
48         struct fields *syv_field;
49   }     sy_v;
50 #define sy_const        sy_v.syv_const
51 #define sy_name         sy_v.syv_name
52 #define sy_file         sy_v.syv_file
53 #define sy_filelink     sy_v.syv_fllink
54 #define sy_field        sy_v.syv_field
55 #define sy_descr        sy_v.syv_descr
56 } t_symbol, *p_symbol;
57
58 /* ALLOCDEF "symbol" 50 */
59
60 extern p_symbol NewSymbol(), Lookup(), Lookfromscope(), add_file();
61 extern p_symbol identify();
62
63 extern p_symbol currfile, listfile;