8 import U_coresyn ( U_coresyn ) -- interface only
9 import U_hpragma ( U_hpragma ) -- interface only
14 type U_infixTree = (ProtoName, U_tree, U_tree)
16 rdU_infixTree :: _Addr -> UgnM U_infixTree
18 = ioToUgnM (_casm_ ``%r = gident(*Rginfun_hs((struct Sap *)%0));'' pt) `thenUgn` \ op_t ->
19 ioToUgnM (_casm_ ``%r = (*Rginarg1_hs((struct Sap *)%0));'' pt) `thenUgn` \ arg1_t ->
20 ioToUgnM (_casm_ ``%r = (*Rginarg2_hs((struct Sap *)%0));'' pt) `thenUgn` \ arg2_t ->
22 rdU_unkId op_t `thenUgn` \ op ->
23 rdU_tree arg1_t `thenUgn` \ arg1 ->
24 rdU_tree arg2_t `thenUgn` \ arg2 ->
25 returnUgn (op, arg1, arg2)
26 data U_tree = U_hmodule U_stringId U_list U_list U_binding U_long | U_ident U_unkId | U_lit U_literal | U_tuple U_list | U_ap U_tree U_tree | U_lambda U_list U_tree U_long | U_let U_binding U_tree | U_casee U_tree U_list | U_ife U_tree U_tree U_tree | U_par U_tree | U_as U_unkId U_tree | U_lazyp U_tree | U_plusp U_tree U_literal | U_wildp | U_restr U_tree U_ttype | U_comprh U_tree U_list | U_qual U_tree U_tree | U_guard U_tree | U_def U_tree | U_tinfixop U_infixTree | U_lsection U_tree U_unkId | U_rsection U_unkId U_tree | U_eenum U_tree U_list U_list | U_llist U_list | U_ccall U_stringId U_stringId U_list | U_scc U_hstring U_tree | U_negate U_tree
28 rdU_tree :: _Addr -> UgnM U_tree
30 = ioToUgnM (_ccall_ ttree t) `thenUgn` \ tag@(I# _) ->
31 if tag == ``hmodule'' then
32 ioToUgnM (_ccall_ ghname t) `thenUgn` \ x_ghname ->
33 rdU_stringId x_ghname `thenUgn` \ y_ghname ->
34 ioToUgnM (_ccall_ ghimplist t) `thenUgn` \ x_ghimplist ->
35 rdU_list x_ghimplist `thenUgn` \ y_ghimplist ->
36 ioToUgnM (_ccall_ ghexplist t) `thenUgn` \ x_ghexplist ->
37 rdU_list x_ghexplist `thenUgn` \ y_ghexplist ->
38 ioToUgnM (_ccall_ ghmodlist t) `thenUgn` \ x_ghmodlist ->
39 rdU_binding x_ghmodlist `thenUgn` \ y_ghmodlist ->
40 ioToUgnM (_ccall_ ghmodline t) `thenUgn` \ x_ghmodline ->
41 rdU_long x_ghmodline `thenUgn` \ y_ghmodline ->
42 returnUgn (U_hmodule y_ghname y_ghimplist y_ghexplist y_ghmodlist y_ghmodline)
43 else if tag == ``ident'' then
44 ioToUgnM (_ccall_ gident t) `thenUgn` \ x_gident ->
45 rdU_unkId x_gident `thenUgn` \ y_gident ->
46 returnUgn (U_ident y_gident)
47 else if tag == ``lit'' then
48 ioToUgnM (_ccall_ glit t) `thenUgn` \ x_glit ->
49 rdU_literal x_glit `thenUgn` \ y_glit ->
50 returnUgn (U_lit y_glit)
51 else if tag == ``tuple'' then
52 ioToUgnM (_ccall_ gtuplelist t) `thenUgn` \ x_gtuplelist ->
53 rdU_list x_gtuplelist `thenUgn` \ y_gtuplelist ->
54 returnUgn (U_tuple y_gtuplelist)
55 else if tag == ``ap'' then
56 ioToUgnM (_ccall_ gfun t) `thenUgn` \ x_gfun ->
57 rdU_tree x_gfun `thenUgn` \ y_gfun ->
58 ioToUgnM (_ccall_ garg t) `thenUgn` \ x_garg ->
59 rdU_tree x_garg `thenUgn` \ y_garg ->
60 returnUgn (U_ap y_gfun y_garg)
61 else if tag == ``lambda'' then
62 ioToUgnM (_ccall_ glampats t) `thenUgn` \ x_glampats ->
63 rdU_list x_glampats `thenUgn` \ y_glampats ->
64 ioToUgnM (_ccall_ glamexpr t) `thenUgn` \ x_glamexpr ->
65 rdU_tree x_glamexpr `thenUgn` \ y_glamexpr ->
66 ioToUgnM (_ccall_ glamline t) `thenUgn` \ x_glamline ->
67 rdU_long x_glamline `thenUgn` \ y_glamline ->
68 returnUgn (U_lambda y_glampats y_glamexpr y_glamline)
69 else if tag == ``let'' then
70 ioToUgnM (_ccall_ gletvdeflist t) `thenUgn` \ x_gletvdeflist ->
71 rdU_binding x_gletvdeflist `thenUgn` \ y_gletvdeflist ->
72 ioToUgnM (_ccall_ gletvexpr t) `thenUgn` \ x_gletvexpr ->
73 rdU_tree x_gletvexpr `thenUgn` \ y_gletvexpr ->
74 returnUgn (U_let y_gletvdeflist y_gletvexpr)
75 else if tag == ``casee'' then
76 ioToUgnM (_ccall_ gcaseexpr t) `thenUgn` \ x_gcaseexpr ->
77 rdU_tree x_gcaseexpr `thenUgn` \ y_gcaseexpr ->
78 ioToUgnM (_ccall_ gcasebody t) `thenUgn` \ x_gcasebody ->
79 rdU_list x_gcasebody `thenUgn` \ y_gcasebody ->
80 returnUgn (U_casee y_gcaseexpr y_gcasebody)
81 else if tag == ``ife'' then
82 ioToUgnM (_ccall_ gifpred t) `thenUgn` \ x_gifpred ->
83 rdU_tree x_gifpred `thenUgn` \ y_gifpred ->
84 ioToUgnM (_ccall_ gifthen t) `thenUgn` \ x_gifthen ->
85 rdU_tree x_gifthen `thenUgn` \ y_gifthen ->
86 ioToUgnM (_ccall_ gifelse t) `thenUgn` \ x_gifelse ->
87 rdU_tree x_gifelse `thenUgn` \ y_gifelse ->
88 returnUgn (U_ife y_gifpred y_gifthen y_gifelse)
89 else if tag == ``par'' then
90 ioToUgnM (_ccall_ gpare t) `thenUgn` \ x_gpare ->
91 rdU_tree x_gpare `thenUgn` \ y_gpare ->
92 returnUgn (U_par y_gpare)
93 else if tag == ``as'' then
94 ioToUgnM (_ccall_ gasid t) `thenUgn` \ x_gasid ->
95 rdU_unkId x_gasid `thenUgn` \ y_gasid ->
96 ioToUgnM (_ccall_ gase t) `thenUgn` \ x_gase ->
97 rdU_tree x_gase `thenUgn` \ y_gase ->
98 returnUgn (U_as y_gasid y_gase)
99 else if tag == ``lazyp'' then
100 ioToUgnM (_ccall_ glazyp t) `thenUgn` \ x_glazyp ->
101 rdU_tree x_glazyp `thenUgn` \ y_glazyp ->
102 returnUgn (U_lazyp y_glazyp)
103 else if tag == ``plusp'' then
104 ioToUgnM (_ccall_ gplusp t) `thenUgn` \ x_gplusp ->
105 rdU_tree x_gplusp `thenUgn` \ y_gplusp ->
106 ioToUgnM (_ccall_ gplusi t) `thenUgn` \ x_gplusi ->
107 rdU_literal x_gplusi `thenUgn` \ y_gplusi ->
108 returnUgn (U_plusp y_gplusp y_gplusi)
109 else if tag == ``wildp'' then
111 else if tag == ``restr'' then
112 ioToUgnM (_ccall_ grestre t) `thenUgn` \ x_grestre ->
113 rdU_tree x_grestre `thenUgn` \ y_grestre ->
114 ioToUgnM (_ccall_ grestrt t) `thenUgn` \ x_grestrt ->
115 rdU_ttype x_grestrt `thenUgn` \ y_grestrt ->
116 returnUgn (U_restr y_grestre y_grestrt)
117 else if tag == ``comprh'' then
118 ioToUgnM (_ccall_ gcexp t) `thenUgn` \ x_gcexp ->
119 rdU_tree x_gcexp `thenUgn` \ y_gcexp ->
120 ioToUgnM (_ccall_ gcquals t) `thenUgn` \ x_gcquals ->
121 rdU_list x_gcquals `thenUgn` \ y_gcquals ->
122 returnUgn (U_comprh y_gcexp y_gcquals)
123 else if tag == ``qual'' then
124 ioToUgnM (_ccall_ gqpat t) `thenUgn` \ x_gqpat ->
125 rdU_tree x_gqpat `thenUgn` \ y_gqpat ->
126 ioToUgnM (_ccall_ gqexp t) `thenUgn` \ x_gqexp ->
127 rdU_tree x_gqexp `thenUgn` \ y_gqexp ->
128 returnUgn (U_qual y_gqpat y_gqexp)
129 else if tag == ``guard'' then
130 ioToUgnM (_ccall_ ggexp t) `thenUgn` \ x_ggexp ->
131 rdU_tree x_ggexp `thenUgn` \ y_ggexp ->
132 returnUgn (U_guard y_ggexp)
133 else if tag == ``def'' then
134 ioToUgnM (_ccall_ ggdef t) `thenUgn` \ x_ggdef ->
135 rdU_tree x_ggdef `thenUgn` \ y_ggdef ->
136 returnUgn (U_def y_ggdef)
137 else if tag == ``tinfixop'' then
138 ioToUgnM (_ccall_ gdummy t) `thenUgn` \ x_gdummy ->
139 rdU_infixTree x_gdummy `thenUgn` \ y_gdummy ->
140 returnUgn (U_tinfixop y_gdummy)
141 else if tag == ``lsection'' then
142 ioToUgnM (_ccall_ glsexp t) `thenUgn` \ x_glsexp ->
143 rdU_tree x_glsexp `thenUgn` \ y_glsexp ->
144 ioToUgnM (_ccall_ glsop t) `thenUgn` \ x_glsop ->
145 rdU_unkId x_glsop `thenUgn` \ y_glsop ->
146 returnUgn (U_lsection y_glsexp y_glsop)
147 else if tag == ``rsection'' then
148 ioToUgnM (_ccall_ grsop t) `thenUgn` \ x_grsop ->
149 rdU_unkId x_grsop `thenUgn` \ y_grsop ->
150 ioToUgnM (_ccall_ grsexp t) `thenUgn` \ x_grsexp ->
151 rdU_tree x_grsexp `thenUgn` \ y_grsexp ->
152 returnUgn (U_rsection y_grsop y_grsexp)
153 else if tag == ``eenum'' then
154 ioToUgnM (_ccall_ gefrom t) `thenUgn` \ x_gefrom ->
155 rdU_tree x_gefrom `thenUgn` \ y_gefrom ->
156 ioToUgnM (_ccall_ gestep t) `thenUgn` \ x_gestep ->
157 rdU_list x_gestep `thenUgn` \ y_gestep ->
158 ioToUgnM (_ccall_ geto t) `thenUgn` \ x_geto ->
159 rdU_list x_geto `thenUgn` \ y_geto ->
160 returnUgn (U_eenum y_gefrom y_gestep y_geto)
161 else if tag == ``llist'' then
162 ioToUgnM (_ccall_ gllist t) `thenUgn` \ x_gllist ->
163 rdU_list x_gllist `thenUgn` \ y_gllist ->
164 returnUgn (U_llist y_gllist)
165 else if tag == ``ccall'' then
166 ioToUgnM (_ccall_ gccid t) `thenUgn` \ x_gccid ->
167 rdU_stringId x_gccid `thenUgn` \ y_gccid ->
168 ioToUgnM (_ccall_ gccinfo t) `thenUgn` \ x_gccinfo ->
169 rdU_stringId x_gccinfo `thenUgn` \ y_gccinfo ->
170 ioToUgnM (_ccall_ gccargs t) `thenUgn` \ x_gccargs ->
171 rdU_list x_gccargs `thenUgn` \ y_gccargs ->
172 returnUgn (U_ccall y_gccid y_gccinfo y_gccargs)
173 else if tag == ``scc'' then
174 ioToUgnM (_ccall_ gsccid t) `thenUgn` \ x_gsccid ->
175 rdU_hstring x_gsccid `thenUgn` \ y_gsccid ->
176 ioToUgnM (_ccall_ gsccexp t) `thenUgn` \ x_gsccexp ->
177 rdU_tree x_gsccexp `thenUgn` \ y_gsccexp ->
178 returnUgn (U_scc y_gsccid y_gsccexp)
179 else if tag == ``negate'' then
180 ioToUgnM (_ccall_ gnexp t) `thenUgn` \ x_gnexp ->
181 rdU_tree x_gnexp `thenUgn` \ y_gnexp ->
182 returnUgn (U_negate y_gnexp)
184 error ("rdU_tree: bad tag selection:"++show tag++"\n")