Pristine Ack-5.5
[Ack-5.5.git] / lang / pc / comp / def.H
1 /* I D E N T I F I E R   D E S C R I P T O R   S T R U C T U R E */
2
3 struct constant {
4         struct node *co_const;  /* result of a constant expression */
5 #define con_const       df_value.df_constant.co_const
6 };
7
8 struct variable {
9         arith va_off;           /* address of variable */
10         char *va_name;          /* name of variable if given */
11 #define var_off         df_value.df_variable.va_off
12 #define var_name        df_value.df_variable.va_name
13 };
14
15 struct bound    {
16         struct type *bo_type;   /* type of conformant array */
17 #define bnd_type        df_value.df_bound.bo_type
18 };
19
20 struct enumval  {
21         unsigned int en_val;    /* value of this enumeration literal */
22         struct def *en_next;    /* next enumeration literal */
23 #define enm_val         df_value.df_enum.en_val
24 #define enm_next        df_value.df_enum.en_next
25 };
26
27 struct field    {
28         arith fd_off;
29         unsigned short fd_flags;
30 #define F_SELECTOR      0x1     /* set if field is a variant selector */
31 #define F_PACKED        0x2     /* set if record is packed */
32
33 #define fld_off         df_value.df_field.fd_off
34 #define fld_flags       df_value.df_field.fd_flags
35 };
36
37 struct lab      {
38         struct lab *lb_next;    /* list of goto statements to this label */
39         int lb_level;           /* level of nesting */
40         label lb_no;            /* instruction label */
41         label lb_descr;         /* label of goto descriptor */
42 #define lab_next        df_value.df_label.lb_next
43 #define lab_level       df_value.df_label.lb_level
44 #define lab_no          df_value.df_label.lb_no
45 #define lab_descr       df_value.df_label.lb_descr
46 };
47
48 /* ALLOCDEF "lab" 10 */
49
50 struct used     {
51         struct def *us_def;     /* used definition */
52 #define usd_def         df_value.df_used.us_def
53 };
54
55 struct forwtype {
56         struct forwtype *f_next;
57         struct node *f_node;
58         struct type *f_type;
59 };
60
61 /* ALLOCDEF "forwtype" 50 */
62
63 struct dfproc   {                       /* used for procedures and functions */
64         struct scopelist *pc_vis;       /* scope of this procedure/function */
65         char *pc_name;                  /* internal name */
66         label pc_label;                 /* label of name (for tracing) */
67         arith pc_res;                   /* offset of function result */
68         arith pc_bool;                  /* offset of run-time boolean */
69 #define prc_vis         df_value.df_proc.pc_vis
70 #define prc_name        df_value.df_proc.pc_name
71 #define prc_label       df_value.df_proc.pc_label
72 #define prc_res         df_value.df_proc.pc_res
73 #define prc_bool        df_value.df_proc.pc_bool
74 };
75
76 struct def      {               /* list of definitions for a name */
77         struct def *df_next;    /* next definition in definitions chain */
78         struct def *df_nextinscope;
79                                 /* link all definitions in a scope */
80         struct idf *df_idf;     /* link back to the name */
81         struct scope *df_scope; /* scope in which this definition resides */
82         long df_kind;           /* the kind of this definition: */
83 #define D_PROCEDURE     0x000001L       /* procedure */
84 #define D_FUNCTION      0x000002L       /* function */
85 #define D_TYPE          0x000004L       /* a type */
86 #define D_CONST         0x000008L       /* a constant */
87 #define D_ENUM          0x000010L       /* an enumeration literal */
88 #define D_FIELD         0x000020L       /* a field in a record */
89 #define D_PROGRAM       0x000040L       /* the program */
90 #define D_VARIABLE      0x000080L       /* a variable */
91 #define D_PARAMETER     0x000100L       /* program parameter */
92 #define D_FORWTYPE      0x000200L       /* forward type */
93 #define D_FTYPE         0x000400L       /* resolved forward type */
94 #define D_FWPROCEDURE   0x000800L       /* forward procedure */
95 #define D_FWFUNCTION    0x001000L       /* forward function */
96 #define D_LABEL         0x002000L       /* a label */
97 #define D_LBOUND        0x004000L       /* lower bound id. in conform. array */
98 #define D_UBOUND        0x008000L       /* upper bound id. in conform. array */
99 #define D_FORWARD       0x010000L       /* directive "forward" */
100 #define D_EXTERN        0x020000L       /* directive "extern" */
101 #define D_ERROR         0x040000L       /* a compiler generated definition
102                                          * for an undefined variable */
103 #define D_MODULE        0x080000L       /* the module */
104 #define D_INUSE         0x100000L       /* variable is in use */
105
106 /* special values for stab.c */
107 #define D_END           (D_PROGRAM|D_PROCEDURE)
108 #define D_PEND          (D_PROGRAM|D_PROCEDURE|D_VARIABLE)
109
110 #define D_VALUE         (D_FUNCTION | D_CONST | D_ENUM | D_FIELD | D_VARIABLE\
111                          | D_FWFUNCTION | D_LBOUND | D_UBOUND)
112 #define D_ROUTINE      (D_FUNCTION | D_FWFUNCTION | D_PROCEDURE | D_FWPROCEDURE)
113         unsigned short df_flags;
114 #define D_NOREG         0x001   /* set if it may not reside in a register */
115 #define D_VALPAR        0x002   /* set if it is a value parameter */
116 #define D_VARPAR        0x004   /* set if it is a var parameter */
117 #define D_LOOPVAR       0x008   /* set if it is a control-variable */
118 #define D_EXTERNAL      0x010   /* set if proc/func is external declared */
119 #define D_PROGPAR       0x020   /* set if input/output was mentioned in
120                                  * the program-heading */
121 #define D_USED          0x040   /* set when the variable is used */
122 #define D_SET           0x080   /* set when the variable is set */
123 #define D_INLOOP        0x100   /* set when we are inside a loop */
124 #define D_WITH          0x200   /* set inside a with statement */
125 #define D_SETINHIGH     0x400   /* set in a higher scope level (for loops) */
126
127         struct type *df_type;
128         union {
129                 struct constant df_constant;
130                 struct variable df_variable;
131                 struct bound df_bound;
132                 struct enumval df_enum;
133                 struct field df_field;
134                 struct lab df_label;
135                 struct used df_used;
136                 struct forwtype *df_fwtype;
137                 struct dfproc df_proc;
138                 int df_reqname; /* define for required name */
139         } df_value;
140 #define df_fortype      df_value.df_fwtype
141 };
142
143 /* ALLOCDEF "def" 50 */
144
145 extern struct def
146         *define(),
147         *MkDef(),
148         *DeclProc(),
149         *DeclFunc();
150
151 extern struct def
152         *lookup(),
153         *lookfor();
154
155 #define NULLDEF ((struct def *) 0)