changeset 170:6e0f67b7d200 short-fix

test files
author kono
date Mon, 24 Nov 2003 20:15:14 +0900
parents b2a480be3c85
children 3902240d4930
files Changes test/conv.c test/regargs.c test/short.c test/simp0.c
diffstat 5 files changed, 257 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Mon Nov 24 19:44:46 2003 +0900
+++ b/Changes	Mon Nov 24 20:15:14 2003 +0900
@@ -3514,3 +3514,7 @@
 
 うーん、こんなエラー残っているのか。code_cpostint とか
 はぜんぜん使われないわけ?
+
+struct { char a[4],a; } は直しました。
+
+short の引数の扱いも修正。
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/conv.c	Mon Nov 24 20:15:14 2003 +0900
@@ -0,0 +1,86 @@
+#include "stdio.h"
+
+f0(int i) {
+    int k,j;
+    k = 3+i;
+    j = g0(i+3);
+    return k+4+j;
+}
+
+g0(int i) {
+    return i+4;
+}
+
+typedef char *stack;
+
+struct cont_interface { // General Return Continuation
+    code (*ret)();
+};
+
+code f(int i,stack sp) {
+    int k,j;
+    k = 3+i;
+    goto f_g0(i,k,sp);
+}
+
+struct f_g0_interface {  // Specialized Return Continuation
+    code (*ret)();
+    int i_,k_,j_;
+};
+
+code f_g1(int j,stack sp);
+
+code f_g0(int i,int k,stack sp) { // Caller
+    struct f_g0_interface *c = 
+	(struct f_g0_interface *)(sp -= sizeof(struct f_g0_interface));
+
+    c->ret = f_g1;
+    c->k_ = k;
+    c->i_ = i;
+
+    goto g(i+3,sp);
+}
+
+code f_g1(int j,stack sp) {  // Continuation 
+    struct f_g0_interface *c = sp;
+    int k = c->k_;
+    sp += sizeof(struct f_g0_interface);
+    goto (( (struct cont_interface *)sp)->ret)(k+4+j,sp);
+}
+
+code g(int i,stack sp) {
+    goto (( (struct cont_interface *)sp)->ret)(i+4,sp);
+}
+
+struct main_continuation { // General Return Continuation
+    code (*ret)();
+    code (*main_ret)();
+    void *env;
+};
+
+code main_return(int i,stack sp) {
+    printf("%d\n",i);
+    goto (( (struct main_continuation *)sp)->main_ret)(0),
+           ((struct main_continuation *)sp)->env;
+}
+
+#define STACK_SIZE 2048
+stack main_stack[STACK_SIZE];
+#define stack_last (&main_stack[STACK_SIZE])
+
+main()
+{
+    struct main_continuation *cont;
+    stack sp = stack_last;
+
+    printf("%d\n",f0(233));
+
+    sp -= sizeof(*cont);
+    cont = (struct main_continuation *)sp;
+    cont->ret = main_return;
+    cont->main_ret = return;
+    cont->env = environment;
+    goto f(233,sp);
+}
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/regargs.c	Mon Nov 24 20:15:14 2003 +0900
@@ -0,0 +1,18 @@
+
+int
+arg1(int a1,int a2,int a3,int a4)
+{
+    printf("%d %d %d %d\n",a1,a2,a3,a4);
+}
+
+int
+arg0(int a1,int a2,int a3,int a4)
+{
+    arg1(0,1,2,3);
+    printf("%d %d %d %d\n",a1,a2,a3,a4);
+}
+
+main()
+{
+    arg0(0,1,2,3);
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/short.c	Mon Nov 24 20:15:14 2003 +0900
@@ -0,0 +1,144 @@
+
+short gj;
+short gi;
+
+short a[100];
+unsigned short b[100];
+unsigned char c[100];
+
+short data[] = {10,20,-40};
+unsigned short udata[] = {10,20,-40};
+
+short f(short i,unsigned short j,unsigned short k,short m,short a); 
+unsigned
+short g(short i,unsigned short j,unsigned short k,short m,short a); 
+
+main()
+{
+     int ii;
+     short i,k,*p;
+     unsigned short j,m,*up;
+     unsigned char g0,h0;
+     char g1,h1;
+     unsigned short sg0,sh0;
+     short sg1,sh1;
+     unsigned char *pg0,*ph0;
+     char *pg1,*ph1;
+     unsigned short *psg0,*psh0;
+     short *psg1,*psh1;
+     
+
+     i = -3;
+     j = 3;
+     k = 44;
+     k = i*j+3+k;
+     m = i*j-7+k;
+     printf("%d %d %d\n",i,k,m);
+
+     g0 = 123;
+     g0++; --g0;
+     ++g0; g0--;
+     printf("g0=%d\n",g0);
+     g1 = -123;
+     g1++; --g1;
+     ++g1; g1--;
+     printf("g1=%d\n",g1);
+
+     sg0 = 123;
+     sg0++; --sg0;
+     ++sg0; sg0--;
+     printf("sg0=%d\n",sg0);
+     sg1 = -123;
+     sg1++; --sg1;
+     ++sg1; sg1--;
+     printf("sg1=%d\n",sg1);
+
+     pg0 = &g0;
+     ph0 = &h0;
+     *pg0 = 123;
+     //*pg0++; *--pg0;
+     //*++pg0; *g0--;
+     printf("g0=%d\n",*pg0);
+     pg1 = &g1;
+     ph1 = &h1;
+     *pg1 = -123;
+     //*pg1++; --*pg1;
+     //++*pg1; *pg1--;
+     printf("g1=%d\n",*pg1);
+
+     psg0 = &sg0;
+     psh0 = &sh0;
+     *psg0 = 123;
+     //*sg0++; *--sg0;
+     //*++sg0; *sg0--;
+     printf("sg0=%d\n",*psg0);
+     psg1 = &sg1;
+     psh1 = &sh1;
+     *psg1 = -123;
+     //*sg1++; *--sg1;
+     //*++sg1; *sg1--;
+     printf("sg1=%d\n",*psg1);
+
+
+     h0 = g0 - 20;
+     c[33] = g0;
+
+     if (i==j) {  printf("i==j\n"); } else { printf("i!=j\n"); }
+
+     a[33] = i;
+     b[33] = 105;
+     printf("i=%d\n",i);
+     printf("j=%d\n",j);
+     i++; --i; 
+     j++; --j; 
+     printf("i=%d\n",i);
+     printf("j=%d\n",j);
+     gi = 3333;
+     gj = 6666;
+     gi++; --gi; 
+     gj++; --gj; 
+     printf("gi=%d\n",gi);
+     printf("gj=%d\n",gj);
+
+     printf("k=%d\n",k);
+     printf("m=%d\n",m);
+     printf("a[33]=%d\n",a[33]);
+     printf("b[33]=%d\n",b[33]);
+     printf("a[33]=%d\n",++a[33]);
+     printf("b[33]=%d\n",b[33]--);
+
+     printf("g0=%d\n",g0);
+     printf("h0=%d\n",h0);
+     printf("c[33]=%d\n",c[33]);
+
+     p = data;
+     printf("*p++ = %d\n",*p++);
+     printf("*++p = %d\n",*++p);
+     *p++ = -343;
+     printf("*p-- = %d\n",*p--);
+     printf("*--p = %d\n",*--p);
+     up = udata;
+     printf("*up-- = %d\n",*up--);
+     printf("*--up = %d\n",*--up);
+     *up++ = 65530;
+     printf("*up-- = %d\n",*up--);
+     printf("*--up = %d\n",*--up);
+     
+
+     ii = f(i,j,k,m,a[33]); 
+     printf("f()=%d\n",ii);
+     ii = g(i,j,k,m,a[33]); 
+     printf("f()=%d\n",ii);
+  
+}
+
+short f(short i,unsigned short j,unsigned short k,short m,short a)
+{
+    return  i+j*k-m/a;
+}
+
+unsigned
+short g(short i,unsigned short j,unsigned short k,short m,short a)
+{
+    return  i+j*k-m/a;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/simp0.c	Mon Nov 24 20:15:14 2003 +0900
@@ -0,0 +1,5 @@
+
+main(int ac,char *av[])
+{
+    printf("%d %d %d %s\n",1,2,3,av[ac-1]);
+}