changeset 455:563a5d29ec5e

inline continue...
author kono
date Tue, 30 Nov 2004 16:46:55 +0900
parents 214272c8f2da
children b8f95294eb77
files mc-codegen.c mc-macro.c mc-parse.c
diffstat 3 files changed, 45 insertions(+), 12 deletions(-) [+]
line wrap: on
line diff
--- a/mc-codegen.c	Tue Nov 30 02:30:20 2004 +0900
+++ b/mc-codegen.c	Tue Nov 30 16:46:55 2004 +0900
@@ -148,7 +148,7 @@
   int e2,e3,t,d,t1;
   NMTBL *n;
 
-  if (mode==INLINE) {
+  if (inmode) {
 	return (parse = list3(ST_COMP,parse,e1));
   }
   if (!control) return VOID;
@@ -269,6 +269,8 @@
     case CODE:
 	jump(e2,caddr(e1));
 	return VOID;
+    case INLINE:
+	return g_expr0(pexpr(e1));
     case INDIRECT:
 	return g_expr0(e2);
     case RINDIRECT:  
@@ -3119,6 +3121,7 @@
 extern void
 checkret(void)
 {
+    if (inmode) error(-1);
     if (cslabel==0) {
 	if (!control) error(-1); // no execute code in switch
 	checkjmp(0);
@@ -4200,7 +4203,7 @@
 
 static void
 st_decl(int e1){
-    NMTBL *n = (NMTBL *)caddr(e1);
+    // NMTBL *n = (NMTBL *)caddr(e1);
     // int stmode = cadddr(e1);
 }
  
@@ -4366,7 +4369,7 @@
  
 static void
 st_comp(int e1){
-    g_expr_u(e1);
+    g_expr_u(caddr(e1));
 }
 
  
@@ -4559,7 +4562,7 @@
 
 static void
 st_comment(int e1){
-    gen_comment((char *)car(e1));
+    gen_comment((char *)caddr(e1));
 }
 
 /* end */
--- a/mc-macro.c	Tue Nov 30 02:30:20 2004 +0900
+++ b/mc-macro.c	Tue Nov 30 16:46:55 2004 +0900
@@ -211,6 +211,7 @@
 {
     int i;
     int c;
+    char num[10];
 
     if (next_eof) {
 	next_eof=0;
@@ -242,7 +243,31 @@
 	    }
 	}
 	*chptr = '\0';
-	if (lsrc && !asmf && !macro_if_skip && linebuf[0]) gen_comment(linebuf);
+	if (lsrc && !asmf && !macro_if_skip && linebuf[0]) {
+	    gen_comment(linebuf);
+	    if (inmode) {
+		int i=0;
+		int c;
+		char *p = cheap->ptr;
+		sprintf(num,"%d: ",lineno);
+		c = 0;
+		while((*cheap->ptr = num[c++])) 
+		    cheap = increment_cheap(cheap,&p);
+		while((c = *cheap->ptr = linebuf[i++])) {
+		    cheap = increment_cheap(cheap,&p);
+		    if (c=='\n') {
+			*cheap->ptr = 0;
+			cheap = increment_cheap(cheap,&p);
+			parse = list3(ST_COMMENT,parse,(int)p);
+			p = cheap->ptr;
+			sprintf(num,"%d: ",lineno);
+			c = 0;
+			while((*cheap->ptr = num[c++])) 
+			    cheap = increment_cheap(cheap,&p);
+		    }
+		}
+	    }
+	}
 	if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
 	    if (macro_processing()) return;
 	}
--- a/mc-parse.c	Tue Nov 30 02:30:20 2004 +0900
+++ b/mc-parse.c	Tue Nov 30 16:46:55 2004 +0900
@@ -1638,7 +1638,8 @@
 	extrn_use(n);
 	retlabel=fwdlabel();
     } else {
-	if (parse) error(-1);
+	if (parse && (car(parse)!=ST_DECL&&car(parse)!=ST_COMMENT)) error(-1);
+	parse = 0;
     }
     local_static_list = &null_nptr;
     fnptr=n;
@@ -1761,7 +1762,8 @@
 	docomp(use);
 	return;
     case BREAK:
-	checkret();
+	if (!inmode)
+	    checkret();
 	conv->break_();
 	if (control) {
 	    if (inmode) {
@@ -1774,9 +1776,12 @@
 	checksym(SM);
 	return;
     case CONTINUE:
-	checkret();
+	if (!inmode)
+	    checkret();
 	conv->continue_();
-	if (control) gen_jmp(clabel);
+	if (inmode) {
+	    parse = list2(ST_CONTINUE,parse);
+	} else if (control) gen_jmp(clabel);
 	getsym(0);
 	checksym(SM);
 	return;
@@ -1930,7 +1935,7 @@
     sbreak=blabel;
     scontinue=clabel;
     if (inmode) {
-	parse = pparse; parse = 0;
+	pparse = parse; parse = 0;
     } else {
 	blabel=fwdlabel();
 	clabel=fwdlabel();
@@ -3196,7 +3201,7 @@
 	    if (inmode) {
 		int sparse = parse; parse = 0;
 		docomp(1);
-		e1 = list3(ST_COMP,0,parse);
+		e1 = parse;
 		parse = sparse;
 	    } else {
 		if (cntl) {
@@ -3452,7 +3457,7 @@
 {
     char *p,*q,*from,*to;
     int i;
-    if (cheap->ptr == cheap->last) {
+    if (cheap->ptr >= cheap->last-1) {
 	if (!cheap->next) { 
 	    cheap->next = new_cheap();
 	}