changeset 596:94d3a8c1b3e8

*** empty log message ***
author kono
date Mon, 23 Jan 2006 14:09:20 +0900
parents cfd1eba00ce6
children 756ba7c78e4c
files Changes Makefile Makefile.powerpc mc-codegen.c mc-codegen.h mc-parse.c mc-tree.c
diffstat 7 files changed, 44 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sat Jan 21 20:51:21 2006 +0900
+++ b/Changes	Mon Jan 23 14:09:20 2006 +0900
@@ -8586,6 +8586,10 @@
 goto hoge(),env; で、env が 0 だったら、fp の切替えをしない
 って方が良くない? 出力コードは複雑になるが...
 
-
-
-
+Mon Jan 23 13:52:32 JST 2006
+
+あ、なんか、converter すごいかも。やっぱり、このままで、
+c2cbc,cbc2c が楽勝で書けるみたい。なんで 1 pass じゃだめだ
+と思ったんだろう?
+
+
--- a/Makefile	Sat Jan 21 20:51:21 2006 +0900
+++ b/Makefile	Mon Jan 23 14:09:20 2006 +0900
@@ -14,7 +14,7 @@
 MC=mc-$(ARCH)
 MLIB = -lm
 PRINTF= # printf.c
-CONVERTER=conv/c.o conv/null.o
+CONVERTER=conv/c.o conv/null.o conv/c2cbc.o
 # conv/c2cbc.o conv/cbc2c.o
 COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
 # CODE=mc-code-ia32.c
@@ -185,7 +185,7 @@
                 mc-code-mips.c
 
 clean :
-	-rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
+	-rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.?
 
 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
 	$(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
@@ -272,7 +272,10 @@
 conv/c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
 conv/c.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
 conv/c.o: mc-parse.h conv/conv.h conv/convdef.h conv/c.h
-conv/c2cbc.o: mc.h
+conv/c2cbc.o: /usr/include/stdio.h /usr/include/_types.h
+conv/c2cbc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+conv/c2cbc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+conv/c2cbc.o: mc-parse.h conv/conv.h conv/convdef.h conv/c2cbc.h
 conv/cbc2c.o: mc.h
 conv/null.o: /usr/include/stdio.h /usr/include/_types.h
 conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
--- a/Makefile.powerpc	Sat Jan 21 20:51:21 2006 +0900
+++ b/Makefile.powerpc	Mon Jan 23 14:09:20 2006 +0900
@@ -14,7 +14,7 @@
 MC=mc-$(ARCH)
 MLIB = -lm
 PRINTF= # printf.c
-CONVERTER=conv/c.o conv/null.o
+CONVERTER=conv/c.o conv/null.o conv/c2cbc.o
 # conv/c2cbc.o conv/cbc2c.o
 COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
 # CODE=mc-code-ia32.c
@@ -119,7 +119,6 @@
 	make check-code$(MK) TARGET=test/tmp2
 	make check-code$(MK) TARGET=test/tmp4
 	make check-code$(MK) TARGET=test/tmp6
-	make check-code$(MK) TARGET=test/tmpb
 	make check-code$(MK) TARGET=test/scope
 	make check-code$(MK) TARGET=test/throw
 	make check-code$(MK) TARGET=test/too-long-argument
@@ -186,7 +185,7 @@
                 mc-code-mips.c
 
 clean :
-	-rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i
+	-rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.bak *.s *.o *.cc mc mc1 mc2 a.out *~ core* */*.o *.bak test/*.s test/*.cc test/*.o test/*.bak test/*~ conv/*.s conv/*.cc conv/*.o conv/*.bak conv/*~ *.out */*.out *.i */*.i *.cbc.? */*.cbc.?
 
 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
 	$(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
@@ -273,7 +272,10 @@
 conv/c.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
 conv/c.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
 conv/c.o: mc-parse.h conv/conv.h conv/convdef.h conv/c.h
-conv/c2cbc.o: mc.h
+conv/c2cbc.o: /usr/include/stdio.h /usr/include/_types.h
+conv/c2cbc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
+conv/c2cbc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
+conv/c2cbc.o: mc-parse.h conv/conv.h conv/convdef.h conv/c2cbc.h
 conv/cbc2c.o: mc.h
 conv/null.o: /usr/include/stdio.h /usr/include/_types.h
 conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
--- a/mc-codegen.c	Sat Jan 21 20:51:21 2006 +0900
+++ b/mc-codegen.c	Mon Jan 23 14:09:20 2006 +0900
@@ -3375,7 +3375,7 @@
 }
 
 
-static NMTBL str_ret;
+NMTBL str_ret;
 
 /*
     If function has structure return value, it has an extra
--- a/mc-codegen.h	Sat Jan 21 20:51:21 2006 +0900
+++ b/mc-codegen.h	Mon Jan 23 14:09:20 2006 +0900
@@ -113,4 +113,8 @@
 
 extern int ilog(int i);
 
+/* used by mc-tree */
+
+extern NMTBL str_ret;
+
 /* end */
--- a/mc-parse.c	Sat Jan 21 20:51:21 2006 +0900
+++ b/mc-parse.c	Mon Jan 23 14:09:20 2006 +0900
@@ -732,7 +732,8 @@
     else if (macroeq("cbc2c")) conv=&cbc2c_converter;
     else if (macroeq("c")) conv=&c_converter;
 #else
-    if (macroeq("c")) conv=&c_converter;
+    if (macroeq("c2cbc")) conv=&c2cbc_converter;
+    else if (macroeq("c")) conv=&c_converter;
     else conv=&null_converter;
 #endif
 }
@@ -1845,7 +1846,7 @@
 	    n->dsp = -n->dsp-cadddr(t);
     }
     arg_register(fnptr);
-    conv->code_(fnptr);
+    conv->code_(fnptr); conv->lc_();
     typedefed=0;
     /* local variable declaration */
     stmode=0;
--- a/mc-tree.c	Sat Jan 21 20:51:21 2006 +0900
+++ b/mc-tree.c	Mon Jan 23 14:09:20 2006 +0900
@@ -4,6 +4,7 @@
 #include <stdio.h>
 #include "mc.h"
 #include "mc-parse.h"
+#include "mc-codegen.h"
 
 typedef
 struct tree_node {
@@ -373,9 +374,7 @@
 		struct_type_print(type,out);
 	    }
 	} else if(t==CODE) {
-	    if (!cont) {
-		fprintf(out,"%s ",tn->tree_name);
-	    }
+	    // if (!cont) { fprintf(out,"%s ",tn->tree_name); }
 	    function_type_print1(type,n,out,cont);
 	    return;
 	} else if(t==FUNCTION) {
@@ -408,6 +407,21 @@
 		}
 		fprintf(out,")");
 		return;
+	    } else if(car(t)==CODE) {
+		type_print1(cadr(t),0,out,cont);
+		fprintf(out,"(*");
+		if(n) fprintf(out,"%s",n->nm);
+		fprintf(out,")");
+		fprintf(out,"(");
+		if((args=caddr(t))) {
+		    while (args) {
+			type_print(car(args),0,out);
+			args=cadr(args);
+			if (args) fprintf(out,",");
+		    }
+		}
+		fprintf(out,")");
+		return;
 	    } else if(car(t)==ARRAY) {
 		fprintf(out,"(*");
 		type_print(cadr(t),n,out);