changeset 327:da2e3f2d127d

macro/codegen reorganization
author kono
date Mon, 21 Jun 2004 23:50:34 +0900
parents e5d40f8c4cce
children 7ecb023d29b8
files Changes Makefile conv/c.c conv/null.c conv_func.pl mc-code-ia32.c mc-code-mips.c mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h mc-macro.c mc-macro.h mc-parse.c mc-parse.h mc-switch.c mc-tree.c mc.h
diffstat 18 files changed, 2941 insertions(+), 2716 deletions(-) [+]
line wrap: on
line diff
--- a/Changes	Sun Jun 20 20:54:24 2004 +0900
+++ b/Changes	Mon Jun 21 23:50:34 2004 +0900
@@ -5049,3 +5049,19 @@
 木でやるべきなのか、という問題もあるわけか。
 
 macro も分割した方が良いね。
+
+Mon Jun 21 00:29:12 JST 2004
+
+mc-tree は、もう時代遅れ。切り離した方が良い。
+conv も、だめなんじゃない?
+
+なんか、随分、変えちゃったな。動かすのが大変そう。
+
+できるだけ static にするんだけど...
+     mc-codegen からだけ参照される mc-parse.c のextern
+ってのが C では表現できない。一旦、extern すると使われてなくても
+何にも言わなくなるから。
+
+mc-codegen の使っている変数のうち、どれがstaticなんだが検出できない。
+
+emit_data_closing の場所が変。
--- a/Makefile	Sun Jun 20 20:54:24 2004 +0900
+++ b/Makefile	Mon Jun 21 23:50:34 2004 +0900
@@ -10,7 +10,7 @@
 PRINTF= # printf.c
 CONVERTER=conv/c.o conv/null.o
 # conv/c2cbc.o conv/cbc2c.o
-COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-tree.o
+COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o
 # CODE=mc-code-ia32.c
 CODE=mc-code-$(ARCH).c
 
@@ -21,6 +21,7 @@
 
 TAGS:
 	ctags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \
+		mc-macro.c \
 		mc-parse.c mc-tree.c mc-switch.c mc-switch.h \
 		mc.h conv/c.c conv/c.h \
 		conv/conv.h conv/convdef.h conv/null.c
@@ -143,11 +144,11 @@
 clean :
 	-rm -f mc mc-ia32 mc-powerpc mc-mips *.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
 
-mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o $(CONVERTER)
-	$(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o $(CONVERTER)
+mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o $(CONVERTER)
+	$(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o $(CONVERTER)
 
-mc2 : b00.s b01.s b02.s b03.s  $(CONVERTER)
-	$(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s b04.s $(CONVERTER)
+mc2 : b00.s b01.s b02.s b03.s mc-macro.o  $(CONVERTER)
+	$(CC) -g -o $@ $(PRINTF) b00.s b01.s b02.s b03.s b04.s mc-macro.o $(CONVERTER)
 
 b00.s : mc-parse.c $(MC)
 	./$(MC) -s -ob00.s mc-parse.c
--- a/conv/c.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/conv/c.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,14 +1,16 @@
 #define EXTERN /**/
 
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 
+#include "conv/conv.h"
 #include "conv/convdef.h"
 #include "conv/c.h"
 
 extern void type_print(int type,NMTBL *nptr,FILE *out);
 extern void type_print1(int type,NMTBL *nptr,FILE *out,int cont);
 extern void sym_print(int type,FILE *out);
-extern NMTBL str_ret;
 
 static FILE *vout,*svout;
 static FILE *null;
@@ -206,7 +208,7 @@
 	type_print(n->ty,n,vout);
 	args=cadr(args);
 	if(args) {
-	    if(caddr(args)==(int)&str_ret) break;
+	    /* if(caddr(args)==(int)&str_ret) break; */
 	    fprintf(vout,",");
 	}
     }
--- a/conv/null.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/conv/null.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,11 +1,11 @@
 /* Do not edit this file. This is automatically generated. */
 /* Edit conv_func.tbl */
-#define EXTERN /**/
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
+#include "conv/conv.h"
 #include "conv/convdef.h"
-
 #include "conv/null.h"
-
 static void
 conv_()
 { }
--- a/conv_func.pl	Sun Jun 20 20:54:24 2004 +0900
+++ b/conv_func.pl	Mon Jun 21 23:50:34 2004 +0900
@@ -17,10 +17,15 @@
 print NUL "/* Edit $in */\n";
 
 print OUT "typedef struct converter {\n";
-print NUL "#define EXTERN /**/\n";
+
+print NUL "#include <stdio.h>\n";
 print NUL "#include \"mc.h\"\n";
-print NUL "#include \"conv/convdef.h\"\n\n";
-print NUL "#include \"conv/null.h\"\n\n";
+print NUL "#include \"mc-parse.h\"\n";
+
+print NUL "#include \"conv/conv.h\"\n";
+print NUL "#include \"conv/convdef.h\"\n";
+print NUL "#include \"conv/null.h\"\n";
+
 
 while(<IN>) {
     if (/([^\s]*)\s+([_a-zA-Z0-9]*)\((.*)\)/) {
--- a/mc-code-ia32.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-code-ia32.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,8 +1,9 @@
 /* Micro-C Code Generation Part for intel386 */
 /* $Id$ */
 
-#define EXTERN extern
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 #include "mc-codegen.h"
 #include "mc-code.h"
 
@@ -24,13 +25,6 @@
 #define    SIZE_OF_LONGLONG  8
 #define    ENDIAN  0
 
-int    size_of_int = SIZE_OF_INT;
-int    size_of_short = SIZE_OF_SHORT;
-int    size_of_float = SIZE_OF_FLOAT;
-int    size_of_double = SIZE_OF_DOUBLE;
-int    size_of_longlong = SIZE_OF_LONGLONG;
-int    endian = ENDIAN;
-
 #define SAVE_STACKS 1
 
 #define TEXT_EMIT_MODE 0
@@ -49,7 +43,7 @@
 #define REAL_MAX_REGISTER 8    /* intel386のレジスタが8つということ*/
 static int MAX_DATA_REG=4;    
 static int MAX_POINTER=3;    
-// static int MAX_REGISTGER_VAR=2;    
+int MAX_REGISTER_VAR=2;    
 // static int MAX_FREGISTER=1;
 
 #define MAX_FPU_STACK 7
@@ -91,7 +85,7 @@
           arg2       12 4
             see enter/enter1/leave           see code_enter
  */
-// static int arg_offset = 8;
+static int arg_offset;
 // static int disp_offset = -12;
 #define func_disp_offset -12
 #define code_disp_offset 0
@@ -216,7 +210,8 @@
     return i==REG_L?"%esi":"%eax";
 }
 
-char *init_src = "\
+static
+char *init_src0 = "\
 #define va_list int\n\
 #define va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
 #define va_arg(ap,type)  (*((type *)ap)++)\n\
@@ -236,10 +231,20 @@
 #define __GNUC__ 2\n\
 ";
 
-void
+extern void
 code_init(void)
 {
 
+    /* called only once */
+
+    init_src = init_src0;
+    size_of_int = SIZE_OF_INT;
+    size_of_short = SIZE_OF_SHORT;
+    size_of_float = SIZE_OF_FLOAT;
+    size_of_double = SIZE_OF_DOUBLE;
+    size_of_longlong = SIZE_OF_LONGLONG;
+    endian = ENDIAN;
+
     arg_offset = 8;
     // func_disp_offset = -12;
     disp_offset = -12;
@@ -267,6 +272,13 @@
 
 }
 
+extern void
+emit_reinit()
+{
+    /* called for each file */
+}
+
+
 char *
 register_name(int i,int byte)
 {
@@ -1751,7 +1763,7 @@
     code_disp_label=fwdlabel();
     printf("\tlea _%d(%%ebp),%%esp\n",code_disp_label);
 
-    printf("## args %d disp %d code_arg_offset=%d code_disp_offset=%d\n",args,disp,code_arg_offset,code_disp_offset); 
+    printf("## args %d disp %d  code_disp_offset=%d\n",args,disp,code_disp_offset); 
 }
 
 void
--- a/mc-code-mips.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-code-mips.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,8 +1,10 @@
 /* Micro-C Code Generation Part for Power PC (Mac OS X) */
 /* $Id$ */
 
-#define EXTERN extern
+
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 #include "mc-code.h"
 #include "mc-codegen.h"
 
@@ -59,13 +61,6 @@
 #define SIZE_OF_LONGLONG  8
 #define ENDIAN  0
 
-int size_of_int = SIZE_OF_INT;
-int size_of_short = SIZE_OF_SHORT;
-int size_of_float = SIZE_OF_FLOAT;
-int size_of_double = SIZE_OF_DOUBLE;
-int size_of_longlong = SIZE_OF_LONGLONG;
-int endian = ENDIAN;
-
 static int  reg_sp;   /* REGister Stack-Pointer */
 static int reg_stack[MAX_MAX];  /* 実際のレジスタの領域 */
 
@@ -448,7 +443,7 @@
 
 // va_start, va_arg is wrong, use va_mips.h
 
-char *init_src = "\
+static char *init_src0 = "\
 /* #define __builtin_va_list int */\n\
 /* #define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg)) */\n\
 /* #define __builtin_va_arg(ap,type)  (*((type *)ap)++) */\n\
@@ -473,6 +468,15 @@
 code_init(void)
 {
     int reg;
+    /* called only once */
+
+    size_of_int = SIZE_OF_INT;
+    size_of_short = SIZE_OF_SHORT;
+    size_of_float = SIZE_OF_FLOAT;
+    size_of_double = SIZE_OF_DOUBLE;
+    size_of_longlong = SIZE_OF_LONGLONG;
+    endian = ENDIAN;
+    init_src = init_src0;
 
     init_ptr_cache();
     reg=RET_LREGISTER;
@@ -486,6 +490,13 @@
     regv_h(reg) = LREGISTER_OPERAND_1_H;
 }
 
+extern void
+emit_reinit()
+{
+    /* called for each file */
+}
+
+
 
 void
 gexpr_code_init(void){
@@ -988,6 +999,8 @@
 
 emit_init(void)
 {
+    /* called before each declaration */
+
     free_all_register();
     max_reg_var=0; max_freg_var=0;
     reg_sp = 0;
--- a/mc-code-powerpc.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-code-powerpc.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,8 +1,9 @@
 /* Micro-C Code Generation Part for Power PC (Mac OS X) */
 /* $Id$ */
 
-#define EXTERN extern
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 #include "mc-code.h"
 #include "mc-codegen.h"
 
@@ -13,7 +14,8 @@
 
 // __builtin_expect(a,t) branch prediction
 
-char *init_src = "\
+static
+char *init_src0 = "\
 #define __ppc__ 1\n\
 #define __BIG_ENDIAN__ 1\n\
 #define __STDC__ 1\n\
@@ -61,13 +63,6 @@
 #define SIZE_OF_LONGLONG  8
 #define ENDIAN  1
 
-int size_of_int = SIZE_OF_INT;
-int size_of_short = SIZE_OF_SHORT;
-int size_of_float = SIZE_OF_FLOAT;
-int size_of_double = SIZE_OF_DOUBLE;
-int size_of_longlong = SIZE_OF_LONGLONG;
-int endian = ENDIAN;
-
 static int  reg_sp;   /* REGister Stack-Pointer */
 static int reg_stack[MAX_MAX];  /* 実際のレジスタの領域 */
 
@@ -413,39 +408,29 @@
 void
 code_init(void)
 {
-#if 0
-    macro_define("__ppc__ 1\n");
-    macro_define("__BIG_ENDIAN__ 1\n");
-//    macro_define("_BSD_CT_RUNE_T_ int\n");
-//    macro_define("__STDC__ 1\n");
-    macro_define("__builtin_va_list int\n");
-#endif
+    /* called only once */
+
+    init_src = init_src0;
+    size_of_int = SIZE_OF_INT;
+    size_of_short = SIZE_OF_SHORT;
+    size_of_float = SIZE_OF_FLOAT;
+    size_of_double = SIZE_OF_DOUBLE;
+    size_of_longlong = SIZE_OF_LONGLONG;
+    endian = ENDIAN;
+
     init_ptr_cache();
     regv_l(RET_LREGISTER) = RET_LREGISTER_L;
     regv_h(RET_LREGISTER) = RET_LREGISTER_H;
 }
 
+extern void
+emit_reinit()
+{
+    /* called for each file */
+}
+
 void
 gexpr_code_init(void){
-#if 0
-    int new_reg,old_reg,dm;
-    /* register shuffling */
-    if (is_int_reg(creg)) {
-	dm = get_register();
-	new_reg = get_register();
-	old_reg = creg;
-	ireg = creg = new_reg;
-	free_register(old_reg);
-	free_register(dm);
-    } else if (is_float_reg(creg)) {
-	dm = get_dregister(1);
-	new_reg = get_dregister(1);
-	old_reg = creg;
-	freg = creg = new_reg;
-	free_register(old_reg);
-	free_register(dm);
-    }
-#endif
 }
 
 void
@@ -961,6 +946,8 @@
 
 emit_init(void)
 {
+    /* called before each declaration */
+
     free_all_register();
     max_reg_var=-1; max_freg_var=-1;
     reg_sp = 0;
@@ -2719,7 +2706,7 @@
     printf("\tb\tL_%d\n",l);
 }
 
-void
+extern void
 gen_comment(char *s)
 {
     if (chk) return;
@@ -4979,8 +4966,8 @@
                                1    can't be used in input
  */
 
-int
-asm_operand(char *p,int e1,int mode,int repl,int n,int repl0)
+extern int
+code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0)
 {
     int r;
     int c;
@@ -5035,7 +5022,7 @@
 }
 
 void
-free_asm_operand(int repl)
+code_free_asm_operand(int repl)
 {
     for(;repl;repl=cadr(repl)) {
 	if (car(car(repl))==REGISTER)
@@ -5045,7 +5032,7 @@
 
 
 extern void
-replace_asm_string(char *asm_str,int repl)
+code_asm(char *asm_str,int repl)
 {
     int c,i,rstr,val;
     char *p;
--- a/mc-code.h	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-code.h	Mon Jun 21 23:50:34 2004 +0900
@@ -9,13 +9,7 @@
 
 extern char *l_include_path[];
 
-extern char *init_src;
-extern int size_of_int;
-extern int size_of_short;
-extern int size_of_float;
-extern int size_of_double;
-extern int size_of_longlong;
-extern int endian;
+extern int disp_offset;
 
 extern int MAX_REGISTER; 
 extern int MAX_REGISTGER_VAR;
@@ -29,10 +23,28 @@
 
 #define REG_LVAR_OFFSET 2
 
+
 extern int code_lassop_p;
 
-extern void code_init();
+/* used by mc-codegen */
+
+extern void gexpr_init(void);
+extern void emit_init(void);   /* called before delcalartion */
+extern void gen_gdecl(char *n, int gpc);
+
+extern void code_init();   /* called only once */
+extern void emit_reinit(); /* called for each file */
+
 extern void gexpr_code_init(void);
+
+extern void code_enter(char *name);
+extern void code_enter1(int args);
+extern void code_leave(char *name);
+extern void enter(char *name);
+extern void enter1();
+extern void leave(int control, char *name);
+extern void jmp(int l);
+
 extern int get_register_var(NMTBL *n);
 extern int get_dregister_var(NMTBL *n,int d);
 extern int get_lregister_var(NMTBL *n);
@@ -226,10 +238,12 @@
 
 #if ASM_CODE
 
-extern void replace_asm_string(char *asm_str,int repl);
-extern int asm_operand(char *p,int e1,int mode,int repl,int n,int repl0);
-extern void free_asm_operand(int repl);
+extern void code_asm(char *asm_str,int repl);
+extern int code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0);
+extern void code_free_asm_operand(int repl);
 
 #endif
 
-/* */
+extern void gen_comment(char *s);
+
+/* end */
--- a/mc-codegen.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-codegen.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,25 +1,35 @@
 /* Micro-C Generic Code Generation Part */
 /* $Id$ */
 
-#define EXTERN extern
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 #include "mc-codegen.h"
 #include "mc-code.h"
 
 int use;       /* generated value will be used */
+char *init_src;
+int size_of_int;
+int size_of_short;
+int size_of_float;
+int size_of_double;
+int size_of_longlong;
+int bit_of_byte;
+int endian;
 
-static void remove0(int *parent,int e) ;
-/* static void remove0_all(int *parent,int e) ; */
+static void assign(int e1);
+static void gen_asm(int asm0,int in,int out,int opt,int e);
+static void compatible(int t1, int t2);
+static int contains(int e,int type);
+static int contains_in_list(int e,int type);
+static int contains_in_list_p(int e,int (*p)(int));
+static void iassop(int e1);
 static int is_same_type(int e1,int e2);
 static void jump(int e1, int env);
 static void machinop(int e1);
+static int register_to_lvar(int e);
+static void remove0(int *parent,int e) ;
 static void sassign(int e1);
-static void assign(int e1);
-static void assop(int e1);
-static int g_expr0(int e1);
-static int register_to_lvar(int e);
-static void bexpr_u(int e1, char cond, int l1);
-static void code_asm(int asm0,int in,int out,int opt,int e);
 
 #if FLOAT_CODE
 
@@ -37,19 +47,35 @@
 #endif
 
 
-void
+extern void
 codegen_init()
 {
+    /* called only once */
     code_init();
 }
 
-void 
+extern void
+codegen_reinit()
+{
+    /* called for each file */
+    emit_reinit();
+}
+
+extern void
+codegen_decl_init()
+{
+    /* called before each declaration */
+    emit_init();
+    init_free_lvar_list();
+}
+
+extern void 
 arg_register(NMTBL *fnptr)
 {
     code_arg_register(fnptr);
 }
 
-int
+extern int
 gexpr(int e1,int use0)
 {
     if (chk) return INT;
@@ -63,7 +89,9 @@
     return g_expr0(e1);
 }
 
-int
+/* gexpr for value unused */
+
+extern int
 g_expr_u(int e1)
 {
     int t;
@@ -75,7 +103,9 @@
     return t;
 }
 
-int
+/* gexpr for value used */
+
+extern int
 g_expr(int e1)
 {
     int t;
@@ -87,7 +117,9 @@
     return t;
 }
 
-int
+/* gexpr for used flag untouched */
+
+extern int
 g_expr0(int e1)
 {
     int e2,e3,t,d,t1;
@@ -389,7 +421,7 @@
 	assign(e1);
 	return INT;
     case ASSOP: case CASSOP: case CUASSOP:
-	assop(e1);
+	iassop(e1);
 	return INT;
 #if FLOAT_CODE
     case FASS: case DASS: 
@@ -427,7 +459,7 @@
 	return ADDRESS;
 #if ASM_CODE
     case ASM:
-	code_asm(car(e2),cadr(e2),caddr(e2),cadddr(e2),caddr(e1));
+	gen_asm(car(e2),cadr(e2),caddr(e2),cadddr(e2),caddr(e1));
         /*        asm    in (str) out (str) opt(str)   expr */
 	return VOID;
 #endif
@@ -445,7 +477,7 @@
         op==FOP+EQ|| op==FOP+NEQ || \
         op==EQ|| op==NEQ|| op==DOP+EQ|| op==DOP+NEQ)
 
-int
+static int
 rop_dual(op)
 {
     //   x op y => y dual(op) x
@@ -479,7 +511,9 @@
     return op;
 }
 
-void
+/* bexpr for value unused */
+
+extern void
 bexpr_u(int e1, char cond, int l1)
 {
     int op = car(e1);
@@ -491,7 +525,9 @@
 	b_expr(e1,cond,l1,0);
 }
 
-void
+/* bexpr for value used */
+
+extern void
 bexpr(int e1, char cond, int l1)
 {
     int uses = use; use=1;
@@ -499,7 +535,11 @@
     use = uses;
 }
 
-void
+/* branch expression generator    */
+/*    if (cond?e1:!e1) goto  l1   */
+/* 1 or 0 is return for code_bool */
+
+extern void
 b_expr(int e1, char cond, int l1,int err)
 {
     int e2,l2,t;
@@ -646,21 +686,21 @@
     }
 }
 
-int 
+extern int 
 is_code(NMTBL *fnptr)
 {
     int type = fnptr->ty;
     return type==CODE|| (type>0 && car(type)==CODE);
 }
 
-int 
+extern int 
 is_function(NMTBL *fnptr)
 {
     int type = fnptr->ty;
     return type==FUNCTION || (type>0 && car(type)==FUNCTION);
 }
 
-int 
+extern int 
 function_type(int e1,int *dots)
 {
     int ret_type,t;
@@ -720,7 +760,7 @@
 //
 //  target = list3(target_regnum,next,source_regnum);
 
-void
+extern void
 parallel_rassign(int assigns)
 {
     int free,tmp,tmp_target,remains,t0,t2,src;
@@ -770,7 +810,7 @@
 
 #define DEBUG_PARALLEL_ASSIGN 0
 
-int
+static int
 overrap(int t,int sz,int source)
 {
     int s,s0,s1;
@@ -793,7 +833,7 @@
     return 0;
 }
 
-void
+static void
 remove_target(int *target,int t,int *use)
 {
     int use0=*use;
@@ -810,7 +850,7 @@
     remove0(target,t);
 }
 
-void
+static void
 save_target(int t,int s,int *target,int *use,int sz,int ty)
 {
     int e1;
@@ -846,7 +886,7 @@
     }
 }
 
-int
+static int
 circular_dependency(int t,int s,int *target,int *source)
 {
     int target0=*target;
@@ -872,7 +912,7 @@
     return 0;
 }
 
-void
+static void
 parallel_assign(int *target,int *source,int *processing,int *use)
 {
     int t,s,sz,ty,target0,s1;
@@ -909,7 +949,7 @@
     }
 }
 
-void 
+static void 
 remove0(int *parent,int e) 
 {
     int list;
@@ -923,7 +963,7 @@
 }
 
 /*
-void 
+static void 
 remove0_all(int *parent,int e) 
 {
     int list;
@@ -937,7 +977,7 @@
 }
  */
 
-int
+static int
 is_simple(int e1) 
 {
     return (
@@ -949,7 +989,7 @@
     );
 }
 
-int
+static int
 is_same_type(int e1,int e2)
 {
     int ce1=car(e1);
@@ -968,7 +1008,7 @@
     );
 }
 
-int
+static int
 is_memory(int e1)
 {
     int ce1=car(e1);
@@ -983,7 +1023,7 @@
 }
 
 
-void
+static void
 jump(int e1, int env)
 {
     int e2,e3,e4,sz,arg_size,ty,regs,fregs;
@@ -1111,7 +1151,7 @@
     }
 }
 
-void
+static void
 machinop(int e1)
 {
     int e2,e3,op;
@@ -1133,7 +1173,7 @@
 }
 
 #if FLOAT_CODE
-void
+static void
 dmachinop(int e1,int d)
 {
     int e2,e3,op;
@@ -1151,7 +1191,7 @@
 #endif
 
 #if LONGLONG_CODE
-void
+static void
 lmachinop(int e1)
 {
     int e2,e3,op;
@@ -1173,7 +1213,7 @@
 }
 #endif
 
-void
+static void
 sassign(int e1)
 {
     int e2,e3,e4,sz,xreg,det,offset;
@@ -1248,7 +1288,7 @@
     }
 }
 
-void
+static void
 assign(int e1)
 {
     int e2,e4,byte,e5;
@@ -1337,7 +1377,7 @@
     }
 }
 
-void
+static void
 dassign(int e1)
 {
     int e2,e3,e4,d,e5;
@@ -1389,7 +1429,7 @@
 
 #if LONGLONG_CODE
 
-void
+static void
 lassign_opt(int e5,int e2,int e4)
 {
     int reg;
@@ -1423,7 +1463,7 @@
     }
 }
 
-void
+static void
 lassign(int e1)
 {
     int e2,e3,e4,e5;
@@ -1468,8 +1508,301 @@
 
 #endif
 
-void
-assop(int e1)
+/* numerical type conversion */
+
+static int
+double_value(int e2,int type)
+{
+#if FLOAT_CODE
+    if (car(e2)==CONST)  return dlist2(DCONST,(double)cadr(e2));
+    if (car(e2)==FCONST)  return dlist2(DCONST,dcadr(e2));
+    if(type==DOUBLE) return e2;
+    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2D);
+    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2D);
+    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2D);
+    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2D);
+    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2D);
+    error(TYERR); return dlist2(DCONST,1.0);
+#else
+    error(TYERR); return list2(CONST,0);
+#endif
+}
+
+static int
+float_value(int e2,int type)
+{
+#if FLOAT_CODE
+#if LONGLONG_CODE
+    if (car(e2)==LCONST)  return  dlist2(FCONST,(double)lcadr(e2));
+    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2F);
+    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2F);
+#endif
+    if (car(e2)==CONST)  return dlist2(FCONST,(double)cadr(e2));
+    if (car(e2)==DCONST)  return dlist2(FCONST,dcadr(e2));
+    if(type==FLOAT) return e2;
+    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2F);
+    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2F);
+    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2F);
+    error(TYERR); return dlist2(DCONST,1.0);
+#else
+    error(TYERR); return list2(CONST,0);
+#endif
+}
+
+static int
+longlong_value(int e2,int type)
+{
+#if LONGLONG_CODE
+    if (car(e2)==CONST)  return llist2(LCONST,(long long)cadr(e2));
+    if (car(e2)==LCONST)  return e2;
+#if FLOAT_CODE
+    if (car(e2)==DCONST||car(e2)==FCONST)
+        return llist2(LCONST,(long long)dcadr(e2));
+    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2LL);
+    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2LL);
+#endif
+    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2LL);
+    if(type==LONGLONG) return e2;
+    if(type==ULONGLONG) return e2;
+    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2LL);
+    error(TYERR); return llist2(LCONST,0LL);
+#else
+    return int_value(e2,type);
+#endif
+}
+
+static int
+ulonglong_value(int e2,int type)
+{
+#if LONGLONG_CODE
+    if (car(e2)==CONST)  return llist2(LCONST,(unsigned long long)cadr(e2));
+    if (car(e2)==LCONST)  return e2;
+#if FLOAT_CODE
+    if (car(e2)==DCONST||car(e2)==FCONST)
+        return llist2(LCONST,(unsigned long long)dcadr(e2));
+    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2ULL);
+    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2ULL);
+#endif
+    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2ULL);
+    if(type==LONGLONG) return e2;
+    if(type==ULONGLONG) return e2;
+    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2ULL);
+    error(TYERR); return llist2(LCONST,0LL);
+#else
+    unsigned_value(e2,type);
+#endif
+}
+
+static int
+int_value(int e2,int type)
+{
+    if(scalar(type)) return e2;
+#if FLOAT_CODE
+    if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(int)dcadr(e2));
+    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2I);
+    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2I);
+#endif
+#if LONGLONG_CODE
+    if (car(e2)==LCONST)  return list2(CONST,(int)lcadr(e2));
+    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2I);
+    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2I);
+#endif
+    if(car(type)==ARRAY) return e2;
+    error(TYERR); return list2(CONST,1);
+}
+
+static int
+unsigned_value(int e2,int type)
+{
+    if(scalar(type)) return e2;
+#if FLOAT_CODE
+    // if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(unsigned)dcadr(e2));
+    if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(int)dcadr(e2));
+    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2U);
+    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2U);
+#endif
+#if LONGLONG_CODE
+    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2U);
+    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2U);
+#endif
+    error(TYERR); return e2;
+}
+
+/* assign statement */
+
+/* keep type */
+
+extern int
+assign_expr0(int e1,int e2,int t,int type0) {
+    int stype;
+    stype=type;
+    type = type0;
+    e2 = rvalue(e2);
+    e1=assign_expr(e1,e2,t,type);
+    type=stype;
+    return e1;
+}
+
+
+
+/* with conversion (will destroy type global variable) */
+
+extern int
+assign_expr(int e1,int e2,int t,int type) {
+    if(t==VOID)
+        error(TYERR);
+    if(t==CHAR||t==UCHAR) {
+        e2=(t==UCHAR)?unsigned_value(e2,type):int_value(e2,type);
+        if (!integral(type)) error(TYERR);
+        type= INT;return(list3(CASS,e1,e2));
+    } else if(t==SHORT||t==USHORT) {
+        e2=(t==USHORT)?unsigned_value(e2,type):int_value(e2,type);
+        if (!integral(type)) error(TYERR);
+        type= t;return(list3(SASS,e1,e2));
+#if FLOAT_CODE
+    } else if(t==DOUBLE) {
+        e2=double_value(e2,type);
+        type= t;return(list3(DASS,e1,e2));
+    } else if(t==FLOAT) {
+        e2=float_value(e2,type);
+        type= t;return(list3(FASS,e1,e2));
+#endif
+#if LONGLONG_CODE
+    } else if(t==LONGLONG) {
+        e2=longlong_value(e2,type);
+        type= t;return(list3(LASS,e1,e2));
+    } else if(t==ULONGLONG) {
+        e2=ulonglong_value(e2,type);
+        type= t;return(list3(LASS,e1,e2));
+#endif
+    } else if(scalar(t)) {
+        e2=(t==UNSIGNED)?unsigned_value(e2,type):int_value(e2,type);
+        type=t;
+        return(list3(ASS,e1,e2));
+    } else if (car(t)==BIT_FIELD) {
+	e2 = correct_type(e2,cadr(t));
+        return(list3(BASS,e1,e2));
+    } else if((car(t)==STRUCT||car(t)==UNION)) {
+        if (size(t)!=size(type)) error(TYERR);
+        type=t;
+        if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) {
+            replace_return_struct(cadr(e2),e1);
+            return cadr(e2);
+        } else {
+            return (list4(STASS,e1,e2,size(t)));
+        }
+    } else {
+        error(TYERR); return list3(ASS,e1,e2);
+    }
+}
+
+extern int
+cond(int t,int e1,int e2,int e3)
+{
+    if(car(e1)==CONST) {
+	if(cadr(e1)) {type=t;return e2;} else return e3;
+    }
+#if FLOAT_CODE
+    if(type==DOUBLE||t==DOUBLE) {
+	e2=double_value(e2,t);
+	e3=double_value(e3,type);
+	t=type=DOUBLE;
+	return(list4(DCOND,e1,e2,e3));
+    }
+    if(type==FLOAT||t==FLOAT) {
+	e2=float_value(e2,t);
+	e3=float_value(e3,type);
+	t=type=FLOAT;
+	return(list4(FCOND,e1,e2,e3));
+    }
+#endif
+#if LONGLONG_CODE
+    if(type==LONGLONG||t==LONGLONG) {
+	e2=longlong_value(e2,t);
+	e3=longlong_value(e3,type);
+	t=type=LONGLONG;
+	return(list4(LCOND,e1,e2,e3));
+    }
+    if(type==ULONGLONG||t==ULONGLONG) {
+	e2=ulonglong_value(e2,t);
+	e3=ulonglong_value(e3,type);
+	t=type=ULONGLONG;
+	return(list4(LCOND,e1,e2,e3));
+    }
+#endif
+    if(type==INT||(t!=INT&&type==UNSIGNED))
+	type=t;
+    /* if (t!=type) error(TYERR); */
+    return(list4(COND,e1,e2,e3));
+}
+
+extern int
+assop(int e1,int e2,int op,int t,int no_float)
+{
+    if(!(integral(type)||type==FLOAT||type==DOUBLE||
+	type==LONGLONG||type==ULONGLONG
+	    )) error(TYERR);
+#if FLOAT_CODE
+    if (t==FLOAT) {
+	if (no_float) error(TYERR);
+	e2=float_value(e2,type); type=t;
+	return(list4(FASSOP,e1,e2,op+FOP));
+    } else if (t==DOUBLE) {
+	if (no_float) error(TYERR);
+	e2=double_value(e2,type); type=t;
+	return(list4(DASSOP,e1,e2,op+DOP));
+    }
+#endif
+#if LONGLONG_CODE
+    if (t==LONGLONG) {
+	e2=longlong_value(e2,type); type=t;
+	return(list4(LASSOP,e1,e2,op+LOP));
+    } else if (t==ULONGLONG) {
+	e2=ulonglong_value(e2,type); type=t;
+	return(list4(LASSOP,e1,e2,op+LOP+((op==MUL+AS||op==DIV+AS)?US:0)));
+    }
+#endif
+    if((t==UNSIGNED||t==UCHAR||t==USHORT||type==UNSIGNED)&&
+	(op==MUL||op==DIV||op==MOD))
+	op=op+US;
+    if((t==UNSIGNED||t==UCHAR||t==USHORT)&&(op==RSHIFT||op==LSHIFT))
+	op=op+US;
+    if(t==CHAR) {
+	type= INT;
+	return(list4(CASSOP,e1,e2,op));
+    }
+    if(t==UCHAR) {
+	type= UNSIGNED;
+	return(list4(CUASSOP,e1,e2,op));
+    }
+    if(t==SHORT) {
+	type= INT;
+	return(list4(SASSOP,e1,e2,op));
+    }
+    if(t==USHORT) {
+	type= UNSIGNED;
+	return(list4(SUASSOP,e1,e2,op));
+    }
+    if (t>0 && car(t)==BIT_FIELD) {
+	e2 = correct_type(e2,cadr(t));
+	return(list4(BASSOP,e1,e2,list2(op,t)));
+    }
+    type=t;
+    if(integral(t)) return(list4(ASSOP,e1,e2,op));
+    /* pointer += ... */
+    if(integral(t)) return(list4(ASSOP,e1,e2,op));
+    /* pointer += ... */
+    if((op!=ADD&&op!=SUB)||car(t)!=POINTER) error(TYERR);
+    e2=binop(MUL,e2,list2(CONST,size(cadr(t))),INT,UNSIGNED);
+    type=t;
+
+    return list4(ASSOP,e1,e2,op);
+}
+
+
+
+static void
+iassop(int e1)
 {
     int e2,e3,byte,op,sign,size;
     int n,t;
@@ -1528,7 +1861,7 @@
 
 #if FLOAT_CODE
 
-void
+static void
 dassop(int e1)
 {
     int e2,e3,op,d;
@@ -1564,7 +1897,7 @@
     return (op==LUDIV||op==LUMOD||op==LULSHIFT||op==LURSHIFT)?ULONGLONG:LONGLONG;
 }
 
-void
+static void
 lassop(int e1)
 {
     int e2,e3,op;
@@ -1626,26 +1959,26 @@
 
 #endif 
 
-void 
+extern void 
 cmpdimm(int e, int csreg,int label,int cond)
 {
     code_cmpdimm(e, csreg,label,cond);
 }
 
-int 
+extern int 
 csvalue()
 {
     return code_csvalue();
 }
 
 
-int
+extern int
 fwdlabel(void)
 {       
     return labelno++;
 }
 
-void
+extern void
 fwddef(int l)
 {       
     control=1;
@@ -1653,7 +1986,7 @@
 	code_label(l);
 }
 
-int
+extern int
 backdef(void)
 {       
     control=1;
@@ -1662,7 +1995,7 @@
     return labelno++;
 }
 
-void
+extern void
 def_label(int cslabel, int dlabel)
 {
     int fl;
@@ -1679,20 +2012,14 @@
     }
 }
 
-void
-gen_source(char *s)
-{
-     printf("%s",s);
-}
-
-void
+extern void
 ret(void)
 {       
     code_set_return_register(1);
     jmp(retlabel); 
 }
 
-void
+extern void
 opening(char *filename)
 {
     emit_init();
@@ -1700,14 +2027,14 @@
 	code_opening(filename);
 }
 
-void
+extern void
 closing()
 {
     if (!chk)
 	code_closing();
 }
 
-int
+static int
 contains_in_list(int e,int type)
 {
     while(e) {
@@ -1717,7 +2044,7 @@
     return 0;
 }
 
-int
+static int
 contains(int e,int type)
 {
     while(e) {
@@ -1745,7 +2072,7 @@
         /* nullary operators */
 	    return 0;
 	} else {
-	    fprintf(stderr,"Unknown Tree ID %d\n",car(e));
+	    // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
 	    error(-1);
 	    return 0;
 	}
@@ -1753,7 +2080,7 @@
     return 0;
 }
 
-int
+static int
 contains_in_list_p(int e,int (*p)(int))
 {
     while(e) {
@@ -1763,7 +2090,7 @@
     return 0;
 }
 
-int
+extern int
 contains_p(int e,int (*p)(int))
 {
     while(e) {
@@ -1791,7 +2118,7 @@
         /* nullary operators */
 	    return 0;
 	} else {
-	    fprintf(stderr,"Unknown Tree ID %d\n",car(e));
+	    // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
 	    error(-1);
 	    return 0;
 	}
@@ -1824,7 +2151,7 @@
  */
 
 static void
-code_asm(int asm0,int in,int out,int opt,int e)
+gen_asm(int asm0,int in,int out,int opt,int e)
 {
     int i,e1,n;
     int repl = 0;
@@ -1839,7 +2166,7 @@
     for(i=out;i;i=cadr(i)) {
 	p = (char*)cadr(car(i));
 	e1 = car(e); e = cadr(e);
-	repl = asm_operand(p,e1,ASM_OUTPUT,repl,0,0);
+	repl = code_asm_operand(p,e1,ASM_OUTPUT,repl,0,0);
 	if (car(car(repl))==REGISTER) {
 	    assign = list2(assign_expr0(e1,car(repl),INT,INT),assign);
 	}
@@ -1849,22 +2176,1062 @@
     for(i=in;i;i=cadr(i)) {
 	p = (char*)cadr(car(i));
 	e1 = car(e); e = cadr(e);
-	repl = asm_operand(p,e1,ASM_INPUT,repl,n,repl0);
+	repl = code_asm_operand(p,e1,ASM_INPUT,repl,n,repl0);
 	if (car(car(repl))==REGISTER) {
 	    g_expr_u(assign_expr0(car(repl),e1,INT,INT));
 	}
     }
     repl = reverse0(repl);
-    replace_asm_string((char*)cadr(asm0),repl);
+    code_asm((char*)cadr(asm0),repl);
     for(i=assign;i;i=cadr(i)) {
 	g_expr_u(car(i));
     }
-    free_asm_operand(repl);
+    code_free_asm_operand(repl);
     // no check for opt 
 }
 
+#endif
+
+
+extern NMTBL *
+def(NMTBL *n)
+{
+    int sz,nsc,ndsp;
+    int sbit_f = bit_field_disp;
+    bit_field_disp = 0;  // default is 0, recover only in bit-field
+
+    if (n==0) {
+	n=anonymous_nptr();
+	n->nm = "_";
+    }
+    nsc=ndsp=0;
+    if (stmode==EXTRN||mode==GDECL)
+	n->ty = type;  /* must be in global table/heap */
+    if(type>0&&(car(type)==FUNCTION || car(type)==CODE)) {
+	if ((mode==GDECL)) {
+	    fcheck(n);
+	    return n;
+	    /* function and code segment are defined using fdecl/code_decl */
+            /* in decl() */
+	}
+    }
+    if (mode==GSDECL||mode==LSDECL|| mode==GUDECL||mode==LUDECL) {
+          /* Struct fields name lists are in the struct type or tag. */
+          /* Only name in the table is used. */
+	if (car(n->ty)==BIT_FIELD) {
+	    bit_field_disp=sbit_f;   // default is 0, recover only here.
+            // n->ty = list4(BIT_FIELD,type,bit_offset,bit_width);
+	    caddr(n->ty) = bit_field_disp;  // bitwise offset
+	    bit_field_disp += cadddr(n->ty);
+	    sz = bit_field_disp/bit_of_byte;
+	    bit_field_disp %= bit_of_byte;
+	}  else {
+	    sz = size(type);
+	}
+	fields = list4(type,fields,(int)(n->nm),disp);
+    } else {
+	if (n->sc!=EMPTY &&  !(n->sc==EXTRN||n->sc==EXTRN1||n->sc==STATIC)) {
+	  /* redefined case */
+	  if (mode==ADECL) {  /* K&R arguments case */
+	    if (n->sc==LVAR && n->ty==INT);
+	    else if ( n->sc==REGISTER && n->ty==INT);
+	    else error(RDERR);
+	  } else error(RDERR);
+	}
+	sz = size(n->ty = type);
+    }
+    switch(mode) {
+    case GDECL:
+	gen_gdecl(n->nm,gpc);
+    case STADECL:
+	nsc = GVAR;
+	ndsp = gpc;
+	if (n->dsp!=-1)     /* don't set dsp if initialized static */
+	    n->dsp = ndsp;  /* emit_data will override this */
+	if (stmode==EXTRN)
+	    nsc = EXTRN;
+	else if (stmode==STATIC)
+	    nsc = STATIC;
+	n->sc = nsc;
+	if (stmode==LDECL) {
+	    n->nm = new_static_name(n->nm,'.');
+	}
+	gpc +=sz;
+	return n;
+    case GSDECL: case LSDECL:
+	disp += sz;
+	return n;
+    case GUDECL: case LUDECL:
+	if (disp < sz) disp = sz;
+	return n;
+    case GTDECL:
+	nsc = TYPE;
+	gtypedefed=glist2((int)gnptr,gtypedefed);
+	break;
+    case LTDECL:
+	nsc = TYPE;
+	break;
+    case ADECL:
+	if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) {
+	    type=list2(POINTER,type); n->ty = type;
+	}
+	fnptr->dsp=list4(type,fnptr->dsp,(int)n,0);
+	n->sc = LVAR;
+	if(type==CHAR||type==UCHAR) {
+	    if (n->dsp==0) {
+		n->dsp = args;
+		if (endian) n->dsp += size_of_int-1;
+	    }
+	    args += size_of_int;
+	} else if(type==SHORT||type==USHORT) {
+	    if (n->dsp==0) {
+		n->dsp = args;
+		if (endian) n->dsp += size_of_int-size_of_short;
+	    }
+	    args += size_of_int;
+	} else if(type>0&&(type==UNION||type==STRUCT)) {
+	    n->dsp = args;
+	    args += ((sz+(size_of_int-1))&~(size_of_int-1));
+	} else {
+	    /* if (n->dsp==0) (argument list in ADECL is useless, type
+               list can be found in type ) */
+	    n->dsp = args;
+	    args += sz;
+	}
+	cadddr(fnptr->dsp)=sz;
+	if(type==VOID) {
+	} else {
+	    n->ty = type;
+	}
+	return n;
+    case STAT: /* return (struct hoge)f() case? */
+    case LDECL:
+	if (stmode==REGISTER) {
+	    if(scalar(type)) {
+		ndsp = get_register_var(n);
+#if FLOAT_CODE
+	    } else if (type==FLOAT) {
+		ndsp = get_dregister_var(n,0);
+	    } else if (type==DOUBLE) {
+		ndsp = get_dregister_var(n,1);
+#endif
+#if LONGLONG_CODE
+	    } else if (type==LONGLONG||type==ULONGLONG) {
+		ndsp = get_lregister_var(n);
+#endif
+	    } else error(DCERR);
+	    nsc = car(ndsp);
+	    ndsp = cadr(ndsp);
+	} else {
+	    nsc = LVAR;
+	    ndsp = new_lvar(sz);
+	}
+	n->sc = nsc;
+	n->dsp = ndsp;
+	return n;
+    default:
+	error(DCERR);
+    }
+    n->sc = nsc;
+    n->dsp = ndsp;
+    if (stmode==EXTRN)
+	n->sc = EXTRN;
+    return n;
+}
+
+
+extern void
+emit_init_vars(void)
+{
+    if (!init_vars) return;
+    init_vars = reverse0(init_vars);
+    while(init_vars) {
+	gexpr(car(init_vars),0);
+	init_vars = cadr(init_vars);
+    }
+}
+
+static int
+str_init_eq()
+{
+    // error(-1);  // duplicate struct field value
+    return 2;      // allow override keep unique
+}
+
+static int decl_str_init;
+
+extern int
+assign_data(int e, int t, NMTBL *n,int offset)
+{
+    int ass;
+
+    if(mode==GDECL) {
+ 	emit_data(e,t,n);
+    } else if(mode==STADECL) {
+ 	emit_data(e,t,n);
+    } else if(mode==LDECL) {
+	if (t==EMPTY) return offset+cadr(e);
+	ass = assign_expr0(
+    (n->sc==REGISTER||n->sc==DREGISTER||n->sc==FREGISTER||n->sc==LREGISTER)?
+	    list3(n->sc,n->dsp,(int)n):
+	    list2(LVAR,n->dsp+offset),
+	e,t,type);
+	init_vars = list2(ass,init_vars);
+    } else if(mode==SFDINIT) {
+	decl_str_init=insert_ascend(decl_str_init,
+		list4(offset,0,e,t),str_init_eq);
+    } else {
+	error(DCERR);
+	return offset;
+    }
+    return offset+((t==EMPTY)?cadr(e):size(t));
+}
+
+extern int
+arg_reorder(int arg,int new_arg)
+{
+    /*	list4(type,fnptr->dsp,(int)n,size); */
+    int i,j,sz;
+    int dsp = 0;
+    NMTBL *n,*n1;
+
+    /* f(a,b,c) { int c; short a; char* b;} case */
+
+// fprintf(stderr,"arg_reorder old:\n");
+//    for(j=new_arg;j;j=cadr(j)) {
+//	    n=(NMTBL *)caddr(j);
+// fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j));
+//    }
+// fprintf(stderr,"arg_reorder new:\n");
+    for(j=arg;j;j=cadr(j)) {
+	n=(NMTBL *)caddr(j);
+	for(i=new_arg;i;i=cadr(i)) {
+	    n1=(NMTBL *)caddr(i);
+	    if (!neqname(n1->nm,n->nm)) break;
+	    // if (n1==n) break;
+	}
+// fprintf(stderr,"dsp %d %s %s sz %d type %d\n",dsp,n->nm,n1->nm,cadddr(i),car(i));
+	if (!i) {
+	    /* f(a,b,c) { int c; } case (what?!) */
+	    i = j;
+	}
+	if(n->sc==LVAR) {
+	    n->dsp = dsp;
+	    car(j)=car(i);
+	    caddr(j)=caddr(i);
+	    cadddr(j)=sz= cadddr(i);
+	    if (sz==1||sz==size_of_short) sz = size_of_int;
+	    dsp += sz;
+	}
+    }
+// fprintf(stderr,"arg_reorder end:\n");
+    return arg;
+}
+
+
+static NMTBL str_ret;
+
+/*
+    If function has structure return value, it has an extra
+    argument for where to write the structure. It have to be
+    a first argument. We add it here and we have to fix all arguments'
+    offset. If it is the last value, we don't have to fix, but
+    gcc has a first argument convention.
+ */
+
+extern void
+fdecl_struct(int fntype)
+{
+    int type_save,mode_save,t,sz;
+    NMTBL *n;
+
+    t = cadr(fntype);
+    if (t>0 && (car(t)==STRUCT||car(t)==UNION)) {
+	mode_save = mode;
+	mode=ADECL;
+	type_save = type;
+	/* extra argument for struct return */
+	/* this extra dummy arguments are set at calling sequence */
+	str_ret.nm = "str_ret"; str_ret.sc = EMPTY;
+	str_ret.dsp = 0; str_ret.ty = 0;
+	type=list2(POINTER,t);
+	/* fix all argument's offset */
+	sz = size(type);
+	for(t=fnptr->dsp;t;t=cadr(t)) {
+	    n=(NMTBL *)caddr(t);
+	    n->dsp += sz;
+	}
+	fnptr->dsp = reverse0(fnptr->dsp);
+	if ((sz=size(cadr(fntype)))==-1) error(TYERR);
+	else {
+	    args = 0;
+	    def(&str_ret);
+	    struct_return = list3(list2(LVAR,str_ret.dsp),sz,type);
+	    caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty));
+	}
+	type = type_save;
+	mode = mode_save;
+    } else {
+	struct_return = 0;
+	fnptr->dsp = reverse0(fnptr->dsp);
+    }
+}
+
+extern void
+fcheck(NMTBL *n)
+{
+    if(!(mode==GDECL||mode==ADECL)||
+             (car(type)!=FUNCTION&&car(type)!=CODE)) error(DCERR);
+    if (n->sc==EMPTY) {
+	n->sc=EXTRN;
+	n->ty=type;
+    } else if(is_code(n)) compatible(cadr(n->ty),cadr(type));
+    else if(is_function(n)) compatible(cadr(n->ty),cadr(type));
+    else {
+	error(DCERR);
+    }
+}
+
+static void
+compatible(int t1, int t2)
+{
+    if(integral(t1)) {
+	    if(t1!=t2) error(TYERR);
+    }
+    else if(car(t1)!=car(t2))
+	    error(TYERR);
+    else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
+	    error(TYERR);
+    else if(car(t1)==POINTER || car(t1)==ARRAY ||car(t1)==FUNCTION)
+	    compatible(cadr(t1),cadr(t2));
+}
+
+extern int
+scalar(int t)
+{
+    return(integral(t)||car(t)==POINTER);
+}
+
+extern int
+integral(int t)
+{
+    return(t==INT||t==SIGNED||t==CHAR||t==UNSIGNED||
+        t==UCHAR||t==SHORT||t==USHORT||t==ENUM);
+}
+
+extern void
+checkret(void)
+{
+    if (cslabel==0) {
+	if (!control) error(-1); // no execute code in switch
+	jmp(cslabel=fwdlabel());
+    } else if (retpending) {
+	ret();
+	control=0;
+	retpending=0;
+    }
+    if (lastexp) {
+	gexpr(lastexp,0);
+	lastexp = 0;
+    }
+}
+
+
+extern void
+replace_return_struct(int func,int left) {
+    int e = caddr(func);      /* arg lists */
+    while(cadr(e)) e=cadr(e); /* find first arg */
+    e = car(e);               /* return_struct arg */
+    cadr(e) = left;
+}
+
 
+/* right value , get the value of the variable */
 
+static int
+indirect(int t,int e1)
+{
+    int e2,e3,e4,offset;
+    e2 = e1;
+    offset = 0;
+    e3 = cadr(e2);
+    if (car(e2)==ADD) {
+        e4=caddr(e2);
+        if (car(e4)==CONST) {
+            offset=cadr(e4);
+            e1=e3;
+        }
+    }
+    return list3(t,e1,offset);
+}
+
+extern int
+rvalue(int e)
+{
+    int op;
+
+    op = 0;
+    switch(type) {
+    case INT: break;
+    case UNSIGNED: break;
+    case VOID:	break;
+    case CHAR:	op=COP; type=INT; break;
+    case UCHAR:	op=COP+US; type=UNSIGNED; break;
+    case SHORT:	op=SOP; type=SIGNED; break;
+    case USHORT:	op=SOP+US; type=UNSIGNED; break;
+    case LONGLONG:	op=LOP; break;
+    case ULONGLONG:	op=LOP+US; break;
+    case FLOAT:	op=FOP; break;
+    case DOUBLE:	op=DOP; break;
+    case CODE:	return e;
+    default:
+	if (integral(type)) break;
+	switch(car(type)) {
+	case ARRAY:
+	    type=list2(POINTER,cadr(type));
+	    if(car(e)==INDIRECT) return cadr(e);
+	    return list2(ADDRESS,e);
+	case STRUCT: case UNION:
+	    if(car(e)==RSTRUCT) return e; /* ??? */
+	    return list3(RSTRUCT,e,cadr(type) /* size */);
+	case FUNCTION:
+	    type=cadr(type);
+	    return e;
+	case CODE:
+	    return e;
+	case POINTER:
+	    break;
+	case BIT_FIELD:
+	    return list4(BIT_FIELD,caddr(type),cadddr(type),rvalue(cadddr(e)));
+            /*                      bit offset,   bit size,  rvalue */
+	    type = cadr(e);
+	    break;
+	default:
+	    error(TYERR);
+	}
+    }
+    switch(car(e)) {
+    case GVAR:
+	return(list2(RGVAR+op,cadr(e)));
+    case LVAR:
+	return(list2(RLVAR+op,cadr(e)));
+    case INDIRECT:
+	return(indirect(RINDIRECT+op,cadr(e)));
+    default:return(e); /* idempotent case? */
+    }
+}
+
+extern int
+rvalue_t(int e,int t)
+{
+    int stype = type;
+    type = t;
+    e = rvalue(e);
+    type = stype;
+    return e;
+}
+
+extern void
+lcheck(int e)
+{
+    int t;
+    if(!(scalar(type)||type==DOUBLE||type==FLOAT||
+	type==LONGLONG||type==ULONGLONG)||
+	(car(e)!=GVAR&&car(e)!=LVAR&&car(e)!=INDIRECT
+		&& car(e)!=REGISTER
+		&& car(e)!=DREGISTER
+		&& car(e)!=FREGISTER
+		&& car(e)!=LREGISTER)
+	)
+	if ((t=car(type))<0 && t!=STRUCT && t!=UNION)
+	    error(LVERR);
+}
+
+extern int
+indop(int e)
+{
+    if(type!=INT&&type!=UNSIGNED) {
+	if(car(type)==POINTER)
+	    type=cadr(type);
+	else if(car(type)==CODE || car(type)==FUNCTION)
+	    type=type;
+	else error(TYERR);
+    } else
+	type= CHAR;
+    if(car(e)==ADDRESS)
+	return(cadr(e));
+    return(list2(INDIRECT,e));
+}
+
+/* filed name search */
+
+    /* type = list4(s,disp,fields,tag_nptr); */
+
+extern int
+search_struct_type(int type,char *name,int *dsp)
+{
+    int t;
+    NMTBL *nptr0;
+    t = caddr(type);
+    if (t==0) {
+	nptr0=(NMTBL*)cadddr(type);
+	t = caddr(type) = caddr(nptr0->ty);
+    }
+    for(;t;t = cadr(t)) {
+	if (neqname((char *)caddr(t),name)==0) {
+	    *dsp = cadddr(t);
+	    return car(t);
+	}
+    }
+    return 0;
+}
+
+extern int
+strop(int e,int ind)
+{
+    int dsp = 0;
+
+    if (ind) e = indop(rvalue(e));
+    if (integral(type)||(car(type)!=STRUCT && car(type)!=UNION))
+	e=rvalue(e);
+    /* type = list4(s,disp,fields,tag_nptr); */
+    /* print_fields(caddr(type),"strop"); */
+    type = search_struct_type(type,nptr->nm,&dsp);
+    if (!type) { error(TYERR); type=INT; return e; }
+    if(dsp) {
+	switch(car(e)) {
+	case GVAR:
+	    e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
+	    break;
+	case LVAR:
+	    e=list2(LVAR,cadr(e) + dsp);
+	    break;
+	case INDIRECT:
+	    e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp)));
+	    break;
+	default:
+	    e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
+	}
+    } else {
+	switch(car(e)) {
+	case GVAR: case LVAR: case INDIRECT:
+	    break;
+	default:
+	    e=list2(INDIRECT,e);
+	}
+    }
+    if (type>0&&car(type)==BIT_FIELD) {
+	// n->ty = list4(BIT_FIELD,type,bit_offset, bit_size);
+	e=list4(BIT_FIELD,     caddr(type),cadddr(type), e);
+    }
+    return e;
+}
+
+#if FLOAT_CODE
+/* binary floating computation */
+
+#define DTYPE(dop) (dop==DOP?DOUBLE:FLOAT)
+
+static int
+fdbinop(int op, int e1, int e2, int t1, int t2, int dop)
+{
+    double d1,d2,d;
+    int b=0;
+
+    type= DTYPE(dop);
+    if (dop==DOP) {
+	e1=double_value(e1,t1);
+	e2=double_value(e2,t2);
+    } else {
+	e1=float_value(e1,t1);
+	e2=float_value(e2,t2);
+    }
+    t1=t2=DTYPE(dop);
+    if(car(e1)==dop+CONST&&car(e2)==dop+CONST) {
+	d1=dcadr(e1);
+	d2=dcadr(e2);
+	switch(op) {
+	case ADD: d=d1+d2; break;
+	case SUB: d=d1-d2; break;
+	case MUL: d=d1*d2;break;
+	case DIV:
+	    if(!d2) error(EXERR);d=d1/d2;break;
+	default:
+	    switch(op) {
+		case GT: b=(d1>d2);break;
+		case GE: b=(d1>=d2);break;
+		case LT: b=(d1<d2);break;
+		case LE: b=(d1<=d2);break;
+		case EQ: b=(d1==d2);break;
+		case NEQ: b=(d1!=d2);break;
+		default: error(EXERR);
+	    }
+	    type = INT;
+	    return list2(CONST,b);
+	}
+	return dlist2(dop+CONST,d);
+    }
+    if(car(e1)==dop+CONST) {
+	if ((op==SUB||op==ADD)&&dcadr(e1)==0.0) {
+	    return e2;
+	} else if (op==MUL&&dcadr(e1)==1.0) {
+	    return e2;
+	} else if (op==MUL&&-dcadr(e1)==1.0) {
+	    return list2(dop+MINUS,e2);
+	}
+    }
+    if(car(e2)==dop+CONST) {
+	if ((op==SUB||op==ADD)&&dcadr(e2)==0.0) {
+	    return e1;
+	}
+	if ((op==DIV||op==MUL)&&dcadr(e2)==1.0) {
+	    return e1;
+	}
+	if ((op==DIV||op==MUL)&&-dcadr(e2)==1.0) {
+	    return list2(DMINUS,e1);
+	}
+	if (op==SUB) {
+	    op=ADD; dcadr(e2) = -dcadr(e2);
+	} else if(op==DIV) {
+	    if(dcadr(e2)==0.0) error(EXERR);
+	    op=MUL; dcadr(e2)=1/dcadr(e2);
+	}
+    }
+    if ((op==ADD||op==MUL) && (
+	    car(e1)==dop+CONST ||
+	    car(e2)==DRLVAR || car(e2)==DRGVAR ||
+	    car(e2)==FRLVAR || car(e2)==FRGVAR
+	)) {
+	return(list3(op+dop,e2,e1));
+    }
+    if(op==LT) {
+	type=INT;
+	return(list3(GT+dop,e2,e1));
+    } else if(op==LE) {
+	type=INT;
+	return(list3(GE+dop,e2,e1));
+    } else if(op==GT||op==GE||op==EQ||op==NEQ) {
+	type=INT;
+	return(list3(op+dop,e1,e2));
+    } else if(op==ADD||op==SUB||op==MUL||op==DIV)
+	return(list3(op+dop,e1,e2));
+    else {
+	error(-1);
+	return e1;
+    }
+}
+
+static int
+dbinop(int op, int e1, int e2, int t1, int t2)
+{
+    return fdbinop(op, e1, e2, t1, t2,DOP);
+}
+
+static int
+fbinop(int op, int e1, int e2, int t1, int t2)
+{
+    return fdbinop(op, e1, e2, t1, t2,FOP);
+}
+
+#endif 
+
+#if LONGLONG_CODE
+
+static int
+lbinop(int op, int e1, int e2, int t1, int t2)
+{
+    int e=0;
+    long long le1, le2;
+    long long le = 0;
+    int us = (t1==ULONGLONG&&t2==ULONGLONG);
+
+    if (us||(t1==ULONGLONG&&(op==LSHIFT||op==RSHIFT))) {
+	e1=ulonglong_value(e1,t1);
+	e2=ulonglong_value(e2,t2);
+	type = ULONGLONG;
+    } else {
+	e1=longlong_value(e1,t1);
+	e2=longlong_value(e2,t2);
+	type = LONGLONG;
+    }
+    if(car(e1)==LCONST&&car(e2)==LCONST) {
+	le1=lcadr(e1);
+	le2=lcadr(e2);
+	switch(op) {
+	case BOR:
+	    le=le1|le2;break;
+	case EOR:
+	    le=le1^le2;break;
+	case BAND:
+	    le=le1&le2;break;
+	case ADD:
+	    le=le1+le2;break;
+	case SUB:
+	    le=le1-le2;break;
+	case MUL:
+	    le=le1*le2;break;
+	case DIV:
+	    if(!le2) error(EXERR);
+	    if (us) le=(((unsigned long long )le1)/((unsigned long long )le2)); 
+	    else e=(le1/le2);
+	case MOD:
+	    if(!le2) error(EXERR);
+	    if (us) le=(((unsigned long long )le1)%((unsigned long long )le2)); 
+	    else e=(le1%le2);
+	case RSHIFT:
+	    if (t1==ULONGLONG) le=(((unsigned long long)le1)<<le2); else le=le1<<le2;
+	    break;
+	case LSHIFT:
+	    if (t1==ULONGLONG) le=(((unsigned long long)le1)>>le2); else le=le1>>le2;
+	    break;
+	default:
+	    switch(op) {
+	    case EQ:
+		e=(le1==le2);break;
+	    case NEQ:
+		e=(le1!=le2);break;
+	    case LT:
+		le=le1;le1=le2;le2=le;
+	    case GT:
+		if (us) e=((unsigned long long)le1>(unsigned long long)le2);
+		else e=(le1>le2);
+		break;
+	    case LE:
+		le=le1;le1=le2;le2=le;
+	    case GE:
+		if (us) e=((unsigned long long)le1>=(unsigned long long)le2);
+		else e=(le1>=le2);
+		break;
+	    default:
+		error(-1); return list2(CONST,0);
+	    }
+	    type = INT;
+	    return list2(CONST,e);
+	}
+	return llist2(LCONST,le);
+    }
+    if(op==LT) {
+	type = INT; return(list3(GT+LOP+us,e2,e1));
+    } else if(op==LE) {
+	type = INT; return(list3(GE+LOP+us,e2,e1));
+    } else if(op==GT||op==GE||op==LT||op==LE) {
+	type = INT; return(list3(op+LOP+us,e1,e2));
+    }
+    if(op==SUB&&car(e2)==LCONST) { op=ADD; lcadr(e2)=-lcadr(e2); }
+    if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
+	(car(e1)!=LCONST) && (
+	    car(e2)==LRGVAR||car(e2)==LRLVAR||
+	    car(e2)==LURGVAR||car(e2)==LURLVAR
+		)) {
+	e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
+    }
+    if((op==MUL||op==DIV)&&car(e2)==LCONST&&lcadr(e2)==1) return e1;
+    if(op==BOR||op==EOR||op==BAND||op==ADD||op==SUB||op==EQ||op==NEQ) 
+	return(list3(op+LOP,e1,e2));
+    if(op==LSHIFT||op==RSHIFT) return(list3(op+LOP+(t1==ULONGLONG),e1,e2));
+    return(list3(op+LOP+us,e1,e2));
+}
 #endif
 
+/* binary integer computation */
+
+extern int
+binop(int op, int e1, int e2, int t1, int t2)
+{
+    int e=0;
+    int us = (t1==UNSIGNED&&t2==UNSIGNED);
+
+    if(t1>0&&car(t1)==POINTER) { e2= int_value(e2,t2); t2=INT; }
+    else if(t2>0&&car(t2)==POINTER) { e1= int_value(e1,t1); t1=INT; }
+#if FLOAT_CODE
+    else if(t1==DOUBLE||t2==DOUBLE)
+	return dbinop(op,e1,e2,t1,t2);
+    else if(t1==FLOAT||t2==FLOAT)
+	return fbinop(op,e1,e2,t1,t2);
+#endif
+#if LONGLONG_CODE
+    else if(t1==LONGLONG||t2==LONGLONG||t1==ULONGLONG||t2==ULONGLONG)
+	return lbinop(op,e1,e2,t1,t2);
+#endif
+    if(car(e1)==CONST&&car(e2)==CONST) {
+	e1=cadr(e1);
+	e2=cadr(e2);
+	type= INT;
+	switch(op) {
+	case BOR:
+	    e=e1|e2;break;
+	case EOR:
+	    e=e1^e2;break;
+	case BAND:
+	    e=e1&e2;break;
+	case ADD:
+	    if(integral(t1)) {
+		if(integral(t2)) {
+			e=e1+e2;
+		} else {
+			if(car(t2)!=POINTER) error(TYERR);
+			e=size(cadr(t2))*e1+e2;
+			type=t2;
+		}
+	    } else {
+		if(car(t1)!=POINTER) error(TYERR);
+		e=e1+size(cadr(t1))*e2;
+		type=t1;
+	    }
+	    break;
+	case SUB:
+	    if(integral(t1)) {
+		e=e1-e2;
+	    } else {
+		if(car(t1)!=POINTER) error(TYERR);
+		e=e1-size(cadr(t1))*e2;
+		type=t1;
+	    }
+	    break;
+	case MUL:
+	    e=e1*e2;break;
+	case DIV:
+	    if(!e2) error(EXERR);
+	    if (us) e=(((unsigned)e1)/((unsigned)e2)); else e=e1/e2;
+	    break;
+	case MOD:
+	    if(!e2) error(EXERR);
+	    if (us) e=(((unsigned)e1)%((unsigned)e2)); else e=e1%e2;
+	    break;
+	case RSHIFT:
+	    if (t1==UNSIGNED) e=(((unsigned)e1)>>((unsigned)e2)); else e=e1>>e2;
+	    break;
+	case LSHIFT:
+	    if (t1==UNSIGNED) e=(((unsigned)e1)<<((unsigned)e2)); else e=e1<<e2;
+	    break;
+	case EQ:
+	    e=(e1==e2);break;
+	case NEQ:
+	    e=(e1!=e2);break;
+	case LT:
+	    e=e1;e1=e2;e2=e;
+	case GT:
+	    if (us) e=(((unsigned)e1)>((unsigned)e2)); else e=(e1>e2);
+	    break;
+	case LE:
+	    e=e1;e1=e2;e2=e;
+	case GE:
+	    if (us) e=(((unsigned)e1)>=((unsigned)e2)); else e=(e1>=e2);
+	    break;
+	    e=(e1<=e2);break;
+	default: error(-1); return list2(CONST,0);
+	}
+	return list2(CONST,e);
+    }
+    if(op==LT) {
+	return(list3(GT+us,e2,e1));
+    } else if(op==LE) {
+	return(list3(GE+us,e2,e1));
+    } else if(op==GT||op==GE||op==LT||op==LE) {
+	return(list3(op+us,e1,e2));
+    } else if(op==EQ||op==NEQ) {
+	return(list3(op,e1,e2));
+    }
+    if(op==SUB&&car(e2)==CONST) { op=ADD; cadr(e2)=-cadr(e2); }
+    if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
+	(car(e1)!=CONST&& (
+	    car(e2)==RGVAR||car(e2)==RLVAR||
+	    car(e2)==URGVAR||car(e2)==URLVAR||
+	    car(e2)==SRGVAR||car(e2)==SRLVAR||
+	    car(e2)==SURGVAR||car(e2)==SURLVAR||
+	    car(e2)==CRGVAR||car(e2)==CRLVAR||
+	    car(e2)==CURGVAR||car(e2)==CURLVAR
+	    ))) {
+	e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
+    }
+    if(op==ADD) {
+	if(integral(t1)) {
+	    if(integral(t2)) {
+		if(t1==INT) type=t2;else type=t1;
+		return(list3(ADD,e1,e2));
+	    }
+	    if(car(t2)!=POINTER) error(TYERR);
+	    e=binop(MUL,e1,list2(CONST,size(cadr(t2))),t1,INT);
+	    type=t2;
+	    return(list3(ADD,e,e2));
+	}
+	if(car(t1)!=POINTER||!integral(t2)) error(TYERR);
+	e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
+	type=t1;
+	if (car(e)==CONST && cadr(e)==0)
+	    return(e1);
+	if(car(e1)==ADDRESS&&car(e)==CONST&&car(cadr(e1))!=GVAR)
+	    return(list2(ADDRESS,list2(car(cadr(e1)),
+		cadr(cadr(e1))+cadr(e))));
+	return(list3(ADD,e1,e));
+    }
+    if(op==SUB) {
+	if(integral(t1)) {
+	    if(!integral(t2)) error(TYERR);
+	    if(t1==INT) type=t2;else type=t1;
+	    return(list3(SUB,e1,e2));
+	}
+	if(car(t1)!=POINTER) error(TYERR);
+	if(integral(t2)) {
+	    e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
+	    type=t1;
+	    return(list3(SUB,e1,e));
+	}
+	if(car(t2)!=POINTER)
+	    error(TYERR);
+	compatible(t1,t2);
+	e=list3(SUB,e1,e2);
+	e=binop(DIV,e,list2(CONST,size(cadr(t1))),UNSIGNED,INT);
+	type= INT;
+	return e;
+    }
+    if(!integral(t1)||!integral(t2)) error(TYERR);
+    if(t1==INT) type=t2; else type=t1;  /* ??? */
+    if((op==MUL||op==DIV)&&car(e2)==CONST&&cadr(e2)==1) return e1;
+    if(op==BOR||op==EOR||op==BAND) return(list3(op,e1,e2));
+    if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==UNSIGNED?US:0),e1,e2));
+    // which ops remain?
+    return(list3(op+us,e1,e2));
+}
+
+/* coarse for function/code segments arguments */
+
+extern int
+correct_type(int e,int t)
+{
+    int t1;
+    /* e = rvalue(e); */
+    if (type==FLOAT && t==DOTS) { t=DOUBLE;}  // fall thru
+    if (type==CHAR  && t==DOTS) { t=INT;}     // fall thru
+    if (t==DOTS) return e;
+    if (t==UNSIGNED)                 e = unsigned_value(e,type);
+    else if (integral(t))            e = int_value(e,type);
+#if FLOAT_CODE
+    else if (t==FLOAT)     e = float_value(e,type);
+    else if (t==DOUBLE)    e = double_value(e,type);
+#endif
+#if LONGLONG_CODE
+    else if (t==LONGLONG)     e = longlong_value(e,type);
+    else if (t==ULONGLONG)    e = ulonglong_value(e,type);
+#endif
+    else if ((t1=car(t))==STRUCT||t1==UNION) {
+	if(size(t)!=size(type)) error(TYERR);
+    }
+    type = t;
+    return e;
+}
+
+
+extern int
+cexpr(int e)
+{
+    if (car(e) != CONST) error(CNERR);
+    return (cadr(e));
+}
+
+/* temporal local variable free list */
+
+static int lvar_list,lvar_free_list;
+
+extern int
+new_lvar0(int sz)
+{
+    return disp -= sz;
+}
+
+extern int
+new_lvar(int size)
+{
+    int lvar,plvar;
+
+    for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) {
+        if (caddr(lvar)==size) {
+            if (plvar) cadr(plvar) = cadr(lvar);
+            else lvar_free_list = cadr(lvar);
+            break;
+        }
+        plvar = lvar;
+    }
+    if (!lvar) {
+        lvar_list = glist3((lvar=new_lvar0(size)),lvar_list,size);
+    } else {
+        cadr(lvar) = lvar_list; lvar_list = lvar;
+        lvar = car(lvar_list);
+    }
+    return lvar;
+}
+
+extern void
+free_lvar(int disp)
+{
+    int lvar,plvar;
+
+    for (plvar = 0,lvar = lvar_list;lvar;lvar = cadr(lvar)) {
+        if (car(lvar)==disp) {
+            if (plvar) cadr(plvar) = cadr(lvar);
+            else lvar_list = cadr(lvar);
+            break;
+        }
+        plvar = lvar;
+    }
+    if (!lvar) error(-1);
+    cadr(lvar) = lvar_free_list; lvar_free_list = lvar;
+}
+
+extern void
+init_free_lvar_list()
+{
+    int lvar;
+    while((lvar=lvar_list)) {
+        lvar_list=cadr(lvar_list);
+        free_glist3(lvar);
+    }
+    while((lvar=lvar_free_list)) {
+        lvar_free_list=cadr(lvar_free_list);
+        free_glist3(lvar); 
+    }
+}
+
+extern void
+gen_code_enter(char *name)
+{
+    code_enter(name);
+}
+
+extern void
+gen_code_enter1(int args)
+{
+    code_enter1(args);
+}
+
+extern void
+gen_code_leave(char *name)
+{
+    code_leave(name);
+}
+
+extern void
+gen_enter(char *name)
+{
+    enter(name);
+}
+
+extern void
+gen_enter1()
+{
+    enter1();
+}
+
+extern void
+gen_leave(int control, char *name)
+{
+    leave(control,name);
+}
+
+extern void
+gen_jmp(int l)
+{
+    jmp(l);
+}
+
 /* end */
--- a/mc-codegen.h	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-codegen.h	Mon Jun 21 23:50:34 2004 +0900
@@ -1,6 +1,14 @@
 /* for mc-codegen.c */
 
 extern int use;         /* generated value will be used in gexpr */
+extern char *init_src;
+extern int size_of_int;
+extern int size_of_short;
+extern int size_of_float;
+extern int size_of_double;
+extern int size_of_longlong;
+extern int bit_of_byte;
+extern int endian;
 
 #define USE_CREG (-1)
 #define ASM_INPUT	1
@@ -8,63 +16,92 @@
 #define ASM_USED	3
 #define MAX_ASM_REG	30
 
-/* function provided by mc-code-*.c */
+/* used by mc-parse */
 
-extern int get_register_var(NMTBL *);
-extern int get_dregister_var(NMTBL *,int);
-extern int get_lregister_var(NMTBL *);
+extern int rvalue(int e);
+extern int rvalue_t(int e,int t);
+extern int integral(int t);
+
 
 extern void arg_register(NMTBL *fnptr);
-
-/* function provided by mc-codegen.c */
-
-extern void codegen_init();
+extern int arg_reorder(int arg,int new_arg);
+extern int assign_data(int e, int t, NMTBL *n,int offset);
+extern int assop(int e1,int e2,int op,int t,int no_float);
+extern int backdef(void);
+extern int cexpr(int e);
+extern void checkret(void);
+extern void closing();
+extern void cmpdimm(int e, int csreg,int label,int cond);
+extern void codegen_init();      /* called only once */
+extern void codegen_reinit();    /* called for each file */
+extern void codegen_decl_init(); /* called before each declaration */
+extern int cond(int t,int e1,int e2,int e3);
+extern int correct_type(int e,int t);
+extern int csvalue();
+extern void def_label(int cslabel, int dlabel);
+extern void emit_init_vars(void);
+extern void fdecl_struct(int fntype);
+extern int function_type(int e1,int *dots);
+extern void lcheck(int e);
+extern void opening(char *filename);
+extern void parallel_rassign(int assigns);
+extern int strop(int e,int ind);
 
 extern void def_label(int cslabel, int dlabel);
-extern int backdef(void);
-extern int free_register_count(int);
-extern int fwdlabel(void);
+extern NMTBL * def(NMTBL *n);
+extern int search_struct_type(int type,char *name,int *dsp);
+extern int gexpr(int e1,int use0);
+extern void bexpr_u(int e1, char cond, int l1);
+extern void bexpr(int e1, char cond, int l1);
+extern void ret(void);
+extern void replace_return_struct(int func,int left);
+extern int assign_expr0(int e1,int e2,int t,int type0);
+extern int assign_expr(int e1,int e2,int t,int type);
+extern int binop(int op, int e1, int e2, int t1, int t2);
+extern int indop(int e);
+extern void fcheck(NMTBL *n);
+
+extern void init_free_lvar_list();
+extern void free_lvar(int disp);
+extern int new_lvar(int size);
+extern int new_lvar0(int sz);
+
+extern void gen_code_enter(char *name);
+extern void gen_code_enter1(int args);
+extern void gen_code_leave(char *name);
+extern void gen_enter(char *name);
+extern void gen_enter1();
+extern void gen_leave(int control, char *name);
+extern void gen_jmp(int l);
+
+
+extern int assign_expr0(int e1,int e2,int t,int type0) ;
+extern int assign_expr(int e1,int e2,int t,int type) ;
+extern void bexpr_u(int e1, char cond, int l1);
+extern int binop(int op, int e1, int e2, int t1, int t2);
+extern void fcheck(NMTBL *n);
+extern void replace_return_struct(int func,int left) ;
+extern int gexpr(int e1,int use0);
+extern void bexpr_u(int e1, char cond, int l1);
+extern void bexpr(int e1, char cond, int l1);
+extern void ret(void);
+extern void def_label(int cslabel, int dlabel);
+extern NMTBL * def(NMTBL *n);
+extern int indop(int e);
+extern int search_struct_type(int type,char *name,int *dsp);
+
+/* used by mc-cod-* */
+
+extern int assign_expr0(int e1,int e2,int t,int type0) ;
 extern void b_expr(int e1, char cond, int l1,int err);
-extern void bexpr(int e1, char cond, int l1);
-extern void emit_init(void);
+extern int contains_p(int e,int (*p)(int));
 extern void fwddef(int l);
-
+extern int fwdlabel(void);
+extern int g_expr(int e1);
+extern int g_expr0(int e1);
+extern int g_expr_u(int e1);
 extern int is_code(NMTBL *fnptr);
 extern int is_function(NMTBL *fnptr);
-extern int function_type(int e1,int *dots);
-extern void parallel_rassign(int list);
-
-extern int csvalue();
-extern void cmpdimm(int e, int csreg,int label,int cond);
-extern void code_enter(char *name) ;
-extern void code_enter1(int args);
-extern void code_init(void);
-extern void code_leave(char *name) ;
-extern void emit_data(int e, int t, NMTBL *n);
-extern void emit_data_closing(NMTBL *n);
-extern void emit_init(void);
-extern void enter(char *name);
-extern void enter1();
-extern int g_expr(int e1);
-extern int g_expr_u(int e1);
-extern void gen_comment(char *s);
-extern void gen_gdecl(char *n, int gpc);
-extern void gen_source(char *s);
-extern int gexpr(int e1,int use);
-extern void gexpr_init(void);
-extern void jmp(int l);
-extern void jmp_eq_label(int l);
-extern void jmp_label(int l);
-extern void leave(int control, char *name);
-extern void opening(char *filename);
-extern void closing();
-extern void ret(void);
-extern void creg_destroy();
-
-extern int contains(int e,int type);
-extern int contains_in_list(int e,int type);
-extern int contains_p(int e,int (*p)(int));
-extern int contains_in_list_p(int e,int (*p)(int));
-
+extern int scalar(int t);
 
 /* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mc-macro.c	Mon Jun 21 23:50:34 2004 +0900
@@ -0,0 +1,672 @@
+/* Micro-C Preprocessor Part */ /* $Id$ */
+
+#include <stdio.h>
+#include "mc.h"
+#include "mc-parse.h"
+#include "mc-macro.h"
+#include "mc-code.h"
+
+extern struct {int fd,ln;char *name0;int inc;FILE *fcb;} *filep,filestack[FILES];
+
+int in_macro_if = 0;
+char *chinput;
+
+static char *macropp,macro_buf[MACROSIZE];
+static int mconcat=0;
+
+static void macro_define0();
+static int macro_args(char **pcheapp,char *maxcheap,char **pchptr);
+static int macro_function(int macrop,char **pchptr,NMTBL *nptr,int history);
+static void local_define(char *macro,char *value);
+static void local_undef(char *macro);
+static int macro_eval(int macrop,char *body0,int history);
+static char * mappend(int lists);
+static int macro_processing();
+
+static void
+gen_source(char *s)
+{
+     printf("%s",s);
+}
+
+extern void
+macro_expansion(NMTBL *nptrm)
+{
+    int i = mode;
+    int macrop = 0;
+    int slfree = lfree;
+    mode = STAT;
+
+    macropp = macro_buf;
+    if (nptrm->sc == FMACRO) {
+        macrop=macro_function(macrop,&chptr,nptrm,0);
+    } else {
+        macrop=macro_eval(macrop,(char *)car(nptrm->dsp),0);
+    }
+    macropp = macro_buf;
+    mappend(reverse0(macrop));
+    macropp[-1] ='\n';
+    *macropp =0;
+    while (mconcat) {
+        // ## re-eval macro
+        printf("## %s",macro_buf);
+        mconcat = 0;
+        macrop = 0;
+        macropp = macro_buf;
+        macrop=macro_eval(macrop,macro_buf,0);
+        macropp = macro_buf;
+        mappend(reverse0(macrop));
+        macropp[-1] ='\n';
+        *macropp =0;
+    }
+    mconcat = 0;
+    lfree = slfree;
+    if (lsrc && !asmf && nptrm->sc==FMACRO) gen_comment(macro_buf);
+    macropp[-1] =0;
+    if (macro_buf[0]==0) {
+        mode = i;
+        return;
+    }
+    chptrsave = glist2((int)chptr,chptrsave);
+    chsave = glist2(ch,chsave);
+    chptr = macro_buf;
+    ch = *chptr++;
+    mode = i;
+}
+
+/* file inclusion */
+
+static char *
+expand_file_name(char *path,char *name,int pos,int lbufsize)
+{
+    char *p = name+pos;
+    int i,j;
+    j = 0;
+    for(i=0;path[i];i++,j++); for(i=0;name[i];i++,j++);
+    if (pos+j+1>lbufsize) { error(FILERR); return ""; }
+    while((name[pos++] = *path++));
+    pos--;
+    if (name[pos]!='/') name[pos]='/';
+    for(i = 0; ((name[pos++] = name[i++])););
+    return p;
+}
+
+static FILE *
+getfname(void)
+{
+    int i,end='"',err=0;
+    char *s,*p,**pp,name[LBUFSIZE];
+    FILE *fp;
+
+    getch();
+    if(skipspc()=='"') { end = '"';
+    } else if (ch=='<') { end = '>';
+    } else { error(INCERR); err=1; 
+    }
+    for(i=0;(getch()!=end && ch!='\n');) {
+	if(i<LBUFSIZE-1) name[i++]=ch;
+    }
+    if(ch=='\n') error(INCERR);
+    if (err) return filep->fcb;
+    name[i]=0;
+    fp = fopen(name,"r") ;
+    if (fp) {
+	p = name; 
+    } else {
+	for(pp=(end=='>'||filep->inc=='>')
+		?l_include_path:include_path;*pp;pp++) {
+	    p = expand_file_name(*pp,name,i+1,LBUFSIZE);
+	    if ((fp = fopen(p,"r"))) break ;
+	}
+    }
+    if(!fp) { error(FILERR); return filep->fcb; }
+    copy_current_file_dir(s=p);
+    (filep+1)->name0 = cheapp;
+    (filep+1)->inc = end;
+    while((*cheapp++ = *s++));
+    return ( (filep+1)->fcb = fp );
+}
+
+/* line input and conversion */
+
+static int macro_if_depth ;
+static int macro_if_current ;
+static int macro_if_skip ;
+
+static int
+skip_rest_of_line()
+{
+    getch();
+    do {
+	while(ch!='\n'&&ch!='\r') {
+	    if (!in_comment) {
+		if (ch=='/') {
+		    getch();
+		    if (ch=='/') in_comment=2;
+		    else if (ch=='*') {
+			in_comment=1;
+		    } else continue;
+		}
+	    } else if (ch=='*') {
+		getch();
+		if (ch=='/') {
+		    in_comment=0; 
+		    return macro_if_skip?0:1;
+		}
+		else continue;
+	    }
+	    getch();
+	}
+	if (in_comment==1) { getline(); getch(); }
+    } while(in_comment==1);
+    in_comment=0;
+    return 0;
+}
+
+extern void
+getline(void)
+{
+    int i;
+    int c;
+
+    do {
+	if (chinput) {
+	    if (! *chinput) {
+		chinput=0;
+		continue;
+	    }
+	    chptr=linebuf;
+	    i=0;
+	    while((*chptr++=c=*chinput++)&&(c!='\n')) {
+		if (++i > LBUFSIZE-2) error(LNERR);
+	    }
+	} else {
+	    lineno++;
+	    glineno++;
+	    chptr=linebuf;
+	    i=0;
+	    while ((*chptr++ = c = getc(filep->fcb)) != '\n') {
+		if (++i > LBUFSIZE-2) error(LNERR);
+		if (c==EOF) {
+			error(EOFERR);
+			--chptr;
+		}
+	    }
+	}
+	*chptr = '\0';
+	if (lsrc && !asmf && !macro_if_skip) gen_comment(linebuf);
+	if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
+	    if (macro_processing()) return;
+	}
+    } while(!in_quote && (macro_if_skip || linebuf[0] == '#'));
+}
+
+/* preprocessor directive */
+
+/* line continuation \\ */
+
+extern void
+check_macro_eof()
+{
+    int c;
+    for(c=0;c<LBUFSIZE-3&&chptr[c];c++);
+    if (c>0&&chptr[c-1]=='\\') {
+	return;
+    } else if (c>0&&chptr[c-1]=='\n') {
+	if (c>0&&chptr[c-2]=='\\') {
+	    return;
+	} else {
+	    c--;
+	}
+    } 
+    chptr[c] = ';';
+    chptr[c+1] = '\n';
+    chptr[c+2] = 0;
+}
+
+static void
+macro_if()
+{
+    int i;
+    ch= *chptr;
+    in_macro_if = 1;
+    check_macro_eof();
+    getsym(0);
+    /* i=cexpr(expr(1)); #if allow undefined symbols.. */
+    i=expr(1); 
+    in_macro_if = 0;
+    if (car(i)==CONST) i=cadr(i);
+    else i=0;
+    if (ch) {
+	if (chptr[-1]==ch) {
+	/* we are fall into getch(), which lost the last ch */
+	/* chptr[-1]==ch check is fanatic, but ... */
+	    chptr--;
+	} else error(-1);
+    }
+    macro_if_depth = macro_if_current;
+    macro_if_skip = !i;
+}
+
+static int
+macro_processing()
+{
+    int i;
+    int c;
+    int mode_save;
+
+    ++chptr;
+    while (*chptr==' '||*chptr=='\t') ++chptr;
+    if (macroeq("ifdef") || macroeq("ifndef")) {
+	c = (chptr[-4]=='n');
+	macro_if_current++;
+	if (!macro_if_skip) {
+	    mode_save = mode; mode = IFDEF;
+	    ch= *chptr;
+	    i = getsym(0);
+	    mode = mode_save;
+	    macro_if_depth = macro_if_current;
+	    macro_if_skip = (!i)^c;
+	}
+	return 0;
+    } else if (macroeq("elif")) {
+	if (macro_if_current==0) {
+	    error(MCERR); /* extra #else */
+	    return 0;
+	}
+	if (macro_if_current == macro_if_depth) {
+	    if (!macro_if_skip || macro_if_skip==2) {
+		macro_if_skip=2;
+		return 0;
+	    }
+	    macro_if();
+	}
+	return 0;
+    } else if (macroeq("if")) {
+	macro_if_current++;
+	if (!macro_if_skip) {
+	    macro_if();
+	}
+	return 0;
+    } else if (macroeq("else")) {
+	if (macro_if_current==0) {
+	    error(MCERR); /* extra #else */
+	    return 0;
+	}
+	if (macro_if_current == macro_if_depth) {
+	    if (macro_if_skip==2) ;
+	    else if (macro_if_skip) macro_if_skip=0;
+	    else macro_if_skip=1;
+	}
+	return skip_rest_of_line();
+    } else if (macroeq("endif")) {
+	if (macro_if_current == macro_if_depth) {
+	    macro_if_skip = 0;
+	    macro_if_depth = --macro_if_current;
+	} else {
+	    if (macro_if_current<=0) {
+		error(MCERR); /* extra #if */
+		return 0;
+	    }
+	    macro_if_current--;
+	}
+	return skip_rest_of_line();
+    }
+    if (macro_if_skip) return 0;
+    if (macroeq("define")) {
+	ch= *chptr;
+	macro_define0();
+	*(chptr = linebuf) = '\0';
+    } else if (macroeq("undef")) {
+	i=mode;
+	mode=IFDEF;
+	ch= *chptr;
+	if (getsym(0)) {
+	    if (nptr->sc == MACRO) {
+	        nptr->sc = EMPTY;
+	    } else if (nptr->sc == FMACRO) {
+	        nptr->sc = EMPTY;
+		/* we cannot reclaim it's arg */
+	    } else error(MCERR);
+	}
+	mode=i;
+    } else if (macroeq("include")) {
+	if(filep+1 >= filestack + FILES) error(FILERR);
+	if ( ((filep+1)->fcb=getfname()) == NULL) error(FILERR);
+	(filep+1)->ln=lineno;
+	lineno=0;
+	++filep;
+	*(chptr = linebuf) = '\0';
+#if ASM_CODE
+    } else if (macroeq("asm")) {
+	if (asmf) error(MCERR);
+	asmf = 1;
+	getline();
+	while (asmf) {
+	    gen_source(linebuf);
+	    getline();
+	}
+    } else if (macroeq("endasm")) {
+	if (!asmf) error(MCERR);
+	asmf = 0;
+#endif
+    } else if (macroeq(" "))
+	getline();
+    else error(MCERR);
+    return 0;
+}
+
+extern int
+macroeq(char *s)
+{
+    char *p;
+
+    for (p = chptr; *s;) if (*s++ != *p++) return 0;
+    chptr = p;
+    return 1;
+}
+
+/* macro interpreter */
+
+extern void
+macro_define(char *macro)
+{
+    char *chptr_save;
+    int chsave;
+
+    chptr_save = chptr;
+    chsave = ch;
+    chptr = macro;
+    ch= *chptr++;
+    macro_define0();
+    chptr = chptr_save;
+    ch = chsave;
+}
+
+static void
+macro_define0()
+{
+    int i,args,c;
+    char *scheapp;
+
+    i=mode;
+    mode=MDECL;
+    // ch= *chptr; ??
+// fprintf(stderr,"macro def: ch %c *chptr %c\n",ch,*chptr);
+    getsym(0);
+// fprintf(stderr,"macro def: %s =>",name); 
+    if (nptr->sc != EMPTY) { /* override existing macro */
+    }
+    args = 0;
+    if (ch=='(') {
+	nptr->sc = FMACRO;
+	args = macro_args(&cheapp,cheap+CHEAPSIZE,&chptr);
+    } else {
+	nptr->sc = MACRO;
+	nptr->ty = -1;
+    }
+    // equal is allowed for -Dhoge=aho option
+    if (ch=='=') chptr++;
+    while((c=*chptr)==' '||c=='\t') chptr++;
+    nptr->dsp = list2((int)cheapp,args); /* macro body */
+    scheapp = cheapp;
+    while ((*cheapp++ = c = *chptr++)
+	&& c != '\n') {
+	if (c=='/'&&chptr[0]=='/') {
+	    cheapp--; while(*chptr++); break;
+	} else if (c=='/'&&chptr[0]=='*') {
+	    cheapp--; chptr++;
+	    while((c = *chptr++)) {
+		if (c=='*'&&chptr[0]=='/') {
+		    c = *chptr++; break;
+		}
+	    }
+	    if (!c) break;
+	} else if (c=='\\' && (*chptr=='\n'||*chptr==0)) {
+	    chptr++;
+	    cheapp--;
+	    getline();
+	}
+    }
+    *cheapp++ = '\0';
+    while(cheapp>scheapp&&(*cheapp=='\n'||*cheapp==0)) cheapp--;
+    *++cheapp = '\0'; cheapp++;
+    if (cheapp >= cheap+CHEAPSIZE) /* too late? */
+	error(STRERR);
+// fprintf(stderr,"%s\n",(char *)car(nptr->dsp));
+    mode=i;
+}
+
+// create function macro argument list
+//    return  list2((char*)arg,next)
+
+static int
+macro_args(char **pcheapp,char *maxcheap,char **pchptr)
+{
+    int c;
+    int in_quote = 0;
+    int in_wquote = 0;
+    int plevel = 0;
+    char *cheapp = *pcheapp;
+    char *chptr = *pchptr;
+    int args = list2((int)cheapp,0);
+    for(;;) {
+        *cheapp++ = c = *chptr++;
+	if (cheapp >= maxcheap) error(MCERR);
+	if (!c)  {
+	    chptr--;
+	    error(MCERR);
+	    *pchptr = chptr;
+	    *pcheapp = cheapp;
+	    return reverse0(args);
+	}
+	if (in_quote) {
+	    if (c=='\\') {
+		if (*chptr != '\n') {
+		    *cheapp++ = *chptr++;
+		} else {
+		    getline();
+		}
+	    } else if (c=='\'') {
+		in_quote = 0;
+	    }
+	} else if (in_wquote) {
+	    if (c=='\\') {
+		if (*chptr !='\n') {
+		    *cheapp++ = *chptr++;
+		} else {
+		    *cheapp = '\n';
+		    getline();
+		}
+	    } else if (c=='"') {
+		in_wquote = 0;
+	    }
+	} else if (c=='"') {
+	    in_wquote = 1;
+	} else if (c=='\'') {
+	    in_quote = 1;
+	} if (plevel==0) {
+	    if (c==',') {
+		cheapp[-1] = 0;
+		args = list2((int)cheapp,args);
+	    } else if (c==')') {
+		cheapp[-1] = 0;
+		break;
+	    } else if (c=='(') {
+		plevel++;
+	    } else if (c=='\\') {
+		if (*chptr=='\n') {
+		    cheapp--;
+		    getline();
+		}
+//	    } else if (c==' '||c=='\t') {
+//		cheapp--;
+	    } else if (c=='\n') {
+		cheapp--;
+		getline();
+		chptr = *pchptr;
+	    }
+	} else if (c==')') {
+	    plevel--;
+	} else if (c=='(') {
+	    plevel++;
+	} else if (c=='\n') {
+	    cheapp--;
+	    getline();
+	    chptr = *pchptr;
+	}
+    }
+    *pchptr = chptr;
+    *pcheapp = cheapp;
+    return reverse0(args);
+}
+
+/* output macro expansion result into macrobuf (macropp) */
+
+static int
+macro_function(int macrop,char **pchptr,NMTBL *nptr,int history)
+{
+    int args,sargs,values,evalues;
+    char *macro;
+
+    sargs = args = cadr(nptr->dsp);
+    values = macro_args(&macropp,macro_buf+MACROSIZE,pchptr);
+    if (pchptr==&chptr) {
+	ch = *chptr++;
+    }
+    evalues = 0;
+    while(values) {
+	evalues = list2(macro_eval(0,(char *)car(values),history),evalues);
+	values = cadr(values);
+    }
+    evalues = reverse0(evalues);
+    while(args) {
+	local_define((char *)car(args),mappend(reverse0(car(evalues))));
+/* fprintf(stderr,"%s: %s => %s\n",nptr->nm,(char *)car(args),(char *)car(msearch0((char *)car(args))->dsp)); */
+	args = cadr(args);
+	evalues = cadr(evalues);
+    }
+    macro = (char *)car(nptr->dsp);
+    macrop = macro_eval(macrop,macro,list2((int)macro,history));
+/* fprintf(stderr,"%s: result %s => %s\n",nptr->nm,macro,(char *)car(macrop)); */
+    args = sargs;
+    while(args) {
+	local_undef((char *)car(args));
+	args = cadr(args);
+    }
+    return macrop;
+}
+
+static void
+local_define(char *macro,char *value)
+{
+    NMTBL *nptr0;
+    while(*macro==' '||*macro=='\t') macro++;
+    nptr0 = msearch0(macro);
+    /* save nptr previous contents in a list */
+    nptr0->ty=list3(nptr0->sc,nptr0->ty,nptr0->dsp);
+    /* set new value */
+    nptr0->sc=LMACRO;
+    nptr0->dsp=list2((int)value,0);
+}
+
+static void
+local_undef(char *macro)
+{
+    NMTBL *nptr0;
+    int save;
+    nptr0 = msearch0(macro);
+    save = nptr0->ty;
+    nptr0->sc=car(save);
+    nptr0->dsp=caddr(save);
+    nptr0->ty=cadr(save);
+}
+
+static int
+macro_eval(int macrop,char *body0,int history)
+{
+    int c;
+    int in_quote = 0;
+    int in_wquote = 0;
+    char *macro;
+    char *body = body0;
+    int i;
+    NMTBL *nptrm;
+    macrop = list2((int)macropp,macrop);
+    for(; (c = *body++) ;) {
+	if (macropp+1>macro_buf+MACROSIZE) error(STRERR);
+	if (in_quote) {
+	    if (c=='\\') {
+		*macropp++ = c; c = *body++;
+	    } else if (c=='\'') {
+		in_quote = 0;
+	    }
+	} else if (in_wquote) {
+	    if (c=='\\') {
+		*macropp++ = c; c = *body++;
+	    } else if (c=='"') {
+		in_wquote = 0;
+	    }
+	} else if (c=='"') {
+	    in_wquote = 1;
+	} else if (c=='\'') {
+	    in_quote = 1;
+	} else if (c=='#' && *body=='#') {
+	    // name concatenation. skip ## and re-eval macro line.
+	    mconcat = 1; body++; continue;
+	} else if (alpha(c)) {
+	    i = 0;
+	    do { namebuf[i++] = c; c=*body++;} while (alpha(c)||digit(c));
+	    body--; // ungetc
+	    namebuf[i]=0;
+	    nptrm = msearch0(namebuf);
+	    macro = (char *)car(nptrm->dsp);
+	    if (nptrm->sc==LMACRO) {
+		while((*macropp++ = *macro++));
+		macropp--;
+	    } else if (nptrm->sc==MACRO && neqname(namebuf,macro)) {
+		if (macro[0]==0)  continue;
+		*macropp++=0;
+                macrop=macro_eval(macrop,macro,list2((int)macro,history));
+		macrop = list2((int)macropp,macrop);
+	    } else if (nptrm->sc==FMACRO) {
+		if (c==' '||c=='\t') {
+		    while (c==' '||c=='\t') c=*body++;
+		    body--;
+		}
+		if(c!='(') error(MCERR);
+		*macropp++=0; body++;
+		macrop = macro_function(macrop,&body,nptrm,
+			list2((int)macro,history));
+		macrop = list2((int)macropp,macrop);
+	    } else {
+		macro = namebuf;
+		while((*macropp++ = *macro++));
+		macropp--;
+	    }
+	    continue;
+	}
+	*macropp++ = c;
+    }
+    *macropp++=0;
+    return macrop;
+}
+
+
+static char *
+mappend(int lists)
+{
+    char *p;
+    char *result = macropp;
+    while(lists) {
+        if (macropp>macro_buf+MACROSIZE) error(STRERR);
+        p = (char *)car(lists);
+        while((*macropp++=*p++)) if (p[-1]=='\n') macropp[-1]=' ';
+        macropp--;
+        lists = cadr(lists);
+    }
+    macropp++;
+    return result;
+}
+
+/* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mc-macro.h	Mon Jun 21 23:50:34 2004 +0900
@@ -0,0 +1,10 @@
+/* mc-macro.c */
+
+extern void macro_expansion(NMTBL *nptrm);
+extern int macroeq(char *n);
+extern void check_macro_eof();
+extern void getline(void);
+extern void macro_define(char *macro);
+extern char *chinput;
+
+extern int in_macro_if;
--- a/mc-parse.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-parse.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,22 +1,66 @@
 /* Micro-C Parser Part */ /* $Id$ */
 
-#define EXTERN /**/
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 #include "mc-codegen.h"
 #include "mc-switch.h"
+#include "mc-macro.h"
+#include "conv/conv.h"
+
+#define FILES 10
+#define OUTPUT_FILE_NAME "mcout.s"
+
+extern void exit(int);  /* to avoid stdlib.h inclusion */
+#if LONGLONG_CODE
+#if 0
+extern long long
+     strtoll(char * nptr, char ** endptr, int base);
+#endif
+#endif
+#if FLOAT_CODE
+extern double strtod(const char *nptr, char **endptr);
+#endif
+
+NMTBL null_nptr;
+NMTBL *fnptr;
+NMTBL *msearch0(char *name);
+NMTBL *nptr,*gnptr;
+NMTBL ntable[GSYMS+LSYMS];
+char *cheapp;
+char cheap[CHEAPSIZE]; // should be extendable
+char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
+int args,init_vars,heap[HEAPSIZE];
+int asmf;
+int bit_field_disp;
+int blabel,dlabel;
+int ch;
+int chk;
+int chptrsave; 
+int chsave; 
+int cslabel,control;
+int csvalue1;
+int debug; 
+int fields;
+int glineno; 
+int gtypedefed;
+int in_comment; 
+int in_quote; 
+int labelno,gpc,disp;
+int lastexp;
+int lfree; 
+int lineno; 
+int lsrc; 
+int retlabel,retpending,retcont;
+int struct_return;
+int sym,type,mode,stmode;
+int typedefed;
+struct {int fd,ln;char *name0;int inc;FILE *fcb;} *filep,filestack[FILES];
 
 static NMTBL *decl0(void),*decl1(void),*lsearch(char *name,int sc);
 static NMTBL *gsearch(int sc);
-static NMTBL *def(NMTBL *n);
-static NMTBL *free_nptr();
 static NMTBL *msearch(char *name);
-static NMTBL *msearch0(char *name);
-static char * mappend(int lists);
 static int append3(int p,int a1,int a2);
-static int binop(int op, int e1, int e2, int t1, int t2);
-static int cexpr(int e);
-static int decl_data(int t, NMTBL *n,int offset,int skip);
-static int expr(int);
 static int expr0(void);
 static int expr1(void);
 static int expr10(void);
@@ -34,29 +78,14 @@
 static int expr7(void);
 static int expr8(void);
 static int expr9(void);
-static int getch(void);
 static int getfree(int n);
-static int getsym(int);
-static int indop(int e);
-static int macro_args(char **pcheapp,char* max,char **pchptr);
-static int macro_eval(int macrop,char *body,int history);
-static int macro_function(int macrop,char **pchptr,NMTBL *nptr,int history);
-static int macroeq(char *s);
 static int ndecl0(void);
 static int ndecl1(void);
-static int neqname(char *p,char *name);
 static int postequ(int s1, int s2);
-static int rvalue(int e);
 static int sdecl(int s);
 static int edecl();
-static int skipspc(void);
-static int strop(int e);
-static int typeid(int s);
-static int typename(void);
-static int typespec(void);
 static int adecl(NMTBL *n);
 static void code_decl(NMTBL *n);
-static void compatible(int t1, int t2);
 static void copy(NMTBL *nptr, char *s);
 static void decl(void);
 static void docase(void);
@@ -74,35 +103,35 @@
 static void doasm();
 #endif
 static void errmsg(void);
-static void fcheck(NMTBL *n);
 static void fdecl(NMTBL *n);
-static void fdecl_struct(int type);
-static void getline(void);
 static void getstring(void);
 static void init(void);
-static void lcheck(int e);
-static void local_define();
-static void local_undef();
-static void macro_define0();
-static int macro_processing();
-static void check_macro_eof();
 static void newfile(void);
-static void replace_return_struct(int func,int left);
 static void reserve(char *s, int d);
 static void reverse(int t1);
 static void set_converter(char *s);
+static int escape(void);
 static void statement(int);
-static int correct_type(int e,int t);
-static int arg_reorder(int old_arg,int new_arg);
-static int search_struct_type(int t,char *name,int *dsp);
+static int typename(void);
+static void decl_data_field(int type,NMTBL *n,int offset);
+static int decl_data(int t, NMTBL *n,int offset,int skip);
+static int typeid(int s);
+static int typename(void);
 
+#if FLOAT_CODE
+static double dsymval;
+#endif
+#if LONGLONG_CODE
+static long long  lsymval;
+#endif
+static int symval;
+static char *name;
+static unsigned hash;
+static int gfree;
+static char *sptr;
 
-static int struct_return  = 0;
 static int sdecl_f = 1;
 static int stypedecl;
-static int fields;
-
-static int in_macro_if = 0;
 
 static Converter *conv = &null_converter;
 /* Converter *conv = &c_converter; */
@@ -110,18 +139,22 @@
 static char *ccout = 0;
 
 #define MAX_INCLUDE_PATH_COUNT 10
-static char *include_path[MAX_INCLUDE_PATH_COUNT];
+char *include_path[MAX_INCLUDE_PATH_COUNT];
 int include_path_count;
 extern char *l_include_path[];
 
 static
 char current_file_dir[LBUFSIZE];
 
-static char *chinput=0;
-static int in_quote=0;
-static int lastexp = 0;
+static int ac,ac2;
+static char **av;
+static int cslist;
+static int clabel;
+static int ilabel;
+static int stat_no;
+static int decl_str_init;
 
-static int bit_field_disp;
+static NMTBL mtable[MSYMS];
 
 int
 main(int argc, char **argv)
@@ -172,10 +205,9 @@
 	for (nptr = &ntable[GSYMS],i=LSYMS; i--;) {
 	    (nptr++)->sc = 0;
 	}
-	emit_init();
-	init_free_lvar_list();
 	mode=TOP;
 	lfree= HEAPSIZE;
+	codegen_decl_init();
 	while (chptrsave!=0) {
 	    i = cadr(chptrsave); free_glist2(chptrsave); chptrsave = i;
 	}
@@ -191,9 +223,7 @@
     /*NOTREACHED*/
 }
 
-static void copy_current_file_dir(char *name);
-
-void
+extern void
 error(int n)
 {
     if(n == EOFERR) {
@@ -239,6 +269,7 @@
 	(n==UDERR) ? "Undeclared identifier" :
 	(n==OPTION) ? "Illegal option" :
 	(n==REG_ERR) ? "illegal register var" :
+	(n==INERR) ? "bad initialization" :
 	(n==CODE_ERR) ? "goto code is necessary" :
 	"Bug of compiler");
     errmsg();
@@ -279,6 +310,15 @@
 }
 
 static void
+heap_init()
+{
+    gpc=glineno=0;
+    gfree=ilabel=1;
+    labelno=2;
+    lfree=HEAPSIZE;
+}
+
+static void
 reinit(void)
 {
     int i;
@@ -287,6 +327,8 @@
     cheapp=cheap;
     for(nptr = ntable,i = GSYMS; i--;) (nptr++)->sc = 0;
     for(nptr = mtable,i = MSYMS; i--;) (nptr++)->sc = 0;
+    codegen_reinit();
+
     reserve("int",INT);
     reserve("void",VOID);
     reserve("char",CHAR);
@@ -331,12 +373,7 @@
     reserve("__asm__",ASM);
 #endif
 
-    gpc=glineno=0;
-    gfree=ilabel=1;
-    labelno=2;
-    lfree=HEAPSIZE;
-    codegen_init();
-
+    heap_init();
     macro_define("__micro_c__ 1\n");
     macro_define("__restrict\n"); 
     macro_define("__micro_c__ 1\n");
@@ -354,14 +391,15 @@
 static void
 init(void)
 {
-
+    heap_init();
+    codegen_init();
     reinit();
     filep=filestack;
     newfile();
     getch();
 }
 
-static void
+extern void
 copy_current_file_dir(char *name)
 {
     char *s = name;
@@ -537,6 +575,7 @@
     }
     conv->return_type_(type,n,sd);
     def(n);
+    if (sym==ASS) decl_data(type,n,0,0);
     while(sym==COMMA) {
 	conv->comma_();
 	getsym(0);
@@ -546,6 +585,7 @@
 	if(n == &null_nptr) error(DCERR);
 	conv->return_type_(type,n,1);
 	def(n);
+	if (sym==ASS) decl_data(type,n,0,0);
     }
     if(sym!=SM) error(DCERR);
     conv->sm_();
@@ -555,7 +595,7 @@
 	mode=LDECL;
 }
 
-static int
+extern int
 typespec(void)
 {
     int t = INT;
@@ -757,13 +797,13 @@
 	    if (mode!=GDECL)
 		n->dsp=arg;
 	} else if(sym==COLON) { /* brain dead bit-field */
-	    if (mode=GSDECL||mode==GUDECL||mode=LSDECL||mode==LUDECL) {
+	    if (mode==GSDECL||mode==GUDECL||mode==LSDECL||mode==LUDECL) {
 		if (scalar(type) || type==LONGLONG || type==ULONGLONG) {
 		    getsym(0);
-		    n->ty = list4(BIT_FILED,type,0 /* bit offset */,symval);
+		    n->ty = list4(BIT_FIELD,type,0 /* bit offset */,symval);
 		}
 	    }
-	    error(SYERR);
+	    error(DCERR);
 	    return n;
 	} else
 	    return n;
@@ -776,18 +816,16 @@
 adecl(NMTBL *n)
 {
     NMTBL *arg,*sfnptr;
-    int sreg_var,t;
+    int t;
     int stype,smode,sd,sargs,sstmode;
     int argtypes;
 
-    sstmode=stmode; stmode=REGISTER;
+    sstmode=stmode; stmode=REGISTER; /* nobody use this? */
     stype=type;
     sfnptr=fnptr;
     fnptr=n;
     sd = sdecl_f;
     sdecl_f = 0;
-    sreg_var=reg_var;
-    reg_var=0;
     argtypes = 0;
     smode = mode;
     mode=ADECL;
@@ -830,7 +868,6 @@
     n->dsp=reverse0(n->dsp);
     checksym(RPAR);
     mode=smode;
-    reg_var=sreg_var;
     fnptr=sfnptr;
     type=stype;
     sdecl_f = sd;
@@ -870,7 +907,7 @@
     return t2;
 }
 
-int
+extern int
 size(int t)
 {
     if (t<0) {
@@ -909,70 +946,8 @@
     return 0;
 }
 
-int
-new_lvar0(int sz)
-{
-    return disp -= sz;
-}
 
-/* temporal local variable free list */
-
-static int lvar_list,lvar_free_list;
-
-int
-new_lvar(int size)
-{
-    int lvar,plvar;
-
-    for (plvar = 0,lvar = lvar_free_list;lvar;lvar = cadr(lvar)) {
-	if (caddr(lvar)==size) {
-	    if (plvar) cadr(plvar) = cadr(lvar);
-	    else lvar_free_list = cadr(lvar);
-	    break;
-	}
-	plvar = lvar;
-    }
-    if (!lvar) {
-	lvar_list = glist3((lvar=new_lvar0(size)),lvar_list,size);
-    } else {
-	cadr(lvar) = lvar_list; lvar_list = lvar;
-	lvar = car(lvar_list);
-    }
-    return lvar;
-}
-
-void
-free_lvar(int disp)
-{
-    int lvar,plvar;
-
-    for (plvar = 0,lvar = lvar_list;lvar;lvar = cadr(lvar)) {
-	if (car(lvar)==disp) {
-	    if (plvar) cadr(plvar) = cadr(lvar);
-	    else lvar_list = cadr(lvar);
-	    break;
-	}
-	plvar = lvar;
-    }
-    if (!lvar) error(-1);
-    cadr(lvar) = lvar_free_list; lvar_free_list = lvar;
-}
-
-void
-init_free_lvar_list()
-{
-    int lvar;
-    while((lvar=lvar_list)) {
-	lvar_list=cadr(lvar_list);
-	free_glist3(lvar);
-    }
-    while((lvar=lvar_free_list)) {
-	lvar_free_list=cadr(lvar_free_list);
-	free_glist3(lvar);
-    }
-}
-
-static char *
+extern char *
 new_static_name(char *name,int delimit)
 {
     int ndsp;
@@ -989,210 +964,6 @@
     return p;
 }
 
-static NMTBL *
-def(NMTBL *n)
-{
-    int sz,nsc,ndsp;
-    int sbit_f = bit_field_disp;
-    bit_field_disp = 0;  // default is 0, recover only in bit-field
-
-    conv->def_(n);
-    if (n==0) {
-	n=free_nptr();
-	n->nm = "_";
-    }
-    nsc=ndsp=0;
-    if (stmode==EXTRN||mode==GDECL)
-	n->ty = type;  /* must be in global table/heap */
-    if(type>0&&(car(type)==FUNCTION || car(type)==CODE)) {
-	if ((mode==GDECL)) {
-	    fcheck(n);
-	    return n;
-	    /* function and code segment are defined using fdecl/code_decl */
-            /* in decl() */
-	}
-    }
-    if (mode==GSDECL||mode==LSDECL|| mode==GUDECL||mode==LUDECL) {
-          /* Struct fields name lists are in the struct type or tag. */
-          /* Only name in the table is used. */
-	if (car(n->ty)==BIT_FIELD) {
-	    bit_field_disp=sbit_f;   // default is 0, recover only here.
-            // n->ty = list4(BIT_FILED,type,bit_offset,symval);
-	    caddr(n->ty) = bit_field_disp;  // bitwise offset
-	    bit_field_disp += cadddr(n->ty);
-	    sz = bit_field_disp/BIT_OF_BYTE;
-	    bit_field_disp %= BIT_OF_BYTE;
-	}  else {
-	    sz = size(type);
-	}
-	fields = list4(type,fields,(int)(n->nm),disp);
-    } else {
-	if (n->sc!=EMPTY &&  !(n->sc==EXTRN||n->sc==EXTRN1||n->sc==STATIC)) {
-	  /* redefined case */
-	  if (mode==ADECL) {  /* K&R arguments case */
-	    if (n->sc==LVAR && n->ty==INT);
-	    else if ( n->sc==REGISTER && n->ty==INT);
-	    else error(RDERR);
-	  } else error(RDERR);
-	}
-	sz = size(n->ty = type);
-    }
-    switch(mode) {
-    case GDECL:
-	gen_gdecl(n->nm,gpc);
-    case STADECL:
-	nsc = GVAR;
-	ndsp = gpc;
-	if (n->dsp!=-1)     /* don't set dsp if initialized static */
-	    n->dsp = ndsp;  /* emit_data will override this */
-	if (stmode==EXTRN)
-	    nsc = EXTRN;
-	else if (stmode==STATIC)
-	    nsc = STATIC;
-	n->sc = nsc;
-	if (stmode==LDECL) {
-	    n->nm = new_static_name(n->nm,'.');
-	}
-	if(sym==ASS) {
-	    if (n->dsp==-1) error(-1);  // already initialized
-	    conv->op_(sym);
-	    decl_data(type,n,0,0);
-	    emit_data_closing(n);
-	    /* gpc is incremented by emit_data */
-	} else
-	    gpc +=sz;
-	return n;
-    case GSDECL: case LSDECL:
-	disp += sz;
-	return n;
-    case GUDECL: case LUDECL:
-	if (disp < sz) disp = sz;
-	return n;
-    case GTDECL:
-	nsc = TYPE;
-	gtypedefed=glist2((int)gnptr,gtypedefed);
-	break;
-    case LTDECL:
-	nsc = TYPE;
-	break;
-    case ADECL:
-	if(!integral(type)&&(car(type)==FUNCTION||car(type)==CODE)) {
-	    type=list2(POINTER,type); n->ty = type;
-	}
-	fnptr->dsp=list4(type,fnptr->dsp,(int)n,0);
-	n->sc = LVAR;
-	if(type==CHAR||type==UCHAR) {
-	    if (n->dsp==0) {
-		n->dsp = args;
-		if (endian) n->dsp += size_of_int-1;
-	    }
-	    args += size_of_int;
-	} else if(type==SHORT||type==USHORT) {
-	    if (n->dsp==0) {
-		n->dsp = args;
-		if (endian) n->dsp += size_of_int-size_of_short;
-	    }
-	    args += size_of_int;
-	} else if(type>0&&(type==UNION||type==STRUCT)) {
-	    n->dsp = args;
-	    args += ((sz+(size_of_int-1))&~(size_of_int-1));
-	} else {
-	    /* if (n->dsp==0) (argument list in ADECL is useless, type
-               list can be found in type ) */
-	    n->dsp = args;
-	    args += sz;
-	}
-	cadddr(fnptr->dsp)=sz;
-	if(type==VOID) {
-	} else {
-	    n->ty = type;
-	}
-	return n;
-    case STAT: /* return (struct hoge)f() case? */
-    case LDECL:
-	if (stmode==REGISTER) {
-	    if(scalar(type)) {
-		ndsp = get_register_var(n);
-#if FLOAT_CODE
-	    } else if (type==FLOAT) {
-		ndsp = get_dregister_var(n,0);
-	    } else if (type==DOUBLE) {
-		ndsp = get_dregister_var(n,1);
-#endif
-#if LONGLONG_CODE
-	    } else if (type==LONGLONG||type==ULONGLONG) {
-		ndsp = get_lregister_var(n);
-#endif
-	    } else error(DCERR);
-	    nsc = car(ndsp);
-	    ndsp = cadr(ndsp);
-	} else {
-	    nsc = LVAR;
-	    ndsp = new_lvar(sz);
-	}
-	n->sc = nsc;
-	n->dsp = ndsp;
-	if(sym==ASS) {
-	    conv->op_(sym);
-	    decl_data(type,n,0,0);
-	}
-	return n;
-    default:
-	error(DCERR);
-    }
-    n->sc = nsc;
-    n->dsp = ndsp;
-    if (stmode==EXTRN)
-	n->sc = EXTRN;
-    return n;
-}
-
-static void
-emit_init_vars(void)
-{
-    if (!init_vars) return;
-    init_vars = reverse0(init_vars);
-    while(init_vars) {
-	gexpr(car(init_vars),0);
-	init_vars = cadr(init_vars);
-    }
-}
-
-static int
-str_init_eq()
-{
-    // error(-1);  // duplicate struct field value
-    return 2;      // allow override keep unique
-}
-
-static int decl_str_init;
-
-int
-assign_data(int e, int t, NMTBL *n,int offset)
-{
-    int ass;
-
-    if(mode==GDECL) {
- 	emit_data(e,t,n);
-    } else if(mode==STADECL) {
- 	emit_data(e,t,n);
-    } else if(mode==LDECL) {
-	if (t==EMPTY) return offset+cadr(e);
-	ass = assign_expr0(
-    (n->sc==REGISTER||n->sc==DREGISTER||n->sc==FREGISTER||n->sc==LREGISTER)?
-	    list3(n->sc,n->dsp,(int)n):
-	    list2(LVAR,n->dsp+offset),
-	e,t,type);
-	init_vars = list2(ass,init_vars);
-    } else if(mode==SFDINIT) {
-	decl_str_init=insert_ascend(decl_str_init,
-		list4(offset,0,e,t),str_init_eq);
-    } else {
-	error(DCERR);
-	return offset;
-    }
-    return offset+((t==EMPTY)?cadr(e):size(t));
-}
 
 #define LOCAL_STRUCT_INIT_STATIC 1
 
@@ -1282,6 +1053,10 @@
 {
     int t1,e,i,mode_save;
 
+    if (offset==0 && n->sc==GVAR && n->dsp==-1) {
+	/* duplicate initialization */
+	error(INERR);
+    }
     conv->decl_data_();
     mode_save = mode;
     mode=STAT;
@@ -1392,7 +1167,7 @@
 static int
 sdecl(int s)
 {
-    int smode,sdisp,sbit_filed_disp,type0=0;
+    int smode,sdisp,sbit_field_disp,type0=0;
     NMTBL *nptr0,*gnptr0;
     int sfields = fields;
 
@@ -1496,7 +1271,7 @@
 {
     int t,arglist;
 
-    if(!chk) code_enter(n->nm);
+    if(!chk) gen_code_enter(n->nm);
     fnptr=n;
     n->sc = CODE;
     n->ty = type;
@@ -1504,7 +1279,6 @@
     disp = -args;
     mode=ADECL;
     if (sym!=LC) {
-	reg_var=0;
 	arglist=fnptr->dsp;
 	args=fnptr->dsp=0;
 	while (sym!=LC) { /* argument declaration !ANSI */
@@ -1536,14 +1310,14 @@
     conv->localvar_end_();
     control=1;
     cslabel = -1;
-    if(!chk) code_enter1(args);
+    if(!chk) gen_code_enter1(args);
     emit_init_vars();
     while(sym!=RC) statement(0);
     if(control)
 	error(STERR);
     control=0;
     conv->code_end_();
-    if(!chk) code_leave(fnptr->nm);
+    if(!chk) gen_code_leave(fnptr->nm);
     args = 0;
 }
 
@@ -1572,59 +1346,19 @@
 
 /* function define */
 
-static int
-arg_reorder(int arg,int new_arg)
-{
-    /*	list4(type,fnptr->dsp,(int)n,size); */
-    int i,j,sz;
-    int dsp = 0;
-    NMTBL *n,*n1;
-
-    /* f(a,b,c) { int c; short a; char* b;} case */
-
-// fprintf(stderr,"arg_reorder old:\n");
-//    for(j=new_arg;j;j=cadr(j)) {
-//	    n=(NMTBL *)caddr(j);
-// fprintf(stderr,"dsp %d %s sz %d type %d\n",n->dsp,n->nm,cadddr(j),car(j));
-//    }
-// fprintf(stderr,"arg_reorder new:\n");
-    for(j=arg;j;j=cadr(j)) {
-	n=(NMTBL *)caddr(j);
-	for(i=new_arg;i;i=cadr(i)) {
-	    n1=(NMTBL *)caddr(i);
-	    if (!neqname(n1->nm,n->nm)) break;
-	    // if (n1==n) break;
-	}
-// fprintf(stderr,"dsp %d %s %s sz %d type %d\n",dsp,n->nm,n1->nm,cadddr(i),car(i));
-	if (!i) {
-	    /* f(a,b,c) { int c; } case (what?!) */
-	    i = j;
-	}
-	if(n->sc==LVAR) {
-	    n->dsp = dsp;
-	    car(j)=car(i);
-	    caddr(j)=caddr(i);
-	    cadddr(j)=sz= cadddr(i);
-	    if (sz==1||sz==size_of_short) sz = size_of_int;
-	    dsp += sz;
-	}
-    }
-// fprintf(stderr,"arg_reorder end:\n");
-    return arg;
-}
 
 static void
 fdecl(NMTBL *n)
 {
     int sd = stypedecl;
     int arglist;
-    if(!chk) enter(n->nm);
+    if(!chk) gen_enter(n->nm);
     fnptr=n;
     retlabel=fwdlabel();
     retcont = 0;
+    if (tmp_struct) { tmp_struct->sc = 0; tmp_struct->nm = 0; }
     tmp_struct = 0; /* a = f().filed  */
 
-    reg_var=0;
     n->ty = type;
     fcheck(n);
     n->sc = FUNCTION;
@@ -1653,124 +1387,17 @@
     local_decl();
     control=1;
     cslabel = -1;
-    if(!chk) enter1();
+    if(!chk) gen_enter1();
     emit_init_vars();
     while(sym!=RC) statement(0);
 
     conv->function_end_(); conv->rc_();
-    if(!chk) leave(control,n->nm);
+    if(!chk) gen_leave(control,n->nm);
     retpending = 0;
     control=0;
     arglist=0;
 }
 
-extern NMTBL str_ret;
-NMTBL str_ret;
-
-/*
-    If function has structure return value, it has an extra
-    argument for where to write the structure. It have to be
-    a first argument. We add it here and we have to fix all arguments'
-    offset. If it is the last value, we don't have to fix, but
-    gcc has a first argument convention.
- */
-
-static void
-fdecl_struct(int fntype)
-{
-    int type_save,mode_save,t,sz;
-    NMTBL *n;
-
-    t = cadr(fntype);
-    if (t>0 && (car(t)==STRUCT||car(t)==UNION)) {
-	mode_save = mode;
-	mode=ADECL;
-	type_save = type;
-	/* extra argument for struct return */
-	/* this extra dummy arguments are set at calling sequence */
-	str_ret.nm = "str_ret"; str_ret.sc = EMPTY;
-	str_ret.dsp = 0; str_ret.ty = 0;
-	type=list2(POINTER,t);
-	/* fix all argument's offset */
-	sz = size(type);
-	for(t=fnptr->dsp;t;t=cadr(t)) {
-	    n=(NMTBL *)caddr(t);
-	    n->dsp += sz;
-	}
-	fnptr->dsp = reverse0(fnptr->dsp);
-	if ((sz=size(cadr(fntype)))==-1) error(TYERR);
-	else {
-	    args = 0;
-	    def(&str_ret);
-	    struct_return = list3(list2(LVAR,str_ret.dsp),sz,type);
-	    caddr(fnptr->ty) = glist2(POINTER,caddr(fnptr->ty));
-	}
-	type = type_save;
-	mode = mode_save;
-    } else {
-	struct_return = 0;
-	fnptr->dsp = reverse0(fnptr->dsp);
-    }
-}
-
-void
-fcheck(NMTBL *n)
-{
-    if(!(mode==GDECL||mode==ADECL)||
-             (car(type)!=FUNCTION&&car(type)!=CODE)) error(DCERR);
-    if (n->sc==EMPTY) {
-	n->sc=EXTRN;
-	n->ty=type;
-    } else if(is_code(n)) compatible(cadr(n->ty),cadr(type));
-    else if(is_function(n)) compatible(cadr(n->ty),cadr(type));
-    else {
-	error(DCERR);
-    }
-}
-
-static void
-compatible(int t1, int t2)
-{
-    if(integral(t1)) {
-	    if(t1!=t2) error(TYERR);
-    }
-    else if(car(t1)!=car(t2))
-	    error(TYERR);
-    else if((car(t1)==STRUCT || car(t1)==UNION) && cadr(t1)!=cadr(t2))
-	    error(TYERR);
-    else if(car(t1)==POINTER || car(t1)==ARRAY ||car(t1)==FUNCTION)
-	    compatible(cadr(t1),cadr(t2));
-}
-
-int
-scalar(int t)
-{
-    return(integral(t)||car(t)==POINTER);
-}
-
-int
-integral(int t)
-{
-    return(t==INT||t==SIGNED||t==CHAR||t==UNSIGNED||
-        t==UCHAR||t==SHORT||t==USHORT||t==ENUM);
-}
-
-static void
-checkret(void)
-{
-    if (cslabel==0) {
-	if (!control) error(-1); // no execute code in switch
-	jmp(cslabel=fwdlabel());
-    } else if (retpending) {
-	ret();
-	control=0;
-	retpending=0;
-    }
-    if (lastexp) {
-	gexpr(lastexp,0);
-	lastexp = 0;
-    }
-}
 
 static void
 statement(int use)
@@ -1803,14 +1430,14 @@
     case BREAK:
 	checkret();
 	conv->break_();
-	if (control) jmp(blabel);
+	if (control) gen_jmp(blabel);
 	getsym(0);
 	checksym(SM);
 	return;
     case CONTINUE:
 	checkret();
 	conv->continue_();
-	if (control) jmp(clabel);
+	if (control) gen_jmp(clabel);
 	getsym(0);
 	checksym(SM);
 	return;
@@ -1869,7 +1496,7 @@
     if(sym==ELSE) {
 	conv->if_else_();
 	if ((l2 = control))
-	    jmp(l2=fwdlabel());
+	    gen_jmp(l2=fwdlabel());
 	fwddef(l1);
 	getsym(0);
 	statement(0);
@@ -1909,7 +1536,7 @@
 	statement(0);
 	checkret();
 	if(control)
-	    jmp(clabel);
+	    gen_jmp(clabel);
     }
     conv->while_end_();
     fwddef(blabel);
@@ -2000,7 +1627,7 @@
 	lfree=slfree;
     }
     conv->for_end_();
-    jmp(l);
+    gen_jmp(l);
     fwddef(blabel);
     clabel=scontinue;
     blabel=sbreak;
@@ -2059,7 +1686,7 @@
     conv->switch_end_();
     checkret();
 #if CASE_CODE
-    if (control) jmp(blabel);
+    if (control) gen_jmp(blabel);
     genswitch(cslist,cslabel);
 #else
     if(dlabel) def_label(cslabel,dlabel);
@@ -2135,7 +1762,7 @@
     }
     if (control) {
 	control=0;
-	jmp(l=fwdlabel());
+	gen_jmp(l=fwdlabel());
     }
     if (cslabel) fwddef(cslabel);
     while(cadr(c)) {
@@ -2165,7 +1792,7 @@
 {
     int slfree,e,e1;
 
-    if (!cslabel) jmp(cslabel = fwdlabel());
+    if (!cslabel) gen_jmp(cslabel = fwdlabel());
     if(getsym(0)==SM) {
 	// should check fnptr have no return value
 	conv->return_();
@@ -2204,14 +1831,6 @@
     retpending = 1;
 }
 
-void
-replace_return_struct(int func,int left) {
-    int e = caddr(func);      /* arg lists */
-    while(cadr(e)) e=cadr(e); /* find first arg */
-    e = car(e);               /* return_struct arg */
-    cadr(e) = left;
-}
-
 static void
 dogoto(void)
 {
@@ -2230,9 +1849,9 @@
 	    nptr0->sc=EMPTY;
 	    nptr0=lsearch(nptr0->nm,0);
 	    nptr0->sc = FLABEL;
-	    jmp(nptr0->dsp = fwdlabel());
+	    gen_jmp(nptr0->dsp = fwdlabel());
 	} else if (t==FLABEL||t==BLABEL) {
-	    jmp(nptr0->dsp);
+	    gen_jmp(nptr0->dsp);
 	}
 	control=0;
 	conv->sm_();
@@ -2340,207 +1959,10 @@
 }
 #endif
 
-/* numerical type conversion */
-
-int
-double_value(int e2,int type)
-{
-#if FLOAT_CODE
-    if (car(e2)==CONST)  return dlist2(DCONST,(double)cadr(e2));
-    if (car(e2)==FCONST)  return dlist2(DCONST,dcadr(e2));
-    if(type==DOUBLE) return e2;
-    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2D);
-    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2D);
-    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2D);
-    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2D);
-    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2D);
-    error(TYERR); return dlist2(DCONST,1.0);
-#else
-    error(TYERR); return list2(CONST,0);
-#endif
-}
-
-int
-float_value(int e2,int type)
-{
-#if FLOAT_CODE
-#if LONGLONG_CODE
-    if (car(e2)==LCONST)  return  dlist2(FCONST,(double)lcadr(e2));
-    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2F);
-    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2F);
-#endif
-    if (car(e2)==CONST)  return dlist2(FCONST,(double)cadr(e2));
-    if (car(e2)==DCONST)  return dlist2(FCONST,dcadr(e2));
-    if(type==FLOAT) return e2;
-    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2F);
-    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2F);
-    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2F);
-    error(TYERR); return dlist2(DCONST,1.0);
-#else
-    error(TYERR); return list2(CONST,0);
-#endif
-}
-
-int
-longlong_value(int e2,int type)
-{
-#if LONGLONG_CODE
-    if (car(e2)==CONST)  return llist2(LCONST,(long long)cadr(e2));
-    if (car(e2)==LCONST)  return e2;
-#if FLOAT_CODE
-    if (car(e2)==DCONST||car(e2)==FCONST) 
-	return llist2(LCONST,(long long)dcadr(e2));
-    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2LL);
-    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2LL);
-#endif
-    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2LL);
-    if(type==LONGLONG) return e2;
-    if(type==ULONGLONG) return e2;
-    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2LL);
-    error(TYERR); return llist2(LCONST,0LL);
-#else
-    error(TYERR); return list2(CONST,0);
-#endif
-}
-
-int
-ulonglong_value(int e2,int type)
-{
-#if LONGLONG_CODE
-    if (car(e2)==CONST)  return llist2(LCONST,(unsigned long long)cadr(e2));
-    if (car(e2)==LCONST)  return e2;
-#if FLOAT_CODE
-    if (car(e2)==DCONST||car(e2)==FCONST) 
-	return llist2(LCONST,(unsigned long long)dcadr(e2));
-    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2ULL);
-    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2ULL);
-#endif
-    if(type==UNSIGNED) return list3(CONV,rvalue_t(e2,type),U2ULL);
-    if(type==LONGLONG) return e2;
-    if(type==ULONGLONG) return e2;
-    if(integral(type)) return list3(CONV,rvalue_t(e2,type),I2ULL);
-    error(TYERR); return llist2(LCONST,0LL);
-#else
-    error(TYERR); return list2(CONST,0);
-#endif
-}
-
-int
-int_value(int e2,int type)
-{
-    if(scalar(type)) return e2;
-#if FLOAT_CODE
-    if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(int)dcadr(e2));
-    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2I);
-    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2I);
-#endif
-#if LONGLONG_CODE
-    if (car(e2)==LCONST)  return list2(CONST,(int)lcadr(e2));
-    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2I);
-    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2I);
-#endif
-    if(car(type)==ARRAY) return e2;
-    error(TYERR); return list2(CONST,1);
-}
-
-int
-unsigned_value(int e2,int type)
-{
-    if(scalar(type)) return e2;
-#if FLOAT_CODE
-    // if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(unsigned)dcadr(e2));
-    if (car(e2)==DCONST||car(e2)==FCONST)  return list2(CONST,(int)dcadr(e2));
-    if(type==FLOAT) return list3(CONV,rvalue_t(e2,type),F2U);
-    if(type==DOUBLE) return list3(CONV,rvalue_t(e2,type),D2U);
-#endif
-#if LONGLONG_CODE
-    if(type==LONGLONG) return list3(CONV,rvalue_t(e2,type),LL2U);
-    if(type==ULONGLONG) return list3(CONV,rvalue_t(e2,type),ULL2U);
-#endif
-    error(TYERR); return e2;
-}
-
-static int
-coarse(int otype,int e,int itype)
-{
-    if(otype==LONGLONG) return longlong_value(e,itype);
-    else if(otype==ULONGLONG) return ulonglong_value(e,itype);
-    else if(otype==UCHAR||otype==UNSIGNED) return unsigned_value(e,itype);
-    else if(otype==FLOAT) return float_value(e,itype);
-    else if(otype==DOUBLE) return double_value(e,itype);
-    return int_value(e,itype);
-}
-
-/* assign statement */
-
-/* keep type */
-
-int
-assign_expr0(int e1,int e2,int t,int type0) {
-    int stype;
-    stype=type;
-    type = type0;
-    e2 = rvalue(e2);
-    e1=assign_expr(e1,e2,t,type);
-    type=stype;
-    return e1;
-}
-
-/* with conversion (will destroy type global variable) */
-
-int
-assign_expr(int e1,int e2,int t,int type) {
-    if(t==VOID)
-	error(TYERR);
-    if(t==CHAR||t==UCHAR) {
-	e2=(t==UCHAR)?unsigned_value(e2,type):int_value(e2,type);
-	if (!integral(type)) error(TYERR);
-	type= INT;return(list3(CASS,e1,e2));
-    } else if(t==SHORT||t==USHORT) {
-	e2=(t==USHORT)?unsigned_value(e2,type):int_value(e2,type);
-	if (!integral(type)) error(TYERR);
-	type= t;return(list3(SASS,e1,e2));
-#if FLOAT_CODE
-    } else if(t==DOUBLE) {
-	e2=double_value(e2,type);
-	type= t;return(list3(DASS,e1,e2));
-    } else if(t==FLOAT) {
-	e2=float_value(e2,type);
-	type= t;return(list3(FASS,e1,e2));
-#endif
-#if LONGLONG_CODE
-    } else if(t==LONGLONG) {
-	e2=longlong_value(e2,type);
-	type= t;return(list3(LASS,e1,e2));
-    } else if(t==ULONGLONG) {
-	e2=ulonglong_value(e2,type);
-	type= t;return(list3(LASS,e1,e2));
-#endif
-    } else if(scalar(t)) {
-	e2=(t==UNSIGNED)?unsigned_value(e2,type):int_value(e2,type);
-	type=t;
-	return(list3(ASS,e1,e2));
-    } else if (car(t)==BIT_FIELD) {
-	e2 = coarse(cadr(t),e2,type);
-	type = cadr(t);
-	return(list3(BASS,e1,e2));
-    } else if((car(t)==STRUCT||car(t)==UNION)) {
-	if (size(t)!=size(type)) error(TYERR);
-	type=t;
-	if(car(e2)==RSTRUCT && car(cadr(e2))==FUNCTION) {
-	    replace_return_struct(cadr(e2),e1);
-	    return cadr(e2);
-	} else {
-	    return (list4(STASS,e1,e2,size(t)));
-	}
-    } else {
-	error(TYERR); return list3(ASS,e1,e2);
-    }
-}
 
 /* C expression */
 
-int
+extern int
 expr(int noconv)
 {
     int r;
@@ -2588,63 +2010,7 @@
 	t=type;
 	getsym(0);
 	e2=rvalue(expr1());
-	if(!(integral(type)||type==FLOAT||type==DOUBLE||
-	    type==LONGLONG||type==ULONGLONG
-		)) error(TYERR);
-#if FLOAT_CODE
-	if (t==FLOAT) {
-	    if (no_float) error(TYERR);
-	    e2=float_value(e2,type); type=t;
-	    return(list4(FASSOP,e1,e2,op+FOP));
-	} else if (t==DOUBLE) {
-	    if (no_float) error(TYERR);
-	    e2=double_value(e2,type); type=t;
-	    return(list4(DASSOP,e1,e2,op+DOP));
-	}
-#endif
-#if LONGLONG_CODE
-	if (t==LONGLONG) {
-	    e2=longlong_value(e2,type); type=t;
-	    return(list4(LASSOP,e1,e2,op+LOP));
-	} else if (t==ULONGLONG) {
-	    e2=ulonglong_value(e2,type); type=t;
-	    return(list4(LASSOP,e1,e2,op+LOP+((op==MUL+AS||op==DIV+AS)?US:0)));
-	}
-#endif
-	if((t==UNSIGNED||t==UCHAR||t==USHORT||type==UNSIGNED)&&
-	    (op==MUL||op==DIV||op==MOD))
-	    op=op+US;
-	if((t==UNSIGNED||t==UCHAR||t==USHORT)&&(op==RSHIFT||op==LSHIFT))
-	    op=op+US;
-	if(t==CHAR) {
-	    type= INT;
-	    return(list4(CASSOP,e1,e2,op));
-	}
-	if(t==UCHAR) {
-	    type= UNSIGNED;
-	    return(list4(CUASSOP,e1,e2,op));
-	}
-	if(t==SHORT) {
-	    type= INT;
-	    return(list4(SASSOP,e1,e2,op));
-	}
-	if(t==USHORT) {
-	    type= UNSIGNED;
-	    return(list4(SUASSOP,e1,e2,op));
-	}
-	if (t>0 && car(t)==BIT_FIELD) {
-	    e2 = coarse(cadr(t),e2,type);
-	    type = cadr(t);
-	    return(list4(BASSOP,e1,e2,list2(op,t)));
-	}
-	type=t;
-	if(integral(t)) return(list4(ASSOP,e1,e2,op));
-        /* pointer += ... */
-	if((op!=ADD&&op!=SUB)||car(t)!=POINTER) error(TYERR);
-	e2=binop(MUL,e2,list2(CONST,size(cadr(t))),INT,UNSIGNED);
-	type=t;
-
-	return list4(ASSOP,e1,e2,op);
+	return assop(e1,e2,op,t,no_float);
     default:
 	return(e1);
     }
@@ -2667,41 +2033,7 @@
 	checksym(COLON);
 	e3=rvalue(expr2());
 	conv->cond_end_();
-	if(car(e1)==CONST) {
-	    if(cadr(e1)) {type=t;return e2;} else return e3;
-	}
-#if FLOAT_CODE
-	if(type==DOUBLE||t==DOUBLE) {
-	    e2=double_value(e2,t);
-	    e3=double_value(e3,type);
-	    t=type=DOUBLE;
-	    return(list4(DCOND,e1,e2,e3));
-	}
-	if(type==FLOAT||t==FLOAT) {
-	    e2=float_value(e2,t);
-	    e3=float_value(e3,type);
-	    t=type=FLOAT;
-	    return(list4(FCOND,e1,e2,e3));
-	}
-#endif
-#if LONGLONG_CODE
-	if(type==LONGLONG||t==LONGLONG) {
-	    e2=longlong_value(e2,t);
-	    e3=longlong_value(e3,type);
-	    t=type=LONGLONG;
-	    return(list4(LCOND,e1,e2,e3));
-	}
-	if(type==ULONGLONG||t==ULONGLONG) {
-	    e2=ulonglong_value(e2,t);
-	    e3=ulonglong_value(e3,type);
-	    t=type=ULONGLONG;
-	    return(list4(LCOND,e1,e2,e3));
-	}
-#endif
-	if(type==INT||(t!=INT&&type==UNSIGNED))
-	    type=t;
-	/* if (t!=type) error(TYERR); */
-	return(list4(COND,e1,e2,e3));
+	return cond(t,e1,e2,e3);
     }
     return(e1);
 }
@@ -3238,20 +2570,7 @@
 		return e1;
 	    }
 	    e1=expr13();
-	    if (integral(t)) {
-		if(t==UNSIGNED) e1=unsigned_value(e1,type);
-		else e1=int_value(e1,type);
-	    } else if(t==FLOAT) {
-		e1=float_value(e1,type);
-	    } else if(t==DOUBLE) {
-		e1=double_value(e1,type);
-	    } else if(t==LONGLONG) {
-		e1=longlong_value(e1,type);
-	    } else if(t==ULONGLONG) {
-		e1=ulonglong_value(e1,type);
-	    }
-	    type=t;
-	    return e1;
+	    return correct_type(e1,t);
 	} else if (sym==LC) {
 	    // statement in expression
 	    docomp(1);
@@ -3272,7 +2591,7 @@
 static int
 expr16(int e1)
 {
-    int e2,t;
+    int e2,t,ind;
 
     while(1) {
        if(sym==LBRA) {  /* a[3] */
@@ -3285,595 +2604,22 @@
 	    conv->rbra_(sym);
 	    e1=binop(ADD,e1,e2,t,type);
 	    e1=indop(e1);
-        } else if(sym==LPAR) e1=expr15(e1); /* f() */
-	else {
-	    if(sym==PERIOD) { conv->op_(sym);e1=strop(e1);
-	    } else if(sym==ARROW) { conv->op_(sym);e1=strop(indop(rvalue(e1)));
-	    } else break;
-	}
+        } else if(sym==LPAR) { 
+	    e1=expr15(e1); /* f() */
+	} else if(sym==PERIOD||sym==ARROW) { 
+	    ind = sym;
+	    conv->op_(sym);
+	    getsym(0);
+	    if (sym!=IDENT) error(TYERR);
+	    conv->id_(sym,nptr);
+	    e1=strop(e1,ind==ARROW);
+	    getsym(0);
+	} else break;
     }
     if(car(e1)==FNAME) type=list2(POINTER,type);
     return e1;
 }
 
-/* right value , get the value of the variable */
-
-static int
-indirect(int t,int e1)
-{
-    int e2,e3,e4,offset;
-    e2 = e1;
-    offset = 0;
-    e3 = cadr(e2);
-    if (car(e2)==ADD) {
-        e4=caddr(e2);
-        if (car(e4)==CONST) {
-            offset=cadr(e4);
-            e1=e3;
-        }
-    }
-    return list3(t,e1,offset);
-}
-
-static int
-rvalue(int e)
-{
-    int op;
-
-    op = 0;
-    switch(type) {
-    case INT: break;
-    case UNSIGNED: break;
-    case VOID:	break;
-    case CHAR:	op=COP; type=INT; break;
-    case UCHAR:	op=COP+US; type=UNSIGNED; break;
-    case SHORT:	op=SOP; type=SIGNED; break;
-    case USHORT:	op=SOP+US; type=UNSIGNED; break;
-    case LONGLONG:	op=LOP; break;
-    case ULONGLONG:	op=LOP+US; break;
-    case FLOAT:	op=FOP; break;
-    case DOUBLE:	op=DOP; break;
-    case CODE:	return e;
-    default:
-	if (integral(type)) break;
-	switch(car(type)) {
-	case ARRAY:
-	    type=list2(POINTER,cadr(type));
-	    if(car(e)==INDIRECT) return cadr(e);
-	    return list2(ADDRESS,e);
-	case STRUCT: case UNION:
-	    if(car(e)==RSTRUCT) return e; /* ??? */
-	    return list3(RSTRUCT,e,cadr(type) /* size */);
-	case FUNCTION:
-	    type=cadr(type);
-	    return e;
-	case CODE:
-	    return e;
-	case POINTER:
-	    break;
-	case BIT_FIELD:
-	    return list4(RBIT_FILED,caddr(type),cadddr(type),rvalue(cadddr(e)));
-            /*                      bit offset,   bit size,  rvalue */
-	    type = cadr(e);
-	    break;
-	default:
-	    error(TYERR);
-	}
-    }
-    switch(car(e)) {
-    case GVAR:
-	return(list2(RGVAR+op,cadr(e)));
-    case LVAR:
-	return(list2(RLVAR+op,cadr(e)));
-    case INDIRECT:
-	return(indirect(RINDIRECT+op,cadr(e)));
-    default:return(e); /* idempotent case? */
-    }
-}
-
-int
-rvalue_t(int e,int t)
-{
-    int stype = type;
-    type = t;
-    e = rvalue(e);
-    type = stype;
-    return e;
-}
-
-static void
-lcheck(int e)
-{
-    int t;
-    if(!(scalar(type)||type==DOUBLE||type==FLOAT||
-	type==LONGLONG||type==ULONGLONG)||
-	(car(e)!=GVAR&&car(e)!=LVAR&&car(e)!=INDIRECT
-		&& car(e)!=REGISTER
-		&& car(e)!=DREGISTER
-		&& car(e)!=FREGISTER
-		&& car(e)!=LREGISTER)
-	)
-	if ((t=car(type))<0 && t!=STRUCT && t!=UNION)
-	    error(LVERR);
-}
-
-static int
-indop(int e)
-{
-    if(type!=INT&&type!=UNSIGNED) {
-	if(car(type)==POINTER)
-	    type=cadr(type);
-	else if(car(type)==CODE || car(type)==FUNCTION)
-	    type=type;
-	else error(TYERR);
-    } else
-	type= CHAR;
-    if(car(e)==ADDRESS)
-	return(cadr(e));
-    return(list2(INDIRECT,e));
-}
-
-/* filed name search */
-
-    /* type = list4(s,disp,fields,tag_nptr); */
-
-static int
-search_struct_type(int type,char *name,int *dsp)
-{
-    int t;
-    NMTBL *nptr0;
-    t = caddr(type);
-    if (t==0) {
-	nptr0=(NMTBL*)cadddr(type);
-	t = caddr(type) = caddr(nptr0->ty);
-    }
-    for(;t;t = cadr(t)) {
-	if (neqname((char *)caddr(t),name)==0) {
-	    *dsp = cadddr(t);
-	    return car(t);
-	}
-    }
-    return 0;
-}
-
-static int
-strop(int e)
-{
-    int dsp = 0;
-
-    getsym(0);
-    if (sym!=IDENT) error(TYERR);
-    conv->id_(sym,nptr);
-    if (integral(type)||(car(type)!=STRUCT && car(type)!=UNION))
-	e=rvalue(e);
-    /* type = list4(s,disp,fields,tag_nptr); */
-    /* print_fields(caddr(type),"strop"); */
-    type = search_struct_type(type,nptr->nm,&dsp);
-    if (!type) { error(TYERR); type=INT; return e; }
-    if(dsp) {
-	switch(car(e)) {
-	case GVAR:
-	    e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
-	    break;
-	case LVAR:
-	    e=list2(LVAR,cadr(e) + dsp);
-	    break;
-	case INDIRECT:
-	    e=list2(INDIRECT,list3(ADD,cadr(e),list2(CONST,dsp)));
-	    break;
-	default:
-	    e=list2(INDIRECT,list3(ADD,e,list2(CONST,dsp)));
-	}
-    } else {
-	switch(car(e)) {
-	case GVAR: case LVAR: case INDIRECT:
-	    break;
-	default:
-	    e=list2(INDIRECT,e);
-	}
-    }
-    if (type>0&&car(type)==BIT_FIELD) {
-	getsym(0);
-	// n->ty = list4(BIT_FILED,type,bit_offset, bit_size);
-	return     list4(BIT_FILED,     caddr(type),cadddr(type), e);
-    }
-    getsym(0);
-    return e;
-}
-
-#if FLOAT_CODE
-/* binary floating computation */
-
-#define DTYPE(dop) (dop==DOP?DOUBLE:FLOAT)
-
-static int
-fdbinop(int op, int e1, int e2, int t1, int t2, int dop)
-{
-    double d1,d2,d;
-    int b=0;
-
-    type= DTYPE(dop);
-    if (dop==DOP) {
-	e1=double_value(e1,t1);
-	e2=double_value(e2,t2);
-    } else {
-	e1=float_value(e1,t1);
-	e2=float_value(e2,t2);
-    }
-    t1=t2=DTYPE(dop);
-    if(car(e1)==dop+CONST&&car(e2)==dop+CONST) {
-	d1=dcadr(e1);
-	d2=dcadr(e2);
-	switch(op) {
-	case ADD: d=d1+d2; break;
-	case SUB: d=d1-d2; break;
-	case MUL: d=d1*d2;break;
-	case DIV:
-	    if(!d2) error(EXERR);d=d1/d2;break;
-	default:
-	    switch(op) {
-		case GT: b=(d1>d2);break;
-		case GE: b=(d1>=d2);break;
-		case LT: b=(d1<d2);break;
-		case LE: b=(d1<=d2);break;
-		case EQ: b=(d1==d2);break;
-		case NEQ: b=(d1!=d2);break;
-		default: error(EXERR);
-	    }
-	    type = INT;
-	    return list2(CONST,b);
-	}
-	return dlist2(dop+CONST,d);
-    }
-    if(car(e1)==dop+CONST) {
-	if ((op==SUB||op==ADD)&&dcadr(e1)==0.0) {
-	    return e2;
-	} else if (op==MUL&&dcadr(e1)==1.0) {
-	    return e2;
-	} else if (op==MUL&&-dcadr(e1)==1.0) {
-	    return list2(dop+MINUS,e2);
-	}
-    }
-    if(car(e2)==dop+CONST) {
-	if ((op==SUB||op==ADD)&&dcadr(e2)==0.0) {
-	    return e1;
-	}
-	if ((op==DIV||op==MUL)&&dcadr(e2)==1.0) {
-	    return e1;
-	}
-	if ((op==DIV||op==MUL)&&-dcadr(e2)==1.0) {
-	    return list2(DMINUS,e1);
-	}
-	if (op==SUB) {
-	    op=ADD; dcadr(e2) = -dcadr(e2);
-	} else if(op==DIV) {
-	    if(dcadr(e2)==0.0) error(EXERR);
-	    op=MUL; dcadr(e2)=1/dcadr(e2);
-	}
-    }
-    if ((op==ADD||op==MUL) && (
-	    car(e1)==dop+CONST ||
-	    car(e2)==DRLVAR || car(e2)==DRGVAR ||
-	    car(e2)==FRLVAR || car(e2)==FRGVAR
-	)) {
-	return(list3(op+dop,e2,e1));
-    }
-    if(op==LT) {
-	type=INT;
-	return(list3(GT+dop,e2,e1));
-    } else if(op==LE) {
-	type=INT;
-	return(list3(GE+dop,e2,e1));
-    } else if(op==GT||op==GE||op==EQ||op==NEQ) {
-	type=INT;
-	return(list3(op+dop,e1,e2));
-    } else if(op==ADD||op==SUB||op==MUL||op==DIV)
-	return(list3(op+dop,e1,e2));
-    else {
-	error(-1);
-	return e1;
-    }
-}
-
-static int
-dbinop(int op, int e1, int e2, int t1, int t2)
-{
-    return fdbinop(op, e1, e2, t1, t2,DOP);
-}
-
-static int
-fbinop(int op, int e1, int e2, int t1, int t2)
-{
-    return fdbinop(op, e1, e2, t1, t2,FOP);
-}
-
-#endif 
-
-#if LONGLONG_CODE
-
-static int
-lbinop(int op, int e1, int e2, int t1, int t2)
-{
-    int e=0;
-    long long le1, le2;
-    long long le = 0;
-    int us = (t1==ULONGLONG&&t2==ULONGLONG);
-
-    if (us||(t1==ULONGLONG&&(op==LSHIFT||op==RSHIFT))) {
-	e1=ulonglong_value(e1,t1);
-	e2=ulonglong_value(e2,t2);
-	type = ULONGLONG;
-    } else {
-	e1=longlong_value(e1,t1);
-	e2=longlong_value(e2,t2);
-	type = LONGLONG;
-    }
-    if(car(e1)==LCONST&&car(e2)==LCONST) {
-	le1=lcadr(e1);
-	le2=lcadr(e2);
-	switch(op) {
-	case BOR:
-	    le=le1|le2;break;
-	case EOR:
-	    le=le1^le2;break;
-	case BAND:
-	    le=le1&le2;break;
-	case ADD:
-	    le=le1+le2;break;
-	case SUB:
-	    le=le1-le2;break;
-	case MUL:
-	    le=le1*le2;break;
-	case DIV:
-	    if(!le2) error(EXERR);
-	    if (us) le=(((unsigned long long )le1)/((unsigned long long )le2)); 
-	    else e=(le1/le2);
-	case MOD:
-	    if(!le2) error(EXERR);
-	    if (us) le=(((unsigned long long )le1)%((unsigned long long )le2)); 
-	    else e=(le1%le2);
-	case RSHIFT:
-	    if (t1==ULONGLONG) le=(((unsigned long long)le1)<<le2); else le=le1<<le2;
-	    break;
-	case LSHIFT:
-	    if (t1==ULONGLONG) le=(((unsigned long long)le1)>>le2); else le=le1>>le2;
-	    break;
-	default:
-	    switch(op) {
-	    case EQ:
-		e=(le1==le2);break;
-	    case NEQ:
-		e=(le1!=le2);break;
-	    case LT:
-		le=le1;le1=le2;le2=le;
-	    case GT:
-		if (us) e=((unsigned long long)le1>(unsigned long long)le2);
-		else e=(le1>le2);
-		break;
-	    case LE:
-		le=le1;le1=le2;le2=le;
-	    case GE:
-		if (us) e=((unsigned long long)le1>=(unsigned long long)le2);
-		else e=(le1>=le2);
-		break;
-	    default:
-		error(-1); return list2(CONST,0);
-	    }
-	    type = INT;
-	    return list2(CONST,e);
-	}
-	return llist2(LCONST,le);
-    }
-    if(op==LT) {
-	type = INT; return(list3(GT+LOP+us,e2,e1));
-    } else if(op==LE) {
-	type = INT; return(list3(GE+LOP+us,e2,e1));
-    } else if(op==GT||op==GE||op==LT||op==LE) {
-	type = INT; return(list3(op+LOP+us,e1,e2));
-    }
-    if(op==SUB&&car(e2)==LCONST) { op=ADD; lcadr(e2)=-lcadr(e2); }
-    if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
-	(car(e1)!=LCONST) && (
-	    car(e2)==LRGVAR||car(e2)==LRLVAR||
-	    car(e2)==LURGVAR||car(e2)==LURLVAR
-		)) {
-	e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
-    }
-    if((op==MUL||op==DIV)&&car(e2)==LCONST&&lcadr(e2)==1) return e1;
-    if(op==BOR||op==EOR||op==BAND||op==ADD||op==SUB||op==EQ||op==NEQ) 
-	return(list3(op+LOP,e1,e2));
-    if(op==LSHIFT||op==RSHIFT) return(list3(op+LOP+(t1==ULONGLONG),e1,e2));
-    return(list3(op+LOP+us,e1,e2));
-}
-#endif
-
-/* binary integer computation */
-
-static int
-binop(int op, int e1, int e2, int t1, int t2)
-{
-    int e=0;
-    int us = (t1==UNSIGNED&&t2==UNSIGNED);
-
-    if(t1>0&&car(t1)==POINTER) { e2= int_value(e2,t2); t2=INT; }
-    else if(t2>0&&car(t2)==POINTER) { e1= int_value(e1,t1); t1=INT; }
-#if FLOAT_CODE
-    else if(t1==DOUBLE||t2==DOUBLE)
-	return dbinop(op,e1,e2,t1,t2);
-    else if(t1==FLOAT||t2==FLOAT)
-	return fbinop(op,e1,e2,t1,t2);
-#endif
-#if LONGLONG_CODE
-    else if(t1==LONGLONG||t2==LONGLONG||t1==ULONGLONG||t2==ULONGLONG)
-	return lbinop(op,e1,e2,t1,t2);
-#endif
-    if(car(e1)==CONST&&car(e2)==CONST) {
-	e1=cadr(e1);
-	e2=cadr(e2);
-	type= INT;
-	switch(op) {
-	case BOR:
-	    e=e1|e2;break;
-	case EOR:
-	    e=e1^e2;break;
-	case BAND:
-	    e=e1&e2;break;
-	case ADD:
-	    if(integral(t1)) {
-		if(integral(t2)) {
-			e=e1+e2;
-		} else {
-			if(car(t2)!=POINTER) error(TYERR);
-			e=size(cadr(t2))*e1+e2;
-			type=t2;
-		}
-	    } else {
-		if(car(t1)!=POINTER) error(TYERR);
-		e=e1+size(cadr(t1))*e2;
-		type=t1;
-	    }
-	    break;
-	case SUB:
-	    if(integral(t1)) {
-		e=e1-e2;
-	    } else {
-		if(car(t1)!=POINTER) error(TYERR);
-		e=e1-size(cadr(t1))*e2;
-		type=t1;
-	    }
-	    break;
-	case MUL:
-	    e=e1*e2;break;
-	case DIV:
-	    if(!e2) error(EXERR);
-	    if (us) e=(((unsigned)e1)/((unsigned)e2)); else e=e1/e2;
-	    break;
-	case MOD:
-	    if(!e2) error(EXERR);
-	    if (us) e=(((unsigned)e1)%((unsigned)e2)); else e=e1%e2;
-	    break;
-	case RSHIFT:
-	    if (t1==UNSIGNED) e=(((unsigned)e1)>>((unsigned)e2)); else e=e1>>e2;
-	    break;
-	case LSHIFT:
-	    if (t1==UNSIGNED) e=(((unsigned)e1)<<((unsigned)e2)); else e=e1<<e2;
-	    break;
-	case EQ:
-	    e=(e1==e2);break;
-	case NEQ:
-	    e=(e1!=e2);break;
-	case LT:
-	    e=e1;e1=e2;e2=e;
-	case GT:
-	    if (us) e=(((unsigned)e1)>((unsigned)e2)); else e=(e1>e2);
-	    break;
-	case LE:
-	    e=e1;e1=e2;e2=e;
-	case GE:
-	    if (us) e=(((unsigned)e1)>=((unsigned)e2)); else e=(e1>=e2);
-	    break;
-	    e=(e1<=e2);break;
-	default: error(-1); return list2(CONST,0);
-	}
-	return list2(CONST,e);
-    }
-    if(op==LT) {
-	return(list3(GT+us,e2,e1));
-    } else if(op==LE) {
-	return(list3(GE+us,e2,e1));
-    } else if(op==GT||op==GE||op==LT||op==LE) {
-	return(list3(op+us,e1,e2));
-    } else if(op==EQ||op==NEQ) {
-	return(list3(op,e1,e2));
-    }
-    if(op==SUB&&car(e2)==CONST) { op=ADD; cadr(e2)=-cadr(e2); }
-    if((op==ADD||op==MUL||op==BOR||op==EOR||op==BAND)&&
-	(car(e1)!=CONST&& (
-	    car(e2)==RGVAR||car(e2)==RLVAR||
-	    car(e2)==URGVAR||car(e2)==URLVAR||
-	    car(e2)==SRGVAR||car(e2)==SRLVAR||
-	    car(e2)==SURGVAR||car(e2)==SURLVAR||
-	    car(e2)==CRGVAR||car(e2)==CRLVAR||
-	    car(e2)==CURGVAR||car(e2)==CURLVAR
-	    ))) {
-	e=e1;e1=e2;e2=e;e=t1;t1=t2;t2=e;
-    }
-    if(op==ADD) {
-	if(integral(t1)) {
-	    if(integral(t2)) {
-		if(t1==INT) type=t2;else type=t1;
-		return(list3(ADD,e1,e2));
-	    }
-	    if(car(t2)!=POINTER) error(TYERR);
-	    e=binop(MUL,e1,list2(CONST,size(cadr(t2))),t1,INT);
-	    type=t2;
-	    return(list3(ADD,e,e2));
-	}
-	if(car(t1)!=POINTER||!integral(t2)) error(TYERR);
-	e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
-	type=t1;
-	if (car(e)==CONST && cadr(e)==0)
-	    return(e1);
-	if(car(e1)==ADDRESS&&car(e)==CONST&&car(cadr(e1))!=GVAR)
-	    return(list2(ADDRESS,list2(car(cadr(e1)),
-		cadr(cadr(e1))+cadr(e))));
-	return(list3(ADD,e1,e));
-    }
-    if(op==SUB) {
-	if(integral(t1)) {
-	    if(!integral(t2)) error(TYERR);
-	    if(t1==INT) type=t2;else type=t1;
-	    return(list3(SUB,e1,e2));
-	}
-	if(car(t1)!=POINTER) error(TYERR);
-	if(integral(t2)) {
-	    e=binop(MUL,e2,list2(CONST,size(cadr(t1))),t2,INT);
-	    type=t1;
-	    return(list3(SUB,e1,e));
-	}
-	if(car(t2)!=POINTER)
-	    error(TYERR);
-	compatible(t1,t2);
-	e=list3(SUB,e1,e2);
-	e=binop(DIV,e,list2(CONST,size(cadr(t1))),UNSIGNED,INT);
-	type= INT;
-	return e;
-    }
-    if(!integral(t1)||!integral(t2)) error(TYERR);
-    if(t1==INT) type=t2; else type=t1;  /* ??? */
-    if((op==MUL||op==DIV)&&car(e2)==CONST&&cadr(e2)==1) return e1;
-    if(op==BOR||op==EOR||op==BAND) return(list3(op,e1,e2));
-    if(op==LSHIFT||op==RSHIFT) return(list3(op+(t1==UNSIGNED?US:0),e1,e2));
-    // which ops remain?
-    return(list3(op+us,e1,e2));
-}
-
-/* coarse for function/code segments arguments */
-
-int
-correct_type(int e,int t)
-{
-    int t1;
-    /* e = rvalue(e); */
-    if (type==FLOAT && t==DOTS) { t=DOUBLE;}  // fall thru
-    if (type==CHAR  && t==DOTS) { t=INT;}     // fall thru
-    if (t==DOTS) return e;
-    if (t==UNSIGNED)                 e = unsigned_value(e,type);
-    else if (integral(t))            e = int_value(e,type);
-#if FLOAT_CODE
-    else if (t==FLOAT)     e = float_value(e,type);
-    else if (t==DOUBLE)    e = double_value(e,type);
-#endif
-#if LONGLONG_CODE
-    else if (t==LONGLONG)     e = longlong_value(e,type);
-    else if (t==ULONGLONG)    e = ulonglong_value(e,type);
-#endif
-    else if ((t1=car(t))==STRUCT||t1==UNION) {
-	if(size(t)!=size(type)) error(TYERR);
-    }
-    type = t;
-    return e;
-}
 
 static int
 expr15(int e1)
@@ -4020,18 +2766,6 @@
     }
 }
 
-static int
-cexpr(int e)
-{
-    conv->conv_();
-    if (car(e) != CONST) error(CNERR);
-    return (cadr(e));
-}
-
-static int in_comment = 0;
-
-extern double strtod(const char *nptr, char **endptr);
-
 static void
 get_name()
 {
@@ -4046,52 +2780,6 @@
     name[i++] = '\0';
 }
 
-static int mconcat=0;
-
-static void
-macro_expansion(NMTBL *nptrm)
-{
-    int i = mode;
-    int macrop = 0;
-    int slfree = lfree;
-    mode = STAT;
-
-    macropp = macro_buf;
-    if (nptrm->sc == FMACRO) {
-	macrop=macro_function(macrop,&chptr,nptrm,0);
-    } else {
-	macrop=macro_eval(macrop,(char *)car(nptrm->dsp),0);
-    }
-    macropp = macro_buf;
-    mappend(reverse0(macrop));
-    macropp[-1] ='\n';
-    *macropp =0;
-    while (mconcat) {
-	// ## re-eval macro
-	printf("## %s",macro_buf);
-	mconcat = 0;
-	macrop = 0;
-	macropp = macro_buf;
-	macrop=macro_eval(macrop,macro_buf,0);
-	macropp = macro_buf;
-	mappend(reverse0(macrop));
-	macropp[-1] ='\n';
-	*macropp =0;
-    }
-    mconcat = 0;
-    lfree = slfree;
-    if (lsrc && !asmf && nptrm->sc==FMACRO) gen_comment(macro_buf);
-    macropp[-1] =0;
-    if (macro_buf[0]==0) {
-	mode = i;
-	return;
-    }
-    chptrsave = glist2((int)chptr,chptrsave);
-    chsave = glist2(ch,chsave);
-    chptr = macro_buf;
-    ch = *chptr++;
-    mode = i;
-}
 
 static int
 is_ll()
@@ -4226,7 +2914,7 @@
 #endif
 }
 
-static int
+extern int
 getsym(int sc)
 {
     NMTBL *nptr0,*nptr1,*nptrm;
@@ -4376,13 +3064,13 @@
     return sym=s1;
 }
 
-int
+extern int
 alpha(int c)
 {
     return(('a'<=c&&c<='z')||('A'<=c&&c<='Z')||c=='_');
 }
 
-int
+extern int
 digit(int c)
 {
     return('0'<=c&&c<='9');
@@ -4390,8 +3078,8 @@
 
 int dummy_count = 0;
 
-static NMTBL *
-free_nptr()
+extern NMTBL *
+anonymous_nptr()
 {
     NMTBL *nptr,*iptr;
 
@@ -4471,7 +3159,7 @@
     return nptr;
 }
 
-static NMTBL *
+extern NMTBL *
 msearch0(char *name)
 {
     NMTBL *nptr,*iptr;
@@ -4496,7 +3184,7 @@
     return nptr;
 }
 
-void
+extern void
 extern_define(char *s,int d,int type,int use)
 {
     NMTBL *nptr0;
@@ -4521,7 +3209,7 @@
     while((*cheapp++ = *s++));
 }
 
-static int
+extern int
 neqname(char *p,char *q)
 {
     if (!p)
@@ -4553,7 +3241,7 @@
     symval++;
 }
 
-static int
+extern int
 skipspc(void)
 {
     static int topspc = 0;
@@ -4568,7 +3256,7 @@
     return ch;
 }
 
-static int
+extern int
 getch(void)
 {
     int i,j;
@@ -4590,7 +3278,7 @@
     return getch();
 }
 
-char
+static int
 escape(void)
 {
     char c;
@@ -4633,591 +3321,11 @@
     return c;
 }
 
-static char *
-expand_file_name(char *path,char *name,int pos,int lbufsize)
-{
-    char *p = name+pos;
-    int i,j;
-    j = 0;
-    for(i=0;path[i];i++,j++); for(i=0;name[i];i++,j++);
-    if (pos+j+1>lbufsize) { error(FILERR); return ""; }
-    while((name[pos++] = *path++));
-    pos--;
-    if (name[pos]!='/') name[pos]='/';
-    for(i = 0; ((name[pos++] = name[i++])););
-    return p;
-}
-
-/* preprocessor part */
-
-/* file inclusion */
-
-static FILE *
-getfname(void)
-{
-    int i,end='"',err=0;
-    char *s,*p,**pp,name[LBUFSIZE];
-    FILE *fp;
-
-    getch();
-    if(skipspc()=='"') { end = '"';
-    } else if (ch=='<') { end = '>';
-    } else { error(INCERR); err=1; 
-    }
-    for(i=0;(getch()!=end && ch!='\n');) {
-	if(i<LBUFSIZE-1) name[i++]=ch;
-    }
-    if(ch=='\n') error(INCERR);
-    if (err) return filep->fcb;
-    name[i]=0;
-    fp = fopen(name,"r") ;
-    if (fp) {
-	p = name; 
-    } else {
-	for(pp=(end=='>'||filep->inc=='>')
-		?l_include_path:include_path;*pp;pp++) {
-	    p = expand_file_name(*pp,name,i+1,LBUFSIZE);
-	    if ((fp = fopen(p,"r"))) break ;
-	}
-    }
-    if(!fp) { error(FILERR); return filep->fcb; }
-    copy_current_file_dir(s=p);
-    (filep+1)->name0 = cheapp;
-    (filep+1)->inc = end;
-    while((*cheapp++ = *s++));
-    return ( (filep+1)->fcb = fp );
-}
-
-/* line input and conversion */
-
-static int macro_if_depth ;
-static int macro_if_current ;
-static int macro_if_skip ;
-
-static int
-skip_rest_of_line()
-{
-    getch();
-    do {
-	while(ch!='\n'&&ch!='\r') {
-	    if (!in_comment) {
-		if (ch=='/') {
-		    getch();
-		    if (ch=='/') in_comment=2;
-		    else if (ch=='*') {
-			in_comment=1;
-		    } else continue;
-		}
-	    } else if (ch=='*') {
-		getch();
-		if (ch=='/') {
-		    in_comment=0; 
-		    return macro_if_skip?0:1;
-		}
-		else continue;
-	    }
-	    getch();
-	}
-	if (in_comment==1) { getline(); getch(); }
-    } while(in_comment==1);
-    in_comment=0;
-    return 0;
-}
-
-static void
-getline(void)
-{
-    int i;
-    int c;
-
-    do {
-	if (chinput) {
-	    if (! *chinput) {
-		chinput=0;
-		continue;
-	    }
-	    chptr=linebuf;
-	    i=0;
-	    while((*chptr++=c=*chinput++)&&(c!='\n')) {
-		if (++i > LBUFSIZE-2) error(LNERR);
-	    }
-	} else {
-	    lineno++;
-	    glineno++;
-	    chptr=linebuf;
-	    i=0;
-	    while ((*chptr++ = c = getc(filep->fcb)) != '\n') {
-		if (++i > LBUFSIZE-2) error(LNERR);
-		if (c==EOF) {
-			error(EOFERR);
-			--chptr;
-		}
-	    }
-	}
-	*chptr = '\0';
-	if (lsrc && !asmf && !macro_if_skip) gen_comment(linebuf);
-	if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
-	    if (macro_processing()) return;
-	}
-    } while(!in_quote && (macro_if_skip || linebuf[0] == '#'));
-}
-
-/* preprocessor directive */
-
-/* line continuation \\ */
-
-static void
-check_macro_eof()
-{
-    int c;
-    for(c=0;c<LBUFSIZE-3&&chptr[c];c++);
-    if (c>0&&chptr[c-1]=='\\') {
-	return;
-    } else if (c>0&&chptr[c-1]=='\n') {
-	if (c>0&&chptr[c-2]=='\\') {
-	    return;
-	} else {
-	    c--;
-	}
-    } 
-    chptr[c] = ';';
-    chptr[c+1] = '\n';
-    chptr[c+2] = 0;
-}
-
-static void
-macro_if()
-{
-    int i;
-    ch= *chptr;
-    in_macro_if = 1;
-    check_macro_eof();
-    getsym(0);
-    /* i=cexpr(expr(1)); #if allow undefined symbols.. */
-    i=expr(1); 
-    in_macro_if = 0;
-    if (car(i)==CONST) i=cadr(i);
-    else i=0;
-    if (ch) {
-	if (chptr[-1]==ch) {
-	/* we are fall into getch(), which lost the last ch */
-	/* chptr[-1]==ch check is fanatic, but ... */
-	    chptr--;
-	} else error(-1);
-    }
-    macro_if_depth = macro_if_current;
-    macro_if_skip = !i;
-}
-
-static int
-macro_processing()
-{
-    int i;
-    int c;
-    int mode_save;
-
-    ++chptr;
-    while (*chptr==' '||*chptr=='\t') ++chptr;
-    if (macroeq("ifdef") || macroeq("ifndef")) {
-	c = (chptr[-4]=='n');
-	macro_if_current++;
-	if (!macro_if_skip) {
-	    mode_save = mode; mode = IFDEF;
-	    ch= *chptr;
-	    i = getsym(0);
-	    mode = mode_save;
-	    macro_if_depth = macro_if_current;
-	    macro_if_skip = (!i)^c;
-	}
-	return 0;
-    } else if (macroeq("elif")) {
-	if (macro_if_current==0) {
-	    error(MCERR); /* extra #else */
-	    return 0;
-	}
-	if (macro_if_current == macro_if_depth) {
-	    if (!macro_if_skip || macro_if_skip==2) {
-		macro_if_skip=2;
-		return 0;
-	    }
-	    macro_if();
-	}
-	return 0;
-    } else if (macroeq("if")) {
-	macro_if_current++;
-	if (!macro_if_skip) {
-	    macro_if();
-	}
-	return 0;
-    } else if (macroeq("else")) {
-	if (macro_if_current==0) {
-	    error(MCERR); /* extra #else */
-	    return 0;
-	}
-	if (macro_if_current == macro_if_depth) {
-	    if (macro_if_skip==2) ;
-	    else if (macro_if_skip) macro_if_skip=0;
-	    else macro_if_skip=1;
-	}
-	return skip_rest_of_line();
-    } else if (macroeq("endif")) {
-	if (macro_if_current == macro_if_depth) {
-	    macro_if_skip = 0;
-	    macro_if_depth = --macro_if_current;
-	} else {
-	    if (macro_if_current<=0) {
-		error(MCERR); /* extra #if */
-		return 0;
-	    }
-	    macro_if_current--;
-	}
-	return skip_rest_of_line();
-    }
-    if (macro_if_skip) return 0;
-    if (macroeq("define")) {
-	ch= *chptr;
-	macro_define0();
-	*(chptr = linebuf) = '\0';
-    } else if (macroeq("undef")) {
-	i=mode;
-	mode=IFDEF;
-	ch= *chptr;
-	if (getsym(0)) {
-	    if (nptr->sc == MACRO) {
-	        nptr->sc = EMPTY;
-	    } else if (nptr->sc == FMACRO) {
-	        nptr->sc = EMPTY;
-		/* we cannot reclaim it's arg */
-	    } else error(MCERR);
-	}
-	mode=i;
-    } else if (macroeq("include")) {
-	if(filep+1 >= filestack + FILES) error(FILERR);
-	if ( ((filep+1)->fcb=getfname()) == NULL) error(FILERR);
-	(filep+1)->ln=lineno;
-	lineno=0;
-	++filep;
-	*(chptr = linebuf) = '\0';
-#if ASM_CODE
-    } else if (macroeq("asm")) {
-	if (asmf) error(MCERR);
-	asmf = 1;
-	getline();
-	while (asmf) {
-	    gen_source(linebuf);
-	    getline();
-	}
-    } else if (macroeq("endasm")) {
-	if (!asmf) error(MCERR);
-	asmf = 0;
-#endif
-    } else if (macroeq(" "))
-	getline();
-    else error(MCERR);
-    return 0;
-}
-
-static int
-macroeq(char *s)
-{
-    char *p;
-
-    for (p = chptr; *s;) if (*s++ != *p++) return 0;
-    chptr = p;
-    return 1;
-}
-
-/* macro interpreter */
-
-void
-macro_define(char *macro)
-{
-    char *chptr_save;
-    int chsave;
-
-    chptr_save = chptr;
-    chsave = ch;
-    chptr = macro;
-    ch= *chptr++;
-    macro_define0();
-    chptr = chptr_save;
-    ch = chsave;
-}
-
-static void
-macro_define0()
-{
-    int i,args,c;
-    char *scheapp;
-
-    i=mode;
-    mode=MDECL;
-    // ch= *chptr; ??
-// fprintf(stderr,"macro def: ch %c *chptr %c\n",ch,*chptr);
-    getsym(0);
-// fprintf(stderr,"macro def: %s =>",name); 
-    if (nptr->sc != EMPTY) { /* override existing macro */
-    }
-    args = 0;
-    if (ch=='(') {
-	nptr->sc = FMACRO;
-	args = macro_args(&cheapp,cheap+CHEAPSIZE,&chptr);
-    } else {
-	nptr->sc = MACRO;
-	nptr->ty = -1;
-    }
-    // equal is allowed for -Dhoge=aho option
-    if (ch=='=') chptr++;
-    while((c=*chptr)==' '||c=='\t') chptr++;
-    nptr->dsp = list2((int)cheapp,args); /* macro body */
-    scheapp = cheapp;
-    while ((*cheapp++ = c = *chptr++)
-	&& c != '\n') {
-	if (c=='/'&&chptr[0]=='/') {
-	    cheapp--; while(*chptr++); break;
-	} else if (c=='/'&&chptr[0]=='*') {
-	    cheapp--; chptr++;
-	    while((c = *chptr++)) {
-		if (c=='*'&&chptr[0]=='/') {
-		    c = *chptr++; break;
-		}
-	    }
-	    if (!c) break;
-	} else if (c=='\\' && (*chptr=='\n'||*chptr==0)) {
-	    chptr++;
-	    cheapp--;
-	    getline();
-	}
-    }
-    *cheapp++ = '\0';
-    while(cheapp>scheapp&&(*cheapp=='\n'||*cheapp==0)) cheapp--;
-    *++cheapp = '\0'; cheapp++;
-    if (cheapp >= cheap+CHEAPSIZE) /* too late? */
-	error(STRERR);
-// fprintf(stderr,"%s\n",(char *)car(nptr->dsp));
-    mode=i;
-}
-
-// create function macro argument list
-//    return  list2((char*)arg,next)
-
-static int
-macro_args(char **pcheapp,char *maxcheap,char **pchptr)
-{
-    int c;
-    int in_quote = 0;
-    int in_wquote = 0;
-    int plevel = 0;
-    char *cheapp = *pcheapp;
-    char *chptr = *pchptr;
-    int args = list2((int)cheapp,0);
-    for(;;) {
-        *cheapp++ = c = *chptr++;
-	if (cheapp >= maxcheap) error(MCERR);
-	if (!c)  {
-	    chptr--;
-	    error(MCERR);
-	    *pchptr = chptr;
-	    *pcheapp = cheapp;
-	    return reverse0(args);
-	}
-	if (in_quote) {
-	    if (c=='\\') {
-		if (*chptr != '\n') {
-		    *cheapp++ = *chptr++;
-		} else {
-		    getline();
-		}
-	    } else if (c=='\'') {
-		in_quote = 0;
-	    }
-	} else if (in_wquote) {
-	    if (c=='\\') {
-		if (*chptr !='\n') {
-		    *cheapp++ = *chptr++;
-		} else {
-		    *cheapp = '\n';
-		    getline();
-		}
-	    } else if (c=='"') {
-		in_wquote = 0;
-	    }
-	} else if (c=='"') {
-	    in_wquote = 1;
-	} else if (c=='\'') {
-	    in_quote = 1;
-	} if (plevel==0) {
-	    if (c==',') {
-		cheapp[-1] = 0;
-		args = list2((int)cheapp,args);
-	    } else if (c==')') {
-		cheapp[-1] = 0;
-		break;
-	    } else if (c=='(') {
-		plevel++;
-	    } else if (c=='\\') {
-		if (*chptr=='\n') {
-		    cheapp--;
-		    getline();
-		}
-//	    } else if (c==' '||c=='\t') {
-//		cheapp--;
-	    } else if (c=='\n') {
-		cheapp--;
-		getline();
-		chptr = *pchptr;
-	    }
-	} else if (c==')') {
-	    plevel--;
-	} else if (c=='(') {
-	    plevel++;
-	} else if (c=='\n') {
-	    cheapp--;
-	    getline();
-	    chptr = *pchptr;
-	}
-    }
-    *pchptr = chptr;
-    *pcheapp = cheapp;
-    return reverse0(args);
-}
-
-/* output macro expansion result into macrobuf (macropp) */
-
-static int
-macro_function(int macrop,char **pchptr,NMTBL *nptr,int history)
-{
-    int args,sargs,values,evalues;
-    char *macro;
-
-    sargs = args = cadr(nptr->dsp);
-    values = macro_args(&macropp,macro_buf+MACROSIZE,pchptr);
-    if (pchptr==&chptr) {
-	ch = *chptr++;
-    }
-    evalues = 0;
-    while(values) {
-	evalues = list2(macro_eval(0,(char *)car(values),history),evalues);
-	values = cadr(values);
-    }
-    evalues = reverse0(evalues);
-    while(args) {
-	local_define((char *)car(args),mappend(reverse0(car(evalues))));
-/* fprintf(stderr,"%s: %s => %s\n",nptr->nm,(char *)car(args),(char *)car(msearch0((char *)car(args))->dsp)); */
-	args = cadr(args);
-	evalues = cadr(evalues);
-    }
-    macro = (char *)car(nptr->dsp);
-    macrop = macro_eval(macrop,macro,list2((int)macro,history));
-/* fprintf(stderr,"%s: result %s => %s\n",nptr->nm,macro,(char *)car(macrop)); */
-    args = sargs;
-    while(args) {
-	local_undef((char *)car(args));
-	args = cadr(args);
-    }
-    return macrop;
-}
-
-static void
-local_define(char *macro,char *value)
-{
-    NMTBL *nptr0;
-    while(*macro==' '||*macro=='\t') macro++;
-    nptr0 = msearch0(macro);
-    /* save nptr previous contents in a list */
-    nptr0->ty=list3(nptr0->sc,nptr0->ty,nptr0->dsp);
-    /* set new value */
-    nptr0->sc=LMACRO;
-    nptr0->dsp=list2((int)value,0);
-}
-
-static void
-local_undef(char *macro)
-{
-    NMTBL *nptr0;
-    int save;
-    nptr0 = msearch0(macro);
-    save = nptr0->ty;
-    nptr0->sc=car(save);
-    nptr0->dsp=caddr(save);
-    nptr0->ty=cadr(save);
-}
-
-static int
-macro_eval(int macrop,char *body0,int history)
-{
-    int c;
-    int in_quote = 0;
-    int in_wquote = 0;
-    char *macro;
-    char *body = body0;
-    int i;
-    NMTBL *nptrm;
-    macrop = list2((int)macropp,macrop);
-    for(; (c = *body++) ;) {
-	if (macropp+1>macro_buf+MACROSIZE) error(STRERR);
-	if (in_quote) {
-	    if (c=='\\') {
-		*macropp++ = c; c = *body++;
-	    } else if (c=='\'') {
-		in_quote = 0;
-	    }
-	} else if (in_wquote) {
-	    if (c=='\\') {
-		*macropp++ = c; c = *body++;
-	    } else if (c=='"') {
-		in_wquote = 0;
-	    }
-	} else if (c=='"') {
-	    in_wquote = 1;
-	} else if (c=='\'') {
-	    in_quote = 1;
-	} else if (c=='#' && *body=='#') {
-	    // name concatenation. skip ## and re-eval macro line.
-	    mconcat = 1; body++; continue;
-	} else if (alpha(c)) {
-	    i = 0;
-	    do { namebuf[i++] = c; c=*body++;} while (alpha(c)||digit(c));
-	    body--; // ungetc
-	    namebuf[i]=0;
-	    nptrm = msearch0(namebuf);
-	    macro = (char *)car(nptrm->dsp);
-	    if (nptrm->sc==LMACRO) {
-		while((*macropp++ = *macro++));
-		macropp--;
-	    } else if (nptrm->sc==MACRO && neqname(namebuf,macro)) {
-		if (macro[0]==0)  continue;
-		*macropp++=0;
-                macrop=macro_eval(macrop,macro,list2((int)macro,history));
-		macrop = list2((int)macropp,macrop);
-	    } else if (nptrm->sc==FMACRO) {
-		if (c==' '||c=='\t') {
-		    while (c==' '||c=='\t') c=*body++;
-		    body--;
-		}
-		if(c!='(') error(MCERR);
-		*macropp++=0; body++;
-		macrop = macro_function(macrop,&body,nptrm,
-			list2((int)macro,history));
-		macrop = list2((int)macropp,macrop);
-	    } else {
-		macro = namebuf;
-		while((*macropp++ = *macro++));
-		macropp--;
-	    }
-	    continue;
-	}
-	*macropp++ = c;
-    }
-    *macropp++=0;
-    return macrop;
-}
-
 /* node management (cdr coding ) */
 
 #if LONGLONG_CODE
 
-int
+extern int
 llist2(int e1, long long d1)
 {
     int e;
@@ -5228,7 +3336,7 @@
     return e;
 }
 
-int
+extern int
 llist3(int e1, int e2,long long d1)
 {
     int e;
@@ -5244,7 +3352,7 @@
 
 #if FLOAT_CODE
 
-int
+extern int
 dlist2(int e1, double d1)
 {
     int e;
@@ -5255,7 +3363,7 @@
     return e;
 }
 
-int
+extern int
 dlist3(int e1, int e2,double d1)
 {
     int e;
@@ -5269,7 +3377,7 @@
 
 #endif
 
-int
+extern int
 list2(int e1, int e2)
 {
     int e;
@@ -5280,7 +3388,7 @@
     return e;
 }
 
-int
+extern int
 list3(int e1, int e2, int e3)
 {
     int e;
@@ -5292,7 +3400,7 @@
     return e;
 }
 
-int
+extern int
 list4(int e1, int e2, int e3, int e4)
 {
     int e;
@@ -5327,7 +3435,7 @@
 static int free_glist2_list = 0;
 static int free_glist3_list = 0;
 
-int
+extern int
 glist2(int e1,int e2)
 {
     int smode,ret;
@@ -5344,7 +3452,7 @@
     return ret;
 }
 
-void
+extern void
 free_glist2(int e1)
 {
     if (e1>gfree) return;  /* freeing local heap */
@@ -5356,7 +3464,7 @@
     }
 }
 
-int
+extern int
 glist3(int e1,int e2,int e3)
 {
     int smode,ret;
@@ -5373,7 +3481,7 @@
     return ret;
 }
 
-void
+extern void
 free_glist3(int e1)
 {
     if (e1>gfree) return;  /* freeing local heap */
@@ -5385,7 +3493,7 @@
     }
 }
 
-int
+extern int
 length(int list)
 {
     int n=0;
@@ -5395,7 +3503,7 @@
     return n;
 }
 
-int
+extern int
 nth(int n, int list)
 {
     while(n-->0) {
@@ -5404,7 +3512,7 @@
     return list;
 }
 
-int
+extern int
 insert_ascend(int p,int e,int eq())
 {
     int p1,p2,dup;
@@ -5441,7 +3549,7 @@
     return p1;
 }
 
-int
+extern int
 append4(int p,int a1,int a2,int a3)
 {
     int p1;
@@ -5452,7 +3560,7 @@
     return p1;
 }
 
-int
+extern int
 append3(int p,int a1,int a2)
 {
     int p1;
@@ -5463,23 +3571,7 @@
     return p1;
 }
 
-static char *
-mappend(int lists)
-{
-    char *p;
-    char *result = macropp;
-    while(lists) {
-	if (macropp>macro_buf+MACROSIZE) error(STRERR);
-	p = (char *)car(lists);
-	while((*macropp++=*p++)) if (p[-1]=='\n') macropp[-1]=' ';
-	macropp--;
-	lists = cadr(lists);
-    }
-    macropp++;
-    return result;
-}
-
-void
+extern void
 display_ntable(NMTBL *n, char *s)
 {
     fprintf(stderr,"\n%s %0x %0x ",s,(int)n,(int)ntable);
@@ -5489,13 +3581,15 @@
     fprintf(stderr,"nptr->nm %s\n",n->nm);
 }
 
-int c0(int d)  { fprintf(stderr,"heap[%d]=",d);return car(d); }
-int c1(int d)  { fprintf(stderr,"heap[%d]=",d);return cadr(d); }
-int c2(int d)  { fprintf(stderr,"heap[%d]=",d);return caddr(d); }
-int c3(int d)  { fprintf(stderr,"heap[%d]=",d);return cadddr(d); }
-char *cc0(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)car(d); }
-char *cc1(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadr(d); }
-char *cc2(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)caddr(d); }
-char *cc3(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadddr(d); }
+/* for gdb... */
+
+extern int c0(int d)  { fprintf(stderr,"heap[%d]=",d);return car(d); }
+extern int c1(int d)  { fprintf(stderr,"heap[%d]=",d);return cadr(d); }
+extern int c2(int d)  { fprintf(stderr,"heap[%d]=",d);return caddr(d); }
+extern int c3(int d)  { fprintf(stderr,"heap[%d]=",d);return cadddr(d); }
+extern char *cc0(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)car(d); }
+extern char *cc1(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadr(d); }
+extern char *cc2(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)caddr(d); }
+extern char *cc3(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadddr(d); }
 
 /* end */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mc-parse.h	Mon Jun 21 23:50:34 2004 +0900
@@ -0,0 +1,97 @@
+/* for mc-parse.c */
+
+extern int sym,type,mode,stmode;
+extern int labelno,gpc,disp;
+extern int args,init_vars,heap[HEAPSIZE];
+extern int cslabel,control;
+extern NMTBL *nptr,*gnptr;
+extern NMTBL *fnptr;
+extern int gtypedefed;
+extern int retlabel,retpending,retcont;
+extern int chk;
+#if BITFIELD_CODE
+extern int bit_field_disp;
+#endif
+extern int fields;
+extern int struct_return;
+extern int lastexp;
+extern int debug; 
+
+/* used in mc-macro.c */
+
+extern int asmf;
+extern int ch;
+extern char cheap[CHEAPSIZE]; // should be extendable
+extern char *cheapp;
+extern int chptrsave; 
+extern int chsave; 
+extern char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
+extern int glineno; 
+extern int in_comment; 
+extern int in_quote; 
+extern int lfree; 
+extern int lineno; 
+extern int lsrc; 
+extern char *include_path[MAX_INCLUDE_PATH_COUNT];
+
+/* used in mc-code-* */
+
+extern  NMTBL null_nptr;
+extern NMTBL ntable[GSYMS+LSYMS];
+
+/* used in mc-switch */
+
+extern void free_glist3(int e1);
+extern int csvalue1;
+extern int blabel,dlabel;
+
+/* used in mc-tree.c */
+
+extern int typedefed;
+
+/* global variable end */
+
+extern void free_glist2(int e1);
+
+/* used in mc-codegen.c */
+
+extern NMTBL * anonymous_nptr();;
+extern int append4(int p,int a1,int a2,int a3);
+extern void display_ntable(NMTBL *n, char *s);
+#if FLOAT_CODE
+extern int
+dlist2(int e1, double d1);
+#endif
+extern void error(int n);
+extern int glist2(int e1,int e2);
+extern int glist3(int e1,int e2,int e3);
+
+extern int insert_ascend(int p,int e,int eq());
+extern int length(int list);
+extern int list2(int e1, int e2);
+extern int list3(int e1, int e2, int e3);
+extern int list4(int e1, int e2, int e3, int e4);
+extern void extern_define(char *s,int d,int type,int use);
+
+#if LONGLONG_CODE
+extern int llist2(int e1, long long d1);
+#endif
+extern int neqname(char *p,char *q);
+extern char *new_static_name(char *name,int delimit);
+extern int reverse0(int t1);
+extern int size(int t);
+extern int typespec(void);
+
+/* used in mc-macro.c */
+
+extern int getsym(int sc);
+extern int getch(void);
+extern int skipspc(void);
+extern void copy_current_file_dir(char *name);
+extern int expr(int noconv);
+
+extern NMTBL *msearch0(char *name);
+extern int alpha(int c);
+extern int digit(int c);
+
+/* end */
--- a/mc-switch.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-switch.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,10 +1,11 @@
 /* Micro-C Switch Code generation Part */
 /* $Id$ */
 
-#define EXTERN extern
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
+#include "mc-codegen.h"
 #include "mc-code.h"
-#include "mc-codegen.h"
 
 #if CASE_CODE
 
--- a/mc-tree.c	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc-tree.c	Mon Jun 21 23:50:34 2004 +0900
@@ -1,8 +1,9 @@
 /* Micro-C tree print routine */
 /* $Id$ */
 
-#define EXTERN /**/
+#include <stdio.h>
 #include "mc.h"
+#include "mc-parse.h"
 
 typedef
 struct tree_node {
--- a/mc.h	Sun Jun 20 20:54:24 2004 +0900
+++ b/mc.h	Mon Jun 21 23:50:34 2004 +0900
@@ -1,117 +1,108 @@
 /* Micro-C header file */
 
-#define DEBUG	error(-1)
-
-/*#include "CCLIB.TXT" */
-#ifdef __micro_c__
-#include "stdio.h"
-#else
-#include <stdio.h> 
-#include <stdlib.h> 
-#endif
-
 #define FLOAT_CODE 1
 #define LONGLONG_CODE 1
 #define CASE_CODE 1
 #define ASM_CODE 1
+#define BITFIELD_CODE 1
 
 /* reserved word start */
 
-#define INT	(-1)
-#define UNSIGNED	(-2)
-#define CHAR	(-3)
-#define UCHAR	(-4)
+#define INT     (-1)
+#define UNSIGNED        (-2)
+#define CHAR    (-3)
+#define UCHAR   (-4)
 #define POINTER (-5)
-#define ARRAY	(-6)
-#define STRUCT	(-7)
-#define UNION	(-8)
-#define FUNCTION	(-9)
+#define ARRAY   (-6)
+#define STRUCT  (-7)
+#define UNION   (-8)
+#define FUNCTION        (-9)
 
-#define STATIC	(-10)
-#define GOTO	(-11)
-#define RETURN	(-12)
-#define BREAK	(-13)
-#define CONTINUE	(-14)
-#define IF	(-15)
-#define ELSE	(-16)
-#define FOR	(-17)
-#define DO	(-18)
-#define WHILE	(-19)
-#define SWITCH	(-20)
-#define CASE	(-21)
+#define STATIC  (-10)
+#define GOTO    (-11)
+#define RETURN  (-12)
+#define BREAK   (-13)
+#define CONTINUE        (-14)
+#define IF      (-15)
+#define ELSE    (-16)
+#define FOR     (-17)
+#define DO      (-18)
+#define WHILE   (-19)
+#define SWITCH  (-20)
+#define CASE    (-21)
 #define DEFAULT (-22)
 #define RESERVE (-23)
-#define TAG	(-24)
-#define FIELD	(-25)
-#define IDENT	(-26)
-#define MACRO	(-27)
-#define BLABEL	(-28)
-#define FLABEL	(-29)
+#define TAG     (-24)
+#define FIELD   (-25)
+#define IDENT   (-26)
+#define MACRO   (-27)
+#define BLABEL  (-28)
+#define FLABEL  (-29)
 #define TYPEDEF (-30)
-#define SIZEOF	(-31)
-#define TYPE	(-32)
-#define LONG	(-33)
-#define SHORT	(-34)
-#define USHORT	(-35)
-#define EXTRN	(-36)
-#define EXTRN1	(-37)
-#define VOID	(-38)
-#define INLINE	(-39)
-#define REGISTER	(-40)
-#define FREGISTER      	(-41)
-#define DREGISTER      	(-42)
-#define LREGISTER      	(-43)
-#define CODE	(-44)
-#define ENVIRONMENT	(-45)
-#define DEFINED	(-46)
-#define ENUM	(-47)
-#define KONST	(-48)
-#define FMACRO	(-49)
-#define LMACRO	(-50)
-#define SIGNED	(-51)
-#define DOTS	(-52)
+#define SIZEOF  (-31)
+#define TYPE    (-32)
+#define LONG    (-33)
+#define SHORT   (-34)
+#define USHORT  (-35)
+#define EXTRN   (-36)
+#define EXTRN1  (-37)
+#define VOID    (-38)
+#define INLINE  (-39)
+#define REGISTER        (-40)
+#define FREGISTER       (-41)
+#define DREGISTER       (-42)
+#define LREGISTER       (-43)
+#define CODE    (-44)
+#define ENVIRONMENT     (-45)
+#define DEFINED (-46)
+#define ENUM    (-47)
+#define KONST   (-48)
+#define FMACRO  (-49)
+#define LMACRO  (-50)
+#define SIGNED  (-51)
+#define DOTS    (-52)
 
-#define FLOAT	(-53)
-#define DOUBLE	(-54)
-#define LONGLONG	(-55)
-#define ULONGLONG	(-56)
-#define VOLATILE	(-57)
-#define TYPEOF	(-58)
-#define ASM	(-59)
-#define BITFIELD	(-60)
+#define FLOAT   (-53)
+#define DOUBLE  (-54)
+#define LONGLONG        (-55)
+#define ULONGLONG       (-56)
+#define VOLATILE        (-57)
+#define TYPEOF  (-58)
+#define ASM     (-59)
+#define BIT_FIELD       (-60)
 
 /* reserved word end */
 
-#define EMPTY	(-99)
+#define EMPTY   (-99)
 
 /* mode start */
-#define TOP	0
-#define GDECL	1
-#define GSDECL	2
-#define GUDECL	3
-#define ADECL	4
-#define LDECL	5
-#define LSDECL	6
-#define LUDECL	7
+#define TOP     0
+#define GDECL   1
+#define GSDECL  2
+#define GUDECL  3
+#define ADECL   4
+#define LDECL   5
+#define LSDECL  6
+#define LUDECL  7
 #define STADECL 8
-#define STAT	9
-#define GTDECL	10
-#define LTDECL	11
-#define IFDEF	12
-#define MDECL	13
+#define STAT    9
+#define GTDECL  10
+#define LTDECL  11
+#define IFDEF   12
+#define MDECL   13
 #define GEDECL  14
 #define LEDECL  15
 #define SFDINIT 16
 /* mode end */
 
-#define US	1
-#define AS	10000
-#define SOP	200
-#define COP	400
-#define DOP	600
-#define FOP	800
-#define LOP	1000
-#define BOP	1200    // bit field
+#define US      1
+#define AS      10000
+#define SOP     200
+#define COP     400
+#define DOP     600
+#define FOP     800
+#define LOP     1000
+#define BOP     1200    // bit field
 
 /* tree node tags start */
 
@@ -119,58 +110,58 @@
 
 /* nullary  argments */
 
-#define GVAR	1
-#define RGVAR	2
-#define URGVAR	3
-#define LVAR	4
-#define RLVAR	5
-#define URLVAR	6
-#define CRGVAR	(COP+RGVAR)
-#define CURGVAR	(COP+URGVAR)
-#define CRLVAR	(COP+RLVAR)
-#define CURLVAR	(COP+URLVAR)
-#define FRGVAR	(FOP+RGVAR)
-#define FRLVAR	(FOP+RLVAR)
-#define DRGVAR	(DOP+RGVAR)
-#define DRLVAR	(DOP+RLVAR)
-#define SRGVAR	(SOP+RGVAR)
-#define SURGVAR	(SOP+URGVAR)
-#define SRLVAR	(SOP+RLVAR)
-#define SURLVAR	(SOP+URLVAR)
-#define LRGVAR	(LOP+RGVAR)
-#define LURGVAR	(LOP+URGVAR)
-#define LRLVAR	(LOP+RLVAR)
-#define LURLVAR	(LOP+URLVAR)
-#define BRGVAR	(BOP+RGVAR)
-#define BURGVAR	(BOP+URGVAR)
-#define BRLVAR	(BOP+RLVAR)
-#define BURLVAR	(BOP+URLVAR)
+#define GVAR   	1
+#define RGVAR  	2
+#define URGVAR 	3
+#define LVAR   	4
+#define RLVAR  	5
+#define URLVAR 	6
+#define CRGVAR  (COP+RGVAR)
+#define CURGVAR (COP+URGVAR)
+#define CRLVAR  (COP+RLVAR)
+#define CURLVAR (COP+URLVAR)
+#define FRGVAR  (FOP+RGVAR)
+#define FRLVAR  (FOP+RLVAR)
+#define DRGVAR  (DOP+RGVAR)
+#define DRLVAR  (DOP+RLVAR)
+#define SRGVAR  (SOP+RGVAR)
+#define SURGVAR (SOP+URGVAR)
+#define SRLVAR  (SOP+RLVAR)
+#define SURLVAR (SOP+URLVAR)
+#define LRGVAR  (LOP+RGVAR)
+#define LURGVAR (LOP+URGVAR)
+#define LRLVAR  (LOP+RLVAR)
+#define LURLVAR (LOP+URLVAR)
+#define BRGVAR  (BOP+RGVAR)
+#define BURGVAR (BOP+URGVAR)
+#define BRLVAR  (BOP+RLVAR)
+#define BURLVAR (BOP+URLVAR)
 
-#define CONST	7
-#define DCONST	(DOP+CONST)
-#define FCONST	(FOP+CONST)
-#define LCONST	(LOP+CONST)
-#define STRING	8
-#define FNAME	9
+#define CONST  	7
+#define DCONST  (DOP+CONST)
+#define FCONST  (FOP+CONST)
+#define LCONST  (LOP+CONST)
+#define STRING 	8
+#define FNAME  	9
 
 #define NULLARY_ARGS(i) (i==REGISTER||i==DREGISTER||i==FREGISTER||i==LREGISTER||(GVAR<=(i%SOP)&&(i%SOP)<=FNAME))
 
 /* unary  argments */
 
 #define ADDRESS	10
-#define MINUS	11
-#define LNOT	12
-#define BNOT	13
-#define INC	14
+#define MINUS  	11
+#define LNOT   	12
+#define BNOT   	13
+#define INC    	14
 #define POSTINC	15
-#define UPOSTINC	16
-#define PREINC	17
+#define UPOSTINC       	16
+#define PREINC 	17
 #define UPREINC	18
 #define POSTDEC	19
-#define UPOSTDEC	20
-#define PREDEC	21
+#define UPOSTDEC       	20
+#define PREDEC 	21
 #define UPREDEC	22
-#define DEC	23
+#define DEC    	23
 #define CPOSTINC (COP+POSTINC)
 #define CUPOSTINC (COP+UPOSTINC)
 #define CPREINC (COP+PREINC)
@@ -187,302 +178,254 @@
 #define SUPOSTDEC (SOP+UPOSTDEC)
 #define SPREDEC (SOP+PREDEC)
 #define SUPREDEC (SOP+UPREDEC)
-#define FPOSTINC	(FOP+POSTINC)
-#define FPREINC	(FOP+PREINC)
-#define DPOSTINC	(DOP+POSTINC)
-#define DPREINC	(DOP+PREINC)
-#define LPOSTINC	(LOP+POSTINC)
-#define LPREINC	(LOP+PREINC)
-#define LUPOSTINC	(LOP+UPOSTINC)
-#define LUPREINC	(LOP+UPREINC)
-#define INDIRECT	24
-#define RINDIRECT	25
-#define URINDIRECT	26
-#define CRINDIRECT	(COP+RINDIRECT)
-#define CURINDIRECT	(COP+URINDIRECT)
-#define SRINDIRECT	(SOP+RINDIRECT)
-#define SURINDIRECT	(SOP+URINDIRECT)
-#define FRINDIRECT	(FOP+RINDIRECT)
-#define DRINDIRECT	(DOP+RINDIRECT)
-#define LRINDIRECT	(LOP+RINDIRECT)
-#define LURINDIRECT	(LOP+URINDIRECT)
+#define FPOSTINC        (FOP+POSTINC)
+#define FPREINC (FOP+PREINC)
+#define DPOSTINC        (DOP+POSTINC)
+#define DPREINC (DOP+PREINC)
+#define LPOSTINC        (LOP+POSTINC)
+#define LPREINC (LOP+PREINC)
+#define LUPOSTINC       (LOP+UPOSTINC)
+#define LUPREINC        (LOP+UPREINC)
+#define INDIRECT       	24
+#define RINDIRECT      	25
+#define URINDIRECT     	26
+#define CRINDIRECT      (COP+RINDIRECT)
+#define CURINDIRECT     (COP+URINDIRECT)
+#define SRINDIRECT      (SOP+RINDIRECT)
+#define SURINDIRECT     (SOP+URINDIRECT)
+#define FRINDIRECT      (FOP+RINDIRECT)
+#define DRINDIRECT      (DOP+RINDIRECT)
+#define LRINDIRECT      (LOP+RINDIRECT)
+#define LURINDIRECT     (LOP+URINDIRECT)
 #define RSTRUCT	27
-#define ALLOCA	28
-#define CONV	29
+#define ALLOCA 	28
+#define CONV   	29
 
 #define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV)
 
 /* binary  argments */
 
-#define MUL	30
-#define UMUL	31
-#define DIV	32
-#define UDIV	33
-#define MOD	34
-#define UMOD	35
-#define ADD	36
-#define SUB	37
-#define CMP    	38	
-#define RSHIFT	39
+#define MUL    	30
+#define UMUL   	31
+#define DIV    	32
+#define UDIV   	33
+#define MOD    	34
+#define UMOD   	35
+#define ADD    	36
+#define SUB    	37
+#define CMP    	38      
+#define RSHIFT 	39
 #define URSHIFT	40
-#define LSHIFT	41
+#define LSHIFT 	41
 #define ULSHIFT	42
-#define GT	43
-#define UGT	44
-#define GE	45
-#define UGE	46
-#define LT	47
-#define ULT	48
-#define LE	49
-#define ULE	50
-#define EQ	51
-#define NEQ	52
-#define BAND	53
-#define EOR	54
-#define BOR	55
-#define LAND	56
-#define LOR	57
-#define ASS	58
-#define UCMP	59
-#define UCMPGE	60
-#define CMPGE	61
-#define CMPEQ	62
-#define CMPNEQ	63
-#define ASSOP	64
-#define COMMA	65
+#define GT     	43
+#define UGT    	44
+#define GE     	45
+#define UGE    	46
+#define LT     	47
+#define ULT    	48
+#define LE     	49
+#define ULE    	50
+#define EQ     	51
+#define NEQ    	52
+#define BAND   	53
+#define EOR    	54
+#define BOR    	55
+#define LAND   	56
+#define LOR    	57
+#define ASS    	58
+#define UCMP   	59
+#define UCMPGE 	60
+#define CMPGE  	61
+#define CMPEQ  	62
+#define CMPNEQ 	63
+#define ASSOP  	64
+#define COMMA  	65
 
-#define CASS	66
-#define CASSOP	67
+#define CASS   	66
+#define CASSOP 	67
 #define CUASSOP	68
 
-#define SASS	(SOP+CASS)
+#define SASS    (SOP+CASS)
 #define SASSOP (SOP+CASSOP)
 #define SUASSOP (SOP+CUASSOP)
 
-#define DASS	(DOP+ASS)
-#define DCMPGE	(DOP+CMPGE)
-#define DCMPEQ	(DOP+CMPEQ)
-#define DCMPNEQ	(DOP+CMPNEQ)
-#define DASSOP	(DOP+ASSOP)
-#define DCMP	(DOP+CMP)
-#define DMINUS	(DOP+MINUS)
-#define DMUL	(DOP+MUL)
-#define DDIV	(DOP+DIV)
-#define DADD	(DOP+ADD)
-#define DSUB	(DOP+SUB)
+#define DASS    (DOP+ASS)
+#define DCMPGE  (DOP+CMPGE)
+#define DCMPEQ  (DOP+CMPEQ)
+#define DCMPNEQ (DOP+CMPNEQ)
+#define DASSOP  (DOP+ASSOP)
+#define DCMP    (DOP+CMP)
+#define DMINUS  (DOP+MINUS)
+#define DMUL    (DOP+MUL)
+#define DDIV    (DOP+DIV)
+#define DADD    (DOP+ADD)
+#define DSUB    (DOP+SUB)
 
-#define FASS	(FOP+ASS)
-#define FCMPGE	(FOP+CMPGE)
-#define FCMPEQ	(FOP+CMPEQ)
-#define FCMPNEQ	(FOP+CMPNEQ)
-#define FASSOP	(FOP+ASSOP)
-#define FCMP	(FOP+CMP)
-#define FMINUS	(FOP+MINUS)
-#define FMUL	(FOP+MUL)
-#define FDIV	(FOP+DIV)
-#define FADD	(FOP+ADD)
-#define FSUB	(FOP+SUB)
+#define FASS    (FOP+ASS)
+#define FCMPGE  (FOP+CMPGE)
+#define FCMPEQ  (FOP+CMPEQ)
+#define FCMPNEQ (FOP+CMPNEQ)
+#define FASSOP  (FOP+ASSOP)
+#define FCMP    (FOP+CMP)
+#define FMINUS  (FOP+MINUS)
+#define FMUL    (FOP+MUL)
+#define FDIV    (FOP+DIV)
+#define FADD    (FOP+ADD)
+#define FSUB    (FOP+SUB)
 
-#define LASS	(LOP+CASS)
-#define LCMPGE	(LOP+CMPGE)
-#define LCMPEQ	(LOP+CMPEQ)
-#define LCMPNEQ	(LOP+CMPNEQ)
+#define LASS    (LOP+CASS)
+#define LCMPGE  (LOP+CMPGE)
+#define LCMPEQ  (LOP+CMPEQ)
+#define LCMPNEQ (LOP+CMPNEQ)
 #define LASSOP  (LOP+CASSOP)
 #define LUASSOP (LOP+CUASSOP)
-#define LCMP	(LOP+CMP)
-#define LMINUS	(LOP+MINUS)
-#define LMUL	(LOP+MUL)
-#define LDIV	(LOP+DIV)
-#define LUMUL	(LOP+UMUL)
-#define LUDIV	(LOP+UDIV)
-#define LADD	(LOP+ADD)
-#define LSUB	(LOP+SUB)
+#define LCMP    (LOP+CMP)
+#define LMINUS  (LOP+MINUS)
+#define LMUL    (LOP+MUL)
+#define LDIV    (LOP+DIV)
+#define LUMUL   (LOP+UMUL)
+#define LUDIV   (LOP+UDIV)
+#define LADD    (LOP+ADD)
+#define LSUB    (LOP+SUB)
 
 
-#define LMOD	(LOP+MOD)
-#define LUMOD	(LOP+UMOD)
-#define LLSHIFT	(LOP+LSHIFT)
-#define LULSHIFT	(LOP+ULSHIFT)
-#define LRSHIFT	(LOP+RSHIFT)
-#define LURSHIFT	(LOP+URSHIFT)
-#define LBAND	(LOP+BAND)
-#define LEOR	(LOP+EOR)
-#define LBOR	(LOP+BOR)
+#define LMOD    (LOP+MOD)
+#define LUMOD   (LOP+UMOD)
+#define LLSHIFT (LOP+LSHIFT)
+#define LULSHIFT        (LOP+ULSHIFT)
+#define LRSHIFT (LOP+RSHIFT)
+#define LURSHIFT        (LOP+URSHIFT)
+#define LBAND   (LOP+BAND)
+#define LEOR    (LOP+EOR)
+#define LBOR    (LOP+BOR)
 
-#define BASS	69
+#define BASS   	69
+#define BASSOP 	70
 
-#define STASS	70
+#define STASS  	71
 
 
 #define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS)
 
 /* tarnary  argments */
 
-#define COND	71
-#define SCOND	(SOP+COND)
-#define DCOND	(DOP+COND)
-#define FCOND	(FOP+COND)
-#define LCOND	(LOP+COND)
+#define COND   	72
+#define SCOND   (SOP+COND)
+#define DCOND   (DOP+COND)
+#define FCOND   (FOP+COND)
+#define LCOND   (LOP+COND)
 
 #define TARNARY_ARGS(i) (COND==(i%SOP))
 
 /* not appeared as tags */
 
-#define I2I	72
-#define I2U	73
-#define I2D	74
-#define I2F	75
-#define I2LL	76
-#define I2ULL	77
+#define I2I    	73
+#define I2U    	74
+#define I2D    	75
+#define I2F    	76
+#define I2LL   	77
+#define I2ULL  	78
 
-#define U2I	78
-#define U2U	79
-#define U2D	80
-#define U2F	81
-#define U2LL	82
-#define U2ULL	83
+#define U2I    	79
+#define U2U    	80
+#define U2D    	81
+#define U2F    	82
+#define U2LL   	83
+#define U2ULL  	84
 
-#define D2I	(DOP+I2I)
-#define D2U	(DOP+I2U)
-#define D2D	(DOP+I2D)
-#define D2F	(DOP+I2F)
-#define D2LL	(DOP+I2LL)
-#define D2ULL	(DOP+I2ULL)
+#define D2I     (DOP+I2I)
+#define D2U     (DOP+I2U)
+#define D2D     (DOP+I2D)
+#define D2F     (DOP+I2F)
+#define D2LL    (DOP+I2LL)
+#define D2ULL   (DOP+I2ULL)
 
-#define F2I	(FOP+I2I)
-#define F2U	(FOP+I2U)
-#define F2D	(FOP+I2D)
-#define F2F	(FOP+I2F)
-#define F2LL	(FOP+I2LL)
-#define F2ULL	(FOP+I2ULL)
+#define F2I     (FOP+I2I)
+#define F2U     (FOP+I2U)
+#define F2D     (FOP+I2D)
+#define F2F     (FOP+I2F)
+#define F2LL    (FOP+I2LL)
+#define F2ULL   (FOP+I2ULL)
 
-#define LL2I	(LOP+I2I)
-#define LL2U	(LOP+I2U)
-#define LL2D	(LOP+I2D)
-#define LL2F	(LOP+I2F)
-#define LL2LL	(LOP+I2LL)
-#define LL2ULL	(LOP+I2ULL)
+#define LL2I    (LOP+I2I)
+#define LL2U    (LOP+I2U)
+#define LL2D    (LOP+I2D)
+#define LL2F    (LOP+I2F)
+#define LL2LL   (LOP+I2LL)
+#define LL2ULL  (LOP+I2ULL)
 
-#define ULL2I	(LOP+U2I)
-#define ULL2U	(LOP+U2U)
-#define ULL2D	(LOP+U2D)
-#define ULL2F	(LOP+U2F)
-#define ULL2LL	(LOP+U2LL)
-#define ULL2ULL	(LOP+U2ULL)
+#define ULL2I   (LOP+U2I)
+#define ULL2U   (LOP+U2U)
+#define ULL2D   (LOP+U2D)
+#define ULL2F   (LOP+U2F)
+#define ULL2LL  (LOP+U2LL)
+#define ULL2ULL (LOP+U2ULL)
 
-#define LPAR	84
-#define RPAR	85
-#define LBRA	86
-#define RBRA	87
-#define LC	88
-#define RC	89
-#define COLON	90
-#define SM	91
-#define PERIOD	92
-#define ARROW	93
-#define CNAME	94
+#define LPAR   	85
+#define RPAR   	86
+#define LBRA   	87
+#define RBRA   	88
+#define LC     	89
+#define RC     	90
+#define COLON  	91
+#define SM     	92
+#define PERIOD 	93
+#define ARROW  	94
+#define CNAME  	95
 
 /* tree node tags end */
 
 /* error number start */
 
-#define FILERR	1
-#define DCERR	2
-#define RDERR	3
-#define STERR	4
-#define EXERR	5
-#define CNERR	6
-#define CHERR	7
-#define GSERR	8
-#define LSERR	9
-#define STRERR	10
-#define LNERR	11
-#define EOFERR	12
-#define MCERR	13
-#define INCERR	14
-#define HPERR	15
-#define TYERR	16
-#define LVERR	17
-#define UDERR	18
-#define OPTION	19
-#define REG_ERR	20
-#define CODE_ERR	21
+#define FILERR  1
+#define DCERR   2
+#define RDERR   3
+#define STERR   4
+#define EXERR   5
+#define CNERR   6
+#define CHERR   7
+#define GSERR   8
+#define LSERR   9
+#define STRERR  10
+#define LNERR   11
+#define EOFERR  12
+#define MCERR   13
+#define INCERR  14
+#define HPERR   15
+#define TYERR   16
+#define LVERR   17
+#define UDERR   18
+#define OPTION  19
+#define REG_ERR 20
+#define CODE_ERR        21
 #define MSERR   22
+#define INERR   23
+
 /* error number end */
 
-#define GSYMS	9000
-#define LSYMS	500
-#define MSYMS	3000
-
-#define HEAPSIZE	30000
-/* #define CHEAPSIZE	3000 */
-#define CHEAPSIZE	356000
-#define LBUFSIZE	4096
-#define MACROSIZE	16000
+#define GSYMS   9000
+#define LSYMS   500
+#define MSYMS   3000
 
 #define FILES 10
-#define OUTPUT_FILE_NAME "mcout.s"
-
-EXTERN int sym,ch,type,mode,stmode,gfree,lfree,mflag,lineno,glineno;
-EXTERN int labelno,gpc,disp,reg_var,debug;
-EXTERN int symval,args,init_vars,heap[HEAPSIZE];
-EXTERN int blabel,clabel,dlabel,cslist,cslabel,ilabel,control;
-EXTERN int ac,ac2,lsrc,chk,asmf;
-EXTERN int MAX_REGISTER_VAR;
-
-EXTERN unsigned hash;
+#define MAX_INCLUDE_PATH_COUNT 10
 
-EXTERN int chsave;
-EXTERN int chptrsave;
-EXTERN char linebuf[LBUFSIZE],namebuf[LBUFSIZE],*chptr;
-EXTERN char *name,*cheapp,**av,/*obuf[320],*/*sptr,escape(void);
-EXTERN int arg_offset,stat_no,disp_offset,csvalue1;
-EXTERN int code_arg_offset;
-EXTERN int retlabel,retpending,retcont;
-EXTERN int arglist;
-
-extern char *init_src;
-
-extern int size_of_int;
-extern int size_of_short;
-extern int size_of_float;
-extern int size_of_double;
-extern int size_of_longlong;
-extern int endian;
+#define HEAPSIZE        30000
+#define CHEAPSIZE       356000
+#define LBUFSIZE        4096
+#define MACROSIZE       16000
 
-EXTERN FILE *obuf;
-
-#if 1
 typedef struct nametable {
-	char *nm;
-	int sc,ty,dsp; } NMTBL;
-#else
-typedef struct nametable {
-	char *nm;
-	int sc; int ty; int dsp; } NMTBL;
-#endif
+        char *nm;
+        int sc,ty,dsp; } NMTBL;
 
-EXTERN NMTBL mtable[MSYMS];
-EXTERN NMTBL ntable[GSYMS+LSYMS];
-EXTERN NMTBL *nptr,*gnptr;
-EXTERN NMTBL *fnptr;
-EXTERN NMTBL null_nptr;
-EXTERN int typedefed,gtypedefed;
+extern int heap[HEAPSIZE];
 
-EXTERN struct {int fd,ln;char *name0;int inc;FILE *fcb;} *filep,filestack[FILES];
-EXTERN char cheap[CHEAPSIZE];
-EXTERN char *macropp,macro_buf[MACROSIZE];
-
-extern void macro_define(char *n);
-extern void error(int n);
-extern int size(int t);
-extern int scalar(int t);
 #if FLOAT_CODE
-EXTERN double dsymval;
 extern int dlist2(int e1, double e2);
 #endif
 #if LONGLONG_CODE
-EXTERN long long lsymval;
 extern int llist2(int e1, long long e2);
 #endif
 extern int list2(int e1, int e2);
@@ -491,13 +434,9 @@
 extern int length(int e1);
 extern int nth(int n,int e1);
 extern int reverse0(int t1);
-extern int assign_data(int e, int t, NMTBL *n,int offset);
-extern int assign_expr0(int e1,int e2,int t,int type) ;
-extern int assign_expr(int e1,int e2,int t,int type) ;
 extern int append4(int p,int a1,int a2,int a3);
 extern int insert_ascend(int p,int e,int eq());
 
-
 #define car(e) (heap[(int)(e)])
 
 #define cadr(e) (heap[((int)(e))+1])
@@ -516,47 +455,4 @@
 #define lcaddr(e) (*(long long*)&heap[((int)(e))+2])
 #endif
 
-#include "conv/conv.h"
-/*
-#include "conv/c2cbc.h"
-#include "conv/cbc2c.h"
- */
-
-extern Converter *conv;
-
-EXTERN void extern_define(char *s,int dsp,int type,int use);
-EXTERN void error(int n);
-EXTERN int append4(int p,int a1,int a2,int a3);
-EXTERN int assign_expr(int e1,int e2,int t,int type);
-EXTERN int assign_expr0(int e1,int e2,int t,int type);
-EXTERN int backdef(void);
-EXTERN int fwdlabel(void);
-EXTERN int glist2(int e1,int e2);
-EXTERN int glist3(int e1,int e2,int e3);
-EXTERN void free_glist2(int e1);
-EXTERN void free_glist3(int e1);
-EXTERN int integral(int t);
-EXTERN int integral(int t);
-EXTERN int list2(int e1, int e2);
-EXTERN int list3(int e1, int e2, int e3);
-EXTERN int list4(int e1, int e2, int e3, int e4);
-EXTERN int reverse0(int t1);
-EXTERN int digit(int c);
-EXTERN int alpha(int c);
-/*
-EXTERN int rplacad(int e, int n);
-EXTERN int rplacadd(int e, int n);
- */
-EXTERN int rvalue_t(int e,int type);
-EXTERN int scalar(int t);
-EXTERN void bexpr(int e1, char cond, int l1);
-EXTERN void def_label(int cslabel, int dlabel);
-EXTERN void display_ntable(NMTBL *n, char *s);
-EXTERN void exit(int l);
-EXTERN void fwddef(int l);
-EXTERN int new_lvar(int size);
-
-EXTERN void free_lvar(int lvar);
-EXTERN void init_free_lvar_list();
-
 /* end */