1 /* H I G H L E V E L S Y M B O L E N T R Y */
21 Enter(name, kind, type, pnam)
23 register struct type *type;
26 /* Enter a definition for "name" with kind "kind" and type
27 "type" in the Current Scope. If it is a standard name, also
28 put its number in the definition structure, and mark the
29 name as set, to inhibit warnings about used before set.
31 register struct def *df;
33 df = define(str2idf(name, 0), CurrentScope, kind);
36 df->df_value.df_reqname = pnam;
37 df->df_flags |= D_SET;
40 else if (options['g']) stb_string(df, kind);
46 register struct node *Idlist;
48 register struct node *idlist = Idlist;
49 register struct def *df;
51 for( ; idlist; idlist = idlist->nd_next )
52 if ( !strcmp(input, idlist->nd_IDF->id_text)
54 !strcmp(output, idlist->nd_IDF->id_text)
56 /* the occurence of input or output as program-
57 * parameter is their declaration as a GLOBAL
58 * variable of type text
60 if( df = define(idlist->nd_IDF, CurrentScope,
62 df->df_type = text_type;
63 df->df_flags |= (D_SET | D_PROGPAR | D_NOREG);
64 if( !strcmp(input, idlist->nd_IDF->id_text) ) {
69 df->var_name = output;
73 if (options['g']) stb_string(df, D_VARIABLE);
78 if( df = define(idlist->nd_IDF, CurrentScope,
80 df->df_type = error_type;
81 df->df_flags |= D_PROGPAR;
82 df->var_name = idlist->nd_IDF->id_text;
89 EnterEnumList(Idlist, type)
91 register struct type *type;
93 /* Put a list of enumeration literals in the symbol table.
94 They all have type "type". Also assign numbers to them.
96 register struct def *df, *df1 = 0;
97 register struct node *idlist = Idlist;
100 for( ; idlist; idlist = idlist->nd_next )
101 if( df = define(idlist->nd_IDF, CurrentScope, D_ENUM) ) {
103 df->enm_val = (type->enm_ncst)++;
104 df->df_flags |= D_SET;
106 type->enm_enums = df;
108 else df1->enm_next = df;
114 EnterFieldList(Idlist, type, scope, addr, packed)
116 register struct type *type;
119 unsigned short packed;
121 /* Put a list of fields in the symbol table.
122 They all have type "type", and are put in scope "scope".
124 register struct def *df;
125 register struct node *idlist = Idlist;
127 for( ; idlist; idlist = idlist->nd_next )
128 if( df = define(idlist->nd_IDF, scope, D_FIELD) ) {
131 df->fld_flags |= F_PACKED;
132 df->fld_off = align(*addr, type->tp_palign);
133 *addr = df->fld_off + type->tp_psize;
136 df->fld_off = align(*addr, type->tp_align);
137 *addr = df->fld_off + type->tp_size;
143 EnterVarList(Idlist, type, local)
147 /* Enter a list of identifiers representing variables into the
148 name list. "type" represents the type of the variables.
149 "local" is set if the variables are declared local to a
152 register struct def *df;
153 register struct node *idlist = Idlist;
154 register struct scopelist *sc = CurrVis;
156 for( ; idlist; idlist = idlist->nd_next ) {
157 if( !(df = define(idlist->nd_IDF, CurrentScope, D_VARIABLE)) )
158 continue; /* skip this identifier */
161 /* subtract size, which is already aligned, of
162 * variable to the offset, as the variable list
163 * exists only local to a procedure
165 sc->sc_scope->sc_off -= type->tp_size;
166 df->var_off = sc->sc_scope->sc_off;
168 else { /* Global name */
169 df->var_name = df->df_idf->id_text;
170 df->df_flags |= D_NOREG;
173 if (options['g']) stb_string(df, D_VARIABLE);
174 #endif /* DBSYMTAB */
180 EnterParamList(fpl, parlist)
181 register struct node *fpl;
182 struct paramlist **parlist;
184 register arith nb_pars = (proclevel > 1) ? pointer_size : 0;
185 register struct node *id;
189 for( ; fpl; fpl = fpl->nd_right ) {
190 assert(fpl->nd_class == Link);
193 for( id = fpl->nd_left; id; id = id->nd_next )
194 if( df = define(id->nd_IDF, CurrentScope, D_VARIABLE) ) {
195 df->var_off = nb_pars;
196 if( fpl->nd_INT & D_VARPAR || IsConformantArray(tp) )
197 nb_pars += pointer_size;
199 nb_pars += tp->tp_size;
200 LinkParam(parlist, df);
202 df->df_flags |= fpl->nd_INT;
205 while( IsConformantArray(tp) ) {
206 /* we need room for the descriptors */
208 tp->arr_sclevel = CurrentScope->sc_level;
209 tp->arr_cfdescr = nb_pars;
210 nb_pars += 3 * word_size;
218 EnterParTypes(fpl, parlist)
219 register struct node *fpl;
220 struct paramlist **parlist;
222 /* Parameters in heading of procedural and functional
223 parameters (only types are important, not the names).
225 register arith nb_pars = 0;
226 register struct node *id;
230 for( ; fpl; fpl = fpl->nd_right ) {
232 for( id = fpl->nd_left; id; id = id->nd_next )
233 if( df = new_def() ) {
234 if( fpl->nd_INT & D_VARPAR ||
235 IsConformantArray(tp) )
236 nb_pars += pointer_size;
238 nb_pars += tp->tp_size;
239 LinkParam(parlist, df);
241 df->df_flags |= fpl->nd_INT;
243 while( IsConformantArray(tp) ) {
244 nb_pars += 3 * word_size;
251 LinkParam(parlist, df)
252 struct paramlist **parlist;
255 static struct paramlist *pr;
258 *parlist = pr = new_paramlist();
260 pr->next = new_paramlist();