comparison conv/c.c @ 68:0266905063b5

*** empty log message ***
author kono
date Mon, 24 Feb 2003 02:15:15 +0900
parents 254a0c576114
children dba8d111b7a0
comparison
equal deleted inserted replaced
67:254a0c576114 68:0266905063b5
1 #define EXTERN /**/ 1 #define EXTERN /**/
2 2
3 #include "mc.h" 3 #include "mc.h"
4 4
5 #include "conv/convdef.h" 5 #include "conv/convdef.h"
6
7 extern void type_print(int type,NMTBL *nptr,FILE *out);
8 extern void sym_print(int type,FILE *out);
6 9
7 static FILE *vout; 10 static FILE *vout;
8 11
9 static void 12 static void
10 comment_(int c) 13 comment_(int c)
51 else 54 else
52 fprintf(vout,":"); 55 fprintf(vout,":");
53 } 56 }
54 57
55 void 58 void
56 code_(NMTBL *fnptr,int arglist){ 59 code_(NMTBL *n,int arglist){
57 60 fprintf(vout,"code %s(",n->nm);
61 while(args) {
62 n=(NMTBL *)car(args);
63 type_print(n->ty,n,vout);
64 args=cadr(args);
65 if(args) fprintf(vout,",");
66 }
67 fprintf(vout,")");
58 } 68 }
59 69
60 void 70 void
61 code_end_(){ 71 code_end_(){
62 72
126 fprintf(vout,"extern "); 136 fprintf(vout,"extern ");
127 } 137 }
128 138
129 void 139 void
130 for_(){ 140 for_(){
131 141 fprintf(vout,"for(");
132 } 142 }
133 143
134 void 144 void
135 for1_(){ 145 for1_(){
136 146 fprintf(vout,";");
137 } 147 }
138 148
139 void 149 void
140 for2_(){ 150 for2_(){
141 151 fprintf(vout,";");
142 } 152 }
143 153
144 void 154 void
145 for3_(){ 155 for3_(){
146 156 fprintf(vout,")");
147 } 157 }
148 158
149 void 159 void
150 for_body_(){ 160 for_body_(){
151 161
156 166
157 } 167 }
158 168
159 void 169 void
160 funcall_(int type){ 170 funcall_(int type){
161 171 fprintf(vout,"(");
162 } 172 }
163 173
164 void 174 void
165 funcall_args_(){ 175 funcall_args_(){
166 176 fprintf(vout,")");
167 } 177 }
168 178
169 void 179 void
170 function_(){ 180 function_(NMTBL *n,int args){
171 181 type_print(n->ty,0,vout);
182 fprintf(vout,"%s(",n->nm);
183 while(args) {
184 n=(NMTBL *)car(args);
185 type_print(n->ty,n,vout);
186 args=cadr(args);
187 if(args) fprintf(vout,",");
188 }
189 fprintf(vout,")");
172 } 190 }
173 191
174 void 192 void
175 function_end_(){ 193 function_end_(){
176 194
185 goto_label_(){ 203 goto_label_(){
186 204
187 } 205 }
188 206
189 void 207 void
190 id_(int sy,NMTBL *nptr){ 208 id_(int sym,NMTBL *nptr){
191 209 fprintf(vout," %s ",nptr->nm);
210 }
211
212 void
213 string_(char *s){
214 fprintf(vout,"\"%s\"",s);
215 }
216
217 void
218 const_(int symval){
219 fprintf(vout,"%d",symval);
220 }
221
222 void
223 return_f_(){
224 fprintf(vout,"return");
225 }
226
227 void
228 defined_(char *s){
229 fprintf(vout,"defined(%s)",s);
230 }
231
232 void
233 environment_(){
234 fprintf(vout,"environment");
192 } 235 }
193 236
194 void 237 void
195 if_(){ 238 if_(){
196 239 fprintf(vout,"if (");
197 } 240 }
198 241
199 void 242 void
200 if_else_(){ 243 if_else_(){
201 244 fprintf(vout,"} else {");
202 } 245 }
203 246
204 void 247 void
205 if_endif_(){ 248 if_endif_(){
206 249 fprintf(vout,"}");
207 } 250 }
208 251
209 void 252 void
210 if_then_(){ 253 if_then_(){
211 254 fprintf(vout,") {");
212 } 255 }
213 256
214 void 257 void
215 jump_(int env){ 258 jump_(int env){
216 259
256 299
257 } 300 }
258 301
259 void 302 void
260 op_(int sym){ 303 op_(int sym){
261 304 sym_print(sym,vout);
262 } 305 }
263 306
264 void 307 void
265 postfix_(int sym){ 308 postfix_(int sym){
266 309 /* sym_print(sym,vout); */
267 } 310 }
268 311
269 void 312 void
270 prefix_(int sym){ 313 prefix_(int sym){
271 314 /* sym_print(sym,vout); */
272 } 315 }
273 316
274 void 317 void
275 register_(){ 318 register_(){
276 fprintf(vout,"register "); 319 fprintf(vout,"register ");
277 } 320 }
278 321
279 void 322 void
280 return_(){ 323 return_(){
281 324 fprintf(vout,"return (");
282 } 325 }
283 326
284 void 327 void
285 return_end_(){ 328 return_end_(){
286 329 fprintf(vout,")");
287 } 330 }
288 331
289 extern void type_print(int type,NMTBL *nptr,FILE *out);
290 332
291 void 333 void
292 return_type_(int t,NMTBL *nptr,int cont){ 334 return_type_(int t,NMTBL *nptr,int cont){
293 if (cont) { 335 if (cont) {
294 if(nptr) fprintf(vout,"%s",nptr->nm); 336 if(nptr) fprintf(vout,"%s",nptr->nm);
313 fprintf(vout,"static "); 355 fprintf(vout,"static ");
314 } 356 }
315 357
316 void 358 void
317 switch_(){ 359 switch_(){
318 360 fprintf(vout,"switch (");
319 } 361 }
320 362
321 void 363 void
322 switch_body_(){ 364 switch_body_(){
323 365 fprintf(vout,") {");
324 } 366 }
325 367
326 void 368 void
327 switch_end_(){ 369 switch_end_(){
328 370 fprintf(vout,"}");
329 } 371 }
330 372
331 void 373 void
332 typedef_(){ 374 typedef_(){
333 fprintf(vout,"typedef "); 375 fprintf(vout,"typedef ");
334 } 376 }
335 377
336 void 378 void
337 while_(){ 379 while_(){
338 380 fprintf(vout,"while (");
339 } 381 }
340 382
341 void 383 void
342 while_body_(){ 384 while_body_(){
343 385 fprintf(vout,") {");
344 } 386 }
345 387
346 void 388 void
347 while_end_(){ 389 while_end_(){
348 390 fprintf(vout,"}");
349 } 391 }
350 392
351 /* end */ 393 /* end */