changeset 7:e2c2c0fe0785

function type definition should be in global heap
author kono
date Fri, 14 Jan 2000 09:55:24 +0900
parents bf602558130d
children e714bcee688b
files .gdbinit Idea mc-nop-386.c mc-parse.c test/fact.c
diffstat 5 files changed, 29 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/.gdbinit	Thu Jan 13 13:41:09 2000 +0900
+++ b/.gdbinit	Fri Jan 14 09:55:24 2000 +0900
@@ -1,4 +1,4 @@
 tb main
 b error
 b errmsg
-r -s test/fact-a.c
+r -s test/tmp7.c
--- a/Idea	Thu Jan 13 13:41:09 2000 +0900
+++ b/Idea	Fri Jan 14 09:55:24 2000 +0900
@@ -1060,3 +1060,13 @@
 
 だいたいできたけど、test/tmp7.c のprintf のtype mismatch は
 なんなんだろう?  ASNI の副作用だろうなぁ。
+
+これだと、プロセスの切替えのときには、結構な量のデータを
+コピーすることになる。それでもいいんだけど...
+
+それごと、どっかにとって置く。continuationへの参照みたいなもの
+ができないかな。
+
+コピーができれば、environment/return の組は動くわけだから、
+それへの参照と切替えがあっても良いよね。
+
--- a/mc-nop-386.c	Thu Jan 13 13:41:09 2000 +0900
+++ b/mc-nop-386.c	Fri Jan 14 09:55:24 2000 +0900
@@ -494,7 +494,7 @@
 	} 
 	g_expr(e2);
 	emit_push();  
-/* in case of register full we should copy crn to drn */
+    /* in case of register full we should copy crn to drn */
 	xrn = emit_pop(0);
 	printf("\tmovl (%s),%s\n",xrn,crn);
 	printf("\taddl $%d,(%s)\n",caddr(e1),xrn);
@@ -819,7 +819,6 @@
 	emit_push();
     }
     /* compute arguments in reverse order */
-/* printf("# jump code_arg_offset=%d code_disp_offset=%d\n",code_arg_offset,code_disp_offset); */
     regs = 0;
     i=MAX_REGISTER_VAR;
     for (e3=nargs; e3;e3 =cadr(e3)) {
@@ -836,7 +835,6 @@
 	case RLVAR:
 	case CRLVAR:
 	    if (env==0 && fnptr->sc==CODE) {
-/* printf("# e5=%d car(e3)=%d\n",e5,car(e3)); */
 		if (e5>=0 && e5==car(e3)) {
 		/* The same positioned local variable. No need to copy */
 		    reg_stack[reg_sp++] = -2;
@@ -847,7 +845,6 @@
 	    emit_push();
 	    break;
 	case REGISTER:
-/* printf("# i=%d rname[e5]=%d\n",i,rname[e5]); */
 	    if (i>0 && rname[e5]==REG_ESI+ --i) {
 		/* The same register variable. No need to copy */
 		reg_stack[reg_sp++] = e5;
@@ -868,7 +865,6 @@
     } 
     /* force lvar offset mode to CODE */
     scode = fnptr->sc; fnptr->sc = CODE;
-/* printf("# jump2 code_arg_offset=%d code_disp_offset=%d\n",code_arg_offset,code_disp_offset); */
     /* copy arguments to destination environment if necessary */
     nargs = reverse0(nargs); /* pop in normal order */
     i=0;
@@ -1309,7 +1305,6 @@
     if(disp0) {
 	printf("\tsubl $%d,%%esp\n",-disp0);
     }
-printf("# args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset); 
 }
 
 void
--- a/mc-parse.c	Thu Jan 13 13:41:09 2000 +0900
+++ b/mc-parse.c	Fri Jan 14 09:55:24 2000 +0900
@@ -175,12 +175,6 @@
 	    newfile();
 	    return;
 	} else if(mode == TOP) {	
-		/*
-	    if (!chk) fprintf(stderr,
-		    "Total internal labels	: %u.\n",labelno-1);
-	    fprintf(stderr,
-		    "Total global variables : %u bytes.\n\n",gpc);
-		 */
 	    closing();
 	    exit(0);
 	}
@@ -289,7 +283,6 @@
 newfile(void)
 {
     lineno=0;
-    /* fprintf(stderr,"%s:\n",av[ac2]); */
     opening(av[ac2]);
     if ( (filep->fcb = fopen(av[ac2++],"r")) == NULL ) error(FILERR);
 }
@@ -543,7 +536,7 @@
 	    if(sym==RPAR) break;
 	} else {
 	    if(sym==DOTS) {
-		rplacad(n->ty,list2(INT,cadr(n->ty)));
+		rplacad(n->ty,glist2(INT,cadr(n->ty)));
 		getsym();
 		break;
 	    } 
@@ -560,7 +553,7 @@
 		    def(arg);
 		}
 	    }
-	    rplacad(n->ty,list2(INT,cadr(n->ty)));
+	    rplacad(n->ty,glist2(INT,cadr(n->ty)));
 	    if(sym==RPAR) break;
 	} 
 	if (sym!=COMMA) error(DCERR); 
@@ -716,7 +709,6 @@
 	    } else
 		error(TYERR);
 	}
-printf("# nptr %s dsp %d args %d\n",nptr->nm?nptr->nm:"null",nptr->dsp,args);
 	return;
     case LDECL:
 	if (stmode==REGISTER && reg_var <=MAX_REGISTER_VAR) {
@@ -991,7 +983,7 @@
 	    error(DCERR);
 	else {
 	    n->sc=FUNCTION;
-	    n->ty=list2(cadr(type),0);
+	    n->ty=glist2(cadr(type),0);
 	}
     }
 }
@@ -1755,7 +1747,7 @@
 	case EMPTY:
 	    if(getsym()==LPAR) {	
 		nptr->sc = FUNCTION;
-		nptr->ty= list2(INT,0);
+		nptr->ty= glist2(INT,0);
 		type= list3(FUNCTION,INT,0);
 		e1=expr15(list2(FNAME,(int)nptr));
 		break;
@@ -2602,6 +2594,17 @@
     return e;
 }
 
+int
+glist2(int e1,int e2)
+{
+    int smode,ret;
+    smode = mode;
+    mode = GDECL;
+    ret = list2(e1,e2);
+    mode = smode;
+    return ret;
+}
+
 display_ntable(NMTBL *n, char *s)
 {
     fprintf(stderr,"\n%s %0x %0x ",s,n,ntable); 
--- a/test/fact.c	Thu Jan 13 13:41:09 2000 +0900
+++ b/test/fact.c	Fri Jan 14 09:55:24 2000 +0900
@@ -30,7 +30,8 @@
 	goto (*exit1)(0),exit1env;
     }
     if (n==0)
-	goto (*print)(n,result,orig,print,exit1,exit1env);
+	goto (*print)(n,result,orig,print,exit1,exit1env); 
+	/* goto print(n,result,orig,print,exit1,exit1env); */
     else {
 	result *= n;
 	n--;