• R/O
  • SSH

CbC: Commit

micro-C base Continuation based C


Commit MetaInfo

Revisionadd863b666c544586a4258b3b13c9221e955e1ba (tree)
Zeit2006-03-16 19:02:42
Autorshinji_kono
Commitershinji_kono

Log Message

*** empty log message ***

Ändern Zusammenfassung

Diff

diff -r a47434d01a70 -r add863b666c5 Makefile
--- a/Makefile Sat Feb 18 21:43:41 2006 +0900
+++ b/Makefile Thu Mar 16 19:02:42 2006 +0900
@@ -1,12 +1,12 @@
11 CC = gcc -std=c99
22 # -O2
33 # -O99
4-CFLAGS = -g -Wall -I.
4+CFLAGS = -g -Wall -I. -DUSE_CODE_KEYWORD
55 # CFLAGS = -g -Wall -I. -pg -fprofile-arcs -ftest-coverage
66 # LDFLAGS = -pg
77 # for Linux Zaurus
88 # CFLAGS = -fsigned-char -pipe -g -I. -I/home/zaurus/develop/include
9-CFLAGS1 = -g -I.
9+CFLAGS1 = -g -I. -DUSE_CODE_KEYWORD
1010 BASE=0
1111 STAGE=1
1212 MFLAGS=$(MFALGS) BASE=$(BASE) STAGE=$(STAGE)
@@ -14,7 +14,9 @@
1414 MC=mc-$(ARCH)
1515 MLIB = -lm
1616 PRINTF= # printf.c
17-CONVERTER=conv/c.o conv/null.o conv/c2cbc.o conv/cbc2c.o
17+CONVERTER=conv/c.o conv/null.o conv/cbc2c.o conv/c2cbc.o
18+
19+# conv/c2cbc.o conv/cbc2c.o
1820 COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
1921 # CODE=mc-code-ia32.c
2022 CODE=mc-code-$(ARCH).c
@@ -27,13 +29,16 @@
2729 cp mc-$(ARCH) mc
2830
2931 TAGS:
30- ctags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \
32+ ctags mc-code-null.c mc-code.h mc-codegen.c mc-codegen.h \
3133 mc-macro.c \
3234 mc-parse.c mc-tree.c mc-switch.c mc-switch.h \
3335 mc.h conv/c.c conv/c.h \
3436 mc-inline.h mc-inline.c \
3537 conv/conv.h conv/convdef.h conv/null.c
3638
39+mc-null : mc-code-null.o $(COMPLIB) $(CONVERTER)
40+ $(CC) $(LDFLAGS) -g mc-code-null.o $(COMPLIB) $(CONVERTER) -o $@
41+
3742 mc-powerpc : mc-code-powerpc.o $(COMPLIB) $(CONVERTER)
3843 $(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@
3944
@@ -134,7 +139,7 @@
134139 check: mc $(MC) $(TARGET).c
135140 -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
136141 -./b.out > $(TARGET).gcc.out
137- -./$(MC) -s $(TARGET).c
142+ -./$(MC) -s $(TARGET).c
138143 -$(CC) $(TARGET).s $(MLIB)
139144 -./a.out > $(TARGET).$(MC).out
140145 -diff $(TARGET).gcc.out $(TARGET).$(MC).out
@@ -142,18 +147,18 @@
142147 check-inline: mc $(MC) $(TARGET).c
143148 -$(CC) $(CFLAGS1) $(STDFLAG) $(TARGET).c -o b.out $(MLIB)
144149 -./b.out > $(TARGET).gcc.out
145- -./$(MC) -s -DINLINE=inline $(TARGET).c
150+ -./$(MC) -s -DINLINE=inline $(TARGET).c
146151 -$(CC) $(TARGET).s $(MLIB)
147152 -./a.out > $(TARGET).$(MC).out
148153 -diff $(TARGET).gcc.out $(TARGET).$(MC).out
149154
150155 check-code: mc $(MC)
151- -./$(MC) -s $(TARGET).c
156+ -./$(MC) -s $(TARGET).c
152157 -$(CC) $(TARGET).s $(MLIB)
153158 -./a.out > $(TARGET).$(MC).out
154159 -diff $(TARGET).code-out $(TARGET).$(MC).out
155160 check-code-make: mc $(MC)
156- -./$(MC) -s $(TARGET).c
161+ -./$(MC) -s $(TARGET).c
157162 -$(CC) $(TARGET).s $(MLIB)
158163 -./a.out > $(TARGET).code-out
159164
@@ -175,18 +180,20 @@
175180 make clean
176181 tar cBf - . | gzip > ../comp.tgz
177182
178-depend :
183+depend : conv/conv.h
179184 makedepend mc-code-ia32.c mc-code.h mc-codegen.c mc-codegen.h \
180185 mc-parse.c mc-tree.c mc-switch.c mc-switch.h mc.h \
181186 mc-macro.c mc-inline.c mc-macro.h mc-parse.h \
182187 conv/c.c conv/c.h conv/c2cbc.c conv/c2cbc.h conv/cbc2c.c \
183188 conv/cbc2c.h conv/conv.h conv/convdef.h conv/null.c conv/null.h \
189+ mc-code-null.c \
184190 mc-code-powerpc.c \
185191 mc-code-arm.c \
186192 mc-code-mips.c
187193
188194 clean :
189- -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.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 *.cbc.? */*.cbc.?
195+ -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.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 *.cbc.? */*.cbc.?
196+ -rm -f *.tsv ../test/*.tsv ../test/sample/*.tsv
190197
191198 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
192199 $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
@@ -252,6 +259,7 @@
252259 mc-codegen.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
253260 mc-codegen.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
254261 mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h
262+mc-codegen.o: conv/conv.h
255263 mc-parse.o: /usr/include/stdio.h /usr/include/_types.h
256264 mc-parse.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
257265 mc-parse.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
@@ -289,6 +297,10 @@
289297 conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
290298 conv/null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
291299 conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h
300+mc-code-null.o: /usr/include/stdio.h /usr/include/_types.h
301+mc-code-null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
302+mc-code-null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
303+mc-code-null.o: mc-parse.h mc-code.h mc-codegen.h
292304 mc-code-powerpc.o: /usr/include/stdio.h /usr/include/_types.h
293305 mc-code-powerpc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
294306 mc-code-powerpc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h
diff -r a47434d01a70 -r add863b666c5 Makefile.powerpc
--- a/Makefile.powerpc Sat Feb 18 21:43:41 2006 +0900
+++ b/Makefile.powerpc Thu Mar 16 19:02:42 2006 +0900
@@ -14,7 +14,9 @@
1414 MC=mc-$(ARCH)
1515 MLIB = -lm
1616 PRINTF= # printf.c
17-CONVERTER=conv/c.o conv/null.o conv/c2cbc.o conv/cbc2c.o
17+CONVERTER=conv/c.o conv/null.o conv/cbc2c.o conv/c2cbc.o
18+
19+# conv/c2cbc.o conv/cbc2c.o
1820 COMPLIB = mc-parse.o mc-codegen.o mc-switch.o mc-macro.o mc-tree.o mc-inline.o
1921 # CODE=mc-code-ia32.c
2022 CODE=mc-code-$(ARCH).c
@@ -27,13 +29,16 @@
2729 cp mc-$(ARCH) mc
2830
2931 TAGS:
30- ctags mc-code-powerpc.c mc-code.h mc-codegen.c mc-codegen.h \
32+ ctags mc-code-null.c mc-code.h mc-codegen.c mc-codegen.h \
3133 mc-macro.c \
3234 mc-parse.c mc-tree.c mc-switch.c mc-switch.h \
3335 mc.h conv/c.c conv/c.h \
3436 mc-inline.h mc-inline.c \
3537 conv/conv.h conv/convdef.h conv/null.c
3638
39+mc-null : mc-code-null.o $(COMPLIB) $(CONVERTER)
40+ $(CC) $(LDFLAGS) -g mc-code-null.o $(COMPLIB) $(CONVERTER) -o $@
41+
3742 mc-powerpc : mc-code-powerpc.o $(COMPLIB) $(CONVERTER)
3843 $(CC) $(LDFLAGS) -g mc-code-powerpc.o $(COMPLIB) $(CONVERTER) -o $@
3944
@@ -113,7 +118,6 @@
113118 make check-code$(MK) TARGET=test/fact
114119 make check-code$(MK) TARGET=test/goto
115120 make check-code$(MK) TARGET=test/test1
116- make check-code$(MK) TARGET=test/test2
117121 make check-code$(MK) TARGET=test/tmpa
118122 make check-code$(MK) TARGET=test/tmp1
119123 make check-code$(MK) TARGET=test/tmp2
@@ -121,6 +125,7 @@
121125 make check-code$(MK) TARGET=test/tmp6
122126 make check-code$(MK) TARGET=test/scope
123127 make check-code$(MK) TARGET=test/throw
128+ make check-code$(MK) TARGET=test/test2
124129 make check-code$(MK) TARGET=test/too-long-argument
125130
126131 check-nkf:
@@ -175,18 +180,20 @@
175180 make clean
176181 tar cBf - . | gzip > ../comp.tgz
177182
178-depend :
183+depend : conv/conv.h
179184 makedepend mc-code-ia32.c mc-code.h mc-codegen.c mc-codegen.h \
180185 mc-parse.c mc-tree.c mc-switch.c mc-switch.h mc.h \
181186 mc-macro.c mc-inline.c mc-macro.h mc-parse.h \
182187 conv/c.c conv/c.h conv/c2cbc.c conv/c2cbc.h conv/cbc2c.c \
183188 conv/cbc2c.h conv/conv.h conv/convdef.h conv/null.c conv/null.h \
189+ mc-code-null.c \
184190 mc-code-powerpc.c \
185191 mc-code-arm.c \
186192 mc-code-mips.c
187193
188194 clean :
189- -rm -f mc mc-ia32 mc-powerpc mc-mips mc-arm *.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 *.cbc.? */*.cbc.?
195+ -rm -f mc mc-null mc-ia32 mc-powerpc mc-mips mc-arm *.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 *.cbc.? */*.cbc.?
196+ -rm -f *.tsv ../test/*.tsv ../test/sample/*.tsv
190197
191198 mc1 : b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
192199 $(CC) -g -o $@ $(PRINTF) b00.s b01.s mc-codegen.o mc-tree.o mc-switch.o mc-macro.o mc-inline.o $(CONVERTER)
@@ -252,6 +259,7 @@
252259 mc-codegen.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
253260 mc-codegen.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
254261 mc-codegen.o: mc-parse.h mc-codegen.h mc-code.h mc-switch.h mc-inline.h
262+mc-codegen.o: conv/conv.h
255263 mc-parse.o: /usr/include/stdio.h /usr/include/_types.h
256264 mc-parse.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
257265 mc-parse.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
@@ -289,6 +297,10 @@
289297 conv/null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
290298 conv/null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
291299 conv/null.o: mc-parse.h conv/conv.h conv/convdef.h conv/null.h
300+mc-code-null.o: /usr/include/stdio.h /usr/include/_types.h
301+mc-code-null.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
302+mc-code-null.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h mc.h
303+mc-code-null.o: mc-parse.h mc-code.h mc-codegen.h
292304 mc-code-powerpc.o: /usr/include/stdio.h /usr/include/_types.h
293305 mc-code-powerpc.o: /usr/include/sys/_types.h /usr/include/sys/cdefs.h
294306 mc-code-powerpc.o: /usr/include/machine/_types.h /usr/include/ppc/_types.h
diff -r a47434d01a70 -r add863b666c5 conv/c.c
--- a/conv/c.c Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/c.c Thu Mar 16 19:02:42 2006 +0900
@@ -37,6 +37,11 @@
3737 static FILE *null;
3838
3939 static void
40+expr_(int c)
41+{
42+}
43+
44+static void
4045 comment_(int c)
4146 {
4247 fprintf(vout,"%c",c);
@@ -163,7 +168,7 @@
163168 }
164169
165170 void
166-dowhile_end_(){
171+dowhile_end_(int cond){
167172 fprintf(vout,");");
168173 }
169174
@@ -188,17 +193,17 @@
188193 }
189194
190195 void
191-for2_(){
196+for2_(int cond){
192197 fprintf(vout,";");
193198 }
194199
195200 void
196-for_body_(){
201+for_body_(int conti){
197202 fprintf(vout,")");
198203 }
199204
200205 void
201-for_end_(){
206+for_end_(int p0,int p1,int e){
202207
203208 }
204209
@@ -208,7 +213,7 @@
208213 }
209214
210215 void
211-funcall_args_(){
216+funcall_args_(int f, int t, int arg){
212217 fprintf(vout,")");
213218 }
214219
@@ -304,7 +309,7 @@
304309 }
305310
306311 void
307-if_then_(){
312+if_then_(int cond){
308313 fprintf(vout,")");
309314 }
310315
@@ -379,7 +384,7 @@
379384 }
380385
381386 void
382-return_end_(){
387+return_end_(int e){
383388 fprintf(vout,";");
384389 }
385390
@@ -404,12 +409,12 @@
404409 }
405410
406411 void
407-switch_body_(){
412+switch_body_(int v){
408413 fprintf(vout,")");
409414 }
410415
411416 void
412-switch_end_(){
417+switch_end_(int cases){
413418 }
414419
415420 void
@@ -434,7 +439,7 @@
434439 }
435440
436441 void
437-while_body_(){
442+while_body_(int cond){
438443 fprintf(vout,")");
439444 }
440445
diff -r a47434d01a70 -r add863b666c5 conv/c.h
--- a/conv/c.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/c.h Thu Mar 16 19:02:42 2006 +0900
@@ -5,6 +5,7 @@
55
66
77 Converter c_converter = {
8+ &expr_,
89 &conv_,
910 &noconv_,
1011 &comment_,
diff -r a47434d01a70 -r add863b666c5 conv/c2cbc.c
--- a/conv/c2cbc.c Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/c2cbc.c Thu Mar 16 19:02:42 2006 +0900
@@ -38,6 +38,11 @@
3838 static FILE *hout;
3939
4040 static void
41+expr_(int c)
42+{
43+}
44+
45+static void
4146 comment_(int c)
4247 {
4348 fprintf(vout,"%c",c);
@@ -166,7 +171,7 @@
166171 }
167172
168173 void
169-dowhile_end_(){
174+dowhile_end_(int cond){
170175 fprintf(vout,");");
171176 }
172177
@@ -191,17 +196,18 @@
191196 }
192197
193198 void
194-for2_(){
199+for2_(int cond){
195200 fprintf(vout,";");
196201 }
197202
198203 void
199-for_body_(){
204+for_body_(int conti){
200205 fprintf(vout,")");
201206 }
202207
203208 void
204-for_end_(){
209+for_end_(int p0,int p1,int e){
210+
205211
206212 }
207213
@@ -211,7 +217,7 @@
211217 }
212218
213219 void
214-funcall_args_(){
220+funcall_args_(int f, int t, int args){
215221 fprintf(vout,")");
216222 }
217223
@@ -309,7 +315,7 @@
309315 }
310316
311317 void
312-if_then_(){
318+if_then_(int cond){
313319 fprintf(vout,")");
314320 }
315321
@@ -384,7 +390,7 @@
384390 }
385391
386392 void
387-return_end_(){
393+return_end_(int e){
388394 fprintf(vout,";");
389395 }
390396
@@ -409,12 +415,12 @@
409415 }
410416
411417 void
412-switch_body_(){
418+switch_body_(int v){
413419 fprintf(vout,")");
414420 }
415421
416422 void
417-switch_end_(){
423+switch_end_(int cases){
418424 }
419425
420426 void
@@ -439,7 +445,7 @@
439445 }
440446
441447 void
442-while_body_(){
448+while_body_(int cond){
443449 fprintf(vout,")");
444450 }
445451
@@ -464,4 +470,5 @@
464470 fprintf(vout,"continue;");
465471 }
466472
473+
467474 /* end */
diff -r a47434d01a70 -r add863b666c5 conv/c2cbc.h
--- a/conv/c2cbc.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/c2cbc.h Thu Mar 16 19:02:42 2006 +0900
@@ -5,6 +5,7 @@
55
66
77 Converter c2cbc_converter = {
8+ &expr_,
89 &conv_,
910 &noconv_,
1011 &comment_,
diff -r a47434d01a70 -r add863b666c5 conv/cbc2c.c
--- a/conv/cbc2c.c Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/cbc2c.c Thu Mar 16 19:02:42 2006 +0900
@@ -38,6 +38,11 @@
3838 static FILE *hout;
3939
4040 static void
41+expr_(int c)
42+{
43+}
44+
45+static void
4146 comment_(int c)
4247 {
4348 fprintf(vout,"%c",c);
@@ -166,7 +171,7 @@
166171 }
167172
168173 void
169-dowhile_end_(){
174+dowhile_end_(int cond){
170175 fprintf(vout,");");
171176 }
172177
@@ -191,17 +196,18 @@
191196 }
192197
193198 void
194-for2_(){
199+for2_(int cond){
195200 fprintf(vout,";");
196201 }
197202
198203 void
199-for_body_(){
204+for_body_(int conti){
200205 fprintf(vout,")");
201206 }
202207
203208 void
204-for_end_(){
209+for_end_(int p0,int p1,int e){
210+
205211
206212 }
207213
@@ -211,7 +217,7 @@
211217 }
212218
213219 void
214-funcall_args_(){
220+funcall_args_(int f, int t, int arg){
215221 fprintf(vout,")");
216222 }
217223
@@ -309,7 +315,7 @@
309315 }
310316
311317 void
312-if_then_(){
318+if_then_(int cond){
313319 fprintf(vout,")");
314320 }
315321
@@ -384,7 +390,7 @@
384390 }
385391
386392 void
387-return_end_(){
393+return_end_(int e){
388394 fprintf(vout,";");
389395 }
390396
@@ -409,12 +415,12 @@
409415 }
410416
411417 void
412-switch_body_(){
418+switch_body_(int v){
413419 fprintf(vout,")");
414420 }
415421
416422 void
417-switch_end_(){
423+switch_end_(int cases){
418424 }
419425
420426 void
@@ -439,7 +445,7 @@
439445 }
440446
441447 void
442-while_body_(){
448+while_body_(int cond){
443449 fprintf(vout,")");
444450 }
445451
@@ -464,4 +470,5 @@
464470 fprintf(vout,"continue;");
465471 }
466472
473+
467474 /* end */
diff -r a47434d01a70 -r add863b666c5 conv/cbc2c.h
--- a/conv/cbc2c.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/cbc2c.h Thu Mar 16 19:02:42 2006 +0900
@@ -5,6 +5,7 @@
55
66
77 Converter cbc2c_converter = {
8+ &expr_,
89 &conv_,
910 &noconv_,
1011 &comment_,
diff -r a47434d01a70 -r add863b666c5 conv/conv.h
--- a/conv/conv.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/conv.h Thu Mar 16 19:02:42 2006 +0900
@@ -1,6 +1,7 @@
11 /* Do not edit this file. This is automatically generated. */
22 /* Edit conv_func.tbl */
33 typedef struct converter {
4+ void (*expr_)(int e);
45 void (*conv_)();
56 void (*noconv_)(int f);
67 void (*comment_)(int f);
@@ -21,16 +22,16 @@
2122 void (*def_)(NMTBL *n);
2223 void (*dowhile_)();
2324 void (*dowhile_cond_)();
24- void (*dowhile_end_)();
25+ void (*dowhile_end_)(int cond);
2526 int (*error_)(int n);
2627 void (*extern_)();
2728 void (*for_)();
2829 void (*for1_)();
29- void (*for2_)();
30- void (*for_body_)();
31- void (*for_end_)();
30+ void (*for2_)(int cond);
31+ void (*for_body_)(int conti);
32+ void (*for_end_)(int p0,int p1,int e);
3233 void (*funcall_)(int type);
33- void (*funcall_args_)();
34+ void (*funcall_args_)(int f,int t, int args);
3435 void (*function_)(NMTBL *n,int cont);
3536 void (*function_end_)();
3637 void (*goto_)();
@@ -44,7 +45,7 @@
4445 void (*if_)();
4546 void (*if_else_)();
4647 void (*if_endif_)();
47- void (*if_then_)();
48+ void (*if_then_)(int cond);
4849 void (*jump_)(int env);
4950 void (*label_)();
5051 void (*lbra_)(int sym);
@@ -58,18 +59,18 @@
5859 void (*rc_)();
5960 void (*register_)();
6061 void (*return_)();
61- void (*return_end_)();
62+ void (*return_end_)(int e);
6263 void (*return_type_)(int t,NMTBL *n,int cont);
6364 void (*rpar_)();
6465 void (*sm_)();
6566 void (*static_)();
6667 void (*switch_)();
67- void (*switch_body_)();
68- void (*switch_end_)();
68+ void (*switch_body_)(int v);
69+ void (*switch_end_)(int cslist);
6970 void (*typedef_)();
7071 void (*type_)();
7172 void (*while_)();
72- void (*while_body_)();
73+ void (*while_body_)(int cond);
7374 void (*while_end_)();
7475 void (*decl_data_)();
7576 void (*break_)();
diff -r a47434d01a70 -r add863b666c5 conv/convdef.h
--- a/conv/convdef.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/convdef.h Thu Mar 16 19:02:42 2006 +0900
@@ -1,5 +1,6 @@
11 /* Do not edit this file. This is automatically generated. */
22 /* Edit conv_func.tbl */
3+static void expr_(int e) ;
34 static void conv_() ;
45 static void noconv_(int f) ;
56 static void comment_(int f) ;
@@ -20,16 +21,16 @@
2021 static void def_(NMTBL *n);
2122 static void dowhile_();
2223 static void dowhile_cond_();
23-static void dowhile_end_();
24+static void dowhile_end_(int cond);
2425 static int error_(int n);
2526 static void extern_();
2627 static void for_();
2728 static void for1_();
28-static void for2_();
29-static void for_body_();
30-static void for_end_();
29+static void for2_(int cond);
30+static void for_body_(int conti);
31+static void for_end_(int p0,int p1,int e);
3132 static void funcall_(int type);
32-static void funcall_args_();
33+static void funcall_args_(int f,int t, int args);
3334 static void function_(NMTBL *n,int cont);
3435 static void function_end_();
3536 static void goto_();
@@ -43,7 +44,7 @@
4344 static void if_();
4445 static void if_else_();
4546 static void if_endif_();
46-static void if_then_();
47+static void if_then_(int cond);
4748 static void jump_(int env);
4849 static void label_();
4950 static void lbra_(int sym);
@@ -57,18 +58,18 @@
5758 static void rc_();
5859 static void register_();
5960 static void return_();
60-static void return_end_();
61+static void return_end_(int e);
6162 static void return_type_(int t,NMTBL *n,int cont);
6263 static void rpar_();
6364 static void sm_();
6465 static void static_();
6566 static void switch_();
66-static void switch_body_();
67-static void switch_end_();
67+static void switch_body_(int v);
68+static void switch_end_(int cslist);
6869 static void typedef_();
6970 static void type_();
7071 static void while_();
71-static void while_body_();
72+static void while_body_(int cond);
7273 static void while_end_();
7374 static void decl_data_();
7475 static void break_();
diff -r a47434d01a70 -r add863b666c5 conv/null.c
--- a/conv/null.c Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/null.c Thu Mar 16 19:02:42 2006 +0900
@@ -7,6 +7,10 @@
77 #include "conv/convdef.h"
88 #include "conv/null.h"
99 static void
10+expr_(int e)
11+{ }
12+
13+static void
1014 conv_()
1115 { }
1216
@@ -87,7 +91,7 @@
8791 { }
8892
8993 static void
90-dowhile_end_()
94+dowhile_end_(int cond)
9195 { }
9296
9397 static int
@@ -107,15 +111,15 @@
107111 { }
108112
109113 static void
110-for2_()
114+for2_(int cond)
111115 { }
112116
113117 static void
114-for_body_()
118+for_body_(int conti)
115119 { }
116120
117121 static void
118-for_end_()
122+for_end_(int p0,int p1,int e)
119123 { }
120124
121125 static void
@@ -123,7 +127,7 @@
123127 { }
124128
125129 static void
126-funcall_args_()
130+funcall_args_(int f,int t, int args)
127131 { }
128132
129133 static void
@@ -179,7 +183,7 @@
179183 { }
180184
181185 static void
182-if_then_()
186+if_then_(int cond)
183187 { }
184188
185189 static void
@@ -235,7 +239,7 @@
235239 { }
236240
237241 static void
238-return_end_()
242+return_end_(int e)
239243 { }
240244
241245 static void
@@ -259,11 +263,11 @@
259263 { }
260264
261265 static void
262-switch_body_()
266+switch_body_(int v)
263267 { }
264268
265269 static void
266-switch_end_()
270+switch_end_(int cslist)
267271 { }
268272
269273 static void
@@ -279,7 +283,7 @@
279283 { }
280284
281285 static void
282-while_body_()
286+while_body_(int cond)
283287 { }
284288
285289 static void
diff -r a47434d01a70 -r add863b666c5 conv/null.h
--- a/conv/null.h Sat Feb 18 21:43:41 2006 +0900
+++ b/conv/null.h Thu Mar 16 19:02:42 2006 +0900
@@ -5,6 +5,7 @@
55
66
77 Converter null_converter = {
8+ &expr_,
89 &conv_,
910 &noconv_,
1011 &comment_,
diff -r a47434d01a70 -r add863b666c5 conv_func.tbl
--- a/conv_func.tbl Sat Feb 18 21:43:41 2006 +0900
+++ b/conv_func.tbl Thu Mar 16 19:02:42 2006 +0900
@@ -1,3 +1,4 @@
1+void expr_(int e) ;
12 void conv_() ;
23 void noconv_(int f) ;
34 void comment_(int f) ;
@@ -18,16 +19,16 @@
1819 void def_(NMTBL *n);
1920 void dowhile_();
2021 void dowhile_cond_();
21-void dowhile_end_();
22+void dowhile_end_(int cond);
2223 int error_(int n);
2324 void extern_();
2425 void for_();
2526 void for1_();
26-void for2_();
27-void for_body_();
28-void for_end_();
27+void for2_(int cond);
28+void for_body_(int conti);
29+void for_end_(int p0,int p1,int e);
2930 void funcall_(int type);
30-void funcall_args_();
31+void funcall_args_(int f,int t, int args);
3132 void function_(NMTBL *n,int cont);
3233 void function_end_();
3334 void goto_();
@@ -41,7 +42,7 @@
4142 void if_();
4243 void if_else_();
4344 void if_endif_();
44-void if_then_();
45+void if_then_(int cond);
4546 void jump_(int env);
4647 void label_();
4748 void lbra_(int sym);
@@ -55,18 +56,18 @@
5556 void rc_();
5657 void register_();
5758 void return_();
58-void return_end_();
59+void return_end_(int e);
5960 void return_type_(int t,NMTBL *n,int cont);
6061 void rpar_();
6162 void sm_();
6263 void static_();
6364 void switch_();
64-void switch_body_();
65-void switch_end_();
65+void switch_body_(int v);
66+void switch_end_(int cslist);
6667 void typedef_();
6768 void type_();
6869 void while_();
69-void while_body_();
70+void while_body_(int cond);
7071 void while_end_();
7172 void decl_data_();
7273 void break_();
diff -r a47434d01a70 -r add863b666c5 mc-code-null.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mc-code-null.c Thu Mar 16 19:02:42 2006 +0900
@@ -0,0 +1,1391 @@
1+/* Micro-C Null Code Generation */
2+
3+/*
4+************************************************************************
5+** Copyright (C) 2006 Shinji Kono
6+** Ï¢ÍíÀ衧 ΰµåÂç³Ø¾ðÊó¹©³Ø²Ê ²ÏÌî ¿¿¼£
7+** ¡ÊE-Mail Address: kono@ie.u-ryukyu.ac.jp¡Ë
8+**
9+** ¤³¤Î¥½¡¼¥¹¤Î¤¤¤«¤Ê¤ëÊ£¼Ì¡¤²þÊÑ¡¤½¤Àµ¤âµöÂú¤·¤Þ¤¹¡£¤¿¤À¤·¡¢
10+** ¤½¤ÎºÝ¤Ë¤Ï¡¢Ã¯¤¬¹×¸¥¤·¤¿¤ò¼¨¤¹¤³¤ÎÉôʬ¤ò»Ä¤¹¤³¤È¡£
11+** ºÆÇÛÉۤ仨»ï¤ÎÉÕÏ¿¤Ê¤É¤ÎÌ䤤¹ç¤ï¤»¤âɬÍפ¢¤ê¤Þ¤»¤ó¡£
12+** ±ÄÍøÍøÍѤâ¾åµ­¤ËÈ¿¤·¤Ê¤¤ÈϰϤǵö²Ä¤·¤Þ¤¹¡£
13+** ¥Ð¥¤¥Ê¥ê¤ÎÇÛÉۤκݤˤÏversion message¤òÊݸ¤¹¤ë¤³¤È¤ò¾ò·ï¤È¤·¤Þ¤¹¡£
14+** ¤³¤Î¥×¥í¥°¥é¥à¤Ë¤Ä¤¤¤Æ¤ÏÆä˲¿¤ÎÊݾڤ⤷¤Ê¤¤¡¢°­¤·¤«¤é¤º¡£
15+**
16+** Everyone is permitted to do anything on this program
17+** including copying, modifying, improving,
18+** as long as you don't try to pretend that you wrote it.
19+** i.e., the above copyright notice has to appear in all copies.
20+** Binary distribution requires original version messages.
21+** You don't have to ask before copying, redistribution or publishing.
22+** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
23+***********************************************************************
24+ */
25+
26+#include <stdio.h>
27+#include "mc.h"
28+#include "mc-parse.h"
29+#include "mc-code.h"
30+#include "mc-codegen.h"
31+
32+char *l_include_path[] = {
33+ "/usr/include/",
34+ 0
35+};
36+
37+
38+static
39+char *init_src0 = "\
40+#define __ppc__\n\
41+#define __STDC__ 1\n\
42+#define __GNUC__ 1\n\
43+#define __inline\n\
44+#define __inline__\n\
45+#define inline static\n\
46+#define __builtin_va_list int\n\
47+#define __builtin_va_start(ap,arg) ap=(((int)(&arg))+sizeof(arg))\n\
48+#define __builtin_va_arg(ap,type) (*((type *)ap)++)\n\
49+#define alloca __builtin_alloca\n\
50+";
51+
52+#define TEXT_EMIT_MODE 0
53+#define DATA_EMIT_MODE 1
54+#define RODATA_EMIT_MODE 2
55+
56+int eval_order = NORMAL;
57+
58+int data_alignment = 0;
59+
60+int code_lassop_p = 1;
61+
62+#define SIZE_OF_INT 4
63+#define SIZE_OF_SHORT 2
64+#define SIZE_OF_FLOAT 4
65+#define SIZE_OF_DOUBLE 8
66+#define SIZE_OF_LONGLONG 8
67+#define ENDIAN 1
68+#define ENDIAN_L 1
69+#define ENDIAN_D 1
70+
71+
72+int disp_offset = -12;
73+
74+void
75+code_offset_set()
76+{}
77+
78+
79+void
80+code_lvar(int e2,int reg) {
81+}
82+
83+void
84+code_init(void)
85+{
86+ /* called only once */
87+
88+ init_src = init_src0;
89+ size_of_int = SIZE_OF_INT;
90+ size_of_short = SIZE_OF_SHORT;
91+ size_of_float = SIZE_OF_FLOAT;
92+ size_of_double = SIZE_OF_DOUBLE;
93+ size_of_longlong = SIZE_OF_LONGLONG;
94+ endian = ENDIAN;
95+
96+}
97+
98+extern void
99+emit_reinit()
100+{
101+ /* called for each file */
102+ /* heap is initialized here, setup ptr cache free list */
103+}
104+
105+void
106+gexpr_code_init(void){
107+}
108+
109+void
110+code_gexpr(int e){
111+}
112+
113+
114+void
115+code_arg_register(NMTBL *fnptr)
116+{
117+}
118+
119+
120+int
121+get_register(void)
122+{ /* »È¤ï¤ì¤Æ¤¤¤Ê¤¤¥ì¥¸¥¹¥¿¤òÄ´¤Ù¤ë */
123+ return 1;
124+}
125+
126+
127+int
128+pop_register(void)
129+{ /* ¥ì¥¸¥¹¥¿¤«¤éÃͤò¼è¤ê½Ð¤¹ */
130+ return 1;
131+}
132+
133+#if FLOAT_CODE
134+int
135+get_dregister(int d)
136+{ /* »È¤ï¤ì¤Æ¤¤¤Ê¤¤¥ì¥¸¥¹¥¿¤òÄ´¤Ù¤ë */
137+ return 1;
138+}
139+
140+int
141+pop_fregister(void)
142+{ /* ¥ì¥¸¥¹¥¿¤«¤éÃͤò¼è¤ê½Ð¤¹ */
143+ return 1;
144+}
145+#endif
146+
147+
148+
149+int
150+get_lregister()
151+{
152+ return 1;
153+}
154+
155+int
156+get_lregister_var(NMTBL *n)
157+{
158+ return list3(LVAR,new_lvar(SIZE_OF_LONGLONG),0);
159+}
160+
161+void
162+emit_pop_free(int xreg)
163+{
164+}
165+
166+void
167+
168+free_register(int i) { /* ¤¤¤é¤Ê¤¯¤Ê¤Ã¤¿¥ì¥¸¥¹¥¿¤ò³«Êü */
169+}
170+
171+extern void
172+use_ptr_cache(int r)
173+{
174+}
175+
176+int
177+get_input_dregister_var(int i,NMTBL *n,int is_code,int d)
178+{
179+ return 0;
180+}
181+
182+int
183+get_input_lregister_var(int i,NMTBL *n,int is_code)
184+{
185+ return list3(LREGISTER,1,(int)n);
186+}
187+
188+int
189+get_input_register_var(int i,NMTBL *n,int is_code)
190+{
191+ return 0;
192+}
193+
194+/* double register case? */
195+
196+int
197+get_input_register_var_1(int i,NMTBL *n,int is_code)
198+{
199+ return 0;
200+}
201+
202+int
203+free_register_count(int d)
204+{
205+ return 1;
206+}
207+
208+
209+void
210+free_all_register(void)
211+{
212+ return;
213+}
214+
215+extern int
216+code_register_overlap(int s,int t)
217+{
218+ return 0;
219+}
220+
221+// int lreg_count;
222+
223+void
224+register_usage(char *s)
225+{
226+}
227+
228+void
229+
230+gexpr_init(void)
231+{
232+ gexpr_code_init();
233+}
234+
235+
236+void
237+
238+emit_init(void)
239+{
240+ /* called before each declaration */
241+}
242+
243+
244+int
245+get_register_var(NMTBL *n)
246+{
247+ return list3(LVAR,new_lvar(SIZE_OF_INT),0);
248+}
249+
250+int
251+get_dregister_var(NMTBL *n,int d)
252+{
253+ return list3(LVAR,new_lvar(SIZE_OF_DOUBLE),0);
254+}
255+
256+int
257+emit_push()
258+{
259+ return 1;
260+}
261+
262+int
263+emit_pop(int type)
264+{
265+ return 1;
266+}
267+
268+extern void
269+code_ptr_cache_def(int r,NMTBL *nptr)
270+{
271+}
272+
273+
274+
275+void
276+code_label(int labelno)
277+{
278+ clear_ptr_cache();
279+}
280+
281+
282+void
283+code_gvar(int e1,int reg) {
284+}
285+
286+void
287+code_rgvar(int e1,int reg) {
288+}
289+
290+void
291+code_crgvar(int e1,int reg,int sign,int sz){
292+}
293+
294+
295+
296+void
297+code_register(int e2,int reg) {
298+}
299+
300+extern void
301+code_i2c(int reg)
302+{
303+}
304+
305+extern void
306+code_i2s(int reg)
307+{
308+}
309+
310+extern void
311+code_u2uc(int reg)
312+{
313+}
314+
315+extern void
316+code_u2us(int reg)
317+{
318+}
319+
320+void
321+code_rlvar(int e2,int reg) {
322+}
323+
324+void
325+code_crlvar(int e2,int reg,int sign,int sz) {
326+}
327+
328+void
329+code_fname(NMTBL *n,int reg) {
330+}
331+
332+void
333+code_label_value(int label,int reg) {
334+}
335+
336+void
337+code_const(int e2,int reg) {
338+}
339+
340+
341+void
342+code_neg(int creg) {
343+}
344+
345+
346+void
347+code_not(int creg) {
348+}
349+
350+
351+void
352+code_lnot(int creg) {
353+}
354+
355+void
356+code_preinc(int e1,int e2,int dir,int sign,int sz,int reg) {
357+}
358+
359+
360+void
361+code_postinc(int e1,int e2,int dir,int sign,int sz,int reg) {
362+}
363+
364+
365+void
366+code_return(int creg) {
367+}
368+
369+void
370+code_environment(int creg) {
371+}
372+
373+
374+void
375+code_bool(int e1,int reg) {
376+}
377+
378+
379+void
380+code_cmp_crgvar(int e1,int reg,int sz,int label,int cond) {
381+}
382+
383+
384+void
385+code_cmp_crlvar(int e2,int reg, int sz,int label,int cond) {
386+}
387+
388+
389+void
390+code_cmp_rgvar(int e1,int reg,int label,int cond) {
391+}
392+
393+
394+void
395+code_cmp_rlvar(int e2,int reg,int label,int cond) {
396+}
397+
398+
399+void
400+code_cmp_register(int e2,int label,int cond) {
401+}
402+
403+
404+void
405+code_string(int e1,int creg)
406+{
407+}
408+
409+#define MAX_COPY_LEN 20
410+
411+void
412+emit_copy(int from,int to,int length,int offset,int value,int det)
413+{
414+}
415+
416+int
417+push_struct(int e4,int t,int arg)
418+{
419+ int length;
420+ length=size(t);
421+ if(length%SIZE_OF_INT) {
422+ length += SIZE_OF_INT - (length%SIZE_OF_INT);
423+ }
424+ return length/SIZE_OF_INT;
425+}
426+
427+
428+void
429+code_save_input_registers(int dots)
430+{
431+}
432+
433+int
434+not_simple_p(int e3)
435+{
436+ switch (e3) {
437+ case FUNCTION: case CONV: case LCALL: case STASS:
438+ case LLSHIFT: case LULSHIFT: case LRSHIFT: case LURSHIFT:
439+ case LDIV: case LUDIV: case LMOD: case LUMOD: case LASSOP: case ALLOCA:
440+ case INLINE:
441+ return 1;
442+ }
443+ return 0;
444+}
445+
446+
447+int
448+function(int e1)
449+{
450+ int dots,ret_type;
451+
452+ ret_type = function_type(cadddr(e1),&dots);
453+ if (caddr(cadddr(e1))==0) dots=1;
454+ return ret_type;
455+}
456+
457+void
458+code_alloca(int e1,int reg)
459+{
460+}
461+
462+void
463+code_frame_pointer(int e3) {
464+}
465+
466+int
467+code_frame_pointer_register()
468+{
469+ return list2(REGISTER,1);
470+}
471+
472+void
473+code_fix_frame_pointer(int disp_offset) {
474+}
475+
476+void
477+code_jmp(char *s) {
478+ control=0;
479+}
480+
481+
482+void
483+code_indirect_jmp(int e2) {
484+ control=0;
485+}
486+
487+void
488+code_rindirect(int e1, int reg,int offset, int sign,int sz)
489+{
490+}
491+
492+#if FLOAT_CODE
493+int
494+code_drindirect(int e1, int reg,int offset, int d)
495+{
496+ return d?DOUBLE:FLOAT;
497+}
498+#endif
499+
500+#if LONGLONG_CODE
501+
502+int
503+code_lrindirect(int e1, int reg, int offset, int us)
504+{
505+ return us?ULONGLONG:LONGLONG;
506+}
507+#endif
508+
509+void
510+code_assign_gvar(int e2,int creg,int byte) {
511+}
512+
513+void
514+code_assign_lvar(int e2,int creg,int byte) {
515+}
516+
517+void
518+code_assign_register(int e2,int byte,int creg) {
519+}
520+
521+void
522+code_assign(int e2,int byte,int creg) {
523+}
524+
525+
526+void
527+code_register_assop(int e2,int reg, int op,int byte) {
528+}
529+
530+void
531+code_assop(int op,int creg, int byte,int sign) {
532+}
533+
534+int
535+tosop_operand_safe_p(int op)
536+{
537+ return 1;
538+}
539+
540+void
541+tosop(int op,int creg,int oreg)
542+{
543+}
544+
545+int
546+code_const_op_p(int op,int v)
547+{
548+ v = cadr(v);
549+ return (-32766<v&&v<32767);
550+}
551+
552+void
553+oprtc(int op,int creg, int v)
554+{
555+}
556+
557+
558+int
559+code_csvalue()
560+{
561+ return glist2(REGISTER,2);
562+}
563+
564+void
565+code_cmpdimm(int e, int csreg,int label,int cond)
566+{
567+}
568+
569+void
570+code_opening(char *filename)
571+{
572+}
573+
574+
575+int
576+rexpr(int e1, int l1, int cond,int t)
577+{
578+ return l1;
579+}
580+
581+void
582+jmp(int l)
583+{
584+}
585+
586+extern void
587+code_comment(char *s)
588+{
589+}
590+
591+void
592+code_enter(char *name)
593+{
594+}
595+
596+
597+void
598+code_enter1(int args)
599+{
600+}
601+
602+void
603+code_leave(char *name)
604+{
605+ // local_table();
606+}
607+
608+void
609+enter(char *name)
610+{
611+}
612+
613+void
614+enter1()
615+{
616+}
617+
618+void
619+code_label_call(int l)
620+{
621+}
622+
623+void
624+code_ret()
625+{
626+}
627+
628+void
629+leave(int control, char *name)
630+{
631+ // local_table();
632+}
633+
634+
635+void
636+code_set_return_register(int mode) {
637+}
638+
639+int
640+code_get_fixed_creg(int reg,int type) {
641+ return 1;
642+}
643+
644+void
645+code_set_fixed_creg(int reg,int mode,int type) {
646+}
647+
648+void
649+gen_gdecl(char *n, int gpc)
650+{
651+}
652+
653+extern void
654+ascii(char *s)
655+{
656+}
657+
658+extern int
659+emit_string_label() {
660+ int lb;
661+
662+ lb=fwdlabel();
663+ return lb;
664+}
665+
666+extern void
667+emit_string(char *s,int t)
668+{
669+ return;
670+}
671+
672+void
673+align(int t)
674+{
675+}
676+
677+void
678+emit_global(NMTBL *n,int a,int e)
679+{
680+}
681+
682+extern void
683+emit_space(int sp)
684+{
685+}
686+
687+extern void
688+emit_char(int d)
689+{
690+}
691+
692+extern void
693+emit_short(int d)
694+{
695+}
696+
697+extern void
698+emit_int(int d)
699+{
700+}
701+
702+extern void
703+emit_longlong(int e)
704+{
705+}
706+
707+extern void
708+emit_double(int e)
709+{
710+}
711+
712+extern void
713+emit_float(int e)
714+{
715+}
716+
717+extern void
718+emit_address(char *s,int offset)
719+{
720+}
721+
722+extern void
723+emit_label(int labelno)
724+{
725+}
726+
727+extern void
728+emit_data_closing(NMTBL *n)
729+{
730+}
731+
732+void
733+global_table(void)
734+{
735+}
736+
737+void
738+local_table(void)
739+{
740+}
741+
742+
743+#if FLOAT_CODE
744+
745+/* floating point */
746+
747+void
748+code_cmp_dregister(int e2,int d,int label,int cond)
749+{
750+}
751+
752+void
753+code_dregister(int e2,int freg,int d)
754+{
755+}
756+
757+void
758+code_dassign_gvar(int e2,int freg,int d)
759+{
760+}
761+
762+void
763+code_dassign_lvar(int e2,int freg,int d)
764+{
765+}
766+
767+void
768+code_dassign(int e2,int freg,int d)
769+{
770+}
771+
772+void
773+code_dassign_dregister(int e2,int d,int freg) {
774+}
775+
776+
777+void
778+code_dconst(int e2,int freg,int d)
779+{
780+}
781+
782+
783+void
784+code_dneg(int freg,int d)
785+{
786+}
787+
788+void
789+code_d2i()
790+{
791+}
792+
793+
794+void
795+code_i2d()
796+{
797+}
798+
799+void
800+code_d2u()
801+{
802+}
803+
804+
805+void
806+code_u2d()
807+{
808+}
809+
810+void
811+code_d2f() { }
812+void
813+code_f2d() { }
814+void
815+code_f2i() { code_d2i(); }
816+void
817+code_f2u() { code_d2u(); }
818+void
819+code_i2f() { code_i2d(); }
820+void
821+code_u2f() { code_u2d(); }
822+
823+void
824+code_drgvar(int e2,int d,int freg)
825+{
826+}
827+
828+
829+void
830+code_drlvar(int e2,int d,int freg)
831+{
832+}
833+
834+void
835+code_cmp_drgvar(int e2,int reg,int d,int label,int cond)
836+{
837+}
838+
839+void
840+code_cmp_drlvar(int e2,int reg,int d,int label,int cond)
841+{
842+}
843+
844+void
845+dtosop(int op,int reg,int oreg)
846+{
847+}
848+
849+void
850+code_dassop(int op,int reg,int d) {
851+}
852+
853+void
854+code_register_dassop(int reg,int op,int d) {
855+}
856+
857+
858+void
859+code_dpreinc(int e1,int e2,int d,int reg) {
860+}
861+
862+void
863+code_dpostinc(int e1,int e2,int d,int reg) {
864+}
865+
866+
867+int
868+drexpr(int e1, int e2,int l1, int op,int cond)
869+{
870+ return l1;
871+}
872+
873+int emit_dpop(int d)
874+{
875+ return 1;
876+}
877+
878+void
879+emit_dpop_free(int e1,int d)
880+{
881+}
882+
883+void
884+emit_dpush(int d)
885+{
886+}
887+
888+#endif
889+
890+#if LONGLONG_CODE
891+
892+
893+/* 64bit int part */
894+
895+int
896+lrexpr(int e1, int e2,int l1, int op,int cond)
897+{
898+ return l1;
899+}
900+
901+int
902+emit_lpop()
903+{
904+ return 1;
905+}
906+
907+void
908+code_lregister(int e2,int reg)
909+{
910+}
911+
912+void
913+code_cmp_lregister(int reg,int label,int cond)
914+{
915+}
916+
917+void
918+code_cmp_lrgvar(int e1,int creg,int label,int cond)
919+{
920+}
921+
922+void
923+code_cmp_lrlvar(int e1,int creg,int label,int cond)
924+{
925+}
926+
927+void
928+code_lassign(int e2,int creg)
929+{
930+}
931+
932+void
933+code_lassign_gvar(int e2,int creg)
934+{
935+}
936+
937+void
938+code_lassign_lvar(int e2,int creg)
939+{
940+}
941+
942+void
943+code_lassign_lregister(int e2,int reg)
944+{
945+}
946+
947+
948+void
949+code_lconst(int e1,int creg)
950+{
951+}
952+
953+void
954+code_lneg(int creg)
955+{
956+}
957+
958+void
959+code_lrgvar(int e1,int creg)
960+{
961+}
962+
963+void
964+code_lrlvar(int e1,int creg)
965+{
966+}
967+
968+void
969+ltosop(int op,int reg,int oreg)
970+{
971+}
972+
973+int
974+code_lconst_op_p(int op,int e)
975+{
976+ return 0;
977+}
978+
979+void
980+loprtc(int op,int creg,int e)
981+{
982+}
983+
984+
985+void
986+emit_lpop_free(int xreg)
987+{
988+}
989+
990+void
991+emit_lpush()
992+{
993+}
994+
995+void
996+code_i2ll(int reg)
997+{
998+}
999+
1000+void
1001+code_i2ull(int reg)
1002+{
1003+}
1004+
1005+void
1006+code_u2ll(int reg)
1007+{
1008+}
1009+
1010+void
1011+code_u2ull(int creg)
1012+{
1013+}
1014+
1015+void
1016+code_ll2i(int reg)
1017+{
1018+}
1019+
1020+void
1021+code_ll2u(int creg)
1022+{
1023+}
1024+
1025+void
1026+code_ull2i(int creg)
1027+{
1028+}
1029+
1030+void
1031+code_ull2u(int creg)
1032+{
1033+}
1034+
1035+#if FLOAT_CODE
1036+
1037+void
1038+code_d2ll(int reg)
1039+{
1040+}
1041+
1042+void
1043+code_d2ull(int reg)
1044+{
1045+}
1046+
1047+void
1048+code_f2ll(int reg)
1049+{
1050+}
1051+
1052+void
1053+code_f2ull(int reg)
1054+{
1055+}
1056+
1057+void
1058+code_ll2d(int reg)
1059+{
1060+}
1061+
1062+
1063+void
1064+code_ll2f(int reg)
1065+{
1066+}
1067+
1068+void
1069+code_ull2d(int creg)
1070+{
1071+}
1072+
1073+void
1074+code_ull2f(int creg)
1075+{
1076+}
1077+
1078+#endif
1079+
1080+
1081+void
1082+code_lpreinc(int e1,int e2,int reg)
1083+{
1084+}
1085+
1086+void
1087+code_lpostinc(int e1,int e2,int reg)
1088+{
1089+}
1090+
1091+void
1092+code_lassop(int op,int reg)
1093+{
1094+}
1095+
1096+void
1097+code_register_lassop(int reg,int op) {
1098+ // reg op = pop()
1099+}
1100+
1101+
1102+#endif
1103+
1104+void
1105+code_save_stacks()
1106+{
1107+}
1108+
1109+
1110+void
1111+code_closing()
1112+{
1113+ global_table();
1114+}
1115+
1116+#if CASE_CODE
1117+
1118+int
1119+code_table_jump_p(int delta) { return 1; }
1120+
1121+void
1122+code_table_jump(int l,int csvalue,int delta,int max,int min,int dlabel)
1123+{
1124+}
1125+
1126+void
1127+code_table_open(int l)
1128+{
1129+}
1130+
1131+void
1132+code_table_value(int label,int table_top)
1133+{
1134+}
1135+
1136+void
1137+code_table_close()
1138+{
1139+}
1140+
1141+#endif
1142+
1143+#if ASM_CODE
1144+
1145+/*
1146+ print an operand
1147+ */
1148+
1149+
1150+/*
1151+ prepare asm operands
1152+
1153+ char *constraints sgtring
1154+ int oeprand expr
1155+ int mode (ASM_INPUT,ASM_OUTPUT)
1156+ int replacement list
1157+ int output operands count
1158+ int output operands replacement list
1159+
1160+ retrun replacement list
1161+ list3( operands, next, clobber )
1162+ 0 can be shared in input/output
1163+ 1 can't be used in input
1164+ */
1165+
1166+extern int
1167+code_asm_operand(char *p,int e1,int mode,int repl,int n,int repl0)
1168+{
1169+#if 0
1170+ int r;
1171+ int c;
1172+ int val;
1173+ int clobber = 0;
1174+
1175+ printf("## constraint %s\n",p);
1176+retry:
1177+ switch((c=*p)) {
1178+ case '?':
1179+ case '!':
1180+ case '+':
1181+ case '%':
1182+ case '#':
1183+ case '*':
1184+ case '=':
1185+ // output register
1186+ p++;
1187+ goto retry;
1188+ case '&':
1189+ // earlyclobber
1190+ p++;
1191+ clobber = 1;
1192+ goto retry;
1193+ case 'b': // address base register (what?)
1194+ case 'r':
1195+ if (mode==ASM_INPUT) {
1196+ for(;repl0;repl0 = cadr(repl0)) {
1197+ if (car(car(repl0))==REGISTER && caddr(repl0)==0) {
1198+ r = cadr(car(repl0));
1199+ caddr(repl0) = ASM_USED;
1200+ break;
1201+ }
1202+ }
1203+ r = get_register();
1204+ } else {
1205+ r = get_register();
1206+ }
1207+ repl = list3(list2(REGISTER,r),repl,clobber);
1208+ break;
1209+ case 'm':
1210+ repl = list3(list2(0,0),repl,clobber);
1211+ break;
1212+ case 'i':
1213+ if (car(e1)==GVAR) {
1214+ e1=list3(FNAME,(int)(((NMTBL *)caddr(e1))->nm),0);
1215+ } else if (car(e1)==FNAME) {
1216+ e1=list3(FNAME,(int)(((NMTBL *)cadr(e1))->nm),0);
1217+ } else if (car(e1)==STRING) {
1218+ val = emit_string_label();
1219+ ascii(((NMTBL*)cadr(e1))->nm);
1220+ e1=list3(STRING,val,0);
1221+ } else if (car(e1)==CONST) {
1222+ } else error(-1);
1223+ repl = list3(e1,repl,clobber);
1224+ break;
1225+ case '0': case '1': case '2': case '3': case '4':
1226+ case '5': case '6': case '7': case '8': case '9':
1227+ val = 0;
1228+ do { val = val*10 + c-'0'; } while (digit(c=*p++));
1229+ if (val>MAX_ASM_REG) error(-1); // too large register
1230+ if (n-val<0) error(-1);
1231+ repl = list3(car(nth(n-val-1,repl0)),repl,clobber);
1232+ break;
1233+ default:
1234+ // printf("### unknown asm constraint %c\n",c);
1235+ }
1236+#endif
1237+ return repl;
1238+}
1239+
1240+void
1241+code_free_asm_operand(int repl)
1242+{
1243+}
1244+
1245+
1246+extern void
1247+code_asm(char *asm_str,int repl)
1248+{
1249+#if 0
1250+ int c,i,rstr,val;
1251+ char *p;
1252+ int reg[MAX_ASM_REG];
1253+
1254+ text_mode(0);
1255+ c = *asm_str;
1256+ if (c!='\t'&&c!=' ') printf("\t");
1257+ for(i=0;repl && i<MAX_ASM_REG;i++) {
1258+ reg[i] = car(repl);
1259+ repl = cadr(repl);
1260+ }
1261+ p = asm_str;
1262+ while((c = *p++)) {
1263+ if (c=='%') {
1264+ c = *p++;
1265+ if (!c) { break;
1266+ } else if (c=='%') {
1267+ printf("%%"); continue;
1268+ } else if (!digit(c)) {
1269+ printf("%%%c",c); continue;
1270+ }
1271+ val = 0;
1272+ do { val = val*10 + c-'0'; } while (digit(c=*p++)) ;
1273+ p--;
1274+ if (val>MAX_ASM_REG) error(-1); // too large register
1275+ rstr = reg[val];
1276+ emit_asm_operand(rstr);
1277+ } else {
1278+ printf("%c",c);
1279+ }
1280+ }
1281+ printf("\n");
1282+#endif
1283+}
1284+
1285+#endif
1286+
1287+
1288+#if BIT_FIELD_CODE
1289+
1290+/* bit field alignment calcuration */
1291+
1292+static void
1293+set_bitsz(int type,int *pbitpos,int *pbitsize,
1294+ int *psign,int *pbitsz,int *palign,int *pl)
1295+{
1296+ int sign=0,bitsz=0;
1297+ int align=4,l=0;
1298+ *pbitpos = cadr(caddr(type));
1299+ *pbitsize = caddr(caddr(type));
1300+ switch(cadr(type)) { /* value type */
1301+ case INT: sign=1; bitsz=32; align=4;break;
1302+ case UNSIGNED: bitsz=32; align=4;break;
1303+ case CHAR: sign=1; bitsz= 8; align=1;break;
1304+ case UCHAR: bitsz= 8; align=1;break;
1305+ case SHORT: sign=1; bitsz=16; align=2;break;
1306+ case USHORT: sign=1; bitsz=16; align=2;break;
1307+ case LONGLONG: sign=1; bitsz=64; align=4;l=1; break;
1308+ case ULONGLONG: bitsz=64; align=4;l=1; break;
1309+ default: error(-1);
1310+ }
1311+ *psign = sign;
1312+ *pbitsz = bitsz;
1313+ *palign = align;
1314+ *pl = l;
1315+}
1316+
1317+/*
1318+ bit field alignment calcuration
1319+ this is architecture depenedent
1320+ */
1321+
1322+extern int
1323+code_bit_field_disp(int type,int *poffset,int *bfd,int *sz)
1324+{
1325+ int sign,bitsz,align;
1326+ int i;
1327+ int bitpos = *bfd;
1328+ int bitpos0;
1329+ int bitsize;
1330+ int offset = *poffset;
1331+ int l;
1332+ set_bitsz(type,&bitpos0,&bitsize,&sign,&bitsz,&align,&l);
1333+
1334+ if (bitsize>bitsz) { error(BTERR); bitsize = bitsz; }
1335+
1336+ /* bfd means previous bit field bit offset */
1337+ if (bitpos) {
1338+ /* previous field is bit field and spaces may remain */
1339+ /* calc previsous offset */
1340+
1341+ i= offset-(bitpos+7)/8;
1342+
1343+ for(l = bitpos;l>0;l -= 8,i++) {
1344+ if ((i & (align-1))==0 && l+bitsize <= bitsz) {
1345+ /* alignment is correct and space remains */
1346+ *poffset=offset=i;
1347+ i = l+bitsize;
1348+ *bfd = (i==bitsz)?0:i;
1349+ *sz = (i+7)/8;
1350+// printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",l,bitsize,bitsz,*poffset);
1351+ return l;
1352+ }
1353+ }
1354+ }
1355+
1356+ /* first bit-field */
1357+
1358+ if ((i=(offset & (align-1)))) {
1359+ *poffset = (offset += (align-i));
1360+ }
1361+ bitpos = 0;
1362+ *bfd = (bitsize==bitsz)?0:bitsize;
1363+ *sz = (bitsize+7)/8;
1364+
1365+// printf("## bitpos=%d bitsize=%d bitsz=%d offset=%d\n",bitpos,bitsize,bitsz,*poffset);
1366+ return bitpos;
1367+}
1368+
1369+/* bit field value */
1370+
1371+extern void
1372+code_bit_field(int type,int adr, int reg)
1373+{
1374+}
1375+
1376+/* bit field replacement */
1377+
1378+
1379+extern void
1380+code_bit_replace(int adr,int value,int type)
1381+{
1382+}
1383+
1384+extern void
1385+code_bit_replace_const(int value,int adr,int type)
1386+{
1387+}
1388+
1389+#endif
1390+
1391+/* end */
diff -r a47434d01a70 -r add863b666c5 mc-codegen.c
--- a/mc-codegen.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-codegen.c Thu Mar 16 19:02:42 2006 +0900
@@ -29,6 +29,9 @@
2929 #include "mc-code.h"
3030 #include "mc-switch.h"
3131 #include "mc-inline.h"
32+#include "conv/conv.h"
33+
34+extern Converter *conv;
3235
3336 int use; /* generated value will be used */
3437 char *init_src;
@@ -111,7 +114,7 @@
111114 extern int
112115 gexpr(int e1,int use0)
113116 {
114- if (chk) return INT;
117+ if (chk==1) return INT;
115118 gexpr_init();
116119 use = use0;
117120 return g_expr0(e1);
@@ -161,6 +164,7 @@
161164
162165 for(;e1;e1=e2) {
163166 code_gexpr(e1);
167+ conv->expr_(e1);
164168
165169 e2 = cadr(e1);
166170 switch (car(e1)){
@@ -278,7 +282,7 @@
278282 }
279283 t = function(e1);
280284 return t;
281- case CODE:
285+ case JUMP:
282286 if (car(e2)==FNAME&&is_function((NMTBL*)cadr(e2))) {
283287 // error(GTERR);
284288 return function(e1);
@@ -294,12 +298,14 @@
294298 nptr = (NMTBL*)caddr(e1);
295299 type = cadddr(e1);
296300 e1 = strop(e2,0); t = type;
301+ if (chk) return t;
297302 g_expr0(e1);
298303 return t;
299304 case ARROW:
300305 nptr = (NMTBL*)caddr(e1);
301306 type = cadddr(e1);
302307 e1 = strop(e2,1); t = type;
308+ if (chk) return t;
303309 g_expr0(e1);
304310 return t;
305311 case INLINE:
@@ -600,7 +606,7 @@
600606 return VOID;
601607 }
602608
603-static int
609+extern int
604610 rop_dual(int op)
605611 {
606612 // x op y => y dual(op) x
@@ -642,6 +648,7 @@
642648 bexpr_u(int e1, char cond, int l1)
643649 {
644650 int op = car(e1);
651+ conv->expr_(e1);
645652 if (chk) return l1;
646653 // gexpr_init();
647654 switch(op) {
@@ -1548,6 +1555,7 @@
15481555 g_expr(e2);
15491556 emit_push();
15501557 }
1558+ if (chk) return;
15511559
15521560 /* ÊÂÎóÂåÆþ¤ò¼Â¹Ô */
15531561 parallel_assign(&target,&processing,&use);
@@ -2692,6 +2700,7 @@
26922700 }
26932701 if (!chk)
26942702 code_closing();
2703+ conv->close_();
26952704 }
26962705
26972706 static int
@@ -2722,7 +2731,7 @@
27222731 if (contains(cadr(e),type)) return 1;
27232732 e = caddr(e);
27242733 continue;
2725- } else if (TARNARY_ARGS(car(e))) {
2734+ } else if (TERNARY_ARGS(car(e))) {
27262735 /* tarary operators */
27272736 if (contains(cadr(e), type)) return 1;
27282737 if (contains(caddr(e),type)) return 1;
@@ -2770,7 +2779,7 @@
27702779 if (contains_p(cadr(e),p)) return 1;
27712780 e = caddr(e);
27722781 continue;
2773- } else if (TARNARY_ARGS(car(e))) {
2782+ } else if (TERNARY_ARGS(car(e))) {
27742783 /* tarary operators */
27752784 if (contains_p(cadr(e), p)) return 1;
27762785 if (contains_p(caddr(e),p)) return 1;
@@ -2819,7 +2828,7 @@
28192828 arg=contains_p1(arg,cadr(e),p);
28202829 e = caddr(e);
28212830 continue;
2822- } else if (TARNARY_ARGS(car(e))) {
2831+ } else if (TERNARY_ARGS(car(e))) {
28232832 /* tarary operators */
28242833 arg=contains_p1(arg,cadr(e), p);
28252834 arg=contains_p1(arg,caddr(e),p);
@@ -2840,6 +2849,169 @@
28402849 return arg;
28412850 }
28422851
2852+/* gahter accumurated list in all parse tree for all operator */
2853+
2854+static int
2855+contains_in_list_p2(int arg,int e,int (*p)(int,int))
2856+{
2857+ while(e) {
2858+ arg=contains_p2(arg,car(e),p);
2859+ e = cadr(e);
2860+ }
2861+ return arg;
2862+}
2863+
2864+extern int
2865+contains_p2(int arg,int e,int (*p)(int,int))
2866+{
2867+ while(e) {
2868+ if (!car(e)) return arg;
2869+ if (LIST_ARGS(car(e))){
2870+ /* list arguments */
2871+ arg=p(arg,e);
2872+ return contains_in_list_p2(arg,caddr(e),p);
2873+ } else if (UNARY_ARGS(car(e))) {
2874+ /* unary operators */
2875+ arg=p(arg,e);
2876+ e = cadr(e);
2877+ continue;
2878+ } else if (BINARY_ARGS(car(e))) {
2879+ /* biary operators */
2880+ arg=contains_p2(arg,cadr(e),p);
2881+ arg=p(arg,e);
2882+ e = caddr(e);
2883+ continue;
2884+ } else if (TERNARY_ARGS(car(e))) {
2885+ /* tarary operators */
2886+ arg=contains_p2(arg,cadr(e), p);
2887+ arg=contains_p2(arg,caddr(e),p);
2888+ arg=p(arg,e);
2889+ e = cadddr(e);
2890+ continue;
2891+ } else if (NULLARY_ARGS(car(e))) {
2892+ /* nullary operators */
2893+ arg=p(arg,e);
2894+ return arg;
2895+ } else if (IS_STATEMENT(car(e))) {
2896+ return arg;
2897+ } else {
2898+ // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
2899+ // error(-1);
2900+ return arg;
2901+ }
2902+ }
2903+ return arg;
2904+}
2905+
2906+//
2907+// globalize parse tree
2908+//
2909+
2910+static int
2911+copy_list(int e)
2912+{
2913+ int e1;
2914+ if (!e) return 0;
2915+ e1 = copy_expr(car(e));
2916+ return glist2(e1,copy_list(cadr(e)));
2917+ return 0;
2918+}
2919+
2920+extern int
2921+copy_expr(int e)
2922+{
2923+ int smode = mode;
2924+ if (!car(e)) return 0;
2925+ if (car(e)<0) {
2926+ mode = GDECL;
2927+ switch (car(e)){
2928+ case CONST: e=list2(car(e),cadr(e));
2929+ case FCONST:
2930+ case DCONST: e=dlist2(car(e),dcadr(e));
2931+ case LCONST: e=llist2(car(e),lcadr(e));
2932+ case STRING: e=list3(car(e),cadr(e),caddr(e));
2933+ case STRUCT: // for udpcl
2934+ e=glist3(car(e),copy_expr(cadr(e)),copy_expr(caddr(e)));
2935+ }
2936+ mode = smode;
2937+ return e;
2938+ }
2939+ switch (car(e)%SOP){
2940+ // special cases
2941+ case ARROW:
2942+ case PERIOD:
2943+ return glist4(car(e),copy_expr(cadr(e)),caddr(e),cadddr(e));
2944+ case ARRAY:
2945+ return glist5(car(e),copy_expr(cadr(e)),copy_expr(caddr(e)),cadddr(e),caddddr(e));
2946+ case LVAR: case RLVAR:
2947+ case GVAR: case RGVAR:
2948+ return (e>=lfree)?glist3(car(e),cadr(e),caddr(e)):e;
2949+ case INDIRECT: case RINDIRECT:
2950+ return glist2(car(e),copy_expr(cadr(e)));
2951+ }
2952+ if (LIST_ARGS(car(e))){
2953+ /* list arguments */
2954+ return copy_list(caddr(e));
2955+ } else if (UNARY_ARGS(car(e))) {
2956+ /* unary operators */
2957+ e = glist2(car(e),copy_expr(cadr(e)));
2958+ return e;
2959+ } else if (BINARY_ARGS(car(e))) {
2960+ /* biary operators */
2961+ e = glist3(car(e),copy_expr(cadr(e)),copy_expr(caddr(e)));
2962+ return e;
2963+ } else if (TERNARY_ARGS(car(e))||car(e)==STRUCT) {
2964+ /* ternary operators */
2965+ e = glist4(car(e),copy_expr(cadr(e)),
2966+ copy_expr(caddr(e)),
2967+ copy_expr(cadddr(e)));
2968+ return e;
2969+ } else if (NULLARY_ARGS(car(e))) {
2970+ /* nullary operators */
2971+ if (e>=lfree) { // local
2972+ int smode = mode;
2973+ switch(car(e)%SOP) {
2974+ case GVAR: case RGVAR: case URGVAR:
2975+ case LVAR: case RLVAR: case URLVAR:
2976+ case REGISTER: case FREGISTER:
2977+ case DREGISTER: case LREGISTER:
2978+ case STRING:
2979+ case IVAR: case RIVAR:
2980+ e = glist3(car(e),cadr(e),caddr(e)); break;
2981+ case CONST:
2982+ switch(car(e)) {
2983+ case CONST:
2984+ e = glist2(car(e),cadr(e)); break;
2985+ case DCONST: case FCONST:
2986+ mode=GDECL;
2987+ e = dlist2(car(e),dcadr(e)); mode = smode; break;
2988+ case LCONST:
2989+ mode=GDECL;
2990+ e = llist2(car(e),lcadr(e)); mode = smode; break;
2991+ }
2992+ break;
2993+ case LCALL:
2994+ case FNAME:
2995+ case LABEL:
2996+ e = glist2(car(e),cadr(e)); break;
2997+ case DECL:
2998+ case COMP:
2999+ // is this correct?
3000+ e = glist2(car(e),cadr(e)); break;
3001+ }
3002+ }
3003+ return e;
3004+ } else if (IS_STATEMENT(car(e))) {
3005+ // already in global heap
3006+ return e; // may contain anything
3007+ } else {
3008+ // fprintf(stderr,"Unknown Tree ID %d\n",car(e));
3009+ error(-1);
3010+ return 0;
3011+ }
3012+ return 0;
3013+}
3014+
28433015 #if ASM_CODE
28443016
28453017
@@ -3787,7 +3959,7 @@
37873959 int type0;
37883960 int e1;
37893961
3790- if (inmode) {
3962+ if (inmode || chk) {
37913963 e1 = list4(ind?ARROW:PERIOD,e,(int)nptr,type);
37923964 }
37933965 if (ind) e = indop(rvalue(e));
@@ -3802,7 +3974,7 @@
38023974 /* print_fields(caddr(type),"strop"); */
38033975 type = search_struct_type(type,nptr->nm,&dsp);
38043976 if (!type) { error(TYERR); type=INT; return e; }
3805- if (inmode) {
3977+ if (inmode || chk) {
38063978 // bitfield will be checked after parse
38073979 return e1;
38083980 } else if(dsp) {
@@ -4213,16 +4385,19 @@
42134385 return(e1);
42144386 if (car(e)==CONST) {
42154387 if(car(e1)==ADDRESS) {
4216- if (car(cadr(e1))==GVAR) {
4388+ switch (car(cadr(e1))) {
4389+ case GVAR:
42174390 return(list2(ADDRESS,
42184391 list3(GVAR,cadr(cadr(e1))+cadr(e),caddr(cadr(e1)))));
4219- } else if (car(cadr(e1))==LVAR) {
4392+ case LVAR:
42204393 return(list2(ADDRESS,
42214394 list3(car(cadr(e1)),cadr(cadr(e1))+cadr(e),
42224395 caddr(cadr(e1)))));
4223- } else if (car(cadr(e1))==INDIRECT) {
4396+ case INDIRECT:
4397+ case PERIOD:
4398+ case ARROW:
42244399 return(list3(ADD,e1,e));
4225- } else {
4400+ default:
42264401 error(-1); // ?
42274402 }
42284403 } else if(car(e1)==GVAR) {
diff -r a47434d01a70 -r add863b666c5 mc-codegen.h
--- a/mc-codegen.h Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-codegen.h Thu Mar 16 19:02:42 2006 +0900
@@ -111,6 +111,7 @@
111111 extern int b_expr(int e1, char cond, int l1,int err);
112112 extern int contains_p(int e,int (*p)(int));
113113 extern int contains_p1(int arg,int e,int (*p)(int,int));
114+extern int contains_p2(int arg,int e,int (*p)(int,int));
114115 extern void fwddef(int l);
115116 extern int fwdlabel(void);
116117 extern int g_expr(int e1);
@@ -137,4 +138,8 @@
137138
138139 extern NMTBL str_ret;
139140
141+/* used by conv */
142+extern int rop_dual(int op);
143+extern int copy_expr(int e);
144+
140145 /* end */
diff -r a47434d01a70 -r add863b666c5 mc-inline.c
--- a/mc-inline.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-inline.c Thu Mar 16 19:02:42 2006 +0900
@@ -399,7 +399,7 @@
399399 if (nptr0->ty>0&&car(nptr0->ty)==FUNCTION)
400400 car(nptr0->ty)=CODE;
401401 }
402- gexpr(list3(CODE,e1,env),0);
402+ gexpr(list3(JUMP,e1,env),0);
403403 control=0;
404404 // conv->sm_();
405405 return ;
@@ -815,7 +815,7 @@
815815 switch(car(e1)) {
816816 case RINDIRECT: e1=pexpr(e1); break;
817817 case CODE: e2=pexpr(cadr(e1));
818- e1=list3(CODE,e2,pexpr(caddr(e1))); break;
818+ e1=list3(JUMP,e2,pexpr(caddr(e1))); break;
819819 case FLABEL: /* error(-1); */ break;
820820 case IVAR:
821821 lb = cadr(e1);
@@ -943,7 +943,7 @@
943943 return p_lvar(e1);
944944 case FUNCTION:
945945 return pfunction(e1);
946- case CODE:
946+ case JUMP:
947947 e2 = pexpr(e2);
948948 return list3(car(e1),e2,pexpr(cadddr(e1)));
949949 case ARRAY:
diff -r a47434d01a70 -r add863b666c5 mc-macro.c
--- a/mc-macro.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-macro.c Thu Mar 16 19:02:42 2006 +0900
@@ -312,6 +312,7 @@
312312 int i;
313313 int c;
314314 char num[10];
315+ char *p;
315316
316317 if (next_eof) {
317318 next_eof=0;
@@ -335,6 +336,16 @@
335336 i=0;
336337 while ((*chptr++ = c = getc(filep->fcb)) != '\n') {
337338 if (++i > LBUFSIZE-2) error(LNERR);
339+ if (c=='\r') {
340+ c = getc(filep->fcb);
341+ if (c == '\n') {
342+ chptr[-1]='\n'; break;
343+ } else {
344+ // single cr equal to nl
345+ ungetc(c,filep->fcb);
346+ chptr[-1]=c='\n'; i--; break;
347+ }
348+ }
338349 if (c==EOF) {
339350 next_eof=1;
340351 --chptr;
@@ -349,7 +360,6 @@
349360 // inline mode
350361 int i=0;
351362 int c;
352- char *p;
353363 // should be done in some init
354364 if (!st_cheap) {
355365 st_cheap = cheap1 = new_cheap();
@@ -377,7 +387,9 @@
377387 }
378388 }
379389 }
380- if (*(chptr = linebuf) == '#' && !in_comment && !in_quote) {
390+ p = chptr = linebuf; while(*p==' '||*p=='\t') p++;
391+ if (*p == '#' && !in_comment && !in_quote) {
392+ chptr = p;
381393 if (macro_processing()) return;
382394 }
383395 } while(!in_quote && (macro_if_skip || linebuf[0] == '#'));
@@ -549,10 +561,16 @@
549561 return 0;
550562 }
551563 break;
564+ case 'p':
565+ if (macroeq("pragma")) {
566+ getline();
567+ return 0;
568+ }
569+ break;
552570 #if ASM_CODE
553571 // deprecated, use asm function
554572 case 'a':
555- if (c=='a'&&macroeq("asm")) {
573+ if (macroeq("asm")) {
556574 if (asmf) error(MCERR);
557575 asmf = 1;
558576 getline();
@@ -571,7 +589,7 @@
571589 }
572590 break;
573591 #endif
574- case ' ': case '\t':
592+ case ' ': case '\t': case '\n': case 0:
575593 getline();
576594 return 0;
577595 }
@@ -925,12 +943,12 @@
925943 *result = cheap->ptr;
926944 for(;lists;lists = cadr(lists)) {
927945 p = (char *)car(lists);
928- for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,0)) {
946+ for(;(*cheap->ptr = *p++);cheap = increment_cheap(cheap,result)) {
929947 // in_quote + \n case ? should be \n.
930948 if (p[-1]=='\n') cheap->ptr[0]=' ';
931949 }
932950 }
933- cheap = increment_cheap(cheap,0);
951+ cheap = increment_cheap(cheap,result);
934952 return *result;
935953 }
936954
@@ -942,12 +960,12 @@
942960 *result = cheap->ptr;
943961 for(;lists;lists = cadr(lists)) {
944962 p = (char *)car(lists);
945- for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,0)) {
963+ for(;(*cheap->ptr=*p++);cheap = increment_cheap(cheap,result)) {
946964 // in_quote + \n case ? should be \n.
947965 // if (p[-1]=='\n') cheap->ptr[0]=' ';
948966 }
949967 }
950- cheap = increment_cheap(cheap,0);
968+ cheap = increment_cheap(cheap,result);
951969 return *result;
952970 }
953971
diff -r a47434d01a70 -r add863b666c5 mc-parse.c
--- a/mc-parse.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-parse.c Thu Mar 16 19:02:42 2006 +0900
@@ -33,6 +33,8 @@
3333 #include "mc-inline.h"
3434 #include "conv/conv.h"
3535
36+extern Converter *conv;
37+
3638 #define FILES 10
3739 #define OUTPUT_FILE_NAME "mcout.s"
3840
@@ -205,7 +207,7 @@
205207 static int sdecl_f = 1; // in struct defenition (for converter)
206208 static int stypedecl; // in type defenition (for converter)
207209
208-static Converter *conv = &null_converter;
210+Converter *conv = &null_converter;
209211 /* Converter *conv = &c_converter; */
210212
211213 static char *ccout = 0; // output file name
@@ -591,7 +593,10 @@
591593 reserve("extern",EXTRN);
592594 reserve("defined",DEFINED);
593595 reserve("register",REGISTER);
596+#ifdef USE_CODE_KEYWORD
594597 reserve("code",CODE);
598+#endif
599+ reserve("__code__",CODE);
595600 reserve("environment",ENVIRONMENT);
596601 reserve("float",FLOAT);
597602 reserve("double",DOUBLE);
@@ -606,6 +611,7 @@
606611 reserve("__builtin_constant_p",BUILTINP);
607612 reserve("__builtin_expect",BUILTIN_EXPECT);
608613 reserve("__attribute__",ATTRIBUTE);
614+ reserve("__attribute",ATTRIBUTE);
609615 reserve("__label__",LABEL);
610616 reserve("__FILE__",C_FILE);
611617 reserve("__FUNCTION__",C_FUNCTION);
@@ -730,13 +736,14 @@
730736 while((*cheap->ptr = *s++)) cheap = increment_cheap(cheap,&filep->name0);
731737 *cheap->ptr = 0;
732738 cheap = increment_cheap(cheap,&filep->name0);
733- if(!ccout) {
739+ conv->open_(filep->name0);
740+
741+ if(!ccout && !chk) {
734742 ccout = make_filename_with_extension(filep->name0,"s");
735743 if ( (freopen(ccout,"w",stdout)) == NULL ) error(FILERR);
736744 ccout=0;
737745 }
738746 opening(filep->name0);
739- conv->open_(filep->name0);
740747
741748 if (init_src) {
742749 // before reading any file, perform initialization source
@@ -868,6 +875,7 @@
868875 conv->return_type_(t,0,stypedecl);
869876 conv->sm_(); return;
870877 }
878+ storage_class();
871879 type=t;sd=stypedecl;
872880 n=decl0();
873881 reverse(t);
@@ -2200,6 +2208,8 @@
22002208 doif(void)
22012209 {
22022210 int l1,l2=0,slfree,pparse=0;
2211+ int if0;
2212+
22032213 getsym(0);
22042214 checksym(LPAR);
22052215 conv->if_();
@@ -2207,12 +2217,12 @@
22072217 checkret();
22082218 if (inmode) {
22092219 pparse = parse; parse = 0;
2210- l1 = expr(0);
2220+ l1 = if0 = expr(0);
22112221 } else {
2212- l1 = bexpr(expr(0),0,fwdlabel());
2222+ l1 = bexpr((if0 = expr(0)),0,fwdlabel());
22132223 }
22142224 set_lfree(slfree);
2215- conv->if_then_();
2225+ conv->if_then_(if0);
22162226 checksym(RPAR);
22172227 statement(0);
22182228 checkret();
@@ -2267,7 +2277,7 @@
22672277 slfree=lfree;
22682278 e=expr(0);
22692279 checksym(RPAR);
2270- conv->while_body_();
2280+ conv->while_body_(e);
22712281 if(sym==SM) {
22722282 if (inmode) {
22732283 parse = list4(ST_WHILE,pparse,e,0);
@@ -2332,11 +2342,11 @@
23322342 e = expr(0);
23332343 parse = list4(ST_DO,pparse,e,l);
23342344 } else {
2335- bexpr(expr(0),1,l);
2345+ bexpr((e=expr(0)),1,l);
23362346 }
2347+ conv->dowhile_end_(e);
23372348 set_lfree(slfree);
23382349 checksym(RPAR);
2339- conv->dowhile_end_();
23402350 checksym(SM);
23412351 if (!inmode)
23422352 fwddef(blabel);
@@ -2377,7 +2387,11 @@
23772387 decl();
23782388 mode=STAT;
23792389 checkret();
2380- emit_init_vars();
2390+ if (chk) {
2391+ p0 = list3(ST_COMP,reverse0(init_vars),0);
2392+ } else {
2393+ emit_init_vars();
2394+ }
23812395 if (inmode) {
23822396 p0 = reverse0(parse); parse = 0;
23832397 }
@@ -2408,31 +2422,29 @@
24082422 if (inmode) {
24092423 p1 = expr(0);
24102424 } else {
2411- bexpr(expr(0),0,blabel);
2425+ bexpr((p1=expr(0)),0,blabel);
24122426 }
24132427 checksym(SM);
2414- conv->for2_();
2428+ conv->for2_(p1);
24152429 } else {
2416- conv->for2_();
2430+ conv->for2_(0);
24172431 p1 = 0;
24182432 getsym(0);
24192433 }
24202434 set_lfree(slfree);
2435+ e = 0;
24212436 if(sym==RPAR) {
24222437 // no continue expression
24232438 clabel=l;
2424- conv->for_body_();
2439+ conv->for_body_(0);
24252440 getsym(0);
24262441 statement(0);
24272442 checkret();
2428- if (inmode) {
2429- e = 0;
2430- }
24312443 } else {
24322444 // continue expression
24332445 clabel=fwdlabel();
24342446 e=expr(0);
2435- conv->for_body_();
2447+ conv->for_body_(e);
24362448 checksym(RPAR);
24372449 statement(0);
24382450 checkret();
@@ -2442,9 +2454,8 @@
24422454 }
24432455 set_lfree(slfree);
24442456 }
2445- lfree_type_limit = slimit ;
2457+ conv->for_end_(p0,p1,e);
24462458 if (dflag) leave_scope();
2447- conv->for_end_();
24482459 if (inmode) {
24492460 parse = list3(ST_FOR,pparse,list4(p0,p1,e,reverse0(parse)));
24502461 // parse = list3(ST_FOR,pparse,list4(p0,p1,e,parse));
@@ -2452,6 +2463,7 @@
24522463 gen_jmp(l);
24532464 fwddef(blabel);
24542465 }
2466+ lfree_type_limit = slimit ;
24552467 clabel=scontinue;
24562468 blabel=sbreak;
24572469 init_vars=sinit_vars;
@@ -2544,14 +2556,14 @@
25442556 csvalue1=cst ? glist2(CONST,cadr(v)): csvalue() ;
25452557 set_lfree(slfree);
25462558 checksym(RPAR);
2547- conv->switch_body_();
2559+ conv->switch_body_(v);
25482560 if (cst) {
25492561 gen_jmp( cslabel = fwdlabel());
25502562 } else {
25512563 cslabel = control = 0;
25522564 }
25532565 } else {
2554- conv->switch_body_();
2566+ conv->switch_body_(v);
25552567 checksym(RPAR);
25562568 }
25572569 /* next syntax should be a case statement but...
@@ -2568,7 +2580,7 @@
25682580 Can be done in checkret();
25692581 */
25702582 statement(0);
2571- conv->switch_end_();
2583+ conv->switch_end_(cslist);
25722584 checkret();
25732585 if (inmode) {
25742586 parse = list4(ST_SWITCH,pparse,v,reverse0(parse));
@@ -2780,7 +2792,7 @@
27802792 if(getsym(0)==SM) {
27812793 // should check fnptr have no return value
27822794 conv->return_();
2783- conv->return_end_();
2795+ conv->return_end_(0);
27842796 getsym(0);
27852797 if (inmode)
27862798 parse = list3(ST_RETURN,parse,0);
@@ -2822,12 +2834,12 @@
28222834 e = correct_type(expr(0),cadr(fnptr->ty));
28232835 parse = list3(ST_RETURN,parse,e);
28242836 } else {
2825- gexpr(correct_type(expr(0),cadr(fnptr->ty)),1);
2837+ gexpr(correct_type((e=expr(0)),cadr(fnptr->ty)),1);
28262838 }
28272839 }
2840+ conv->return_end_(e);
28282841 set_lfree(slfree);
28292842
2830- conv->return_end_();
28312843 checksym(SM);
28322844 /* control = 0; still control continue until pending return emission */
28332845 retpending = 1;
@@ -2851,9 +2863,9 @@
28512863 // car(nptr0->ty)=CODE;
28522864 }
28532865 if (inmode) {
2854- parse = list3(ST_GOTO,parse,list3(CODE,e1,env));
2866+ parse = list3(ST_GOTO,parse,list3(JUMP,e1,env));
28552867 } else {
2856- gexpr(list3(CODE,e1,env),0);
2868+ gexpr(list3(JUMP,e1,env),0);
28572869 }
28582870 control=0;
28592871 conv->sm_();
@@ -3346,6 +3358,9 @@
33463358 case REGISTER:
33473359 case GVAR:
33483360 case LVAR:
3361+ case ARRAY:
3362+ case ARROW:
3363+ case PERIOD:
33493364 e=list2(ADDRESS,e);
33503365 break;
33513366 case IVAR:
@@ -3833,7 +3848,7 @@
38333848 e2=rvalue(expr0());
38343849 checksym(RBRA);
38353850 conv->rbra_(sym);
3836- if (inmode) {
3851+ if (inmode || chk) {
38373852 e1 = list5(ARRAY,e1,e2,t,type);
38383853 if (car(t)!=POINTER)
38393854 error(-1);
@@ -3954,7 +3969,7 @@
39543969 error(AGERR);
39553970 }
39563971 checksym(RPAR);
3957- conv->funcall_args_();
3972+ conv->funcall_args_(e1,ftype,arglist);
39583973 if(t==CODE) {
39593974 if (stmode!=GOTO) error(FNERR);
39603975 // code segment has no return type
@@ -4481,6 +4496,10 @@
44814496 }
44824497 if ((nptrm->sc==MACRO&&neqname((char *)car(nptrm->dsp),nptrm->nm)) ||
44834498 (nptrm->sc==FMACRO&&skipspc()=='(')) {
4499+ if (in_macro_if && *((char*)car(nptrm->dsp))==0) {
4500+ symval = 0;
4501+ return (sym=CONST);
4502+ }
44844503 macro_expansion(nptrm);
44854504 sc=0; goto retry;
44864505 }
@@ -4807,7 +4826,7 @@
48074826 car(current_scope) = 0;
48084827 }
48094828
4810-extern void
4829+extern NMTBL *
48114830 extern_define(char *s,int d,int type,int use)
48124831 {
48134832 NMTBL *nptr0;
@@ -4815,6 +4834,7 @@
48154834 (nptr0 = name_space_search(get_name(s,0,DEF),0))->sc = EXTRN;
48164835 nptr0->dsp = d; nptr0->ty=type;
48174836 if (use) extrn_use(nptr0);
4837+ return nptr0;
48184838 }
48194839
48204840 /*
@@ -5101,6 +5121,21 @@
51015121 return ret;
51025122 }
51035123
5124+extern int
5125+glist5(int e1,int e2,int e3,int e4,int e5)
5126+{
5127+ int ret;
5128+ ret = gfree;
5129+ gfree+=4 ;
5130+ heap[ret]=e1;
5131+ heap[ret+1]=e2;
5132+ heap[ret+2]=e3;
5133+ heap[ret+3]=e4;
5134+ heap[ret+4]=e5;
5135+ if(lfree<gfree) error(HPERR);
5136+ return ret;
5137+}
5138+
51045139 extern void
51055140 free_glist3(int e1)
51065141 {
diff -r a47434d01a70 -r add863b666c5 mc-parse.h
--- a/mc-parse.h Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-parse.h Thu Mar 16 19:02:42 2006 +0900
@@ -129,13 +129,14 @@
129129 extern int glist2(int e1,int e2);
130130 extern int glist3(int e1,int e2,int e3);
131131 extern int glist4(int e1,int e2,int e3,int e4);
132+extern int glist5(int e1,int e2,int e3,int e4,int e5);
132133
133134 extern int insert_ascend(int p,int e,int eq());
134135 extern int length(int list);
135136 extern int list2(int e1, int e2);
136137 extern int list3(int e1, int e2, int e3);
137138 extern int list4(int e1, int e2, int e3, int e4);
138-extern void extern_define(char *s,int d,int type,int use);
139+extern NMTBL * extern_define(char *s,int d,int type,int use);
139140 extern void set_lfree(int save);
140141
141142 extern int has_attr(NMTBL *n,int attr);
diff -r a47434d01a70 -r add863b666c5 mc-switch.c
--- a/mc-switch.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-switch.c Thu Mar 16 19:02:42 2006 +0900
@@ -188,10 +188,12 @@
188188 int list;
189189 for(;count-->0;cslist=cadr(cslist)) {
190190 list = car(cslist);
191+#ifdef DEBUG_MERGE
191192 printf("## cascade cases delta=%d count=%d min=%d max=%d\n",
192193 caddr(cslist),car(cadddr(cslist)),
193194 cadr(cadddr(cslist)),caddr(cadddr(cslist))
194195 );
196+#endif
195197 for(;list; list=cadr(list)) {
196198 if (caddr(list))
197199 cmpdimm(car(list),csvalue1,caddr(list),0);
@@ -320,8 +322,10 @@
320322 {
321323 control=1;
322324 for(;count-- !=0 && merge;merge=cadr(merge)) {
325+#ifdef DEBUG_MERGE
323326 printf("## merge count %d delta %d c_count %d\n",
324327 car(merge),caddr(merge),cadddr(merge));
328+#endif
325329 if (cadddr(merge)>CASE_TABLE_COUNT) {
326330 chunks = table_jump(car(merge),caddr(merge),chunks);
327331 } else {
diff -r a47434d01a70 -r add863b666c5 mc-tree.c
--- a/mc-tree.c Sat Feb 18 21:43:41 2006 +0900
+++ b/mc-tree.c Thu Mar 16 19:02:42 2006 +0900
@@ -53,12 +53,14 @@
5353 {ENVIRONMENT,"environment",""},
5454 {CODE,"code",""},
5555 {REGISTER,"register",""},
56+ {ASM,"__asm__",""},
5657 {VOID,"void",""},
5758 {EXTRN,"extern",""},
5859 {SHORT,"short",""},
5960 {USHORT,"unsigned short",""},
6061 {LONG,"long",""},
6162 {TYPE,"type",""},
63+ {VOLATILE,"volatile",""},
6264 {SIZEOF,"sizeof",""},
6365 {TYPEDEF,"typedef",""},
6466 {FLABEL,"flabel",""},
@@ -70,7 +72,7 @@
7072 {TAG,"tag",""},
7173 {RESERVE,"reserve",""},
7274 {DEFAULT,"default",""},
73- {ATTRIBUTE,"attribute",""},
75+ {ATTRIBUTE,"__attribute__",""},
7476 {CASE,"case",""},
7577 {SWITCH,"switch",""},
7678 {WHILE,"while",""},
@@ -464,4 +466,129 @@
464466 type_print1(type,n,out,0);
465467 }
466468
469+/*
470+ parse tree を印刷する
471+
472+ 正しく括弧とかを付けるアルゴリズムが不明...
473+ 先読みして、優先順位を判別する必要があるはず。
474+ */
475+
476+void
477+print_expr(int e, FILE *vout)
478+{
479+ NMTBL *nptr,*n;
480+
481+ switch (car(e)%SOP) {
482+ case LVAR:
483+ case RLVAR:
484+ if ((nptr = (NMTBL*)caddr(e))) {
485+ fprintf(vout,"%s",nptr->nm);
486+ } else {
487+ // anonymous variable
488+ fprintf(vout,"_%d",caddr(e));
489+ }
490+ break;
491+ case GVAR:
492+ case RGVAR:
493+ if ((nptr = (NMTBL*)caddr(e))) {
494+ fprintf(vout,"%s",nptr->nm);
495+ } else {
496+ // anonymous variable
497+ fprintf(vout,"_%d",caddr(e));
498+ }
499+ if (cadr(e)) {
500+ // offset
501+ // certainly this is wrong
502+ fprintf(vout,"+%d",caddr(e));
503+ }
504+ break;
505+ case REGISTER:
506+ if ((nptr = (NMTBL*)caddr(e))) {
507+ fprintf(vout,"%s",nptr->nm);
508+ } else {
509+ // anonymous register variable
510+ fprintf(vout,"_%d",caddr(e));
511+ }
512+ break;
513+ case IDENT:
514+ nptr = (NMTBL*)cadr(e);
515+ fprintf(vout,"%s",nptr->nm); break;
516+ case CONST:
517+ switch(car(e)) {
518+ case CONST:
519+ fprintf(vout,"%d",cadr(e)); break;
520+#if FLOAT_CODE
521+ case FCONST:
522+ fprintf(vout,"%g",dcadr(e)); break;
523+ case DCONST:
524+ fprintf(vout,"%g",dcadr(e)); break;
525+#endif
526+#if LONGLONG_CODE
527+ case LCONST:
528+ fprintf(vout,"%lld",lcadr(e)); break;
529+#endif
530+ }
531+ break;
532+ case ADDRESS:
533+ if (car(cadr(e))!=STRING) {
534+ fprintf(vout,"&");
535+ print_expr(cadr(e),vout);
536+ break;
537+ }
538+ case STRING:
539+ {
540+ nptr = (NMTBL*)cadr(e);
541+ int c; char *s = nptr->nm; int i=nptr->dsp;
542+ fprintf(vout,"\"");
543+ while(--i>0) {
544+ c=*s++;
545+ if(c=='\n') fprintf(vout,"\\n");
546+ else if(c=='\r') fprintf(vout,"\\r");
547+ else if(c=='\t') fprintf(vout,"\\t");
548+ else if(c=='\e') fprintf(vout,"\\e");
549+ else if(c=='"') fprintf(vout,"\\\"");
550+ else if(c=='\\') fprintf(vout,"\\\\");
551+ else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
552+ else fprintf(vout,"%c",c);
553+ }
554+ fprintf(vout,"\"");
555+ }
556+ break;
557+ case ARRAY:
558+ print_expr(cadr(e),vout);
559+ fprintf(vout,"[");
560+ print_expr(caddr(e),vout);
561+ fprintf(vout,"]");
562+ break;
563+ case PERIOD:
564+ print_expr(cadr(e),vout);
565+ n = (NMTBL*)caddr(e);
566+ fprintf(vout,".%s",n->nm);
567+ break;
568+ case ARROW:
569+ print_expr(cadr(e),vout);
570+ n = (NMTBL*)caddr(e);
571+ fprintf(vout,"->%s",n->nm);
572+ break;
573+ case INDIRECT:
574+ case RINDIRECT:
575+ fprintf(vout,"*");
576+ print_expr(cadr(e),vout);
577+ break;
578+ case FNAME:
579+ n = (NMTBL*)cadr(e);
580+ fprintf(vout,"%s",n->nm);
581+ break;
582+ case ADD:
583+ fprintf(vout,"(");
584+ print_expr(cadr(e),vout);
585+ fprintf(vout,"+");
586+ print_expr(caddr(e),vout);
587+ fprintf(vout,")");
588+ break;
589+ default:
590+ error(-1);
591+ }
592+}
593+
467594 /* end */
diff -r a47434d01a70 -r add863b666c5 mc.h
--- a/mc.h Sat Feb 18 21:43:41 2006 +0900
+++ b/mc.h Thu Mar 16 19:02:42 2006 +0900
@@ -68,46 +68,47 @@
6868 #define FREGISTER (-29)
6969 #define DREGISTER (-30)
7070 #define LREGISTER (-31)
71+#define POSSIBLE_VALUES (-32)
7172
72-#define DOTS (-32)
73+#define DOTS (-33)
7374
7475 /* keyword */
7576
76-#define GOTO (-33)
77-#define RETURN (-34)
78-#define BREAK (-35)
79-#define CONTINUE (-36)
80-#define IF (-37)
81-#define ELSE (-38)
82-#define FOR (-39)
83-#define DO (-40)
84-#define WHILE (-41)
85-#define SWITCH (-42)
86-#define CASE (-43)
87-#define DEFAULT (-44)
88-#define RESERVE (-45)
89-#define TAG (-46)
90-#define FIELD (-47)
91-#define IDENT (-48)
92-#define MACRO (-49)
93-#define BLABEL (-50)
94-#define FLABEL (-51)
95-#define TYPEDEF (-52)
96-#define SIZEOF (-53)
97-#define TYPE (-54)
98-#define DEFINED (-55)
77+#define GOTO (-34)
78+#define RETURN (-35)
79+#define BREAK (-36)
80+#define CONTINUE (-37)
81+#define IF (-38)
82+#define ELSE (-39)
83+#define FOR (-40)
84+#define DO (-41)
85+#define WHILE (-42)
86+#define SWITCH (-43)
87+#define CASE (-44)
88+#define DEFAULT (-45)
89+#define RESERVE (-46)
90+#define TAG (-47)
91+#define FIELD (-48)
92+#define IDENT (-49)
93+#define MACRO (-50)
94+#define BLABEL (-51)
95+#define FLABEL (-52)
96+#define TYPEDEF (-53)
97+#define SIZEOF (-54)
98+#define TYPE (-55)
99+#define DEFINED (-56)
99100
100-#define ENVIRONMENT (-56)
101-
102-#define FMACRO (-57)
103-#define LMACRO (-58)
101+#define ENVIRONMENT (-57)
104102
105-#define TYPEOF (-59)
106-#define ASM (-60)
103+#define FMACRO (-58)
104+#define LMACRO (-59)
107105
108-#define C_FILE (-61)
109-#define C_FUNCTION (-62)
110-#define C_LINE (-63)
106+#define TYPEOF (-60)
107+#define ASM (-61)
108+
109+#define C_FILE (-62)
110+#define C_FUNCTION (-63)
111+#define C_LINE (-64)
111112
112113 /* reserved word end */
113114
@@ -196,15 +197,17 @@
196197 #define LNOT 19
197198 #define BNOT 20
198199 #define INC 21
199-#define POSTINC 22
200-#define UPOSTINC 23
201-#define PREINC 24
202-#define UPREINC 25
203-#define POSTDEC 26
204-#define UPOSTDEC 27
205-#define PREDEC 28
206-#define UPREDEC 29
207-#define DEC 30
200+#define PERIOD 22
201+#define ARROW 23
202+#define POSTINC 24
203+#define UPOSTINC 25
204+#define PREINC 26
205+#define UPREINC 27
206+#define POSTDEC 28
207+#define UPOSTDEC 29
208+#define PREDEC 30
209+#define UPREDEC 31
210+#define DEC 32
208211 #define CPOSTINC (COP+POSTINC)
209212 #define CUPOSTINC (COP+UPOSTINC)
210213 #define CPREINC (COP+PREINC)
@@ -229,9 +232,9 @@
229232 #define LPREINC (LOP+PREINC)
230233 #define LUPOSTINC (LOP+UPOSTINC)
231234 #define LUPREINC (LOP+UPREINC)
232-#define INDIRECT 31
233-#define RINDIRECT 32
234-#define URINDIRECT 33
235+#define INDIRECT 33
236+#define RINDIRECT 34
237+#define URINDIRECT 35
235238 #define CRINDIRECT (COP+RINDIRECT)
236239 #define CURINDIRECT (COP+URINDIRECT)
237240 #define SRINDIRECT (SOP+RINDIRECT)
@@ -240,17 +243,15 @@
240243 #define DRINDIRECT (DOP+RINDIRECT)
241244 #define LRINDIRECT (LOP+RINDIRECT)
242245 #define LURINDIRECT (LOP+URINDIRECT)
243-#define RSTRUCT 34
244-#define ALLOCA 35
245-#define BUILTINP 36
246-#define BUILTIN_EXPECT 37
247-#define ATTRIBUTE 38
248-#define BIT_FIELD 39
249-#define RBIT_FIELD 40
250-#define BPREINC 41
251-#define BPOSTINC 42
252-#define RPERIOD 43
253-#define RARROW 44
246+#define RSTRUCT 36
247+#define ALLOCA 37
248+#define BUILTINP 38
249+#define BUILTIN_EXPECT 39
250+#define ATTRIBUTE 40
251+#define BIT_FIELD 41
252+#define RBIT_FIELD 42
253+#define BPREINC 43
254+#define BPOSTINC 44
254255 #define CONV 45
255256
256257 #define UNARY_ARGS(i) (ADDRESS<=(i%SOP)&&(i%SOP)<=CONV)
@@ -356,15 +357,17 @@
356357 #define BASSOP 86
357358 #define BFD_REPL 87
358359
359-#define STASS 88
360+#define JUMP 88
361+
362+#define STASS 89
360363
361364
362-#define BINARY_ARGS(i) (MUL<=(i%SOP)&&(i%SOP)<=STASS)
365+#define BINARY_ARGS(i) ((MUL<=(i%SOP)&&(i%SOP)<=STASS))
363366
364-/* tarnary argments */
367+/* ternary argments */
365368
366-#define COND 89
367-#define UCOND 90
369+#define COND 90
370+#define UCOND 91
368371 #define SCOND (SOP+COND)
369372 #define SUCOND (SOP+UCOND)
370373 #define DCOND (DOP+COND)
@@ -372,39 +375,37 @@
372375 #define LCOND (LOP+COND)
373376 #define LUCOND (LOP+UCOND)
374377
375-#define TARNARY_ARGS(i) (COND==(i%SOP)||UCOND==(i%SOP))
378+#define TERNARY_ARGS(i) (COND==(i%SOP)||UCOND==(i%SOP))
376379
377380 /* not appeared as tags */
378381
379-#define LPAR 91
380-#define RPAR 92
381-#define LBRA 93
382-#define RBRA 94
383-#define LC 95
384-#define RC 96
385-#define COLON 97
386-#define SM 98
387-#define PERIOD 99
388-#define ARROW 100
389-#define CNAME 101
382+#define LPAR 92
383+#define RPAR 93
384+#define LBRA 94
385+#define RBRA 95
386+#define LC 96
387+#define RC 97
388+#define COLON 98
389+#define SM 99
390+#define CNAME 100
390391
391-#define I2C 102
392-#define I2S 103
393-#define I2I 104
394-#define I2U 105
395-#define I2D 106
396-#define I2F 107
397-#define I2LL 108
398-#define I2ULL 109
392+#define I2C 101
393+#define I2S 102
394+#define I2I 103
395+#define I2U 104
396+#define I2D 105
397+#define I2F 106
398+#define I2LL 107
399+#define I2ULL 108
399400
400-#define U2UC 110
401-#define U2US 111
402-#define U2I 112
403-#define U2U 113
404-#define U2D 114
405-#define U2F 115
406-#define U2LL 116
407-#define U2ULL 117
401+#define U2UC 109
402+#define U2US 110
403+#define U2I 111
404+#define U2U 112
405+#define U2D 113
406+#define U2F 114
407+#define U2LL 115
408+#define U2ULL 116
408409
409410
410411 #define D2I (DOP+I2I)
@@ -439,27 +440,27 @@
439440
440441 /* statement start */
441442
442-#define ST_DECL 118
443-#define ST_IF 119
444-#define ST_DO 120
445-#define ST_WHILE 121
446-#define ST_FOR 122
447-#define ST_SWITCH 123
448-#define ST_COMP 124
449-#define ST_BREAK 125
450-#define ST_CONTINUE 126
451-#define ST_CASE 127
452-#define ST_DEFAULT 128
453-#define ST_RETURN 129
454-#define ST_GOTO 130
455-#define ST_ASM 131
456-#define ST_LABEL 132
457-#define ST_OP 133
458-#define ST_COMMENT 134
443+#define ST_DECL 117
444+#define ST_IF 118
445+#define ST_DO 119
446+#define ST_WHILE 120
447+#define ST_FOR 121
448+#define ST_SWITCH 122
449+#define ST_COMP 123
450+#define ST_BREAK 124
451+#define ST_CONTINUE 125
452+#define ST_CASE 126
453+#define ST_DEFAULT 127
454+#define ST_RETURN 128
455+#define ST_GOTO 129
456+#define ST_ASM 130
457+#define ST_LABEL 131
458+#define ST_OP 132
459+#define ST_COMMENT 133
459460
460461 #define IS_STATEMENT(i) (i==INLINE||(ST_DECL<=i&&i<=ST_COMMENT))
461462
462-#define HAS_ADDRESS 135
463+#define HAS_ADDRESS 134
463464
464465 /* statement end */
465466
@@ -515,9 +516,10 @@
515516 #define MAX_INCLUDE_PATH_COUNT 10
516517 /*
517518 For this comiler 8192*2 is Ok. Linux kernel requires 8192*4.
519+ we need automatic increment of gsyms?
518520 */
519-#define GSYMS (8192*4)
520-#define HEAPSIZE 30000
521+#define GSYMS (8192*32)
522+#define HEAPSIZE 120000
521523 #define CHEAPSIZE (sizeof(NMTBL)*8192)
522524 #define LBUFSIZE 4096
523525 #define STRSIZE 4096
@@ -553,6 +555,10 @@
553555 extern void free_nptr(NMTBL *n);
554556 extern NMTBL *get_nptr();
555557
558+// mc-tree.c
559+
560+extern void print_expr(int e, FILE *vout);
561+
556562 #if 1
557563 extern int heapsize;
558564 #define CHECK_HEAP(b) ({int _k=(int)(b);if(_k>heapsize||_k<0)error(-1);_k;})
Show on old repository browser