changeset 720:6b7372e17970

*** empty log message ***
author kono
date Sat, 12 Apr 2008 03:53:11 +0900
parents 4c5ac4025fbd
children 76761a18703b
files Changes mc-macro.c mc-parse.c test/arg.c test/conv1.c test/fact-a.c test/fact.c test/goto.c test/hoge.c test/macro.c test/test1.c test/test2.c test/throw.c test/tmp1.c test/tmp4.c test/tmp6.c test/tmpa.c test/too-long-argument.c
diffstat 18 files changed, 96 insertions(+), 52 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Wed Nov 28 19:38:01 2007 +0900
+++ b/Changes	Sat Apr 12 03:53:11 2008 +0900
@@ -9797,3 +9797,18 @@
 
 おっと、ptr_cache を取るのは早すぎたが... lqa は aligned address
 しか扱わないので、汎用のshuffle byte code を使えない....
+
+Tue Dec 25 22:22:11 JST 2007
+
+あぁ、Recursive Macro は、やっぱり扱ってないじゃないか〜
+
+Mon Jan 21 11:46:52 JST 2008
+
+PS3 PPC が動かなくなっているんだよな。
+
+
+
+
+
+
+
--- a/mc-macro.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/mc-macro.c	Sat Apr 12 03:53:11 2008 +0900
@@ -982,7 +982,7 @@
 	    else
 		macro="";
 //	    if (check_recurse(macro,history)) goto skip;
-//		string_falg = 0;
+//		string_flag = 0;
 	    switch(nptrm->sc) {
 	    case FMACRO:
 		if (c==' '||c=='\t') {
--- a/mc-parse.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/mc-parse.c	Sat Apr 12 03:53:11 2008 +0900
@@ -586,6 +586,7 @@
     reserve("static",STATIC,RESERVE);
     reserve("goto",GOTO,RESERVE);
     reserve("return",RETURN,RESERVE);
+    reserve("__return",RETURN,RESERVE);
     reserve("break",BREAK,RESERVE);
     reserve("continue",CONTINUE,RESERVE);
     reserve("if",IF,RESERVE);
--- a/test/arg.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/arg.c	Sat Apr 12 03:53:11 2008 +0900
@@ -4,6 +4,8 @@
    int a0;int a1;int a2;int a3;int a4;
 };
 
+extern void exit(int); 
+
 void *exit_env;
 __code (*exit___code)();
 
@@ -70,7 +72,7 @@
 
 int main1(int n)
 {
-    goto carg1(0,1,2,3,4,exit___code=return,exit_env=environment);
+    goto carg1(0,1,2,3,4,exit___code=__return,exit_env=__environment);
     return n;
 }
 
--- a/test/conv1.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/conv1.c	Sat Apr 12 03:53:11 2008 +0900
@@ -2,7 +2,7 @@
 
 static int loop;
 
-#ifdef __micro_c__
+#if 1 // def __micro_c__
 #define CC_ONLY 0
 #else
 #define CC_ONLY 1
@@ -60,7 +60,7 @@
 }
 
 __code f_g1(int j,stack sp) {  // Continuation 
-    struct f_g0_interface *c = sp;
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
     int k = c->k_;
     sp+=sizeof(struct f_g0_interface);
     c = (struct f_g0_interface *)sp;
@@ -80,7 +80,7 @@
 }
 
 __code g_h1(int j,stack sp) {  // Continuation 
-    struct f_g0_interface *c = sp;
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
     int i = c->i_;
     sp+=sizeof(struct f_g0_interface);
     c = (struct f_g0_interface *)sp;
@@ -88,7 +88,7 @@
 }
 
 __code h(int i,stack sp) {
-    struct f_g0_interface *c = sp;
+    struct f_g0_interface *c = (struct f_g0_interface *)sp;
     goto (c->ret)(i+4,sp);
 }
 
@@ -169,8 +169,8 @@
 }
 
 #define STACK_SIZE 2048
-stack main_stack[STACK_SIZE];
-#define stack_last (&main_stack[STACK_SIZE])
+char main_stack[STACK_SIZE];
+#define stack_last (main_stack+STACK_SIZE)
 
 #endif
 
@@ -198,24 +198,24 @@
 	sp -= sizeof(*cont);
 	cont = (struct main_continuation *)sp;
 	cont->ret = main_return;
-	cont->main_ret = return;
-	cont->env = environment;
+	cont->main_ret = __return;
+	cont->env = __environment;
 	goto f(233,sp);
     } else if (sw==2) {
 	loop = LOOP_COUNT;
 	sp -= sizeof(*cont);
 	cont = (struct main_continuation *)sp;
 	cont->ret = main_return2;
-	cont->main_ret = return;
-	cont->env = environment;
+	cont->main_ret = __return;
+	cont->env = __environment;
 	goto f2(233,sp);
     } else if (sw==3) {
 	loop = LOOP_COUNT;
 	sp -= sizeof(*cont);
 	cont = (struct main_continuation *)sp;
 	cont->ret = main_return2_1;
-	cont->main_ret = return;
-	cont->env = environment;
+	cont->main_ret = __return;
+	cont->env = __environment;
 	goto f2_1(233,sp);
 #endif
     }
--- a/test/fact-a.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/fact-a.c	Sat Apr 12 03:53:11 2008 +0900
@@ -22,7 +22,7 @@
     int n;
     // n = atoi(av[1]);
     n = 10;
-    goto factorial(n,1,n,print,return,environment);
+    goto factorial(n,1,n,print,__return,__environment);
 }
 
 __code print(int n,int result,int orig,__code(*print)(),__code (*exit1)(),void*exit1env)
--- a/test/fact.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/fact.c	Sat Apr 12 03:53:11 2008 +0900
@@ -8,7 +8,7 @@
     int n;
     // n = atoi(av[1]);
     n = 10;
-    goto factorial(n,1,n,print,return,environment);
+    goto factorial(n,1,n,print,__return,__environment);
 }
 
 __code print(n,result,orig,print,exit1,exit1env)
--- a/test/goto.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/goto.c	Sat Apr 12 03:53:11 2008 +0900
@@ -1,4 +1,4 @@
-
+extern int printf(const char *,...);
 
 __code (*conv)(int,__code (*)());
 __code a2(int i,__code conv());
@@ -51,7 +51,7 @@
 }
 
 __code
-a7(int i,,int j,int k,__code (*conv)())
+a7(int i,int j,int k,__code (*conv)())
 {
     printf("#0055:a7 %d %s\n",i,print_conv(conv));
     goto conv(i+1,j,k,a9);
@@ -72,8 +72,8 @@
 }
 
 main(int ac,char *av[]) {
-    exit0 = return;
-    env   = environment;
+    exit0 = __return;
+    env   = __environment;
     conv = a2;
     goto conv(1,a3);
 }
--- a/test/hoge.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/hoge.c	Sat Apr 12 03:53:11 2008 +0900
@@ -2,6 +2,8 @@
 // #include "hoge.h"
 // #include "task.h"
 
+struct task;
+
 typedef
 struct pkt {
     int val;
@@ -52,7 +54,7 @@
 int
 main()
 {
-    exit0 = return;
-    env = environment;
+    exit0 = __return;
+    env = __environment;
     goto increment(&pkt,&task);
 }
--- a/test/macro.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/macro.c	Sat Apr 12 03:53:11 2008 +0900
@@ -19,15 +19,32 @@
 #define c(a,b)  g(a+1,b+1)
 #define g(a,b)  printf("#0018:%d %d\n",a+1,b+1);
 #define d(a,b)  cadr(b)+3
+
+int stdio0 = 1;
+int stdio1 = 2;
+int stdio2 = 3;
+
+#define stdio0 stdio0
+
+#define stdio2 stdio1
+#define stdio1 stdio2
+
+int recurse(int a,int b) {
+    return a + b + stdio0;
+}
+
+#define recurse(a,b)   a+recurse(a,b)
+
 /*
 
-    #define stdio stdio
     #define f(a,b) aho+a+b
     f (a,b)
 */
 
 int f()
 {
+    printf("%d %d %d %d\n",stdio0,stdio1,stdio2, recurse(1,2));
+
 #if ENDIAN_L==0
     printf("ok\n");
 #else
--- a/test/test1.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/test1.c	Sat Apr 12 03:53:11 2008 +0900
@@ -2,7 +2,9 @@
     test for CbC converted __code from C
  */
 
-#include "stdio.h"
+#include <stdio.h>
+
+extern void *malloc(int);
 
 typedef void *stack;
 
@@ -107,10 +109,10 @@
     j = i;
     
     printf("#0108:sp: %x %x\n",sp-(int*)stack0,sizeof(*stack0));
-    goto f0(i,j,return,environment,sp);
+    goto f0(i,j,__return,__environment,sp);
 }
 
-__code print(int i,int j,(*exit1)(),void*exit1env)
+__code print(int i,int j,__code (*exit1)(),void*exit1env)
 {
     printf("#0114:%d %d\n",i,j);
     goto (*exit1)(0),exit1env;
--- a/test/test2.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/test2.c	Sat Apr 12 03:53:11 2008 +0900
@@ -33,8 +33,8 @@
         pkt.bit = 1;
         pkt.msg = "hogehoge";
         pkt.next = initSender;
-        ret = return;
-        env = environment;
+        ret = __return;
+        env = __environment;
         printf("main bit: %d\n", pkt.bit);
         printf("main message: %s\n", pkt.msg);
         goto initSender(0, pkt);
--- a/test/throw.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/throw.c	Sat Apr 12 03:53:11 2008 +0900
@@ -1,5 +1,6 @@
 
 extern int printf(const char *,...);
+extern void *malloc(int);
 
 __code (*ret)();
 void *env;
@@ -40,7 +41,8 @@
 void
 setup(interface1 *arg)
 {
-    for(register int i=0;i<100;i++) arg->c[i]=i;
+    register int i;
+    for(i=0;i<100;i++) arg->c[i]=i;
 }
 
 int
@@ -55,8 +57,8 @@
     arg.last = 96;
 
     printf("main0\n");
-    ret = return;
-    env = environment;
+    ret = __return;
+    env = __environment;
 
     goto throw(arg,-7,76);
 }
@@ -76,8 +78,8 @@
     arg.last=98;
 
     printf("main1\n");
-    ret = return;
-    env = environment;
+    ret = __return;
+    env = __environment;
 
     goto throw1(arg,-6,77),space;
 }
@@ -96,8 +98,8 @@
     arg.last=99;
 
     printf("main2\n");
-    ret = return;
-    env = environment;
+    ret = __return;
+    env = __environment;
 
     goto throw1(arg,-5,78);
 }
--- a/test/tmp1.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/tmp1.c	Sat Apr 12 03:53:11 2008 +0900
@@ -1,5 +1,7 @@
 /* easy test */
 
+extern int printf(const char *,...);
+
 __code (*ret)();
 void *env;
 __code exit1(int ac);
@@ -8,11 +10,11 @@
 int ac;
 char *av[];
 {
-    ret = return;
-    env = environment;
+    ret = __return;
+    env = __environment;
     printf("#0012:main0 %d start.\n",ac);
     if (ac>=1)
-	goto code0(ac,av,return);
+	goto code0(ac,av,__return);
     goto code1(ac,av,exit1);
     // not reached. (warning?)
     printf("#0017:main0 %d end.\n",ac);
@@ -55,13 +57,14 @@
 __code code0(ac,av,ret)
 int ac;
 char *av[];
-__code ret();
+__code (*ret)(int);
 {
     goto code1(ac,av,ret);
 }
 
 __code code1(ac,av,exit)
-int ac,exit;
+int ac;
+__code (*exit)(int);
 char *av[];
 {
     __code (*f)(int);
--- a/test/tmp4.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/tmp4.c	Sat Apr 12 03:53:11 2008 +0900
@@ -21,7 +21,7 @@
     j=456;
     k=789;
     fprintf(stdout,"2: %s\n",av[0]+2);
-    goto code0(i,j,k,av,return,environment);
+    goto code0(i,j,k,av,__return,__environment);
 }
 
 __code code0(i,j,k,av,ret,retenv)
--- a/test/tmp6.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/tmp6.c	Sat Apr 12 03:53:11 2008 +0900
@@ -12,10 +12,10 @@
     if(ac!=2)	{
 	fprintf(stdout,"#0012:a used.\n");
 	// return(0);
-	i=main0(2,a,return,environment);
+	i=main0(2,a,__return,__environment);
         return 0;
     }
-    i=main0(ac,av,return,environment);
+    i=main0(ac,av,__return,__environment);
     fprintf(stdout,"#0018:1: %s %d\n",av[0],i);
     return 0;
 }
@@ -32,7 +32,7 @@
     j=456;
     k = atoi(av[1]);
     fprintf(stdout,"#0033:2: av=%x av[0]=%x %s\n",av==a,av[0]==a[0],av[0]);
-    goto code0(i,j,k,av,ret,retenv,return,environment);
+    goto code0(i,j,k,av,ret,retenv,__return,__environment);
 }
 
 __code code0(i,j,k,av,ret,retenv,ret1,ret1env)
--- a/test/tmpa.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/tmpa.c	Sat Apr 12 03:53:11 2008 +0900
@@ -33,8 +33,8 @@
     interface args = {15,{0,0,0,0},return,environment};
 #else
     interface args = {15,{0,0,0,0},0,0};
-    args.ret = return;
-    args.env = environment;
+    args.ret = __return;
+    args.env = __environment;
 #endif
 
     e.charno=5; e.x=50.0; e.y=30.0; e.ap=100;
--- a/test/too-long-argument.c	Wed Nov 28 19:38:01 2007 +0900
+++ b/test/too-long-argument.c	Sat Apr 12 03:53:11 2008 +0900
@@ -53,10 +53,10 @@
 {
 #ifdef WRONGNUMBER
      goto tcode2(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,
-	return,environment);
+	__return,__environment);
 #else
      goto tcode2(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
-	return,environment);
+	__return,__environment);
 #endif
 }
 
@@ -65,23 +65,23 @@
 {
 #ifdef WRONGNUMBER
      goto tcode1(0,1,2,3,4,5,6,7,8,9,10,11,12,13,
-	return,environment);
+	__return,__environment);
 #else
      goto tcode1(0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,
-	return,environment);
+	__return,__environment);
 #endif
 }
 
 int
 main2()
 {
-     goto tcode0(0,1,tcode1,return,environment);
+     goto tcode0(0,1,tcode1,__return,__environment);
 }
 
 int
 main4()
 {
-     goto tcode4(0,1,tcode2,return,environment);
+     goto tcode4(0,1,tcode2,__return,__environment);
 }
 
 int