Pristine Ack-5.5
[Ack-5.5.git] / util / ego / cs / cs_aux.c
1 /* $Id: cs_aux.c,v 1.4 1994/06/24 10:21:52 ceriel Exp $ */
2 /*
3  * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands.
4  * See the copyright notice in the ACK home directory, in the file "Copyright".
5  */
6 #include "../share/types.h"
7 #include "../share/debug.h"
8 #include "../share/aux.h"
9 #include "../share/global.h"
10 #include "../share/lset.h"
11 #include "cs.h"
12 #include "cs_entity.h"
13
14 offset array_elemsize(vn)
15         valnum vn;
16 {
17         /* Vn is the valuenumber of an entity that points to
18          * an array-descriptor. The third element of this descriptor holds
19          * the size of the array-elements.
20          * IF we can find this entity, AND IF we can find the descriptor AND IF
21          * this descriptor is located in ROM, then we return the size.
22          */
23         entity_p enp;
24
25         enp = find_entity(vn);
26
27         if (enp == (entity_p) 0)
28                 return UNKNOWN_SIZE;
29
30         if (enp->en_kind != ENAEXTERNAL)
31                 return UNKNOWN_SIZE;
32
33         if (enp->en_ext->o_dblock->d_pseudo != DROM)
34                 return UNKNOWN_SIZE;
35
36         return aoff(enp->en_ext->o_dblock->d_values, 2);
37 }
38
39 occur_p occ_elem(i)
40         Lindex i;
41 {
42         return (occur_p) Lelem(i);
43 }
44
45 entity_p en_elem(i)
46         Lindex i;
47 {
48         return (entity_p) Lelem(i);
49 }
50
51 /* The value numbers associated with each distinct value
52  * start at 1.
53  */
54
55 STATIC valnum val_no;
56
57 valnum newvalnum()
58 {
59         /* Return a completely new value number. */
60
61         return ++val_no;
62 }
63
64 start_valnum()
65 {
66         /* Restart value numbering. */
67
68         val_no = 0;
69 }