462
|
1 /* Micro-C Partial Evaluator Part */
|
|
2 /* $Id$ */
|
|
3
|
|
4 #include <stdio.h>
|
|
5 #include "mc.h"
|
|
6 #include "mc-parse.h"
|
|
7 #include "mc-codegen.h"
|
|
8 #include "mc-switch.h"
|
464
|
9 #include "mc-code.h"
|
|
10 #include "mc-inline.h"
|
462
|
11
|
463
|
12 static int pvartable;
|
|
13 static int pdisp;
|
462
|
14
|
514
|
15 static int ret_register,ret_reg_mode;
|
|
16
|
527
|
17 static int inline_lvars;
|
|
18
|
462
|
19 /*
|
|
20 Basic code generator from parse tree
|
|
21 */
|
|
22
|
|
23 extern void
|
|
24 st_decl(int e1){
|
|
25 // NMTBL *n = (NMTBL *)caddr(e1);
|
|
26 // int stmode = cadddr(e1);
|
|
27 }
|
|
28
|
|
29 extern void
|
|
30 st_if(int e1){
|
|
31 int l1,l2,slfree;
|
|
32 int e2=caddr(e1),e3;
|
|
33 // conv->if_();
|
|
34 slfree=lfree;
|
|
35 checkret();
|
|
36 l1 = bexpr(car(e2),0,fwdlabel());
|
|
37 // conv->if_then_();
|
|
38 g_expr_u(cadr(e2));
|
|
39 checkret();
|
|
40 if ((e3=caddr(e2))) { // else
|
|
41 // conv->if_else_();
|
|
42 if ((l2 = control))
|
|
43 gen_jmp(l2=fwdlabel());
|
|
44 fwddef(l1);
|
|
45 g_expr_u(e3);
|
|
46 checkret();
|
|
47 if (l2) fwddef(l2);
|
|
48 } else {
|
|
49 fwddef(l1);
|
|
50 }
|
|
51 // conv->if_endif_();
|
|
52 }
|
|
53
|
|
54
|
|
55 extern void
|
|
56 st_do(int e1){
|
|
57 int sbreak,scontinue,l;
|
|
58
|
|
59 sbreak=blabel;
|
|
60 scontinue=clabel;
|
|
61 blabel=fwdlabel();
|
|
62 clabel=fwdlabel();
|
|
63 control=1;
|
|
64 checkret();
|
|
65 l=backdef();
|
|
66 // conv->dowhile_();
|
|
67 g_expr_u(cadddr(e1));
|
|
68 checkret();
|
|
69 // conv->dowhile_cond_();
|
|
70 bexpr(caddr(e1),1,l);
|
|
71 // conv->dowhile_end_();
|
|
72 fwddef(blabel);
|
|
73 clabel=scontinue;
|
|
74 blabel=sbreak;
|
|
75 }
|
|
76
|
|
77
|
|
78 extern void
|
|
79 st_while(int e1){
|
|
80 int sbreak,scontinue,e;
|
|
81
|
|
82 sbreak=blabel;
|
|
83 scontinue=clabel;
|
|
84 blabel=fwdlabel();
|
|
85 control=1;
|
|
86 checkret();
|
|
87 clabel=backdef();
|
|
88 // conv->while_();
|
|
89 // conv->while_body_();
|
|
90 if(!(e=cadddr(e1))) {
|
|
91 bexpr(caddr(e1),1,clabel);
|
|
92 // conv->sm_();
|
|
93 } else {
|
|
94 bexpr(caddr(e1),0,blabel);
|
|
95 g_expr_u(e);
|
|
96 checkret();
|
|
97 if(control)
|
|
98 gen_jmp(clabel);
|
|
99 }
|
|
100 // conv->while_end_();
|
|
101 fwddef(blabel);
|
|
102 clabel=scontinue;
|
|
103 blabel=sbreak;
|
|
104 }
|
|
105
|
|
106
|
|
107 extern void
|
|
108 st_for(int e1){
|
|
109 int p0,p1,p2,body;
|
|
110 int l,e;
|
|
111 int sbreak=blabel;
|
|
112 int scontinue=clabel;
|
|
113
|
|
114 e = caddr(e1);
|
|
115 p0 = car(e); p1 = cadr(e); p2 = caddr(e); body = cadddr(e);
|
|
116
|
|
117 blabel=fwdlabel();
|
|
118 // conv->for_();
|
|
119 if (p0) {
|
|
120 checkret();
|
|
121 g_expr_u(p0);
|
|
122 }
|
|
123 // conv->for1_();
|
|
124 control=1;
|
|
125 checkret();
|
|
126 l=backdef();
|
|
127 if (p1) {
|
|
128 bexpr(p1,0,blabel);
|
|
129 }
|
|
130 // conv->for2_();
|
|
131 // conv->for_body_();
|
|
132 if (!p2) {
|
|
133 clabel=l;
|
|
134 g_expr_u(body);
|
|
135 checkret();
|
|
136 } else {
|
|
137 clabel=fwdlabel();
|
|
138 g_expr_u(body);
|
|
139 checkret();
|
|
140 fwddef(clabel);
|
|
141 g_expr_u(p2);
|
|
142 }
|
|
143 // conv->for_end_();
|
|
144 gen_jmp(l);
|
|
145 fwddef(blabel);
|
|
146 clabel=scontinue;
|
|
147 blabel=sbreak;
|
|
148 }
|
|
149
|
|
150
|
|
151 extern void
|
|
152 st_switch(int e1){
|
|
153 int sbreak,scase,sdefault,slfree,svalue,slist;
|
|
154
|
|
155 checkret();
|
|
156 slist = cslist;
|
|
157 cslist = 0;
|
|
158 sbreak=blabel; /* save parents break label */
|
|
159 blabel=fwdlabel();
|
|
160 sdefault=dlabel; /* save parents default label */
|
|
161 dlabel=0;
|
|
162 scase=cslabel; /* save parents next case label */
|
|
163 // conv->switch_();
|
|
164 slfree=lfree;
|
|
165 svalue=csvalue1; /* save parents switch value */
|
506
|
166 gexpr(caddr(e1),1); /* switch value */
|
462
|
167 csvalue1=csvalue() ;
|
|
168 // conv->switch_body_();
|
|
169 cslabel = control = 0;
|
|
170 g_expr_u(cadddr(e1));
|
|
171 // conv->switch_end_();
|
|
172 checkret();
|
|
173 #if CASE_CODE
|
|
174 if (control) gen_jmp(blabel);
|
|
175 genswitch(cslist,cslabel);
|
|
176 #else
|
|
177 if(dlabel) def_label(cslabel,dlabel);
|
|
178 else fwddef(cslabel);
|
|
179 #endif
|
|
180 csvalue1=svalue;
|
|
181 cslabel=scase;
|
|
182 dlabel=sdefault;
|
|
183 fwddef(blabel);
|
|
184 blabel=sbreak;
|
|
185 cslist = slist;
|
|
186 }
|
|
187
|
|
188
|
|
189 extern void
|
|
190 st_comp(int e1){
|
|
191 g_expr_u(caddr(e1));
|
|
192 }
|
|
193
|
|
194
|
|
195 extern void
|
|
196 st_break(int e1){
|
|
197 checkret();
|
|
198 // conv->break_();
|
|
199 if (control)
|
|
200 gen_jmp(blabel);
|
|
201 }
|
|
202
|
|
203
|
|
204 extern void
|
|
205 st_continue(int e1){
|
|
206 checkret();
|
|
207 // conv->continue_();
|
|
208 if (control) gen_jmp(clabel);
|
|
209 }
|
|
210
|
|
211
|
|
212 extern void
|
|
213 st_case(int e1){
|
|
214 #if CASE_CODE
|
|
215 int l,clist=caddr(e1),c;
|
|
216 l = fwdlabel();
|
|
217 // conv->case_begin_(0,0);
|
|
218 // conv->case_(0,0);
|
|
219 if (retpending) {
|
|
220 ret(); retpending=0;
|
|
221 }
|
|
222 if (!cslabel) {
|
|
223 if (!control) {
|
|
224 cmpdimm(car(clist),csvalue1,cslabel=fwdlabel(),1);
|
|
225 caddr(clist)=0;
|
|
226 } else {
|
|
227 error(-1);
|
|
228 }
|
|
229 }
|
|
230 while(clist) {
|
|
231 caddr(clist) = l;
|
|
232 clist = cadr(c=clist); cadr(c) = 0; // insert destroy cadr of clist
|
|
233 cslist=insert_ascend(cslist,c,docase_eq);
|
|
234 }
|
|
235 fwddef(l);
|
|
236 control=1;
|
|
237 #else
|
|
238 /* casading branch implementation */
|
|
239 int c,l;
|
|
240 c = caddr(e1);
|
|
241 if (retpending) {
|
|
242 ret(); retpending=0;
|
|
243 }
|
|
244 // conv->case_begin_(0,0);
|
|
245 // conv->case_(0,0);
|
|
246 l=fwdlabel();
|
|
247 if (control) {
|
|
248 control=0;
|
|
249 gen_jmp(l);
|
|
250 }
|
|
251 if (cslabel) fwddef(cslabel);
|
|
252 while(cadr(c)) {
|
|
253 cmpdimm(car(c),csvalue1,l,0);
|
|
254 c=cadr(c);
|
|
255 }
|
|
256 cmpdimm(car(c),csvalue1,cslabel=fwdlabel(),1);
|
|
257 if (l) fwddef(l);
|
|
258 #endif
|
|
259 }
|
|
260
|
|
261
|
|
262 extern void
|
|
263 st_default(int e1){
|
|
264 control=1;
|
|
265 checkret();
|
|
266 if (dlabel) error(STERR); // double default:
|
|
267 dlabel = backdef();
|
|
268 // conv->case_(0,1);
|
|
269 }
|
|
270
|
|
271
|
|
272 extern void
|
|
273 st_return(int e1){
|
514
|
274 int e,t;
|
462
|
275
|
|
276 if (!cslabel) gen_jmp(cslabel = fwdlabel());
|
|
277 if(!(e=caddr(e1))) {
|
513
|
278 // no return value
|
462
|
279 retpending = 1;
|
|
280 return;
|
|
281 }
|
551
|
282 t = type_value(cadr(fnptr->ty));
|
|
283 if (t>0 && (car(t)==STRUCT || car(t)==UNION)) {
|
|
284 // copy is included in e, pass the pointer
|
|
285 t = list2(POINTER,type_value(cadr(fnptr->ty)));
|
|
286 }
|
|
287 g_expr(e);
|
|
288 if (ret_reg_mode==0) {
|
|
289 // return value register is not fixed
|
|
290 ret_reg_mode=1;
|
|
291 ret_register = code_get_fixed_creg(USE_CREG,t);
|
462
|
292 } else {
|
551
|
293 code_set_fixed_creg(ret_register,1,t);
|
462
|
294 }
|
|
295 // conv->return_end_();
|
|
296 retpending = 1;
|
|
297 }
|
|
298
|
|
299 extern void
|
|
300 st_goto(int e){
|
551
|
301 NMTBL *nptr0;
|
|
302 int e1,e2,env;
|
462
|
303
|
|
304 checkret();
|
|
305 e1 = caddr(e);
|
|
306 if (car(e1)==RINDIRECT) {
|
|
307 gen_indirect_goto(cadr(e1));
|
505
|
308 return ;
|
552
|
309 } else if (car(e1)==RLVAR) {
|
551
|
310 gen_indirect_goto(e1);
|
|
311 return ;
|
552
|
312 } else if (car(e1)==LVAR||car(e1)==FLABEL) {
|
551
|
313 gen_jmp(cadr(e1));
|
462
|
314 control=0;
|
505
|
315 return ;
|
551
|
316 } else if (car(e1)==CODE) {
|
462
|
317 /* CbC continuation */
|
|
318 // conv->jump_(env);
|
551
|
319 // should be separate function
|
462
|
320 e2 = cadr(e1);
|
|
321 env = caddr(e1);
|
|
322 if (car(e2) == FNAME) {
|
|
323 nptr0=(NMTBL *)cadr(e2);
|
|
324 if (nptr0->sc==EMPTY)
|
|
325 nptr0->sc = EXTRN1;
|
|
326 else if(nptr0->sc==FUNCTION)
|
|
327 nptr0->sc = CODE;
|
|
328 if (nptr0->ty>0&&car(nptr0->ty)==FUNCTION)
|
|
329 car(nptr0->ty)=CODE;
|
|
330 }
|
|
331 gexpr(list3(CODE,e1,env),0);
|
|
332 control=0;
|
|
333 // conv->sm_();
|
505
|
334 return ;
|
551
|
335 } else {
|
|
336 error(-1);
|
462
|
337 }
|
|
338 }
|
|
339
|
|
340
|
|
341 #if ASM_CODE
|
|
342 extern void
|
|
343 st_asm(int e1){
|
|
344 checkret();
|
|
345 g_expr_u(list3(ASM,caddr(e1),cadddr(e1)));
|
|
346 }
|
|
347 #endif
|
|
348
|
|
349
|
|
350 extern void
|
|
351 st_label(int e1){
|
551
|
352 int lb = caddr(e1);
|
462
|
353 control=1;
|
|
354 checkret();
|
551
|
355 if (car(lb)==LVAR) { // label variable case
|
|
356 } else if (car(lb)!=FLABEL) error(-1);
|
|
357 fwddef(cadr(lb));
|
462
|
358 }
|
|
359
|
|
360 extern void
|
|
361 st_comment(int e1){
|
|
362 gen_comment((char *)caddr(e1));
|
|
363 }
|
|
364
|
|
365 /*
|
|
366 partial evaluator
|
|
367 */
|
|
368
|
|
369 static int
|
463
|
370 p_vartable(int e,int adisp,int ldisp)
|
462
|
371 {
|
464
|
372 int i;
|
505
|
373 int pvartable = getfree(adisp-ldisp); // have to be local heap
|
509
|
374 pdisp = pvartable-ldisp;
|
|
375 for(i=ldisp;i<0;i++) {
|
|
376 heap[pdisp+i] = 0;
|
463
|
377 }
|
505
|
378 return pvartable;
|
462
|
379 }
|
|
380
|
|
381 static int
|
|
382 p_lvar(int e1)
|
|
383 {
|
463
|
384 int sz = is_memory(e1);
|
|
385 int d = cadr(e1);
|
527
|
386 int d1,e;
|
502
|
387 if ((d1=(heap[pdisp+d]))) return d1;
|
527
|
388 e = heap[pdisp+d]=list3(LVAR,new_lvar(sz),0);
|
|
389 inline_lvars = glist2(e,inline_lvars);
|
|
390 return e;
|
462
|
391 }
|
|
392
|
|
393 static int
|
|
394 pfunction(int e)
|
|
395 {
|
501
|
396 // list4(INLINE,e1,arglist,ftype);
|
|
397 // include code segement case
|
|
398 int e1 = pexpr(cadr(e));
|
|
399 int arglist = caddr(e);
|
|
400 int newargs = 0;
|
|
401 int ftype = cadddr(e);
|
|
402 int e3;
|
|
403 for (e3 = arglist; e3; e3 = cadr(e3)) {
|
514
|
404 newargs = list3( pexpr(car(e3)), newargs, caddr(e3));
|
501
|
405 }
|
|
406 newargs = reverse0(newargs);
|
513
|
407 return list4(car(e),e1,newargs,ftype);
|
462
|
408 }
|
|
409
|
|
410 static int
|
|
411 prindirect(int e)
|
|
412 {
|
525
|
413 int lvar;
|
533
|
414 int offset = caddr(e);
|
530
|
415 if (car(lvar=cadr(e))==IVAR) {
|
525
|
416 lvar=p_lvar(cadr(e)); // can be anything....
|
530
|
417 switch(car(lvar)) {
|
|
418 case LVAR:
|
533
|
419 if(offset) {
|
|
420 return list3(car(e),lvar,offset);
|
|
421 }
|
530
|
422 return rvalue_t(lvar,cadddr(e));
|
|
423 case REGISTER: case DREGISTER:
|
|
424 case FREGISTER: case LREGISTER:
|
|
425 case CONST: case FCONST: case DCONST: case LCONST:
|
|
426 // should do type check
|
533
|
427 if (offset) error(-1);
|
530
|
428 return lvar;
|
|
429 }
|
512
|
430 }
|
533
|
431 return list3(car(e),pexpr(cadr(e)),offset);
|
462
|
432 }
|
|
433
|
|
434 static int
|
527
|
435 pindirect(int e)
|
|
436 {
|
553
|
437 //int lvar;
|
|
438 //if (car(lvar=cadr(e))==IVAR)
|
|
439 // lvar=p_lvar(cadr(e)); // can be anything....
|
527
|
440 return list3(car(e),pexpr(cadr(e)),caddr(e));
|
|
441 }
|
|
442
|
|
443 static int
|
462
|
444 paddress(int e)
|
|
445 {
|
501
|
446 return list2(car(e),pexpr(cadr(e)));
|
462
|
447 }
|
|
448
|
|
449 static int
|
464
|
450 p_conv(int e1,int e2)
|
462
|
451 {
|
527
|
452 return list3(CONV,pexpr(e2),e1);
|
462
|
453 }
|
|
454
|
|
455 static int
|
464
|
456 pbinop(int op,int e1,int e2)
|
462
|
457 {
|
533
|
458 // we should call binop here, but we don't know the type...
|
555
|
459 int e = pexpr(e1);
|
|
460 return list3(op,e,pexpr(e2));
|
462
|
461 }
|
|
462
|
|
463 static int
|
502
|
464 prexpr(int op,int e1,int e2)
|
|
465 {
|
555
|
466 int e = pexpr(e1);
|
|
467 return list3(op,e,pexpr(e2));
|
502
|
468 }
|
|
469
|
|
470 static int
|
526
|
471 plor(int op,int e1,int e2)
|
|
472 {
|
555
|
473 int e = pexpr(e1);
|
|
474 return list3(op,e,pexpr(e2));
|
526
|
475 }
|
|
476
|
|
477 static int
|
|
478 pland(int op,int e1,int e2)
|
|
479 {
|
555
|
480 int e = pexpr(e1);
|
|
481 return list3(op,e,pexpr(e2));
|
526
|
482 }
|
|
483
|
|
484 static int
|
462
|
485 psassign(int e)
|
|
486 {
|
555
|
487 int e1 = pexpr(cadr(e));
|
|
488 int e2 = pexpr(caddr(e));
|
|
489 return list4(car(e),e1,e2,cadddr(e));
|
462
|
490 }
|
|
491
|
|
492 static int
|
|
493 passign(int e)
|
|
494 {
|
555
|
495 int e1 = pexpr(cadr(e));
|
|
496 int e2 = pexpr(caddr(e));
|
|
497 return list3(car(e),e1,e2);
|
462
|
498 }
|
|
499
|
|
500 static int
|
|
501 passop(int e)
|
|
502 {
|
555
|
503 int e1 = pexpr(cadr(e));
|
|
504 int e2 = pexpr(caddr(e));
|
|
505 return list4(car(e),e1,e2,cadddr(e));
|
462
|
506 }
|
|
507
|
|
508 static int
|
|
509 pdassign(int e)
|
|
510 {
|
555
|
511 int e1 = pexpr(cadr(e));
|
|
512 int e2 = pexpr(caddr(e));
|
|
513 return list3(car(e),e1,e2);
|
462
|
514 }
|
|
515
|
|
516 static int
|
|
517 pdassop(int e)
|
|
518 {
|
555
|
519 int e1 = pexpr(cadr(e));
|
|
520 int e2 = pexpr(caddr(e));
|
|
521 return list4(car(e),e1,e2,cadddr(e));
|
462
|
522 }
|
|
523
|
|
524 static int
|
|
525 plassign(int e)
|
|
526 {
|
555
|
527 int e1 = pexpr(cadr(e));
|
|
528 int e2 = pexpr(caddr(e));
|
|
529 return list3(car(e),e1,e2);
|
462
|
530 }
|
|
531
|
|
532 static int
|
|
533 plassop(int e)
|
|
534 {
|
555
|
535 int e1 = pexpr(cadr(e));
|
|
536 int e2 = pexpr(caddr(e));
|
|
537 return list4(car(e),e1,e2,cadddr(e));
|
462
|
538 }
|
|
539
|
|
540 static int
|
|
541 palloc(int e)
|
|
542 {
|
501
|
543 return list2(car(e),pexpr(cadr(e)));
|
462
|
544 }
|
|
545
|
|
546 static int
|
464
|
547 pcomma(int e1,int e2)
|
462
|
548 {
|
556
|
549 int e = pexpr(e1);
|
555
|
550 return list3(COMMA,e,pexpr(e2));
|
462
|
551 }
|
|
552
|
|
553 static int
|
|
554 prbit_field(int e)
|
|
555 {
|
501
|
556 return list3(car(e),pexpr(cadr(e)),caddr(e));
|
462
|
557 }
|
|
558
|
|
559 static int
|
|
560 pbassign(int e)
|
|
561 {
|
553
|
562 // list4(BASS,e1,e2,list2(BASS,t)));
|
|
563 int e1=pexpr(caddr(e));
|
|
564 return list4(car(e),pexpr(cadr(e)),e1,cadddr(e));
|
462
|
565 }
|
|
566
|
|
567 static int
|
|
568 pbassop(int e)
|
|
569 {
|
553
|
570 int e1=pexpr(caddr(e));
|
|
571 return list4(car(e),pexpr(cadr(e)),e1,cadddr(e));
|
462
|
572 }
|
|
573
|
|
574 static int
|
|
575 p_decl(int e)
|
|
576 {
|
552
|
577 // list4(ST_DECL,parse,(int)n,list3(mode,stmode,ctmode));
|
554
|
578 int ctmode=cadddr(e);
|
463
|
579 NMTBL *n=(NMTBL*)caddr(e);
|
|
580 int dsp = n->dsp;
|
|
581 int v;
|
552
|
582 int sstmode = stmode;
|
|
583 int smode = mode;
|
500
|
584 // in real partial evaluation, we have to check whether this variable
|
|
585 // is used or not.
|
552
|
586 if (ctmode) {
|
|
587 mode = car(ctmode); stmode = cadr(ctmode); ctmode = caddr(ctmode);
|
|
588 }
|
463
|
589 switch(stmode) {
|
528
|
590 case EXTRN: case EXTRN1: case STATIC:
|
552
|
591 // def(n,ctmode); we don't need this. already done.
|
|
592 // stmode = sstmode;
|
|
593 stmode = sstmode;
|
|
594 mode = smode;
|
|
595 return pexpr(cadr(e));
|
|
596 // case LLDECL: LLDECL is mode, not stmode (bad design)
|
|
597 // v = list2(FLABEL,fwdlabel()); break;
|
529
|
598 #if 1
|
463
|
599 case REGISTER:
|
|
600 switch(n->ty) {
|
|
601 case ULONGLONG: case LONGLONG:
|
|
602 v = get_lregister_var(n); break;
|
|
603 case FLOAT:
|
|
604 v = get_dregister_var(n,0); break;
|
|
605 case DOUBLE:
|
|
606 v = get_dregister_var(n,1); break;
|
|
607 default:
|
|
608 if (scalar(n->ty))
|
524
|
609 v = get_register_var(n);
|
463
|
610 else
|
|
611 error(TYERR);
|
|
612 }
|
529
|
613 break;
|
528
|
614 #endif
|
463
|
615 default:
|
552
|
616 if (n->sc==FLABEL)
|
|
617 v = list3(LVAR,fwdlabel(),(int)n);
|
|
618 else
|
|
619 v = list3(LVAR,new_lvar(size(n->ty)),(int)n);
|
463
|
620 }
|
552
|
621 if (n->sc!=FLABEL)
|
|
622 inline_lvars = glist2(v,inline_lvars);
|
463
|
623 if (heap[pdisp+dsp]) error(-1);
|
|
624 heap[pdisp+dsp]=v;
|
552
|
625 stmode = sstmode;
|
|
626 mode = smode;
|
463
|
627 return pexpr(cadr(e));
|
462
|
628 }
|
|
629
|
|
630 static int
|
500
|
631 p_if(int e1)
|
462
|
632 {
|
500
|
633 int cond,l1,l2;
|
|
634 int e2=caddr(e1),e3;
|
|
635 cond = pexpr(car(e2));
|
|
636 // conv->if_then_();
|
|
637 l1 = pexpr(cadr(e2));
|
|
638 if ((e3=caddr(e2))) { // else
|
|
639 l2 = pexpr(e3);
|
|
640 } else {
|
|
641 l2 = 0;
|
|
642 }
|
|
643 return list3(ST_IF,pexpr(cadr(e1)),list3(cond,l1,l2));
|
462
|
644 }
|
|
645
|
|
646 static int
|
|
647 p_do(int e)
|
|
648 {
|
524
|
649 int e2 = pexpr(caddr(e));
|
|
650 int e3 = pexpr(cadddr(e));
|
|
651 return list4(ST_DO,pexpr(cadr(e)),e2,e3);
|
462
|
652 }
|
|
653
|
|
654 static int
|
|
655 p_while(int e)
|
|
656 {
|
524
|
657 int e2 = pexpr(caddr(e));
|
|
658 int e3 = pexpr(cadddr(e));
|
|
659 return list4(ST_WHILE,pexpr(cadr(e)),e2,e3);
|
462
|
660 }
|
|
661
|
|
662 static int
|
|
663 p_for(int e)
|
|
664 {
|
501
|
665 int e1=caddr(e);
|
524
|
666 int p0=pexpr(car(e1));
|
|
667 int p1=pexpr(cadr(e1));
|
|
668 int p2=pexpr(caddr(e1));
|
|
669 int p3=pexpr(cadddr(e1));
|
|
670 return list3(ST_FOR,pexpr(cadr(e)), list4(p0,p1,p2,p3));
|
462
|
671 }
|
|
672
|
|
673 static int
|
|
674 p_switch(int e)
|
|
675 {
|
524
|
676 int e2 = pexpr(caddr(e));
|
|
677 int e3 = pexpr(cadddr(e));
|
|
678 return list4(ST_SWITCH,pexpr(cadr(e)),e2,e3);
|
462
|
679 }
|
|
680
|
|
681 static int
|
|
682 p_comp(int e)
|
|
683 {
|
524
|
684 int e1=pexpr(caddr(e));
|
|
685 return list3(ST_COMP,pexpr(cadr(e)),e1);
|
462
|
686 }
|
|
687
|
|
688 static int
|
|
689 p_break(int e)
|
|
690 {
|
502
|
691 return list2(ST_BREAK,pexpr(cadr(e)));
|
462
|
692 }
|
|
693
|
|
694 static int
|
|
695 p_continue(int e)
|
|
696 {
|
502
|
697 return list2(ST_CONTINUE,pexpr(cadr(e)));
|
462
|
698 }
|
|
699
|
|
700 static int
|
|
701 p_case(int e)
|
|
702 {
|
506
|
703 int new=0,clist = caddr(e);
|
|
704 // insert destory clist, we have to copy it now
|
|
705 for(;clist;clist=cadr(clist))
|
|
706 new=glist3(car(clist),new,0);
|
|
707 return list3(ST_CASE,pexpr(cadr(e)),reverse0(new));
|
462
|
708 }
|
|
709
|
|
710 static int
|
|
711 p_default(int e)
|
|
712 {
|
502
|
713 return list2(ST_DEFAULT,pexpr(cadr(e)));
|
462
|
714 }
|
|
715
|
|
716 static int
|
|
717 p_return(int e)
|
|
718 {
|
524
|
719 int e1=pexpr(caddr(e));
|
|
720 return list3(ST_RETURN,pexpr(cadr(e)),e1);
|
462
|
721 }
|
|
722
|
|
723 static int
|
|
724 p_goto(int e)
|
|
725 {
|
555
|
726 int e1,lb,e2;
|
501
|
727 if ((e1=caddr(e))) {
|
|
728 switch(car(e1)) {
|
|
729 case RINDIRECT: e1=pexpr(e1); break;
|
555
|
730 case CODE: e2=pexpr(cadr(e1));
|
|
731 e1=list3(CODE,e2,pexpr(caddr(e1))); break;
|
551
|
732 case FLABEL: /* error(-1); */ break;
|
|
733 case IVAR:
|
|
734 lb = cadr(e1);
|
|
735 if (!(e1=heap[pdisp+lb])) {
|
|
736 e1 = heap[pdisp+lb]=list2(FLABEL,fwdlabel());
|
|
737 }
|
501
|
738 }
|
|
739 }
|
502
|
740 return list3(ST_GOTO,pexpr(cadr(e)),e1);
|
501
|
741 }
|
|
742
|
|
743 static int
|
|
744 p_list_expr(int e)
|
|
745 {
|
|
746 int e3,new = 0;
|
|
747 for (e3 = e; e3; e3 = cadr(e3)) {
|
|
748 new= list2( pexpr(car(e3)), new);
|
|
749 }
|
|
750 return reverse0(new);
|
462
|
751 }
|
|
752
|
|
753 static int
|
|
754 p_asm(int e)
|
|
755 {
|
501
|
756 int param=caddr(e);
|
|
757 int e1 = p_list_expr(cadddr(e));
|
|
758 return list4(ST_ASM,pexpr(cadr(e)),param,e1);
|
462
|
759 }
|
|
760
|
|
761 static int
|
|
762 p_label(int e)
|
|
763 {
|
551
|
764 int e1,lb;
|
|
765 if ((e1=caddr(e))) {
|
|
766 switch(car(e1)) {
|
|
767 case FLABEL: /* error(-1); */ break;
|
|
768 case IVAR:
|
|
769 lb = cadr(e1);
|
|
770 if (!(e1=heap[pdisp+lb])) {
|
|
771 e1 = heap[pdisp+lb]=list2(FLABEL,fwdlabel());
|
|
772 }
|
|
773 }
|
|
774 }
|
|
775 return list3(ST_LABEL,pexpr(cadr(e)),e1);
|
|
776 }
|
|
777
|
|
778 static int
|
|
779 p_label_var(int e)
|
|
780 {
|
|
781 int d,e1;
|
|
782 switch(car(e1=e)) {
|
|
783 case LVAR: /* error(-1) */ break;
|
|
784 case IVAR:
|
|
785 // should this done in p_decl? (in __label__?)
|
|
786 d = cadr(e);
|
|
787 if (!(e1=(heap[pdisp+d]))) {
|
552
|
788 // error(-1);
|
551
|
789 e1 = heap[pdisp+d]=list3(LVAR,fwdlabel(),caddr(e));
|
|
790 }
|
|
791 }
|
|
792 return list2(LABEL,e1);
|
462
|
793 }
|
|
794
|
|
795 static int
|
|
796 p_bool(int e)
|
|
797 {
|
501
|
798 error(-1);
|
464
|
799 return e;
|
|
800 }
|
462
|
801
|
464
|
802 static int
|
|
803 p_comment(int e)
|
|
804 {
|
501
|
805 return list3(ST_COMMENT,pexpr(cadr(e)),caddr(e));
|
462
|
806 }
|
|
807
|
508
|
808 static int
|
512
|
809 p_inline(int e)
|
508
|
810 {
|
|
811 int e3;
|
|
812 int narg;
|
|
813
|
|
814 /* inline function arguments */
|
|
815 narg = 0;
|
|
816 for (e3 = caddr(e); e3; e3 = cadr(e3)) {
|
|
817 narg=list3(pexpr(car(e3)),narg,caddr(e3));
|
|
818 }
|
|
819 return list4(INLINE,cadr(e),reverse0(narg),cadddr(e));
|
|
820 }
|
|
821
|
463
|
822 extern int
|
|
823 pexpr(int e1)
|
462
|
824 {
|
|
825 int e2,e3;
|
|
826
|
463
|
827 // if (inmode) error(-1);
|
502
|
828 if (e1==0) return 0;
|
462
|
829 e2 = cadr(e1);
|
|
830 switch (car(e1)){
|
|
831 case GVAR: case RGVAR: case CRGVAR: case CURGVAR: case SRGVAR:
|
|
832 case SURGVAR: case REGISTER:
|
|
833 case DREGISTER: case FREGISTER:
|
500
|
834 case FRGVAR: case DRGVAR:
|
462
|
835 case LREGISTER:
|
500
|
836 case LRGVAR: case LURGVAR:
|
551
|
837 case CONST:
|
462
|
838 case DCONST: case FCONST:
|
|
839 case LCONST:
|
|
840 case STRING:
|
|
841 case FNAME:
|
503
|
842 case FLABEL:
|
462
|
843 return e1;
|
551
|
844 case RSTRUCT:
|
|
845 // list3(RSTRUCT,e,size)
|
|
846 return pexpr(e2);
|
|
847 case LABEL:
|
|
848 return p_label_var(e2);
|
462
|
849 case LVAR:
|
|
850 case RLVAR: case CRLVAR: case CURLVAR: case SRLVAR: case SURLVAR:
|
500
|
851 case FRLVAR: case DRLVAR:
|
|
852 case LRLVAR: case LURLVAR:
|
|
853 return e1;
|
|
854 case IVAR:
|
462
|
855 return p_lvar(e1);
|
|
856 case FUNCTION:
|
|
857 return pfunction(e1);
|
|
858 case CODE:
|
463
|
859 return list2(car(e1),pexpr(e2));
|
462
|
860 case INLINE:
|
512
|
861 return p_inline(e1);
|
462
|
862 case INDIRECT:
|
527
|
863 return pindirect(e1);
|
462
|
864 case RINDIRECT: case URINDIRECT:
|
|
865 case CRINDIRECT: case CURINDIRECT:
|
|
866 case SRINDIRECT: case SURINDIRECT:
|
|
867 case FRINDIRECT: case DRINDIRECT:
|
|
868 case LRINDIRECT: case LURINDIRECT:
|
|
869 return prindirect(e1);
|
|
870 case ADDRESS:
|
502
|
871 return paddress(e1);
|
462
|
872 case MINUS:
|
463
|
873 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
874 if (car(e3)==CONST) return list2(CONST,-cadr(e3));
|
|
875 return list2(car(e1),e3);
|
|
876 #if LONGLONG_CODE
|
|
877 case LMINUS:
|
463
|
878 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
879 if (car(e3)==LCONST) return llist2(LCONST,-lcadr(e3));
|
|
880 return list2(car(e1),e3);
|
|
881 #endif
|
|
882 #if FLOAT_CODE
|
|
883 case DMINUS:
|
463
|
884 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
885 if (car(e3)==DCONST) return dlist2(DCONST,-dcadr(e3));
|
|
886 if (car(e3)==FCONST) return dlist2(FCONST,-dcadr(e3));
|
|
887 return list2(car(e1),e3);
|
|
888 case FMINUS:
|
463
|
889 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
890 if (car(e3)==DCONST) return dlist2(DCONST,-dcadr(e3));
|
|
891 if (car(e3)==FCONST) return dlist2(FCONST,-dcadr(e3));
|
|
892 return list2(car(e1),e3);
|
|
893 #endif
|
|
894 case CONV:
|
501
|
895 return p_conv(caddr(e1),e2);
|
462
|
896 case BNOT: /* ~ */
|
463
|
897 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
898 if (car(e3)==CONST) return list2(CONST,~cadr(e3));
|
|
899 return list2(BNOT,e3);
|
|
900 case LNOT: /* ! */
|
463
|
901 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
902 if (car(e3)==CONST) return list2(CONST,!cadr(e3));
|
|
903 return list2(LNOT,e3);
|
|
904 case PREINC:
|
|
905 case UPREINC:
|
463
|
906 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
907 if (car(e3)==CONST) return list2(CONST,cadr(e3)+1);
|
503
|
908 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
909 case POSTINC:
|
|
910 case UPOSTINC:
|
463
|
911 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
912 if (car(e3)==CONST) return e3;
|
503
|
913 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
914 #if FLOAT_CODE
|
|
915 case DPREINC: /* ++d */
|
463
|
916 if ((e3 = pexpr(e2))==e2) return e1;
|
|
917 if (car(e3)==FCONST) return dlist2(FCONST,dcadr(e3)+cadr(e2));
|
|
918 if (car(e3)==DCONST) return dlist2(DCONST,dcadr(e3)+cadr(e2));
|
503
|
919 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
920 case DPOSTINC: /* d++ */
|
463
|
921 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
922 if (car(e3)==FCONST||car(e3)==DCONST) return e3;
|
503
|
923 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
924 case FPREINC: /* ++f */
|
463
|
925 if ((e3 = pexpr(e2))==e2) return e1;
|
|
926 if (car(e3)==FCONST) return dlist2(FCONST,dcadr(e3)+cadr(e2));
|
|
927 if (car(e3)==DCONST) return dlist2(DCONST,dcadr(e3)+cadr(e2));
|
503
|
928 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
929 case FPOSTINC: /* f++ */
|
463
|
930 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
931 if (car(e3)==FCONST||car(e3)==DCONST) return e3;
|
503
|
932 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
933 #endif
|
|
934 #if LONGLONG_CODE
|
|
935 case LPREINC: /* ++d */
|
|
936 case LUPREINC: /* ++d */
|
463
|
937 if ((e3 = pexpr(e2))==e2) return e1;
|
|
938 if (car(e3)==LCONST) return llist2(LCONST,lcadr(e3)+cadr(e2));
|
503
|
939 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
940 case LPOSTINC: /* d++ */
|
|
941 case LUPOSTINC: /* d++ */
|
463
|
942 if ((e3 = pexpr(e2))==e2) return e1;
|
462
|
943 if (car(e3)==LCONST) return e3;
|
503
|
944 return list4(car(e1),e3,caddr(e1),cadddr(e1));
|
462
|
945 #endif
|
|
946 case MUL: case UMUL:
|
|
947 case DIV: case UDIV:
|
|
948 case MOD: case UMOD:
|
|
949 case LSHIFT: case ULSHIFT: case RSHIFT: case URSHIFT:
|
|
950 case ADD: case SUB: case BAND: case EOR: case BOR: case CMP: case CMPGE:
|
|
951 case UCMP: case CMPEQ: case CMPNEQ: case UCMPGE:
|
|
952 #if FLOAT_CODE
|
|
953 case DMUL: case DDIV:
|
|
954 case DADD: case DSUB:
|
|
955 case DCMP: case DCMPGE: case DCMPEQ: case DCMPNEQ:
|
|
956 case FMUL: case FDIV:
|
|
957 case FADD: case FSUB:
|
|
958 case FCMP: case FCMPGE: case FCMPEQ: case FCMPNEQ:
|
|
959 #endif
|
|
960 #if LONGLONG_CODE
|
|
961 case LMUL: case LUMUL:
|
|
962 case LDIV: case LUDIV:
|
|
963 case LMOD: case LUMOD:
|
|
964 case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
|
|
965 case LADD: case LSUB: case LBAND: case LEOR: case LBOR: case LCMP:
|
|
966 #endif
|
501
|
967 return pbinop(car(e1),e2,caddr(e1));
|
528
|
968 case LCOND: case DCOND: case FCOND: case COND: case UCOND: case LUCOND:
|
555
|
969 e2 = pexpr(e2);
|
|
970 if (car(e2)==CONST) return
|
|
971 caddr(e1)? pexpr(cadr(e2)?caddr(e1):cadddr(e1)) :
|
|
972 pexpr(cadr(e2)?e2:cadddr(e1)); // GNU extension h?:g
|
|
973 e3=pexpr(caddr(e1));
|
|
974 return list4(car(e1),e2,e3,pexpr(cadddr(e1)));
|
462
|
975 case STASS:
|
|
976 return psassign(e1);
|
|
977 case ASS: case CASS: case SASS:
|
|
978 return passign(e1);
|
|
979 case SASSOP: case SUASSOP:
|
|
980 case ASSOP: case CASSOP: case CUASSOP:
|
|
981 return passop(e1);
|
|
982 #if FLOAT_CODE
|
|
983 case FASS: case DASS:
|
|
984 return pdassign(e1);
|
|
985 case DASSOP: case FASSOP:
|
|
986 return pdassop(e1);
|
|
987 #endif
|
|
988 #if LONGLONG_CODE
|
|
989 case LASS:
|
|
990 return plassign(e1);
|
|
991 case LASSOP: case LUASSOP:
|
|
992 return plassop(e1);
|
|
993 #endif
|
|
994 case ALLOCA:
|
501
|
995 return palloc(e2);
|
462
|
996 case BUILTINP:
|
463
|
997 return list2(CONST,is_const(pexpr(e2)));
|
462
|
998 case COMMA:
|
555
|
999 return pcomma(e2,caddr(e1));
|
462
|
1000 case RETURN:
|
|
1001 case ENVIRONMENT:
|
|
1002 case LCALL:
|
|
1003 return e1;
|
502
|
1004 // relational operator
|
|
1005 case GT: case UGT: case GE: case UGE: case LT:
|
|
1006 case ULT: case LE: case ULE:
|
526
|
1007 case LOP+GT: case LOP+UGT: case LOP+GE: case LOP+UGE: case LOP+LT:
|
|
1008 case LOP+ULT: case LOP+LE: case LOP+ULE:
|
502
|
1009 case DOP+GT: case DOP+GE: case DOP+LT: case DOP+LE:
|
|
1010 case FOP+GT: case FOP+GE: case FOP+LT: case FOP+LE:
|
|
1011 case FOP+EQ: case FOP+NEQ:
|
|
1012 case EQ: case NEQ: case DOP+EQ: case DOP+NEQ:
|
526
|
1013 case LOP+EQ: case LOP+NEQ:
|
502
|
1014 return prexpr(car(e1),cadr(e1),caddr(e1));
|
526
|
1015 case LAND:
|
|
1016 return pland(car(e1),cadr(e1),caddr(e1));
|
|
1017 case LOR:
|
|
1018 return plor(car(e1),cadr(e1),caddr(e1));
|
462
|
1019 #if BIT_FIELD_CODE
|
|
1020 case RBIT_FIELD:
|
|
1021 return prbit_field(e1);
|
553
|
1022 case BIT_FIELD:
|
|
1023 return list3(BIT_FIELD,pexpr(e2),caddr(e1));
|
462
|
1024 case BASS:
|
|
1025 return pbassign(e1);
|
|
1026 case BPREINC:
|
|
1027 case BPOSTINC:
|
|
1028 case BASSOP:
|
|
1029 return pbassop(e1);
|
|
1030 #endif
|
|
1031 #if ASM_CODE
|
|
1032 case ASM:
|
|
1033 return list3(ASM,list4(
|
501
|
1034 car(e2),cadr(e2),caddr(e2),cadddr(e2)),
|
|
1035 caddr(e1));
|
462
|
1036 #endif
|
|
1037 case ST_DECL: return p_decl(e1);
|
|
1038 case ST_IF: return p_if(e1);
|
|
1039 case ST_DO: return p_do(e1);
|
|
1040 case ST_WHILE: return p_while(e1);
|
|
1041 case ST_FOR: return p_for(e1);
|
|
1042 case ST_SWITCH: return p_switch(e1);
|
|
1043 case ST_COMP: return p_comp(e1);
|
|
1044 case ST_BREAK: return p_break(e1);
|
|
1045 case ST_CONTINUE: return p_continue(e1);
|
|
1046 case ST_CASE: return p_case(e1);
|
|
1047 case ST_DEFAULT: return p_default(e1);
|
|
1048 case ST_RETURN: return p_return(e1);
|
|
1049 case ST_GOTO: return p_goto(e1);
|
|
1050 case ST_ASM: return p_asm(e1);
|
|
1051 case ST_LABEL: return p_label(e1);
|
|
1052 case ST_COMMENT: return p_comment(e1);
|
|
1053 default:
|
551
|
1054 error(-1);
|
462
|
1055 return p_bool(e1);
|
|
1056 }
|
|
1057 return VOID;
|
|
1058 }
|
|
1059
|
463
|
1060 #define round4(i) ((i+(SIZE_OF_INT-1))&~(SIZE_OF_INT-1))
|
|
1061
|
531
|
1062 // extern int lreg_count;
|
530
|
1063
|
463
|
1064 extern int
|
|
1065 gen_inline(int e)
|
462
|
1066 {
|
514
|
1067 // these saved value should be some struct
|
|
1068 int sretlabel;
|
|
1069 NMTBL *sfnptr;
|
552
|
1070 int svartable;
|
|
1071 int sretcont;
|
513
|
1072 int scslabel = cslabel;
|
463
|
1073 int sdisp = pdisp;
|
552
|
1074 int sret_register;
|
|
1075 int sret_reg_mode;
|
|
1076 int sinline_lvars;
|
|
1077 int slfree;
|
531
|
1078 // int slreg_count=lreg_count;
|
513
|
1079
|
463
|
1080 int narg,arg;
|
|
1081 NMTBL *n = (NMTBL*)cadr(cadr(e));
|
|
1082 int e1 = attr_value(n,INLINE);
|
500
|
1083 int parse = car(e1); // inline parse tree
|
519
|
1084 int arg_disp = cadr(e1); // number of arguments
|
552
|
1085 NMTBL *local_statics = (NMTBL*)cadddr(e1); // local static list
|
|
1086 int e2,e3,t,e4,e5,dots;
|
508
|
1087 int ret_type = function_type(cadddr(e),&dots);
|
526
|
1088 int fargtype;
|
555
|
1089 int evals = 0;
|
526
|
1090 NMTBL *anptr;
|
463
|
1091
|
552
|
1092 checkret();
|
|
1093 checkjmp(-1);
|
|
1094
|
|
1095 svartable = pvartable;
|
|
1096 sretcont = retcont;
|
|
1097 scslabel = cslabel;
|
|
1098 sdisp = pdisp;
|
|
1099 sret_register = ret_register;
|
|
1100 sret_reg_mode = ret_reg_mode;
|
|
1101 sinline_lvars = inline_lvars;
|
|
1102 slfree=lfree;
|
|
1103 // int slreg_count=lreg_count;
|
514
|
1104
|
|
1105 sretlabel = retlabel;
|
|
1106 sfnptr = fnptr;
|
513
|
1107 retcont = 0;
|
|
1108 cslabel = -1;
|
|
1109 retpending = 0;
|
514
|
1110 ret_reg_mode = 0;
|
|
1111 ret_register = 5555;
|
527
|
1112 inline_lvars = 0;
|
514
|
1113 retlabel = fwdlabel();
|
513
|
1114
|
511
|
1115 enter_scope(); // to make label scope happy
|
|
1116
|
510
|
1117 fnptr = n; // st_return see this
|
503
|
1118 pvartable = p_vartable(e,arg_disp,caddr(e1));
|
526
|
1119
|
|
1120 /* function arguments type */
|
|
1121 fargtype = n->dsp; // we cannot do destruct reverse here
|
|
1122
|
463
|
1123 /* inline function arguments */
|
|
1124 narg = 0;
|
552
|
1125 if (!fargtype) {
|
|
1126 goto no_args; // wrong number of arguments
|
|
1127 }
|
|
1128 for (e3 = e5 = reverse0(caddr(e)); e3; e3 = cadr(e3)) {
|
526
|
1129 anptr = (NMTBL*)caddr(fargtype);
|
552
|
1130 if (!anptr) break; // should not happen?
|
500
|
1131 t=caddr(e3); // type
|
|
1132 e4 = car(e3);
|
556
|
1133 if ((has_attr(anptr,KONST) && !has_attr(anptr,HAS_ADDRESS)&&
|
|
1134 (is_const(e4) || (0 && is_memory(e4))))) {
|
|
1135 if (is_memory(e4))
|
|
1136 heap[pdisp+narg]=rvalue_t(e4,t);
|
|
1137 else
|
|
1138 heap[pdisp+narg]=e4;
|
463
|
1139 } else {
|
509
|
1140 arg = heap[pdisp+narg]=list3(LVAR,new_lvar(size(t)),0);
|
527
|
1141 inline_lvars = glist2(arg,inline_lvars);
|
509
|
1142 // should contain correct argument variable name
|
529
|
1143 // if (anptr) printf("## var %s\n",anptr->nm);
|
|
1144 // else printf("## var 0\n");
|
555
|
1145 if (eval_order==REVERSE) {
|
|
1146 evals=list2(assign_expr0(arg,e4,anptr->ty,t),evals);
|
|
1147 } else
|
|
1148 g_expr_u(assign_expr0(arg,e4,anptr->ty,t));
|
463
|
1149 }
|
500
|
1150 narg ++;
|
526
|
1151 fargtype = cadr(fargtype);
|
463
|
1152 }
|
552
|
1153 caddr(e) = reverse0(e5); // make it normal
|
555
|
1154 if (eval_order==REVERSE) {
|
|
1155 for(;evals;evals=cadr(evals)) {
|
|
1156 g_expr_u(car(evals));
|
|
1157 }
|
|
1158 }
|
552
|
1159 no_args:
|
511
|
1160 e2 = pexpr(parse);
|
463
|
1161 pdisp = sdisp;
|
464
|
1162 pvartable = svartable;
|
513
|
1163
|
|
1164 if (ret_type!=VOID)
|
|
1165 g_expr0(e2);
|
|
1166 else
|
|
1167 g_expr_u(e2);
|
524
|
1168 checkret();
|
513
|
1169 fwddef(retlabel);
|
514
|
1170 control=1;
|
513
|
1171
|
|
1172 if (retcont) error(STERR); // inline can't handle return/environment
|
510
|
1173
|
511
|
1174 leave_scope();
|
552
|
1175 if (local_statics && local_statics != &null_nptr) {
|
|
1176 // append our local static variables to the parent list
|
|
1177 n = local_statics;
|
|
1178 while(n->next != &null_nptr) n=n->next;
|
|
1179 n->next = local_static_list; local_static_list = local_statics;
|
|
1180 cadddr(e1) = 0; // prevent duplicate initialize
|
|
1181 }
|
527
|
1182 while(inline_lvars) {
|
|
1183 int e;
|
|
1184 int l = car(inline_lvars);
|
|
1185 switch(car(l)) {
|
|
1186 case LVAR: free_lvar(cadr(l)); break;
|
|
1187 case REGISTER: case DREGISTER:
|
|
1188 case FREGISTER: case LREGISTER:
|
|
1189 free_register(cadr(l));
|
|
1190 }
|
|
1191 e = cadr(inline_lvars);
|
|
1192 free_glist2(inline_lvars);
|
|
1193 inline_lvars = e;
|
|
1194 }
|
513
|
1195 fnptr = sfnptr;
|
|
1196 retlabel = sretlabel;
|
|
1197 retcont = sretcont;
|
|
1198 cslabel = scslabel;
|
514
|
1199 ret_register = sret_register;
|
|
1200 ret_reg_mode = sret_reg_mode;
|
527
|
1201 inline_lvars = sinline_lvars;
|
528
|
1202 lfree=slfree;
|
513
|
1203
|
531
|
1204 // if (slreg_count!=lreg_count && lreg_count>0) {
|
|
1205 // printf("## lreg_count %d != %d\n", slreg_count,lreg_count);
|
|
1206 // }
|
530
|
1207
|
508
|
1208 return ret_type;
|
462
|
1209 }
|
|
1210
|
|
1211 /* end */
|