# HG changeset patch # User kono # Date 993706424 -32400 # Node ID fdbf2fbc8140578f5dad1977b955daa62b75edf3 # Parent ca0bce3b48100b0af0761db5ae4ec271e56aa640 *** empty log message *** diff -r ca0bce3b4810 -r fdbf2fbc8140 test/fact0.c --- a/test/fact0.c Mon Jan 17 16:08:16 2000 +0900 +++ b/test/fact0.c Thu Jun 28 14:33:44 2001 +0900 @@ -13,5 +13,5 @@ { if (i==n) return j; - fact(i+1,j*i,n); + /* return */ fact(i+1,j*i,n); } diff -r ca0bce3b4810 -r fdbf2fbc8140 test/test1.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/test1.c Thu Jun 28 14:33:44 2001 +0900 @@ -0,0 +1,112 @@ +#include "stdio.h" + + typedef void *stack; + + struct cont_save { /* General Return Continuation */ + code (*ret)(); + }; + +/* + code g(int,void *); + code f_g0(int ,int ,void *); + code f_g1(int,void *); + */ + + struct f_g0_save { /* Specialized Return Continuation */ + code (*ret)(); + int ii,kk,jj; + }; + + code g(int i,void *sp) { + goto (* ((struct cont_save *)sp)->ret)(i+4,sp); + } + + code f_g1(int j,void *sp) { /* Continuation */ + int k; + struct f_g0_save *c; + + c = sp; + k = c->kk; + sp += sizeof(struct f_g0_save); + goto (* ((struct cont_save *)sp)->ret)(k+4+j,sp); + } + + code f(int i,void *sp) { + int k,j; + struct f_g0_save *c; + printf("f 0 sp: %x\n",sp); + + k = 3+i; + + printf("f 1 sp: %x\n",sp); + sp -= sizeof(struct f_g0_save); + printf("f 2 sp: %x\n",sp); + c = sp; + c->kk = k; + c->ii = i; + c->jj = j; + c->ret = f_g1; + goto g(i,sp); + } + + +void *stack0; + + +struct f0_save { /* Specialized Return Continuation */ + code (*ret)(); + code (*exit1)(); + void *exit1env; + int jj; +}; + +code f0(int i,int j,code(*exit2)(), void *exit2env,void *sp) +{ + struct f0_save *c; + printf("f0 1 sp: %x\n",sp); + sp -= sizeof(struct f0_save); + printf("f0 2 sp: %x\n",sp); + c = sp; + c->jj = j; + c->exit1 = exit2; + c->exit1env = exit2env; + c->ret = f1; + printf("f0 3 sp: %x\n",sp); + goto f(i,sp); +} + +code f1(int i,void *sp) { + int j; + int *exit2env; + code (*exit2)(); + struct f0_save *c; + + c = sp; + j = c->jj; + exit2 = c->exit1; + exit2env = c->exit1env; + + sp += sizeof(struct f0_save); + goto print(i,j,exit2,exit2env); +} + +int main( int ac, char *av[]) +{ + int i,j; + int *sp; + + i = atoi(av[1]); + stack0 = ((char *)malloc(1024)+1024); + sp = stack0; + j = i; + + printf("sp: %x\n",sp); + goto f0(i,j,return,environment,sp); +} + +code print(int i,int j,(*exit1)(),void*exit1env) +{ + printf("%d %d\n",i,j); + goto (*exit1)(1),exit1env; +} + diff -r ca0bce3b4810 -r fdbf2fbc8140 test/tmp8.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tmp8.c Thu Jun 28 14:33:44 2001 +0900 @@ -0,0 +1,7 @@ + + +int +f(int i,int j,int k,void *l) +{ + return f(i,j,k,alloca(i)); +}