[project @ 1996-11-21 16:45:53 by simonm]
[ghc-hetmet.git] / ghc / utils / ugen / tree.c
1 #include "id.h"
2 #include "tree.h"
3
4 extern char *malloc ();
5
6 Ttree ttree(t)
7  tree t;
8 {
9         return(t -> tag);
10 }
11
12
13 /************** typdef ******************/
14
15 tree mktypdef(PPgtid, PPgtdeflist)
16  id PPgtid;
17  tree PPgtdeflist;
18 {
19         register struct Stypdef *pp =
20                 (struct Stypdef *) malloc(sizeof(struct Stypdef));
21         pp -> tag = typdef;
22         pp -> Xgtid = PPgtid;
23         pp -> Xgtdeflist = PPgtdeflist;
24         return((tree)pp);
25 }
26
27 id *Rgtid(t)
28  struct Stypdef *t;
29 {
30 #ifdef UGEN_DEBUG
31         if(t -> tag != typdef)
32                 fprintf(stderr,"gtid: illegal selection; was %d\n", t -> tag);
33 #endif /* UGEN_DEBUG */
34         return(& t -> Xgtid);
35 }
36
37 tree *Rgtdeflist(t)
38  struct Stypdef *t;
39 {
40 #ifdef UGEN_DEBUG
41         if(t -> tag != typdef)
42                 fprintf(stderr,"gtdeflist: illegal selection; was %d\n", t -> tag);
43 #endif /* UGEN_DEBUG */
44         return(& t -> Xgtdeflist);
45 }
46
47 /************** deflist ******************/
48
49 tree mkdeflist(PPgdeflist, PPgdef)
50  tree PPgdeflist;
51  tree PPgdef;
52 {
53         register struct Sdeflist *pp =
54                 (struct Sdeflist *) malloc(sizeof(struct Sdeflist));
55         pp -> tag = deflist;
56         pp -> Xgdeflist = PPgdeflist;
57         pp -> Xgdef = PPgdef;
58         return((tree)pp);
59 }
60
61 tree *Rgdeflist(t)
62  struct Sdeflist *t;
63 {
64 #ifdef UGEN_DEBUG
65         if(t -> tag != deflist)
66                 fprintf(stderr,"gdeflist: illegal selection; was %d\n", t -> tag);
67 #endif /* UGEN_DEBUG */
68         return(& t -> Xgdeflist);
69 }
70
71 tree *Rgdef(t)
72  struct Sdeflist *t;
73 {
74 #ifdef UGEN_DEBUG
75         if(t -> tag != deflist)
76                 fprintf(stderr,"gdef: illegal selection; was %d\n", t -> tag);
77 #endif /* UGEN_DEBUG */
78         return(& t -> Xgdef);
79 }
80
81 /************** def ******************/
82
83 tree mkdef(PPgdid, PPgditemlist)
84  id PPgdid;
85  tree PPgditemlist;
86 {
87         register struct Sdef *pp =
88                 (struct Sdef *) malloc(sizeof(struct Sdef));
89         pp -> tag = def;
90         pp -> Xgdid = PPgdid;
91         pp -> Xgditemlist = PPgditemlist;
92         return((tree)pp);
93 }
94
95 id *Rgdid(t)
96  struct Sdef *t;
97 {
98 #ifdef UGEN_DEBUG
99         if(t -> tag != def)
100                 fprintf(stderr,"gdid: illegal selection; was %d\n", t -> tag);
101 #endif /* UGEN_DEBUG */
102         return(& t -> Xgdid);
103 }
104
105 tree *Rgditemlist(t)
106  struct Sdef *t;
107 {
108 #ifdef UGEN_DEBUG
109         if(t -> tag != def)
110                 fprintf(stderr,"gditemlist: illegal selection; was %d\n", t -> tag);
111 #endif /* UGEN_DEBUG */
112         return(& t -> Xgditemlist);
113 }
114
115 /************** itemlist ******************/
116
117 tree mkitemlist(PPgitemlist, PPgitem)
118  tree PPgitemlist;
119  tree PPgitem;
120 {
121         register struct Sitemlist *pp =
122                 (struct Sitemlist *) malloc(sizeof(struct Sitemlist));
123         pp -> tag = itemlist;
124         pp -> Xgitemlist = PPgitemlist;
125         pp -> Xgitem = PPgitem;
126         return((tree)pp);
127 }
128
129 tree *Rgitemlist(t)
130  struct Sitemlist *t;
131 {
132 #ifdef UGEN_DEBUG
133         if(t -> tag != itemlist)
134                 fprintf(stderr,"gitemlist: illegal selection; was %d\n", t -> tag);
135 #endif /* UGEN_DEBUG */
136         return(& t -> Xgitemlist);
137 }
138
139 tree *Rgitem(t)
140  struct Sitemlist *t;
141 {
142 #ifdef UGEN_DEBUG
143         if(t -> tag != itemlist)
144                 fprintf(stderr,"gitem: illegal selection; was %d\n", t -> tag);
145 #endif /* UGEN_DEBUG */
146         return(& t -> Xgitem);
147 }
148
149 /************** emitemlist ******************/
150
151 tree mkemitemlist(void)
152 {
153         register struct Semitemlist *pp =
154                 (struct Semitemlist *) malloc(sizeof(struct Semitemlist));
155         pp -> tag = emitemlist;
156         return((tree)pp);
157 }
158
159 /************** item ******************/
160
161 tree mkitem(PPgitemfunid, PPgitemtypid)
162  id PPgitemfunid;
163  id PPgitemtypid;
164 {
165         register struct Sitem *pp =
166                 (struct Sitem *) malloc(sizeof(struct Sitem));
167         pp -> tag = item;
168         pp -> Xgitemfunid = PPgitemfunid;
169         pp -> Xgitemtypid = PPgitemtypid;
170         return((tree)pp);
171 }
172
173 id *Rgitemfunid(t)
174  struct Sitem *t;
175 {
176 #ifdef UGEN_DEBUG
177         if(t -> tag != item)
178                 fprintf(stderr,"gitemfunid: illegal selection; was %d\n", t -> tag);
179 #endif /* UGEN_DEBUG */
180         return(& t -> Xgitemfunid);
181 }
182
183 id *Rgitemtypid(t)
184  struct Sitem *t;
185 {
186 #ifdef UGEN_DEBUG
187         if(t -> tag != item)
188                 fprintf(stderr,"gitemtypid: illegal selection; was %d\n", t -> tag);
189 #endif /* UGEN_DEBUG */
190         return(& t -> Xgitemtypid);
191 }