annotate mc-tree.c @ 935:7672a37e7545 default tip

Raspbery PI ARM support begin
author kono
date Sat, 24 Dec 2016 03:02:57 +0000
parents f7803d618f36
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
1 /* Micro-C tree print routine */
607
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
2
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
3 /************************************************************************
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
4 ** Copyright (C) 2006 Shinji Kono
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
5 ** 連絡先: 琉球大学情報工学科 河野 真治
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
6 ** (E-Mail Address: kono@ie.u-ryukyu.ac.jp)
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
7 **
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
8 ** このソースのいかなる複写,改変,修正も許諾します。ただし、
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
9 ** その際には、誰が貢献したを示すこの部分を残すこと。
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
10 ** 再配布や雑誌の付録などの問い合わせも必要ありません。
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
11 ** 営利利用も上記に反しない範囲で許可します。
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
12 ** バイナリの配布の際にはversion messageを保存することを条件とします。
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
13 ** このプログラムについては特に何の保証もしない、悪しからず。
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
14 **
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
15 ** Everyone is permitted to do anything on this program
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
16 ** including copying, modifying, improving,
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
17 ** as long as you don't try to pretend that you wrote it.
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
18 ** i.e., the above copyright notice has to appear in all copies.
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
19 ** Binary distribution requires original version messages.
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
20 ** You don't have to ask before copying, redistribution or publishing.
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
21 ** THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE.
e055df7c1082 *** empty log message ***
kono
parents: 599
diff changeset
22 ***********************************************************************/
1
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
23
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 81
diff changeset
24 #include <stdio.h>
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
25 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 81
diff changeset
26 #include "mc-parse.h"
596
94d3a8c1b3e8 *** empty log message ***
kono
parents: 564
diff changeset
27 #include "mc-codegen.h"
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
28
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
29 extern void tree_print(int e);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
30 extern void tree_parse(int e);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
31 extern void tree_print_t(int e,int t);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
32 extern void type_print(int type,NMTBL *n,FILE *out);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
33 extern void type_print1(int type,NMTBL *n,FILE *out,int cont);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
34 extern void sym_print(int type,FILE *out);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
35 static void print_function_call(int e, FILE *out);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
36 static void print_operator(int e, FILE *vout);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
37 static void print_statement(int e, FILE *vout);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
38
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
39 /* ascendant order for binary search */
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
40
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
41 typedef
d35df41eac69 Initial revision
kono
parents:
diff changeset
42 struct tree_node {
d35df41eac69 Initial revision
kono
parents:
diff changeset
43 int tree_type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
44 char *tree_name;
d35df41eac69 Initial revision
kono
parents:
diff changeset
45 char *tree_args;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
46 int tree_order;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
47 } tree_node_type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
48
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
49 static int
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
50 tree_nodes(int id, char **name, char **args, int *order) {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
51 int found = 1;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
52 switch(id%SOP) {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
53 case DOTS: *name = "..."; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
54 case LMACRO: *name = "lmacro"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
55 case FMACRO: *name = "fmacro"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
56 case KONST: *name = "const"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
57 case DEFINED: *name = "defined"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
58 case ENVIRONMENT: *name = "environment"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
59 case CODE: *name = "code"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
60 case C_FILE: *name = "__FILE__"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
61 case C_FUNCTION: *name = "__FUNCTION__"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
62 case C_LINE: *name = "__LINE__"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
63 case REGISTER: *name = "register"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
64 case CAST: *name = "cast"; *args="e"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
65 case ASM: *name = "__asm__"; *args="eeee"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
66 case ST_ASM: *name = "__asm__"; *args="eeee"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
67 case VOID: *name = "void"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
68 case EXTRN: *name = "extern"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
69 case EXTRN1: *name = "extern"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
70 case SHORT: *name = "short"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
71 case USHORT: *name = "unsigned short"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
72 case LONG: *name = "long"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
73 case TYPE: *name = "type"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
74 case VOLATILE: *name = "volatile"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
75 case SIZEOF: *name = "sizeof"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
76 case TYPEDEF: *name = "typedef"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
77 case FLABEL: *name = "flabel"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
78 case BLABEL: *name = "blabel"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
79 case LABEL: *name = "label"; *args="e"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
80 case ST_LABEL: *name = "label"; *args="e"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
81 case MACRO: *name = "macro"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
82 case STRING: *name = "string"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
83 case IDENT: *name = "ident"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
84 case ENUM: *name = "enum"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
85 case FIELD: *name = "field"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
86 case TAG: *name = "tag"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
87 case RESERVE: *name = "reserve"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
88 case ST_DEFAULT: *name = "default"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
89 case ATTRIBUTE: *name = "__attribute__"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
90 case ST_CASE: *name = "case"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
91 case ST_SWITCH: *name = "switch"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
92 case ST_WHILE: *name = "while"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
93 case ST_DO: *name = "do"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
94 case ST_FOR: *name = "for"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
95 case ELSE: *name = "else"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
96 case ST_IF: *name = "if"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
97 case CONTINUE: *name = "continue"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
98 case BREAK: *name = "break"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
99 case ST_RETURN: *name = "return"; *args="e"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
100 case RETURN: *name = "return"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
101 case ST_GOTO: *name = "goto"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
102 case JUMP: *name = "goto"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
103 case STATIC: *name = "static"; *args=""; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
104 case EMPTY: *name = "empty"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
105 case FUNCTION: *name = "function"; *args="t"; *order=15; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
106 case UNION: *name = "union"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
107 case STRUCT: *name = "struct"; *args="vt"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
108 case ARRAY: *name = "array"; *args="tv"; *order=16; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
109 case POINTER: *name = "*"; *args="t"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
110 case UNSIGNED: *name = "unsigned"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
111 case INLINE: *name = "inline"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
112 case SIGNED: *name = "signed"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
113 case CHAR: *name = "char"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
114 case UCHAR: *name = "unsigned char"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
115 case INT: *name = "int"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
116 case FLOAT: *name = "float"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
117 case DOUBLE: *name = "double"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
118 case LONGLONG: *name = "long long"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
119 case ULONGLONG: *name = "unsigned long long"; *args=""; *order=-1; break;
37
412ad2e6c2a2 struct copy
kono
parents: 33
diff changeset
120
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
121 case GVAR: *name = "gvar"; *args="vs"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
122 case IVAR: *name = "ivar"; *args="vs"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
123 case RGVAR: *name = "rgvar"; *args="vs"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
124 case CRGVAR: *name = "crgvar"; *args="vs"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
125 case LVAR: *name = "lvar"; *args="v"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
126 case RLVAR: *name = "rlvar"; *args="v"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
127 case CRLVAR: *name = "crlvar"; *args="v"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
128 case CONST: *name = "const"; *args="v"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
129 case FNAME: *name = "fname"; *args="n"; *order=14; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
130 case MUL: *name = "*"; *args="e"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
131 case RINDIRECT: *name = "*"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
132 case CRINDIRECT: *name = "*"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
133 case ADDRESS: *name = "&"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
134 case BAND: *name = "&"; *args="e"; *order=7; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
135 case MINUS: *name = "-"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
136 case LNOT: *name = "!"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
137 case BNOT: *name = "~"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
138 case INC: *name = "++"; *args=""; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
139 case ALLOCA: *name = "alloca"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
140 case BUILTINP: *name = "__builtinp"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
141 case BUILTIN_EXPECT: *name = "__builtin_expect"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
142 case BUILTIN_FABSF: *name = "__builtin_fabsf"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
143 case BUILTIN_FABS: *name = "__builtin_fbas"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
144 case BUILTIN_FABSL: *name = "__builtin_fbasl"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
145 case BUILTIN_INFF: *name = "__builtin_inff"; *args=""; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
146 case BUILTIN_INF: *name = "__builtin_inf"; *args=""; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
147 case BUILTIN_INFL: *name = "__builtin_infl"; *args=""; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
148 case POSTINC: *name = "++"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
149 case BPOSTINC: *name = "++"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
150 case PREINC: *name = "++"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
151 case CPOSTINC: *name = "++"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
152 case CPREINC: *name = "++"; *args="ee"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
153 case DEC: *name = "--"; *args="e"; *order=13; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
154 case DIV: *name = "/"; *args="ee"; *order=12; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
155 case UDIV: *name = "/"; *args="ee"; *order=12; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
156
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
157 case UMUL: *name = "*"; *args="ee"; *order=12; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
158 case MOD: *name = "%"; *args="ee"; *order=12; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
159 case UMOD: *name = "%"; *args="ee"; *order=12; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
160 case ADD: *name = "+"; *args="ee"; *order=11; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
161 case SUB: *name = "-"; *args="ee"; *order=11; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
162 case RSHIFT: *name = ">>"; *args="ee"; *order=10; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
163 case URSHIFT: *name = ">>"; *args="ee"; *order=10; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
164 case LSHIFT: *name = "<<"; *args="ee"; *order=10; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
165 case ULSHIFT: *name = "<<"; *args="ee"; *order=10; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
166 case GT: *name = ">"; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
167 case UGT: *name = ">"; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
168 case GE: *name = ">="; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
169 case UGE: *name = ">="; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
170 case LT: *name = "<"; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
171 case ULT: *name = "<"; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
172 case LE: *name = "<="; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
173 case ULE: *name = "<="; *args="ee"; *order=9; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
174 case EQ: *name = "=="; *args="ee"; *order=8; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
175 case NEQ: *name = "!="; *args="ee"; *order=8; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
176
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
177 case EOR: *name = "^"; *args="ee"; *order=6; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
178 case BOR: *name = "|"; *args="ee"; *order=5; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
179 case LAND: *name = "&&"; *args="ee"; *order=4; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
180 case LOR: *name = "||"; *args="ee"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
181 case COND: *name = "?"; *args="eee"; *order=2; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
182 case ASS: *name = "="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
183 case ASSOP: *name = "assop"; *args="eev"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
184 case CASSOP: *name = "cassop"; *args="eev"; *order=1; break;
861
c005a392e27e fix for Marvaricks
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 712
diff changeset
185 case COMMA: *name = ","; *args="ee"; *order=0; break;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
186 case LPAR: *name = "("; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
187 case RPAR: *name = ")"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
188 case LBRA: *name = "["; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
189 case RBRA: *name = "]"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
190 case LC: *name = "{"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
191 case RC: *name = "}"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
192 case COLON: *name = ":"; *args="ee"; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
193 case SM: *name = ";"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
194 case PERIOD: *name = "."; *args=""; *order=16; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
195 case ARROW: *name = "->"; *args=""; *order=16; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
196 case SASS: *name = "sass"; *args=""; *order=-1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
197 case AS+MUL: *name = "*="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
198 case AS+UMUL: *name = "*="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
199 case AS+DIV: *name = "/="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
200 case AS+UDIV: *name = "/="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
201 case AS+MOD: *name = "%="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
202 case AS+UMOD: *name = "%="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
203 case AS+ADD: *name = "+="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
204 case AS+MINUS: *name = "-="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
205 case AS+RSHIFT: *name = ">>="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
206 case AS+URSHIFT: *name = ">>="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
207 case AS+LSHIFT: *name = "<<="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
208 case AS+ULSHIFT: *name = "<<="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
209 case AS+BAND: *name = "&="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
210 case AS+EOR: *name = "^="; *args="ee"; *order=1; break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
211 case AS+BOR: *name = "|="; *args="ee"; *order=1; break;
914
kono
parents: 902
diff changeset
212 case RESTRICT: *name = "restrict"; *args=""; *order=1; break;
kono
parents: 902
diff changeset
213 case TYPEOF: *name = "typeof"; *args="e"; *order=1; break;
kono
parents: 902
diff changeset
214 case BUILTIN_TYPES_COMPATIBLE_P: *name = "__builtin_types_compatible_p"; *args="e"; *order=1; break;
kono
parents: 902
diff changeset
215 case FOR: *name = "for"; *args="eee"; *order=1; break;
kono
parents: 902
diff changeset
216 case IF: *name = "if"; *args="ee"; *order=1; break;
kono
parents: 902
diff changeset
217 case SWITCH: *name = "switch"; *args="ee"; *order=1; break;
kono
parents: 902
diff changeset
218 case CASE: *name = "case"; *args="e"; *order=1; break;
kono
parents: 902
diff changeset
219 case DEFAULT: *name = "default"; *args=""; *order=1; break;
kono
parents: 902
diff changeset
220 case WHILE: *name = "while"; *args="ee"; *order=1; break;
kono
parents: 902
diff changeset
221 case GOTO: *name = "goto"; *args="e"; *order=1; break;
kono
parents: 902
diff changeset
222 case DO: *name = "do"; *args="ee"; *order=1; break;
kono
parents: 902
diff changeset
223
kono
parents: 902
diff changeset
224 default:
kono
parents: 902
diff changeset
225 found = 0;
kono
parents: 902
diff changeset
226
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
227 fprintf(stderr,"Unknown ID %d [%d]in find node\n",id,OP(id));
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
228
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
229 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
230 return found;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
231 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
232
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
233 static int
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
234 attr_print(int t)
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
235 {
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
236 while (t>0 && car(t)==ATTRIBUTE) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
237 switch (caddr(t)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
238 case KONST: printf( "const"); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
239 case VOLATILE: printf( "volatile"); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
240 case RESTRICT: printf( "restrict"); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
241 case INLINE: printf( "inline"); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
242 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
243 t = cadr(t);
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
244 }
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
245 return t;
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
246 }
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
247
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
248 void
50
kono
parents: 37
diff changeset
249 tree_print_t(int e,int t)
kono
parents: 37
diff changeset
250 {
kono
parents: 37
diff changeset
251 printf("# type: ");
kono
parents: 37
diff changeset
252 tree_print(t);
kono
parents: 37
diff changeset
253 printf("expr: ");
kono
parents: 37
diff changeset
254 tree_print(e);
kono
parents: 37
diff changeset
255 printf("\n");
kono
parents: 37
diff changeset
256 }
kono
parents: 37
diff changeset
257
kono
parents: 37
diff changeset
258 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
259 tree_print(int e)
d35df41eac69 Initial revision
kono
parents:
diff changeset
260 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
261 printf("* generate code on type:\n* ");
d35df41eac69 Initial revision
kono
parents:
diff changeset
262 tree_parse(type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
263 printf("\n* expr:\n* ");
d35df41eac69 Initial revision
kono
parents:
diff changeset
264 tree_parse(e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
265 printf("\n");
d35df41eac69 Initial revision
kono
parents:
diff changeset
266 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
267
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
268 static
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
269 int tree_level;
d35df41eac69 Initial revision
kono
parents:
diff changeset
270
18
df7fa8cee67b pass -Wall
kono
parents: 1
diff changeset
271 void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
272 tree_parse(int e)
d35df41eac69 Initial revision
kono
parents:
diff changeset
273 {
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
274 tree_node_type node_type,*t;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
275 int i,j;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
276 char *s, **p;
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
277 NMTBL **n;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
278
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
279 t = &node_type; t->tree_type=e;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
280
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
281 if(e<0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
282 if (tree_nodes(e,&t->tree_name,&t->tree_args,&t->tree_order)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
283 for(j=0;j<tree_level;j++) putchar(' ');
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
284 printf("list(%s)",t->tree_name);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
285 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
286 } else {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
287 i = car(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
288 if (tree_nodes(e,&t->tree_name,&t->tree_args,&t->tree_order)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
289 tree_level++;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
290 for(j=0;j<tree_level;j++) putchar(' ');
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
291 printf("list(%s",t->tree_name);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
292 for(i=1,s=t->tree_args;*s;s++,i++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
293 switch(*s) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
294 case 'e':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
295 case 't':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
296 printf(",\n*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
297 tree_parse(heap[e+i]); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
298 case 'v':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
299 printf(",%d",heap[e+i]); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
300 case 'n':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
301 n = (NMTBL**)&(heap[e+i]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
302 printf(",%s",(*n)->nm); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
303 case 's':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
304 p = (char**)&(heap[e+i]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
305 printf(",%s",*p); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
306 case 'i':
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
307 printf(",%d",heap[e+i]); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
308 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
309 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
310 tree_level--;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
311 printf(")");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
312 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
313 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
314 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
315
254a0c576114 argument type list
kono
parents: 50
diff changeset
316 void struct_type_print(int type,FILE *out)
254a0c576114 argument type list
kono
parents: 50
diff changeset
317 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
318 NMTBL *n;
254a0c576114 argument type list
kono
parents: 50
diff changeset
319 int tags;
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
320 if((n=ncadddr(type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
321 fprintf(out,"%s ",n->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
322 return;
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
323 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
324 if((tags=caddr(type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
325 fprintf(out,"{");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
326 while(tags) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
327 n=ncaddr(tags);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
328 type_print(car(tags),n,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
329 fprintf(out,";");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
330 tags = cadr(tags);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
331 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
332 fprintf(out,"}");
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
333 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
334 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
335
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
336 void function_type_print1(int type,NMTBL *n,FILE *out,int cont)
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
337 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
338 int args;
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
339 type_print1(cadr(type),0,out,cont);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
340 if(n) fprintf(out," %s",n->nm);
254a0c576114 argument type list
kono
parents: 50
diff changeset
341 fprintf(out,"(");
254a0c576114 argument type list
kono
parents: 50
diff changeset
342 if((args=caddr(type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
343 while (args) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
344 type_print(car(args),0,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
345 args=cadr(args);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
346 if (args) fprintf(out,",");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
347 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
348 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
349 fprintf(out,")");
254a0c576114 argument type list
kono
parents: 50
diff changeset
350 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
351
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
352 void function_type_print(int type,NMTBL *n,FILE *out)
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
353 {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
354 function_type_print1(type,n,out,0);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
355 }
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
356
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
357 void sym_print(int sym,FILE *out)
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
358 {
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
359 tree_node_type tn;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
360 if (!(tree_nodes(sym,&tn.tree_name,&tn.tree_args,&tn.tree_order))) { error(-1); return; }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
361 fprintf(out,"%s",tn.tree_name);
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
362 }
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
363
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
364 NMTBL *
468
464e7480395c *** empty log message ***
kono
parents: 327
diff changeset
365 typedef_search(int t,int type)
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
366 {
2e84590720a6 typedef name
kono
parents: 69
diff changeset
367 while(t) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
368 if ((ncaddr(t))->ty==type)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
369 return ncaddr(t);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
370 t=cadr(t);
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
371 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
372 return 0;
2e84590720a6 typedef name
kono
parents: 69
diff changeset
373 }
2e84590720a6 typedef name
kono
parents: 69
diff changeset
374
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
375 static void n_attr_print(int attr, FILE *out)
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
376 {
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
377 for(;attr;attr=cadr(attr)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
378 switch(car(attr)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
379 case INLINE: fprintf(out,"inline "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
380 case CONST: fprintf(out,"const "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
381 case VOLATILE: fprintf(out,"const "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
382 case RESTRICT: fprintf(out,"const "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
383 }
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
384 }
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
385 }
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
386
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
387 void type_print1(int type,NMTBL *n,FILE *out,int cont)
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
388 {
254a0c576114 argument type list
kono
parents: 50
diff changeset
389 int t;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
390 tree_node_type *tn,tn0;
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
391 NMTBL *td;
72
3b5d293cea36 type def etc
kono
parents: 70
diff changeset
392 int args;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
393 tn = &tn0;
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
394
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
395 if (n) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
396 if (n->attr) n_attr_print(n->attr,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
397 while(type>0 && car(type)==ATTRIBUTE) type=cadr(type);
564
25f431685d80 *** empty log message ***
kono
parents: 563
diff changeset
398 } else
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
399 type = attr_print(type);
75
92dcf107a837 c code output
kono
parents: 74
diff changeset
400 if(type>0&&(td=typedef_search(typedefed,type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
401 if (!cont)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
402 fprintf(out,"%s ",td->nm);
75
92dcf107a837 c code output
kono
parents: 74
diff changeset
403 } else if(type>0&&(td=typedef_search(gtypedefed,type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
404 if (!cont)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
405 fprintf(out,"%s ",td->nm);
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
406 } else if (type<0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
407 t=type;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
408 if (!(tree_nodes(t,&tn->tree_name,&tn->tree_args,&tn->tree_order))) { error(-1); return; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
409 if (!cont)
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
410 fprintf(out,"%s ",tn->tree_name);
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
411 } else if ((t=car(type))) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
412 if (!(tree_nodes(t,&tn->tree_name,&tn->tree_args,&tn->tree_order))) { error(-1); return; }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
413 if(t==STRUCT||t==UNION) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
414 if (!cont) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
415 fprintf(out,"%s ",tn->tree_name);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
416 struct_type_print(type,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
417 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
418 } else if(t==CODE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
419 // if (!cont) { fprintf(out,"%s ",tn->tree_name); }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
420 function_type_print1(type,n,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
421 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
422 } else if(t==FUNCTION) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
423 function_type_print1(type,n,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
424 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
425 } else if(t==ARRAY) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
426 type_print1(cadr(type),n,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
427 if (caddr(type))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
428 fprintf(out,"[%d]",caddr(type));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
429 else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
430 fprintf(out,"[]");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
431 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
432 } else if(t==POINTER) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
433 t=cadr(type);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
434 if(t<0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
435 type_print1(t,0,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
436 fprintf(out,"*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
437 } else if(car(t)==FUNCTION) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
438 type_print1(cadr(t),0,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
439 fprintf(out,"(*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
440 if(n) fprintf(out,"%s",n->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
441 fprintf(out,")");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
442 fprintf(out,"(");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
443 if((args=caddr(t))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
444 while (args) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
445 type_print(car(args),0,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
446 args=cadr(args);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
447 if (args) fprintf(out,",");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
448 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
449 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
450 fprintf(out,")");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
451 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
452 } else if(car(t)==CODE) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
453 type_print1(cadr(t),0,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
454 fprintf(out,"(*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
455 if(n) fprintf(out,"%s",n->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
456 fprintf(out,")");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
457 fprintf(out,"(");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
458 if((args=caddr(t))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
459 while (args) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
460 type_print(car(args),0,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
461 args=cadr(args);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
462 if (args) fprintf(out,",");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
463 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
464 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
465 fprintf(out,")");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
466 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
467 } else if(car(t)==ARRAY) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
468 fprintf(out,"(*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
469 type_print(cadr(t),n,out);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
470 if (caddr(type))
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
471 fprintf(out,")[%d]",caddr(type));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
472 else
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
473 fprintf(out,")[]");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
474 return;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
475 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
476 type_print1(t,0,out,cont);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
477 fprintf(out,"*");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
478 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
479 }
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
480 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
481 if(n) fprintf(out,"%s",n->nm);
254a0c576114 argument type list
kono
parents: 50
diff changeset
482 }
254a0c576114 argument type list
kono
parents: 50
diff changeset
483
74
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
484 void type_print(int type,NMTBL *n,FILE *out)
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
485 {
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
486 type_print1(type,n,out,0);
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
487 }
6de658ae384c *** empty log message ***
kono
parents: 72
diff changeset
488
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
489 /*
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
490 parse tree を印刷する
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
491
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
492 正しく括弧とかを付けるアルゴリズムが不明...
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
493 先読みして、優先順位を判別する必要があるはず。
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
494
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
495 そういえば、cast とかは、落ちて変換コードに変わっている
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
496 はず。cast を木にしないとだめか。
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
497 */
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
498
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
499 void
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
500 print_expr(int e, FILE *vout)
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
501 {
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
502 NMTBL *nptr,*n;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
503
660
3e1dba5758d8 *** empty log message ***
kono
parents: 620
diff changeset
504 if (e==0) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
505 // can't happen in normal C language
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
506 fprintf(vout,"#");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
507 return;
660
3e1dba5758d8 *** empty log message ***
kono
parents: 620
diff changeset
508 }
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
509 switch (car(e)%SOP) {
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
510 case LVAR:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
511 case RLVAR:
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
512 case URLVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
513 if ((nptr = ncaddr(e))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
514 fprintf(vout,"%s",nptr->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
515 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
516 // anonymous variable
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
517 fprintf(vout,"_%d",caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
518 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
519 break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
520 case GVAR:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
521 case RGVAR:
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
522 case URGVAR:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
523 if ((nptr = ncaddr(e))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
524 fprintf(vout,"%s",nptr->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
525 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
526 // anonymous variable
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
527 fprintf(vout,"_%d",caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
528 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
529 if (cadr(e)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
530 // offset
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
531 // certainly this is wrong
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
532 fprintf(vout,"+%d",caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
533 }
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
534 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
535 case REGISTER:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
536 if ((nptr = ncaddr(e))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
537 fprintf(vout,"%s",nptr->nm);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
538 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
539 // anonymous register variable
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
540 fprintf(vout,"_%d",caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
541 }
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
542 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
543 case IDENT:
712
bf94c295d763 *** empty log message ***
kono
parents: 711
diff changeset
544 nptr = ncaddr(e);
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
545 fprintf(vout,"%s",nptr->nm); break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
546 case CONST:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
547 switch(car(e)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
548 case CONST:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
549 fprintf(vout,"%d",cadr(e)); break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
550 #if FLOAT_CODE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
551 case FCONST:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
552 fprintf(vout,"%g",dcadr(e)); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
553 case DCONST:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
554 fprintf(vout,"%g",dcadr(e)); break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
555 #endif
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
556 #if LONGLONG_CODE
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
557 case LCONST:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
558 fprintf(vout,"%lld",lcadr(e)); break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
559 #endif
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
560 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
561 break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
562 case ADDRESS:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
563 if (car(cadr(e))!=STRING) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
564 fprintf(vout,"&");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
565 print_expr(cadr(e),vout);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
566 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
567 }
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
568 case STRING:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
569 {
620
0e7281ec9007 *** empty log message ***
kono
parents: 609
diff changeset
570 int c; char *s; int i;
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
571 nptr = ncaddr(e); s = nptr->nm;i=nptr->dsp;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
572 fprintf(vout,"\"");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
573 while(--i>0) {
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
574 c=*s++;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
575 if(c=='\n') fprintf(vout,"\\n");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
576 else if(c=='\r') fprintf(vout,"\\r");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
577 else if(c=='\t') fprintf(vout,"\\t");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
578 else if(c=='\e') fprintf(vout,"\\e");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
579 else if(c=='"') fprintf(vout,"\\\"");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
580 else if(c=='\\') fprintf(vout,"\\\\");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
581 else if(!(' '<=c&&c<=0x7f)) fprintf(vout,"\\%03o",c);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
582 else fprintf(vout,"%c",c);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
583 }
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
584 fprintf(vout,"\"");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
585 }
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
586 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
587 case ARRAY:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
588 print_expr(cadr(e),vout);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
589 fprintf(vout,"[");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
590 print_expr(caddr(e),vout);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
591 fprintf(vout,"]");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
592 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
593 case PERIOD:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
594 print_expr(cadr(e),vout);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
595 n = ncaddr(e);
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
596 fprintf(vout,".%s",n->nm);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
597 break;
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
598 case ARROW:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
599 print_expr(cadr(e),vout);
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
600 n = ncaddr(e);
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
601 fprintf(vout,"->%s",n->nm);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
602 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
603 case INDIRECT:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
604 case RINDIRECT:
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
605 case URINDIRECT:
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
606 fprintf(vout,"*");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
607 print_expr(cadr(e),vout);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
608 break;
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
609 case FNAME:
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
610 n = ncaddr(e);
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
611 fprintf(vout,"%s",n->nm);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
612 break;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
613 case FUNCTION:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
614 print_function_call(e,vout);
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
615 break;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
616 /*
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
617 case ADD:
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
618 fprintf(vout,"(");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
619 print_expr(cadr(e),vout);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
620 fprintf(vout,"+");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
621 print_expr(caddr(e),vout);
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
622 fprintf(vout,")");
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
623 break;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
624 */
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
625 default:
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
626 print_operator(e, vout);
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
627 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
628 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
629
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
630 static void
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
631 print_expr_paren(int order,char *args,int e)
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
632 {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
633 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
634
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
635 static void
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
636 print_operator(int e, FILE *vout)
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
637 {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
638 char *name; char *args; int order ;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
639 if (tree_nodes(car(e), &name, &args, &order) ) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
640 if (order>0) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
641 int i = 0;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
642 for(;*args;args++,i++) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
643 print_expr_paren(order,args,heap[e+i]);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
644 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
645 } else {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
646 print_statement(e, vout);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
647 }
609
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
648 }
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
649 }
af6b9ae79583 modificatioon for udpcl
kono
parents: 607
diff changeset
650
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
651 static void
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
652 print_decl(int e, FILE *vout)
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
653 {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
654 NMTBL *n = ncaddr(e);
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
655 int e1 = cadddr(e);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
656 // int mode = car(e1);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
657 int stmode = cadr(e1);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
658 int ctmode = caddr(e1);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
659
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
660 if (n==&null_nptr) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
661 error(-1); // can't happen
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
662 return;
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
663 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
664 if (stmode==STATIC) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
665 fprintf(vout,"static ");
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
666 } else if (stmode==EXTRN||stmode==EXTRN1) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
667 fprintf(vout,"extern ");
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
668 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
669 type_print(n->ty,n,vout);
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 680
diff changeset
670 if (ctmode & KONST_BIT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
671 fprintf(vout,"const ");
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 680
diff changeset
672 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 680
diff changeset
673 if (ctmode & VOLATILE_BIT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
674 fprintf(vout,"volatile ");
681
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 680
diff changeset
675 }
e16b34f2b386 DECL_DATA has parse tree now.
kono
parents: 680
diff changeset
676 if (ctmode & RESTRICT_BIT) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
677 fprintf(vout,"restrict ");
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
678 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
679 fprintf(vout,"%s; ",nptr->nm);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
680 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
681
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
682 static void
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
683 print_statement(int e, FILE *vout)
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
684 {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
685 int e1;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
686 NMTBL *n;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
687 for (;e!=0; e = cadr(e)) {
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
688 switch (car(e)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
689 case ST_DECL:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
690 print_decl(e, vout); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
691 case ST_IF:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
692 fprintf(vout,"if "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
693 case ST_DO:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
694 fprintf(vout,"do "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
695 case ST_WHILE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
696 fprintf(vout,"while "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
697 case ST_FOR:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
698 fprintf(vout,"for "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
699 case ST_SWITCH:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
700 fprintf(vout,"switch "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
701 case ST_COMP:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
702 fprintf(vout,"{");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
703 fprintf(vout,"}");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
704 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
705 case ST_BREAK:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
706 fprintf(vout,"break; "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
707 case ST_CONTINUE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
708 fprintf(vout,"continue; "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
709 case ST_CASE:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
710 for(e1 = caddr(e);e1;e1 = cadr(e1)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
711 fprintf(vout,"case ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
712 fprintf(vout,"%d: ",car(e1));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
713 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
714 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
715 case ST_DEFAULT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
716 fprintf(vout,"default: "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
717 case ST_RETURN:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
718 fprintf(vout,"return ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
719 if (( e1 = caddr(e))) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
720 print_expr(e1,vout);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
721 }
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
722 fprintf(vout,"; ");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
723 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
724 case ST_GOTO:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
725 fprintf(vout,"goto "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
726 case ST_ASM:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
727 fprintf(vout,"__asm__ "); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
728 case ST_LABEL:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
729 n = ncaddr(caddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
730 fprintf(vout,"%s:", n->nm); break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
731 case ST_OP:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
732 e1 = caddr(e);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
733 print_expr(list3(cadr(e),car(e1),cadr(e1)),vout);
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
734 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
735 case ST_COMMENT:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
736 fprintf(vout,"\n# %s\n",scaddr(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
737 break;
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
738 default:
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
739 fprintf(stderr,"Unknown Statement ID %d\n",car(e));
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
740 }
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
741 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
742 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
743
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
744 static void
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
745 print_function_call(int e1,FILE *vout)
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
746 {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
747 int e2,e3;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
748 NMTBL *fn = 0;
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
749
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
750 e2 = cadr(e1);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
751 if (car(e2) == FNAME) {
711
35e6841ba01a pointer fixes (partial)
kono
parents: 681
diff changeset
752 fn=ncaddr(e2);
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
753 fprintf(vout,"%s",fn->nm);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
754 } else {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
755 if (car(e2)==INDIRECT) e2=cadr(e2); // (*func)(i) case
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
756 fprintf(vout,"(");
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
757 print_expr(e2,vout);
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
758 fprintf(vout,")");
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
759 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
760
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
761 fprintf(vout,"(");
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
762 for (e3 = e1 = reverse0(caddr(e1)); e3; e3 = cadr(e3)) {
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
763 print_expr(car(e3),vout);
880
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
764 if (cadr(e3)) {
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
765 fprintf(vout,",");
5313ed059cee no tabs in source
Shinji KONO <kono@ie.u-ryukyu.ac.jp>
parents: 861
diff changeset
766 }
680
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
767 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
768 fprintf(vout,")");
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
769 reverse0(e1); // make it normal order
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
770
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
771 }
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
772
f536897fa3cb *** empty log message ***
kono
parents: 660
diff changeset
773
67
254a0c576114 argument type list
kono
parents: 50
diff changeset
774 /* end */