changeset 544:dbfd6e88e2c3 s-dandy-ok

s-dandy compile OK
author kono
date Mon, 02 Jan 2006 12:55:17 +0900
parents af90edc74aa5
children 2f577690bcfb
files Changes mc-code-arm.c mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-codegen.c mc-parse.c mc.h test/scope.c test/tmpa.code-out
diffstat 10 files changed, 94 insertions(+), 28 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Mon Jan 02 09:49:35 2006 +0900
+++ b/Changes	Mon Jan 02 12:55:17 2006 +0900
@@ -7758,7 +7758,21 @@
 local struct static を切ればいいんだけど。式があったら、
 代入するようにすれば良いんだが。(ま、いいか?)
 
-
-
-
-
+inline でも、
+
+adpt_ps2/adpt_libps.c(.text+0xb0c): undefined reference to `ot_Init_node'
+adpt_ps2/adpt_libps.o: In function `GsClearOt':
+
+ちゃんと extern 付けてくれれば、動くのになぁ。
+
+adpt_ps2/adpt_libps.c:    ot_Init_node(); 
+adpt_ps2/ot.c:ot_Init_node( void ) 
+adpt_ps2/ot.c:    ot_Init_node();
+adpt_ps2/ot.h:inline char ot_Init_node( void );
+
+あぁ、ひどい。inline っていう嘘」をつくことが可能なのか。しかも、
+Warning さえ出ないのか。でも、動いてはいるのか。
+
+n->sc にFUNCTIONが入るのは間違い?
+
+
--- a/mc-code-arm.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-code-arm.c	Mon Jan 02 12:55:17 2006 +0900
@@ -377,7 +377,7 @@
 {
     int lvar_offsetv;
     int r1_offsetv;
-    int code_f = (fnptr->sc==CODE);
+    int code_f = is_code(fnptr);
 
     disp &= -SIZE_OF_INT;
 
@@ -434,7 +434,7 @@
 lvar_intro(int l)
 {
     int large;
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {
 	    large = LARGE_OFFSET(CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
         } else
@@ -462,7 +462,7 @@
 	free_register(large_lvar);
 	return;
     }
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
             printf("[sp, #%d]%s\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET),cext);
         } else
@@ -483,7 +483,7 @@
     int tmp = -1;
     char *trn;
     inc_inst(1);
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
 	    code_add(creg,CODE_CALLER_ARG(l-ARG_LVAR_OFFSET),REG_sp);
         } else
@@ -3742,6 +3742,7 @@
 	    comm(n);
 	} else if ((n->sc==STATIC) && n->dsp != -1) {
 	    /* n->dsp = -1 means initialized global */
+	    if (is_code(n)||is_function(n)) continue;
 	    if (init==0) {
 		data_mode(0);
 		init=1;
--- a/mc-code-ia32.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-code-ia32.c	Mon Jan 02 12:55:17 2006 +0900
@@ -2204,12 +2204,14 @@
     init=0;
     for(n=global_list;n;n = n->next) {
 	if ((n->sc == GVAR||n->sc == STATIC) && n->dsp != -1) {
+	    if (is_code(n)||is_function(n)) continue;
 	    /* n->dsp = -1 means initialized global */
 	    if (init==0) {
 		data_mode(0);
 		init=1;
 	    }
 	    printf(".comm %s,%d\n",n->nm,size(n->ty));
+	    // .lcomm?
 	}
     }
 }
--- a/mc-code-mips.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-code-mips.c	Mon Jan 02 12:55:17 2006 +0900
@@ -441,7 +441,7 @@
 static void
 lvar(int l)
 {
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
             printf("%d($sp)\n",CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
         } else
@@ -458,7 +458,7 @@
 static void
 lvar_address(int l,int creg)
 {
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
             printf("\taddu\t%s,$sp,%d\n",
 		register_name(creg),CODE_CALLER_ARG(l-ARG_LVAR_OFFSET));
@@ -1591,7 +1591,7 @@
 	// offset should not be used
 	printf("\tmove $4,%s\n",trn);
         /* overrap must be allowed */
-	if (fnptr->sc==CODE) {
+	if (is_code(fnptr)) {
 	    printf("\tla\t$25,%s\n",memmove);
 	    printf("\tjalr\t$25\n");
 	    printf("\tlw\t$gp,$L_%d($sp)\n",cprestore_label);
@@ -2055,7 +2055,7 @@
 code_call(int e2,NMTBL *fn,int jmp)
 {
     // char *jrn;
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
 	if (car(e2) == FNAME) {
 	    printf("\tla\t$25,%s\n",fn->nm);
 	} else {
@@ -2272,7 +2272,7 @@
     crn = register_name(reg);
     printf("\tsubu $sp,$sp,%s\n",crn);
     printf("\taddu %s,$sp,$L_%d+4\n",crn,cprestore_label);
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
 	printf("\tsw\t$gp,$L_%d($sp)\n",cprestore_label);
     }
 }
@@ -3069,7 +3069,7 @@
 void
 code_label_call(int l)
 {
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
 	printf("\tla\t$25,L_%d\n",l);
 	printf("\tjalr\t$25\n");
 	printf("\tlw\t$gp,$L_%d($sp)\n",cprestore_label);
@@ -3421,6 +3421,8 @@
 	    }
 	    comm(n);
 	} else if ((n->sc==STATIC) && n->dsp != -1) {
+	    // is this really happen? why don't we use local static list?
+	    if (is_function(n)||is_code(n)) continue;
 	    /* n->dsp = -1 means initialized global */
 	    if (init==0) {
 		data_mode(0);
@@ -3492,7 +3494,7 @@
      code_save_stacks();
      clear_ptr_cache();
      extern_define(conv,0,FUNCTION,1);
-     if (fnptr->sc==CODE) {
+     if (is_code(fnptr)) {
 	printf("\tla\t$25,%s\n",conv);
 	printf("\tjalr\t$25\n");
 	printf("\tlw\t$gp,$L_%d($sp)\n",cprestore_label);
--- a/mc-code-powerpc.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-code-powerpc.c	Mon Jan 02 12:55:17 2006 +0900
@@ -351,7 +351,7 @@
 {
     char *rn;
     if (!large_offset_reg) {
-	if (fnptr->sc==CODE) {
+	if (is_code(fnptr)) {
 	    if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
 		printf("lo16(%d)(r1)\n",CODE_CALLER_ARG);
 	    } else
@@ -365,7 +365,7 @@
 	}
     } else {
         rn = register_name(large_offset_reg);
-        if (fnptr->sc==CODE) {
+        if (is_code(fnptr)) {
             if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
                 printf("lo16(%d)(%s)\n",CODE_CALLER_ARG,rn);
             } else
@@ -395,7 +395,7 @@
 {
     char *rn;
     large_offset_reg=0;
-    if (fnptr->sc==CODE) {
+    if (is_code(fnptr)) {
         if (l>=ARG_LVAR_OFFSET) {  /* caller's arguments */
             if (LARGE_OFFSET(CODE_CALLER_ARG)) {
                 rn=register_name(large_offset_reg=get_register());
@@ -1108,7 +1108,7 @@
 code_ptr_cache_def(int r,NMTBL *nptr)
 {
     char *rrn = register_name(r);
-    if (nptr->sc==STATIC) {
+    if (nptr->sc==STATIC && !(is_code(nptr)||is_function(nptr))) {
 	printf("\taddis %s,r31,ha16(_%s-L_%d)\n",
 		 rrn,nptr->nm,code_base);
 	printf("\tla %s,lo16(_%s-L_%d)(%s)\n",
@@ -3173,6 +3173,7 @@
 	    printf(".comm _%s,%d\n",n->nm,size(n->ty));
 	} else if ((n->sc==STATIC) && n->dsp != -1) {
 	    /* n->dsp = -1 means initialized global */
+	    if (is_code(n)||is_function(n)) continue;
 	    if (init==0) {
 		data_mode(0);
 		init=1;
@@ -3203,7 +3204,7 @@
 printf("L_%s$lazy_ptr:\n",extrn);
 printf("\t.indirect_symbol _%s\n",extrn);
 printf("\t.long dyld_stub_binding_helper\n");
-	    } else if (n->sc==FUNCTION||n->sc==CODE) {
+	    } else if (n->sc==STATIC) {
 		text_mode(0);
 printf("\t.set L_%s$stub,_%s\n",extrn,extrn);
 		data_mode(0);
--- a/mc-codegen.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-codegen.c	Mon Jan 02 12:55:17 2006 +0900
@@ -2480,10 +2480,12 @@
     NMTBL *n;
     for(e=inline_funcs;e;e=cadr(e)) {
 	n = (NMTBL*)car(e);
-	if (/* 1 || */ n->sc==EXTRN || n->sc==EXTRN1 || has_attr(n,FNAME)) {  
-            // global or used as pointer
-	    // generate possibly called inline function
-	    pfdecl(n);
+        if (is_code(n)||is_function(n)) {
+            if (n->sc!=STATIC || has_attr(n,FNAME)) {
+		// global or used as pointer
+		// generate possibly called inline function
+		pfdecl(n);
+	    }
 	}
     }
     if (!chk)
--- a/mc-parse.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc-parse.c	Mon Jan 02 12:55:17 2006 +0900
@@ -497,6 +497,9 @@
     reserve("__builtin_expect",BUILTIN_EXPECT);
     reserve("__attribute__",ATTRIBUTE);
     reserve("__label__",LABEL);
+    reserve("__FILE__",C_FILE);
+    reserve("__FUNCTION__",C_FUNCTION);
+    reserve("__LINE__",C_LINE);
 #if ASM_CODE
     reserve("asm",ASM);
     reserve("__asm__",ASM);
@@ -1652,7 +1655,7 @@
     extrn_use(n);
     local_static_list = &null_nptr;
     fnptr=n;
-    n->sc = CODE;
+    // n->sc = CODE;
     n->ty = type;
     fcheck(n);
     disp = -args;
@@ -1752,7 +1755,7 @@
 
     n->ty = type;
     fcheck(n);
-    n->sc = FUNCTION;
+    // n->sc = FUNCTION;  // static information?
     mode=ADECL;
     if (sym!=LC) {
 	arglist = fnptr->dsp;
@@ -1811,7 +1814,13 @@
 
     top_init();
 
-    stmode = (n->sc==EXTRN||n->sc==EXTRN1)?EXTRN:STATIC;
+    stmode = STATIC;
+    if (is_code(n)||is_function(n)) {
+	if (n->sc==EXTRN1||n->sc==EXTRN) {
+	    stmode = EXTRN;
+	}
+    }
+
     if(!chk) gen_enter(n->nm);
     extrn_use(n);
     local_static_list = &null_nptr;
@@ -3254,8 +3263,10 @@
 	    extrn_use(nptr);
 	    break;
 	case FLABEL: case BLABEL:
+	    return fname(nptr);
 	case FUNCTION: case CODE:
-	    return fname(nptr);
+	    error(-1);
+	    break;
 	case LVAR:
 	case IVAR:
 	case LREGISTER:
@@ -3354,6 +3365,24 @@
 	e1=list2(ENVIRONMENT,0);
 	getsym(0);
 	break;
+    case C_FILE:
+	nptr=get_name(filep->name0,0,0);
+	type=list3(ARRAY,CHAR,nptr->dsp);
+	e1=list3(STRING,(int)nptr->nm,nptr->dsp);
+	getsym(0);
+	break;
+    case C_FUNCTION:
+	nptr=get_name(fnptr->nm,0,0);
+	type=list3(ARRAY,CHAR,nptr->dsp);
+	e1=list3(STRING,(int)nptr->nm,nptr->dsp);
+	getsym(0);
+	break;
+    case C_LINE:
+	type=UNSIGNED;
+	e1=list2(CONST,lineno);
+	getsym(0);
+	break;
+
     case LPAR:
 	conv->lpar_();
 	getsym(0);
--- a/mc.h	Mon Jan 02 09:49:35 2006 +0900
+++ b/mc.h	Mon Jan 02 12:55:17 2006 +0900
@@ -83,6 +83,10 @@
 #define TYPEOF  (-59)
 #define ASM     (-60)
 
+#define C_FILE     (-61)
+#define C_FUNCTION     (-62)
+#define C_LINE     (-63)
+
 /* reserved word end */
 
 #define EMPTY   (-99)
--- a/test/scope.c	Mon Jan 02 09:49:35 2006 +0900
+++ b/test/scope.c	Mon Jan 02 12:55:17 2006 +0900
@@ -24,6 +24,14 @@
     int i,k;
     void *exit = &&exit0;
     i = 3;k=10;
+
+        printf("%s,%s,%d\n",
+	    __FILE__,
+	    __FUNCTION__,
+	    __LINE__
+	    );
+
+
     for(int k=0;k<10;k++) { 
 	int i;
 	i = 4;
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/tmpa.code-out	Mon Jan 02 12:55:17 2006 +0900
@@ -0,0 +1,3 @@
+#0011:charno:5   x,y:50.000000,30.000000   hp:100
+#0042:0 0
+#0023:15