diff mc-macro.c @ 712:bf94c295d763 compiler-64bit

*** empty log message ***
author kono
date Sat, 27 Oct 2007 23:20:44 +0900
parents 35e6841ba01a
children 88e364604533
line wrap: on
line diff
--- a/mc-macro.c	Sat Oct 27 13:30:38 2007 +0900
+++ b/mc-macro.c	Sat Oct 27 23:20:44 2007 +0900
@@ -44,6 +44,13 @@
 static int macro_processing();
 
 /*
+    nptr->dsp
+        list3s(MACRO,arg,char*)
+
+    list3s(STRING,next,char*)
+ */
+
+/*
 
 macro_expansion(NMTBL *nptrm)
     innput macro term (and chptr for arguments)
@@ -54,7 +61,7 @@
 
     In macro_function and macro_eavl,
     expand result is put into macrop local variable.
-	list2("replaced string",next)
+	list3s(STRING,next,char*)
     to generate result, mappend/reverse0 is necessary.
     
  */
@@ -76,7 +83,7 @@
     if (nptrm->sc == FMACRO) {
         macrop=macro_function(macrop,&chptr,nptrm,0);
     } else {
-        macrop=macro_eval(macrop,(char *)car(nptrm->dsp),0);
+        macrop=macro_eval(macrop,scaddr(nptrm->dsp),0);
     }
 
     // copy output from resulted listed string
@@ -138,7 +145,7 @@
      }
 #endif
     // push previous chptr, and change it to the generate macro
-    chptrsave = glist2((int)chptr,chptrsave);  // push old one into the stack
+    chptrsave = glist3s(STRING,chptrsave,chptr); // push old one into the stack
     chsave = glist2(ch,chsave);
     chptr = macropp;
     ch = *chptr++;
@@ -675,7 +682,7 @@
 /* macro define from chptr 
 
        body will be copied and stored in nptr->dsp 
-	    list2( string,  list of argments (if any))
+	    list3s( STRING, list of argments (if any), char *)
        We don't expand macro here, it just copied.
 
  */
@@ -705,8 +712,8 @@
     // equal is allowed for -Dhoge=aho option
     // if (ch=='=') chptr++;
     while((c=*chptr)==' '||c=='\t') chptr++;
-    nptr->dsp = list2((int)cheap->ptr,args); /* macro body */
-    body = (char **)&car(nptr->dsp);
+    nptr->dsp = list3s(MACRO,args,cheap->ptr); /* macro body */
+    body = (char **)&scaddr(nptr->dsp);
 
     // now copy it to the body
     while ((*cheap->ptr = c = *chptr++)
@@ -757,8 +764,8 @@
     int plevel = 0;
     char **body;
     char *chptr = *pchptr;
-    int args = list2((int)cheap->ptr,0);
-    body = (char **)&car(args);
+    int args = glist3s(STRING,0,cheap->ptr);
+    body = (char **)&scaddr(args);
     for(;;) {
         *cheap->ptr = c = *chptr++;
 	cheap = increment_cheap(cheap,body);
@@ -808,8 +815,8 @@
 	} if (plevel==0) {
 	    if (c==',') {
 		cheap->ptr[-1] = 0;
-		args = list2((int)cheap->ptr,args);
-		body = (char **)&car(args);
+		args = list3s(STRING,args,cheap->ptr);
+		body = (char **)&scaddr(args);
 	    } else if (c==')') {
 		cheap->ptr[-1] = 0;
 		break;
@@ -863,7 +870,7 @@
     // eval all argument list
     evalues = 0;
     while(values) {
-	evalues = list2(macro_eval(0,(char *)car(values),history),evalues);
+	evalues = list2(macro_eval(0,scaddr(values),history),evalues);
 	values = cadr(values);
     }
     // define all arguments locally
@@ -873,13 +880,13 @@
     enter_scope();
     while(args) {
 	mappend0(reverse0(car(evalues)),&macro);
-	local_define((char *)car(args),macro);
+	local_define(scaddr(args),macro);
 	args = cadr(args);
 	evalues = cadr(evalues);
     }
     // process body replacement
-    macro = (char *)car(nptr->dsp);
-    macrop = macro_eval(macrop,macro,list2((int)macro,history));
+    macro = scaddr(nptr->dsp);
+    macrop = macro_eval(macrop,macro,list3s(STRING,history,macro));
     args = sargs;
     // unbind arguments
     leave_scope();
@@ -920,8 +927,8 @@
     char *body = body0;
     char **expand;
     NMTBL *nptrm;
-    macrop = list2((int)cheap->ptr,macrop);
-    expand = (char **)&car(macrop);
+    macrop = list3s(STRING,macrop,cheap->ptr);
+    expand = (char **)&scaddr(macrop);
     for(; (c = *body++) ;) {
 	if (in_quote) {
 	    if (c=='\\') {
@@ -971,7 +978,7 @@
 	    c = *body;
 	    nptrm = name_space_search(nptrm,MACRO);
 	    if (nptrm->dsp)
-		macro = (char *)car(nptrm->dsp);
+		macro = scaddr(nptrm->dsp);
 	    else
 		macro="";
 //	    if (check_recurse(macro,history)) goto skip;
@@ -987,9 +994,9 @@
 		cheap = increment_cheap(cheap,expand);
 		body++;
 		macrop = macro_function(macrop,&body,nptrm,
-			list2((int)macro,history));
-		macrop = list2((int)cheap->ptr,macrop);
-		expand = (char **)&(car(macrop));
+			list3s(STRING,history,macro));
+		macrop = list3s(STRING,macrop,cheap->ptr);
+		expand = (char **)&(scaddr(macrop));
 		break;
 	    case MACRO:
 		if (neqname(nptrm->nm,macro)) {
@@ -1003,9 +1010,9 @@
 		    }
 		    *cheap->ptr = 0;
 		    cheap = increment_cheap(cheap,expand);
-		    macrop=macro_eval(macrop,macro,list2((int)macro,history));
-		    macrop = list2((int)cheap->ptr,macrop);
-		    expand = (char **)&(car(macrop));
+		    macrop=macro_eval(macrop,macro,list3s(STRING,history,macro));
+		    macrop = list3s(STRING,macrop,cheap->ptr);
+		    expand = (char **)&(scaddr(macrop));
 		    break;
 		}
 	    default:
@@ -1041,7 +1048,7 @@
     char *p;
     *result = cheap->ptr;
     for(;lists;lists = cadr(lists)) {
-        p = (char *)car(lists);
+        p = scaddr(lists);
         for(;(*cheap->ptr = *p++);cheap = increment_cheap(cheap,result)) {
 	    // in_quote + \n case ? should be \n.
 	    if (p[-1]=='\n') cheap->ptr[0]=' ';
@@ -1058,7 +1065,7 @@
     char *p;
     *result = cheap->ptr;
     for(;lists;lists = cadr(lists)) {
-        p = (char *)car(lists);
+        p = scaddr(lists);
         for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,result)) {
 	    // in_quote + \n case ? should be \n.
 	    // if (p[-1]=='\n') cheap->ptr[0]=' ';