annotate mc-parse.c @ 426:fb136af3bf09

Bitfield reorganization.
author kono
date Sat, 30 Oct 2004 14:04:45 +0900 (2004-10-30)
parents efbd420386c5
children d92786033042
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
1 /* Micro-C Parser Part */ /* $Id$ */
1
0529f5abe9d0 *** empty log message ***
kono
parents: 0
diff changeset
2
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3 #include <stdio.h>
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4 #include "mc.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
5 #include "mc-parse.h"
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
6 #include "mc-codegen.h"
297
0f79c95df73a switch index no compile error
kono
parents: 293
diff changeset
7 #include "mc-switch.h"
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
8 #include "mc-macro.h"
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
9 #include "conv/conv.h"
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
10
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
11 #define FILES 10
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
12 #define OUTPUT_FILE_NAME "mcout.s"
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
13
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
14 extern void exit(int); /* to avoid stdlib.h inclusion */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
15 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
16 #if 0
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
17 extern long long
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
18 strtoll(char * nptr, char ** endptr, int base);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
19 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
20 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
21 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
22 extern double strtod(const char *nptr, char **endptr);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
23 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
24
358
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
25 #define HEAP_REPORT 0
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
26
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
27 NMTBL null_nptr;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
28 NMTBL *fnptr;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
29 NMTBL *nptr,*gnptr;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
30 static NMTBL *htable0[GSYMS];
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
31 NMTBL **htable = htable0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
32 struct cheap *cheap,*cheap0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
33
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
34 static struct cheap *nptr_pool,*nptr_pool0;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
35 static NMTBL *free_nptr_list;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
36
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
37 static int current_scope;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
38
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
39 char linebuf[LBUFSIZE];
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
40 char *chptr;
357
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
41 int args,init_vars;
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
42 int *heap;
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
43 int heapsize = HEAPSIZE;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
44 int asmf;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
45 int bit_field_disp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
46 int blabel,dlabel;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
47 int ch;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
48 int chk;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
49 int chptrsave;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
50 int chsave;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
51 int cslabel,control;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
52 int csvalue1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
53 int debug;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
54 int fields;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
55 int glineno;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
56 int gtypedefed;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
57 int in_comment;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
58 int in_quote;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
59 int labelno,gpc,disp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
60 int lastexp;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
61 int lfree;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
62 int lineno;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
63 int lsrc;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
64 int retlabel,retpending,retcont;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
65 int struct_return;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
66 int sym,type,mode,stmode;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
67 int typedefed;
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
68 int decl_str_init;
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
69
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
70 NMTBL *local_static_list,*global_list;
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
71
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
72
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
73 struct {int fd,ln;char *name0;int inc;FILE *fcb;} *filep,filestack[FILES];
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
74
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
75 static NMTBL *decl0(void),*decl1(void),*l_top_search(char *name,int sc);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
76 static int append3(int p,int a1,int a2);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
77 static int expr0(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
78 static int expr1(void);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
79 static int expr10(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
80 static int expr11(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
81 static int expr12(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
82 static int expr13(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
83 static int expr14(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
84 static int expr15(int e1);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
85 static int expr16(int e1);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
86 static int expr2(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
87 static int expr3(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
88 static int expr4(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
89 static int expr5(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
90 static int expr6(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
91 static int expr7(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
92 static int expr8(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
93 static int expr9(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
94 static int getfree(int n);
d35df41eac69 Initial revision
kono
parents:
diff changeset
95 static int ndecl0(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
96 static int ndecl1(void);
d35df41eac69 Initial revision
kono
parents:
diff changeset
97 static int postequ(int s1, int s2);
d35df41eac69 Initial revision
kono
parents:
diff changeset
98 static int sdecl(int s);
176
kono
parents: 174
diff changeset
99 static int edecl();
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
100 static int adecl(NMTBL *n);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
101 static void code_decl(NMTBL *n);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
102 static void decl(void);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
103 static int typespec(void);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
104 static void docase(void);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
105 static void docomp(int);
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
106 static void dodefault(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
107 static void dodo(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
108 static void dofor(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
109 static void dogoto(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
110 static void doif(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
111 static void dolabel(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
112 static void doreturn(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
113 static void doswitch(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
114 static void dowhile(void);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
115 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
116 static void doasm();
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
117 #endif
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
118 static void errmsg(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
119 static void fdecl(NMTBL *n);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
120 static void getstring(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
121 static void init(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
122 static void newfile(void);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
123 static void reserve(char *s, int d);
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
124 static void reverse(int t1);
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
125 static void set_converter(char *s);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
126 static int escape(void);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
127 static void statement(int);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
128 static int typename(void);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
129 static void decl_data_field(int type,NMTBL *n,int offset);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
130 static int decl_data(int t, NMTBL *n,int offset,int skip);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
131 static int typeid(int s);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
132 static int typename(void);
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
133 extern NMTBL * get_name_from_chptr();
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
134 static NMTBL * hash_search(char *name,struct cheap *scheap,int len,unsigned int hash,int mode);
359
7ab4434ad869 macro scope
kono
parents: 358
diff changeset
135 extern NMTBL * make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc);
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
136 static NMTBL * make_top_scope(NMTBL *nlist,NMTBL *nptr1,int sc);
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
137 static void extrn_use(NMTBL *nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
138
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
139 static struct cheap * new_cheap();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
140
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
141 #if FLOAT_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
142 static double dsymval;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
143 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
144 #if LONGLONG_CODE
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
145 static long long lsymval;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
146 #endif
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
147 static int symval;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
148 static int gfree;
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
149
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
150 static int sdecl_f = 1;
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
151 static int stypedecl;
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
152
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
153 static Converter *conv = &null_converter;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
154 /* Converter *conv = &c_converter; */
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
155
65
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
156 static char *ccout = 0;
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
157
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
158 #define MAX_INCLUDE_PATH_COUNT 10
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
159 char *include_path[MAX_INCLUDE_PATH_COUNT];
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
160 int include_path_count;
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
161 extern char *l_include_path[];
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
162
224
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
163 static
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
164 char current_file_dir[LBUFSIZE];
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
165
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
166 static int ac,ac2;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
167 static char **av;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
168 static int cslist;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
169 static int clabel;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
170 static int ilabel;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
171 static int stat_no;
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
172
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
173 int
d35df41eac69 Initial revision
kono
parents:
diff changeset
174 main(int argc, char **argv)
d35df41eac69 Initial revision
kono
parents:
diff changeset
175 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
176 int i;
d35df41eac69 Initial revision
kono
parents:
diff changeset
177
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
178 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
179 option handling
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
180 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
181 if(argc==1) exit(1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
182 lsrc = chk = asmf = 0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
183 ac=argc;
d35df41eac69 Initial revision
kono
parents:
diff changeset
184 av=argv;
224
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
185 current_file_dir[0] = 0;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
186 include_path[include_path_count++] = current_file_dir;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
187 for (ac2=1; (ac2 < ac) && (*av[ac2] == '-'); ++ac2) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
188 switch (*(av[ac2]+1)) {
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
189 case 's':
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
190 lsrc = 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
191 break;
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
192 case 'o':
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
193 ccout = av[ac2]+2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
194 break;
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
195 case 'c':
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
196 chk = 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
197 break;
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
198 case 'd':
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
199 debug = 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
200 break;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
201 case 'D':
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
202 break;
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
203 case 'C':
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
204 if (av[ac2+1]) set_converter(av[ac2]+2);
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
205 chk = 1;
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
206 ccout=0;
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
207 break;
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
208 case 'I':
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
209 include_path[include_path_count++] = av[ac2]+2;
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
210 if (include_path_count<MAX_INCLUDE_PATH_COUNT)
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
211 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
212 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
213 error(OPTION);
d35df41eac69 Initial revision
kono
parents:
diff changeset
214 exit(1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
215 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
216 }
65
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
217 if (!chk && ccout)
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
218 if ( (freopen(ccout,"w",stdout)) == NULL ) error(FILERR);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
219 init();
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
220 /* top level */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
221 while(1) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
222 mode=TOP;
358
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
223 if (gfree > heapsize-30000) {
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
224 heapsize *= 2;
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
225 #if HEAP_REPORT
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
226 fprintf(stderr,"** heap extended to %d\n",heapsize);
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
227 #endif
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
228 heap = realloc(heap,heapsize*sizeof(int));
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
229 }
357
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
230 lfree= heapsize;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
231 codegen_decl_init();
275
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
232 while (chptrsave!=0) {
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
233 i = cadr(chptrsave); free_glist2(chptrsave); chptrsave = i;
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
234 }
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
235 while (chsave!=0) {
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
236 i = cadr(chsave); free_glist2(chsave); chsave = i;
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
237 }
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
238 // a in previous extern f(a) is in current scope, release it
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
239 leave_scope();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
240 while(getsym(0)==SM) conv->sm_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
241 mode=GDECL;
d35df41eac69 Initial revision
kono
parents:
diff changeset
242 stmode=0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
243 args=0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
244 decl();
d35df41eac69 Initial revision
kono
parents:
diff changeset
245 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
246 /*NOTREACHED*/
d35df41eac69 Initial revision
kono
parents:
diff changeset
247 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
248
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
249 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
250 error handler
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
251 when EOF, process next file
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
252 */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
253 extern void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
254 error(int n)
d35df41eac69 Initial revision
kono
parents:
diff changeset
255 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
256 if(n == EOFERR) {
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
257 if(filep!=filestack) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
258 fclose(filep->fcb);
d35df41eac69 Initial revision
kono
parents:
diff changeset
259 lineno=filep->ln;
d35df41eac69 Initial revision
kono
parents:
diff changeset
260 --filep;
224
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
261 copy_current_file_dir(filep->name0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
262 return;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
263 } else if(ac2!=ac) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
264 fclose(filep->fcb);
d35df41eac69 Initial revision
kono
parents:
diff changeset
265 newfile();
d35df41eac69 Initial revision
kono
parents:
diff changeset
266 return;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
267 } else if(mode == TOP) {
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
268 if (chk) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
269 fprintf(stderr, "Total internal labels : %u.\n",labelno-1);
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
270 fprintf(stderr, "Total global variables: %u bytes.\n",gpc);
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
271 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
272 closing();
d35df41eac69 Initial revision
kono
parents:
diff changeset
273 exit(0);
d35df41eac69 Initial revision
kono
parents:
diff changeset
274 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
275 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
276 if (conv->error_(n)) return;
25
b7a94557bf92 *** empty log message ***
kono
parents: 23
diff changeset
277 fprintf(stderr,"%s:%d:%s\n",filep->name0,lineno,
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
278 (n==FILERR) ? "Can't open specified file" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
279 (n==DCERR) ? "Declaration syntax" :
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
280 (n==RDERR) ? "Redefined" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
281 (n==STERR) ? "Statement syntax" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
282 (n==EXERR) ? "Expression syntax" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
283 (n==CNERR) ? "Constant required" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
284 (n==CHERR) ? "Illegal character" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
285 (n==GSERR) ? "Too many global symbols" :
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
286 (n==HSERR) ? "Too many string or symbols" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
287 (n==LSERR) ? "Too many local symbols" :
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
288 (n==MSERR) ? "Too many macro symbols" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
289 (n==STRERR) ? "Too many strings or macros" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
290 (n==LNERR) ? "Line too long" :
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
291 (n==NMERR) ? "Name too long" :
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
292 (n==MMERR) ? "malloc error" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
293 (n==EOFERR) ? "Unexpected end of file" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
294 (n==MCERR) ? "Macro syntax" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
295 (n==INCERR) ? "Include syntax" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
296 (n==HPERR) ? "Too long expression" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
297 (n==TYERR) ? "Type mismatch" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
298 (n==LVERR) ? "Lvalue required" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
299 (n==UDERR) ? "Undeclared identifier" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
300 (n==OPTION) ? "Illegal option" :
389
68fb244e0e3c mc-arm generates code-gen-all.s with no error,
kono
parents: 379
diff changeset
301 (n==RGERR) ? "too many register usage (internal error)" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
302 (n==REG_ERR) ? "illegal register var" :
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
303 (n==INERR) ? "bad initialization" :
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
304 (n==CODE_ERR) ? "goto code is necessary" :
d35df41eac69 Initial revision
kono
parents:
diff changeset
305 "Bug of compiler");
d35df41eac69 Initial revision
kono
parents:
diff changeset
306 errmsg();
d35df41eac69 Initial revision
kono
parents:
diff changeset
307 exit(1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
308 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
309
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
310 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
311 errmsg(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
312 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
313 char *p,*lim;
d35df41eac69 Initial revision
kono
parents:
diff changeset
314
d35df41eac69 Initial revision
kono
parents:
diff changeset
315 if(lineno==0) return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
316 fprintf(stderr,"%s",linebuf);
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
317 lim=chptr;
115
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
318 while (chptrsave) {
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
319 lim = (char*)car(chptrsave);
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
320 chptrsave = cadr(chptrsave);
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
321 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
322 for (p=linebuf; p < lim;)
d35df41eac69 Initial revision
kono
parents:
diff changeset
323 fprintf(stderr,(*p++ == '\t') ? "\t" : " ");
d35df41eac69 Initial revision
kono
parents:
diff changeset
324 fprintf (stderr,"^\n");
d35df41eac69 Initial revision
kono
parents:
diff changeset
325 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
326
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
327 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
328 required symbol check
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
329 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
330 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
331 checksym(int s)
d35df41eac69 Initial revision
kono
parents:
diff changeset
332 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
333 char *p;
d35df41eac69 Initial revision
kono
parents:
diff changeset
334
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
335 if (sym != s) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
336 p=(s==RPAR) ? "')'": (s==RBRA) ? "']'": (s==SM) ? "';'":
d35df41eac69 Initial revision
kono
parents:
diff changeset
337 (s==LPAR) ? "'('": (s==WHILE) ? "'while'":
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
338 (s==ASS) ? "'='":
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
339 (s==COLON) ? "':'": "Identifier";
d35df41eac69 Initial revision
kono
parents:
diff changeset
340 fprintf(stderr,"%d:%s expected.\n",lineno,p);
d35df41eac69 Initial revision
kono
parents:
diff changeset
341 errmsg();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
342 } else
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
343 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
344 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
345
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
346 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
347 heap array memory pool initialize
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
348 init before reserve()
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
349 this can be called twice or more.
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
350 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
351
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
352 static void
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
353 heap_init()
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
354 {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
355 gpc=glineno=0;
357
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
356 if (!heap) heap = (int *)malloc(heapsize*sizeof(int));
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
357 if (!heap) error(MMERR);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
358 gfree=ilabel=1;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
359 labelno=2;
357
1057d6740a36 *** empty log message ***
kono
parents: 356
diff changeset
360 lfree=heapsize;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
361 }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
362
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
363 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
364 Par file initialization.
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
365 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
366
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
367 static void
181
4beb7f079055 new file
kono
parents: 180
diff changeset
368 reinit(void)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
369 {
181
4beb7f079055 new file
kono
parents: 180
diff changeset
370 int i;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
371
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
372 struct cheap *p;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
373
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
374 global_list = &null_nptr;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
375 cheap=cheap0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
376 for(p=cheap;p;p=p->next) p->ptr=p->first;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
377
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
378 nptr_pool = nptr_pool0;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
379 for(p=nptr_pool;p;p=p->next) p->ptr=p->first;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
380 free_nptr_list = 0;
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
381 for(i=0;i<GSYMS;i++) htable[i] = 0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
382
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
383 heap_init();
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
384
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
385 reserve("int",INT);
d35df41eac69 Initial revision
kono
parents:
diff changeset
386 reserve("void",VOID);
d35df41eac69 Initial revision
kono
parents:
diff changeset
387 reserve("char",CHAR);
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
388 reserve("const",KONST);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
389 reserve("struct",STRUCT);
d35df41eac69 Initial revision
kono
parents:
diff changeset
390 reserve("union",UNION);
d35df41eac69 Initial revision
kono
parents:
diff changeset
391 reserve("unsigned",UNSIGNED);
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
392 reserve("signed",SIGNED);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
393 reserve("static",STATIC);
d35df41eac69 Initial revision
kono
parents:
diff changeset
394 reserve("goto",GOTO);
d35df41eac69 Initial revision
kono
parents:
diff changeset
395 reserve("return",RETURN);
d35df41eac69 Initial revision
kono
parents:
diff changeset
396 reserve("break",BREAK);
d35df41eac69 Initial revision
kono
parents:
diff changeset
397 reserve("continue",CONTINUE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
398 reserve("if",IF);
d35df41eac69 Initial revision
kono
parents:
diff changeset
399 reserve("else",ELSE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
400 reserve("for",FOR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
401 reserve("do",DO);
d35df41eac69 Initial revision
kono
parents:
diff changeset
402 reserve("while",WHILE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
403 reserve("switch",SWITCH);
d35df41eac69 Initial revision
kono
parents:
diff changeset
404 reserve("case",CASE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
405 reserve("default",DEFAULT);
d35df41eac69 Initial revision
kono
parents:
diff changeset
406 reserve("typedef",TYPEDEF);
d35df41eac69 Initial revision
kono
parents:
diff changeset
407 reserve("sizeof",SIZEOF);
d35df41eac69 Initial revision
kono
parents:
diff changeset
408 reserve("long",LONG);
d35df41eac69 Initial revision
kono
parents:
diff changeset
409 reserve("short",SHORT);
d35df41eac69 Initial revision
kono
parents:
diff changeset
410 reserve("extern",EXTRN);
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
411 reserve("defined",DEFINED);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
412 reserve("register",REGISTER);
d35df41eac69 Initial revision
kono
parents:
diff changeset
413 reserve("code",CODE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
414 reserve("environment",ENVIRONMENT);
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
415 reserve("float",FLOAT);
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
416 reserve("double",DOUBLE);
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
417 reserve("inline",INLINE);
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
418 reserve("enum",ENUM);
177
352feeae4b0a macro else/ccout
kono
parents: 176
diff changeset
419 reserve("volatile",VOLATILE);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
420 reserve("__volatile__",VOLATILE);
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
421 reserve("typeof",TYPEOF);
324
575481408653 minor fix
kono
parents: 323
diff changeset
422 reserve("__typeof__",TYPEOF);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
423 reserve("__builtin_alloca",ALLOCA);
362
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
424 reserve("__label__",LABEL);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
425 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
426 reserve("asm",ASM);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
427 reserve("__asm__",ASM);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
428 #endif
19
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
429
328
7ecb023d29b8 macro/codegen reorganization done.
kono
parents: 327
diff changeset
430 codegen_reinit();
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
431 macro_define("__restrict\n");
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
432 macro_define("__micro_c__ 1\n");
115
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
433 #ifdef __APPLE__
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
434 macro_define("__APPLE__ 1\n");
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
435 #endif
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
436 #ifdef bsd
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
437 macro_define("bsd 1\n");
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
438 #endif
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
439 for(i=0;av[i]&&av[i][0]=='-'&&av[i][1]=='D';i++) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
440 macro_define(av[i]+2);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
441 }
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
442 current_scope = 0;
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
443 enter_scope();
181
4beb7f079055 new file
kono
parents: 180
diff changeset
444 }
4beb7f079055 new file
kono
parents: 180
diff changeset
445
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
446 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
447 one time initialization
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
448 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
449
181
4beb7f079055 new file
kono
parents: 180
diff changeset
450 static void
4beb7f079055 new file
kono
parents: 180
diff changeset
451 init(void)
4beb7f079055 new file
kono
parents: 180
diff changeset
452 {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
453 cheap0 = new_cheap();
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
454 nptr_pool0 = new_cheap();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
455 codegen_init();
181
4beb7f079055 new file
kono
parents: 180
diff changeset
456 reinit();
185
427008a06333 comment
kono
parents: 184
diff changeset
457 filep=filestack;
181
4beb7f079055 new file
kono
parents: 180
diff changeset
458 newfile();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
459 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
460 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
461
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
462 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
463 keep track current directory
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
464 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
465
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
466 extern void
224
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
467 copy_current_file_dir(char *name)
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
468 {
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
469 char *s = name;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
470 char *d = current_file_dir;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
471 char *p;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
472 for(p = d;d<current_file_dir+LBUFSIZE && *s; ) {
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
473 if (*s=='/') p = d+1;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
474 *d++ = *s++;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
475 }
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
476 *p = 0;
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
477 }
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
478
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
479 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
480 search possible exisiting file name
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
481 with new extension hoge.c -> hoge.s
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
482 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
483
181
4beb7f079055 new file
kono
parents: 180
diff changeset
484 static int first_newfile = 1;
4beb7f079055 new file
kono
parents: 180
diff changeset
485
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
486 extern char *
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
487 make_filename_with_extension(char *filename,char *ext)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
488 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
489 char *p=cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
490 char *s,*t;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
491 struct cheap scheap,scheap1;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
492 save_cheap(&scheap,cheap);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
493
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
494 if (! *filename) filename="mcout";
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
495 for (t=0,s=filename;(*cheap->ptr = *s);cheap=increment_cheap(cheap,&p)) {
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
496 if (*s++ =='.') {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
497 t=cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
498 save_cheap(&scheap1,cheap);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
499 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
500 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
501 if (t) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
502 cheap = reset_cheap(&scheap1);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
503 cheap->ptr = t;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
504 *cheap->ptr='.';
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
505 } else {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
506 cheap->ptr[-1]='.';
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
507 cheap->ptr--;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
508 }
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
509 cheap = increment_cheap(cheap,&p);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
510 for(s = ext; *s; s++) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
511 *cheap->ptr = *s; cheap = increment_cheap(cheap,&p);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
512 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
513 cheap = reset_cheap(&scheap);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
514 return p;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
515 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
516
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
517 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
518 start new file in argument list
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
519 create filep
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
520 */
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
521
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
522 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
523 newfile(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
524 {
25
b7a94557bf92 *** empty log message ***
kono
parents: 23
diff changeset
525 char *s;
65
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
526
181
4beb7f079055 new file
kono
parents: 180
diff changeset
527 if (!first_newfile) {
4beb7f079055 new file
kono
parents: 180
diff changeset
528 closing();
4beb7f079055 new file
kono
parents: 180
diff changeset
529 reinit();
4beb7f079055 new file
kono
parents: 180
diff changeset
530 } else
4beb7f079055 new file
kono
parents: 180
diff changeset
531 first_newfile = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
532 lineno=0;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
533 if (chk) fprintf(stderr,"%s:\n",av[ac2]);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
534 if ( (filep->fcb = fopen(av[ac2++],"r")) == NULL ) error(FILERR);
25
b7a94557bf92 *** empty log message ***
kono
parents: 23
diff changeset
535 s = av[ac2-1];
224
82a55cc6b5fc *** empty log message ***
kono
parents: 223
diff changeset
536 copy_current_file_dir(s);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
537 filep->name0 = cheap->ptr;
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
538 filep->inc = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
539 while((*cheap->ptr = *s++)) cheap = increment_cheap(cheap,&filep->name0);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
540 *cheap->ptr = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
541 cheap = increment_cheap(cheap,&filep->name0);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
542 if(!ccout) {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
543 ccout = make_filename_with_extension(filep->name0,"s");
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
544 if ( (freopen(ccout,"w",stdout)) == NULL ) error(FILERR);
65
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
545 ccout=0;
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
546 }
8ad746efa4f8 *** empty log message ***
kono
parents: 62
diff changeset
547 opening(filep->name0);
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
548 conv->open_(filep->name0);
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
549
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
550 if (init_src) {
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
551 // before reading any file, perform initialization source
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
552 chinput = init_src;
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
553 }
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
554 getline();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
555 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
556
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
557 static void
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
558 set_converter(char *s)
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
559 {
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
560 chptr = s;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
561 #if 0
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
562 if (macroeq("c2cbc")) conv=&c2cbc_converter;
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
563 else if (macroeq("cbc2c")) conv=&cbc2c_converter;
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
564 else if (macroeq("c")) conv=&c_converter;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
565 #else
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
566 if (macroeq("c")) conv=&c_converter;
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
567 else conv=&null_converter;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
568 #endif
59
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
569 }
eeca07d1b1c2 *** empty log message ***
kono
parents: 55
diff changeset
570
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
571 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
572 regist reserved word
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
573 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
574
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
575 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
576 reserve(char *s, int d)
d35df41eac69 Initial revision
kono
parents:
diff changeset
577 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
578 NMTBL *nptr;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
579
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
580
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
581 (nptr = name_space_search(get_name(s,0,DEF),d?0:MACRO))->sc = RESERVE;
19
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
582 if (d==0) {
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
583 nptr->sc = MACRO;
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
584 nptr->dsp = (int)""; nptr->ty=0;
19
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
585 } else {
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
586 nptr->dsp = d;
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
587 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
588 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
589
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
590 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
591 Parse part
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
592 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
593
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
594 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
595 storage class
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
596 volatile, static, extern..
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
597 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
598
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
599 static void
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
600 storage_class()
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
601 {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
602 if(sym==VOLATILE) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
603 getsym(0);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
604 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
605 switch(sym) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
606 case STATIC:
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
607 if(mode==LDECL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
608 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
609 conv->static_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
610 mode=STADECL;
d35df41eac69 Initial revision
kono
parents:
diff changeset
611 stmode=LDECL;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
612 } else if(mode==GDECL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
613 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
614 conv->static_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
615 stmode=STATIC;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
616 } else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
617 error(DCERR);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
618 break;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
619 case REGISTER:
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
620 if(mode!=LDECL)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
621 error(DCERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
622 stmode=REGISTER;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
623 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
624 conv->register_();
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
625 break;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
626 case EXTRN:
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
627 if(mode==LDECL) {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
628 getsym(0);
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
629 conv->static_();
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
630 mode=GDECL;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
631 stmode=EXTRN;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
632 } else if(mode==GDECL) {
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
633 getsym(0);
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
634 conv->extern_();
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
635 stmode=EXTRN;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
636 } else
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
637 error(DCERR);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
638 break;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
639 case LABEL: /* GNU extension */
362
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
640 if(mode==LDECL) {
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
641 getsym(0);
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
642 mode = LLDECL;
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
643 } else error(DCERR);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
644 break;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
645 case TYPEDEF:
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
646 if(mode==GDECL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
647 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
648 conv->typedef_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
649 mode=GTDECL;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
650 } else if(mode==LDECL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
651 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
652 conv->typedef_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
653 mode=LTDECL;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
654 } else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
655 error(DCERR);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
656 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
657 }
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
658 }
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
659
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
660 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
661 declaration
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
662 int i;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
663 int f(arg) {...}
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
664 STORAGE_CLASS TYPESPEC name () { }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
665 STORAGE_CLASS TYPESPEC name ,
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
666 STORAGE_CLASS TYPESPEC name = value,
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
667 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
668
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
669 static void
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
670 decl(void)
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
671 {
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
672 NMTBL *n;
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
673 int t,sd;
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
674 if (mode==GDECL) { typedefed=0; }
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
675 storage_class();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
676 if((t=typespec())==0) return;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
677 if(sym==SM) {
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
678 conv->return_type_(t,0,stypedecl);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
679 conv->sm_(); return;
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
680 }
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
681 type=t;sd=stypedecl;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
682 n=decl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
683 reverse(t);
d35df41eac69 Initial revision
kono
parents:
diff changeset
684 if (n == &null_nptr) {
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
685 /* only bit field allows null identifier */
336
d488b72254fb bit-field done.
kono
parents: 332
diff changeset
686 if (!(type>0&&car(type)==BIT_FIELD)) {
d488b72254fb bit-field done.
kono
parents: 332
diff changeset
687 error(DCERR); return;
d488b72254fb bit-field done.
kono
parents: 332
diff changeset
688 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
689 }
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
690 if(sym==LC || ( sym!=SM && sym!=COMMA && sym!=ASS)) {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
691 /* function body */
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
692 if (mode!=GDECL) error(DCERR);
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
693 stypedecl=sd;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
694 if (car(type)==CODE) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
695 code_decl(n); return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
696 } else if (car(type)==FUNCTION) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
697 fdecl(n); return;
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
698 } else error(DCERR);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
699 } else {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
700 conv->return_type_(type,n,sd);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
701 n = def(n);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
702 if (sym==ASS && n!=&null_nptr) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
703 decl_data(type,n,0,0); data_closing(n);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
704 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
705 while(sym==COMMA) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
706 conv->comma_();
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
707 getsym(0);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
708 type=t;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
709 n=decl0();
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
710 reverse(t);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
711 if(n == &null_nptr) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
712 /* only bitfield allow null field name */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
713 if (!(type>0&&car(type)==BIT_FIELD))
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
714 error(DCERR);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
715 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
716 conv->return_type_(type,n,1);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
717 def(n);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
718 if (sym==ASS && n!=&null_nptr) {
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
719 decl_data(type,n,0,0);data_closing(n);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
720 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
721 }
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
722 if(sym!=SM) error(DCERR);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
723 conv->sm_();
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
724 if(mode==GTDECL)
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
725 mode=GDECL;
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
726 if(mode==STADECL||mode==LTDECL)
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
727 mode=LDECL;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
728 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
729 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
730
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
731 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
732 type specification
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
733 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
734 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
735 typespec(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
736 {
127
eb4d8975926c Intel float fix
kono
parents: 126
diff changeset
737 int t = INT;
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
738 int slfree;
354
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
739 int smode,stype;
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
740 stypedecl = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
741
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
742 while (sym==KONST) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
743 getsym(0);
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
744 }
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
745 if (sym==INLINE) {
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
746 getsym(0); // should be static?
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
747 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
748 switch(sym) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
749 case VOID:
d35df41eac69 Initial revision
kono
parents:
diff changeset
750 case INT:
d35df41eac69 Initial revision
kono
parents:
diff changeset
751 case CHAR:
d35df41eac69 Initial revision
kono
parents:
diff changeset
752 case CODE:
78
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
753 case FLOAT:
8418d4b7caa7 *** empty log message ***
kono
parents: 77
diff changeset
754 case DOUBLE:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
755 t= sym;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
756 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
757 break;
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
758 case ENUM:
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
759 t = edecl();
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
760 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
761 case STRUCT:
d35df41eac69 Initial revision
kono
parents:
diff changeset
762 case UNION:
d35df41eac69 Initial revision
kono
parents:
diff changeset
763 t=sdecl(sym);
d35df41eac69 Initial revision
kono
parents:
diff changeset
764 break;
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
765 case SIGNED:
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
766 t = INT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
767 if(getsym(0)==INT) getsym(0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
768 else if (sym==CHAR) { getsym(0); t = CHAR; }
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
769 else if (sym==SHORT) {
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
770 t = SHORT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
771 if(getsym(0)==INT) getsym(0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
772 } else if (sym==LONG) {
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
773 getsym(0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
774 t = INT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
775 if(sym==LONG) {
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
776 if(getsym(0)==INT) getsym(0);
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
777 t=LONGLONG;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
778 } else if(sym==INT) {
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
779 getsym(0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
780 t=INT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
781 }
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
782 }
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
783 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
784 case UNSIGNED:
d35df41eac69 Initial revision
kono
parents:
diff changeset
785 t = UNSIGNED;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
786 if(getsym(0)==INT) getsym(0);
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
787 else if (sym==CHAR) { getsym(0); t = UCHAR; }
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
788 else if (sym==SHORT) {
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
789 t = USHORT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
790 if(getsym(0)==INT) getsym(0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
791 } else if (sym==LONG) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
792 getsym(0);
177
352feeae4b0a macro else/ccout
kono
parents: 176
diff changeset
793 t = UNSIGNED;
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
794 if(sym==LONG) {
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
795 if(getsym(0)==INT) getsym(0);
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
796 t=ULONGLONG;
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
797 } else if(sym==INT) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
798 getsym(0);
173
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
799 t=UNSIGNED;
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
800 }
3b33c7daae95 *** empty log message ***
kono
parents: 169
diff changeset
801 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
802 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
803 case SHORT:
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
804 t=SHORT;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
805 if(getsym(0)==INT) getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
806 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
807 case LONG:
d35df41eac69 Initial revision
kono
parents:
diff changeset
808 t=INT;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
809 getsym(0);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
810 if(sym==LONG) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
811 getsym(0);
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
812 t=LONGLONG;
233
2208a18f3799 *** empty log message ***
kono
parents: 231
diff changeset
813 if (sym==INT) getsym(0);
2208a18f3799 *** empty log message ***
kono
parents: 231
diff changeset
814 else if (sym==UNSIGNED) { t=ULONGLONG; getsym(0); break; }
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
815 } else if(sym==DOUBLE) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
816 getsym(0);
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
817 t=DOUBLE;
233
2208a18f3799 *** empty log message ***
kono
parents: 231
diff changeset
818 } else if(sym==INT) { getsym(0);
2208a18f3799 *** empty log message ***
kono
parents: 231
diff changeset
819 } else if(sym==UNSIGNED) { t=UNSIGNED; getsym(0); }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
820 break;
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
821 case TYPEOF:
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
822 getsym(0);
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
823 checksym(LPAR);
354
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
824 slfree=lfree; stype=type;
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
825 smode = mode; mode = LDECL;
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
826 if((t=typespec())==0) {
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
827 mode = STAT;
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
828 expr(0);
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
829 t = type;
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
830 }
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
831 lfree=slfree; type=stype;
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
832 mode = smode;
312
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
833 checksym(RPAR);
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
834 return t;
a93e619cf772 typeof, MIPS stdarg
kono
parents: 311
diff changeset
835 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
836 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
837 if(sym==IDENT) {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
838 if (nptr->sc==TYPE) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
839 t=nptr->ty;
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
840 typedefed=glist2((int)nptr,typedefed);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
841 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
842 break;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
843 } else if(nptr->sc==EMPTY && gnptr->sc==TYPE) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
844 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
845 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
846 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
847 }
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
848 while (sym==KONST) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
849 getsym(0);
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
850 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
851 if(mode==LDECL) return 0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
852 t= INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
853 }
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
854 while (sym==KONST) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
855 getsym(0);
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
856 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
857 return t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
858 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
859
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
860 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
861 indirect *
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
862 type prefix
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
863 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
864 static struct nametable *
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
865 decl0(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
866 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
867 NMTBL *n;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
868 if(sym==MUL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
869 getsym(0);
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
870 while (sym==KONST) {
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
871 getsym(0);
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
872 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
873 n=decl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
874 type=list2(POINTER,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
875 return n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
876 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
877 return decl1();
d35df41eac69 Initial revision
kono
parents:
diff changeset
878 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
879
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
880 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
881 type postfix
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
882 a() a[] (type)
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
883 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
884
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
885 static NMTBL *
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
886 decl1(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
887 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
888 NMTBL *n;
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
889 int i,array_type,arg;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
890
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
891 if(sym==LPAR) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
892 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
893 n=decl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
894 checksym(RPAR);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
895 } else if (sym == IDENT||sym==ALLOCA) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
896 n=nptr;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
897 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
898 } else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
899 /* error(DCERR); */
d35df41eac69 Initial revision
kono
parents:
diff changeset
900 n= &null_nptr;
d35df41eac69 Initial revision
kono
parents:
diff changeset
901 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
902 while(1) {
185
427008a06333 comment
kono
parents: 184
diff changeset
903 if(sym==LBRA) { /* array */
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
904 if(getsym(0)==RBRA) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
905 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
906 if(mode==ADECL) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
907 type=list2(POINTER,type);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
908 } else if (mode==GDECL || stmode==EXTRN) {
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
909 type=list3(ARRAY,type,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
910 } else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
911 error(DCERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
912 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
913 } else {
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
914 array_type=type;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
915 i=cexpr(expr(1));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
916 checksym(RBRA);
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
917 type=list3(ARRAY,array_type,i);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
918 }
185
427008a06333 comment
kono
parents: 184
diff changeset
919 } else if(sym==LPAR) { /* function or code segment */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
920 if(mode==GDECL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
921 mode=ADECL;getsym(0);mode=GDECL; /* ??? */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
922 } else
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
923 getsym(0);
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
924 n->dsp=0;
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
925 if(stmode==EXTRN) n->sc=EXTRN;
185
427008a06333 comment
kono
parents: 184
diff changeset
926 else if(stmode==STATIC) n->sc=STATIC;
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
927 if (type==CODE) {
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
928 n->ty=CODE;
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
929 if(sym==RPAR) {
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
930 getsym(0);arg=0;
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
931 } else {
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
932 if (mode==ADECL) {
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
933 enter_scope();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
934 arg=adecl(n);
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
935 leave_scope();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
936 } else
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
937 arg=adecl(n);
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
938 }
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
939 type=glist3(CODE,CODE,arg);
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
940 } else {
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
941 if(sym==RPAR) {
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
942 getsym(0);arg=0;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
943 } else {
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
944 if (mode==ADECL) {
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
945 enter_scope();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
946 arg=adecl(n);
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
947 leave_scope();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
948 } else
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
949 arg=adecl(n);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
950 }
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
951 type=glist3(FUNCTION,type,arg);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
952 }
185
427008a06333 comment
kono
parents: 184
diff changeset
953 /* Do not set n->ty here. It could be K&R style arguments or
427008a06333 comment
kono
parents: 184
diff changeset
954 struct field names */
427008a06333 comment
kono
parents: 184
diff changeset
955 /* in GDECL n->dsp contains real parameter, if not,
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
956 it contains arg type list. Real parameter list is compatible
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
957 with arg type list. See def/ADECL */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
958 if (mode!=GDECL)
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
959 n->dsp=arg;
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
960 } else if(sym==COLON) { /* bit-field */
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
961 if (mode==GSDECL||mode==GUDECL||mode==LSDECL||mode==LUDECL) {
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
962 if (scalar(type) || type==LONGLONG || type==ULONGLONG) {
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
963 getsym(0);
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 389
diff changeset
964 type = list3(BIT_FIELD,type,
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 389
diff changeset
965 list3(type /*store type*/,0 /*bit offset*/,symval));
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
966 getsym(0);
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
967 }
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
968 } else
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
969 error(DCERR);
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
970 return n;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
971 } else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
972 return n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
973 }
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
974 /* NOT REACHED */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
975 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
976
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
977 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
978 argument declaration (ANSI)
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
979 argtypes=list2(type,argtypes);
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
980 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
981
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
982 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
983 adecl(NMTBL *n)
d35df41eac69 Initial revision
kono
parents:
diff changeset
984 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
985 NMTBL *arg,*sfnptr;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
986 int t;
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
987 int stype,smode,sd,sargs,sstmode;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
988 int argtypes;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
989
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
990 sstmode=stmode; stmode=REGISTER; /* nobody use this? */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
991 stype=type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
992 sfnptr=fnptr;
d35df41eac69 Initial revision
kono
parents:
diff changeset
993 fnptr=n;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
994 sd = sdecl_f;
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
995 sdecl_f = 0;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
996 argtypes = 0;
16
ca0bce3b4810 struct copy
kono
parents: 14
diff changeset
997 smode = mode;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
998 mode=ADECL;
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
999 args = 0;
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
1000 n->dsp=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1001 for(;;) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1002 if(sym==IDENT && nptr->sc!=TYPE) {
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1003 type=INT; /* naked argument, old K&R C */
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
1004 def(nptr);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1005 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1006 if(sym==RPAR) break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1007 } else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1008 if(sym==DOTS) {
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1009 argtypes=list2(DOTS,argtypes);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1010 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1011 break;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1012 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1013 if((t=typespec())==0) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1014 error(DCERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1015 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1016 }
115
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
1017 type=t;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1018 if(sym!=COMMA && sym!=RPAR) {
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1019 sargs = args;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1020 arg=decl0();
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1021 args = sargs;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1022 reverse(t);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1023 if (arg != &null_nptr) {
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1024 if (smode==GDECL)
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
1025 def(arg);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1026 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1027 }
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
1028 argtypes=list2(type,argtypes);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1029 if(sym==RPAR) break;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1030 }
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1031 if (sym!=COMMA) error(DCERR);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1032 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1033 }
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1034 argtypes=reverse0(argtypes);
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
1035 n->dsp=reverse0(n->dsp);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1036 checksym(RPAR);
16
ca0bce3b4810 struct copy
kono
parents: 14
diff changeset
1037 mode=smode;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1038 fnptr=sfnptr;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1039 type=stype;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1040 sdecl_f = sd;
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1041 stmode=sstmode;
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
1042 return argtypes;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1043 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1044
185
427008a06333 comment
kono
parents: 184
diff changeset
1045 /* reverse modifies type also */
427008a06333 comment
kono
parents: 184
diff changeset
1046
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1047 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1048 reverse(int t1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1049 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1050 int t2,t3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1051 t2=t1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1052
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1053 while(type!=t1) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1054 t3=cadr(type);
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1055 cadr(type) = t2;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1056 t2=type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1057 type=t3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1058 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1059 type = t2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1060 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1061
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1062 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1063 destructive reverse
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1064 */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1065 int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1066 reverse0(int t1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1067 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1068 int t2,t3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1069
d35df41eac69 Initial revision
kono
parents:
diff changeset
1070 t2=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1071 while(t1) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1072 t3=cadr(t1);
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1073 cadr(t1) = t2;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1074 t2=t1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1075 t1=t3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1076 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1077 return t2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1078 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1079
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1080 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1081 calcurate size of type
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1082 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1083
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1084 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1085 size(int t)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1086 {
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1087 if (t<0) {
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1088 switch(t) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1089 case CHAR: return 1;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1090 case UCHAR: return 1;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1091 case VOID: return 1; /* not 0 */
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1092 case SHORT: return size_of_short;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1093 case USHORT: return size_of_short;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1094 case REGISTER: return size_of_int;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1095 case DREGISTER: return size_of_double;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1096 case FREGISTER: return size_of_float;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1097 case LREGISTER: return size_of_longlong;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1098 case FLOAT: return size_of_float;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1099 case DOUBLE: return size_of_double;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1100 case LONGLONG: return size_of_longlong;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1101 case ULONGLONG: return size_of_longlong;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1102 case ENUM: return size_of_int;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1103 default:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1104 if(scalar(t)) return size_of_int;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1105 error(DCERR);
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1106 }
166
9e55cc5551fb *** empty log message ***
kono
parents: 165
diff changeset
1107 }
185
427008a06333 comment
kono
parents: 184
diff changeset
1108 /* type represented in a list */
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1109 switch(car(t)) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1110 case STRUCT:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1111 case UNION:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1112 if(cadr(t)==-1) error(DCERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1113 return(cadr(t));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1114 case ARRAY:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1115 return(size(cadr(t))*caddr(t));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1116 case CODE:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1117 return size_of_int;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1118 case FUNCTION:
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
1119 return size_of_int;
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1120 case POINTER:
77
2b8ba655e572 fix arg type
kono
parents: 76
diff changeset
1121 return size_of_int;
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1122 default:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1123 error(DCERR);
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
1124 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1125 return 0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1126 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1127
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1128 #define hash_value(hash,ch) (hash = (39*hash)^((unsigned char)(ch)))
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1129
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1130 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1131 new name for static global variable
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1132 delimitor _
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1133 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1134
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1135 extern NMTBL *
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1136 new_static_name(char *name,int delimit)
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1137 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1138
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1139 int ndsp,ch,len=0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
1140 char *p = cheap->ptr;
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1141 char *q = name;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1142 unsigned int hash = 0;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1143 struct cheap scheap;
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
1144 NMTBL *n;
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
1145 #if 1
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
1146 NMTBL *nlist;
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
1147 #endif
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1148
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1149 while((ch = *name++)) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1150 hash_value(hash,*cheap->ptr = ch);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1151 increment_cheap(cheap,&p);len++;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1152 }
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1153 ndsp = ++stat_no;
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
1154 *cheap->ptr = delimit;
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1155 increment_cheap(cheap,&p); if (delimit=='_') len++;
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1156 while(ndsp>0) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1157 ch = ndsp%10+'0';
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1158 if (delimit=='_')
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1159 hash_value(hash,*cheap->ptr = ch);
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1160 else
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1161 *cheap->ptr = ch;
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1162 increment_cheap(cheap,&p);if (delimit=='_') len++;
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1163 ndsp /= 10;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1164 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
1165 *cheap->ptr = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
1166 increment_cheap(cheap,&p);
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1167 save_cheap(&scheap,cheap);
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
1168 n = name_space_search(nlist=hash_search(delimit=='_'?p:q,&scheap,len,hash,DEF),0);
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
1169 n->nm = p;
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
1170 return n;
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1171 }
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1172
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1173 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1174 data declaration
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1175 a[] = {,,,,};
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1176 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1177
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1178 #define LOCAL_STRUCT_INIT_STATIC 1
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1179
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1180 static void
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1181 decl_data_field(int type,NMTBL *n,int offset)
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1182 {
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1183 int e,t1;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1184 int foffset;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1185 int offset0 = offset;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1186 int decl_str_init_save = decl_str_init;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1187 int mode_save=mode;
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1188 NMTBL *nptr0;
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1189
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1190 decl_str_init = 0;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1191 if(cadr(type)==-1) {
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1192 error(DCERR);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1193 return;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1194 }
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1195 if (mode==LDECL && LOCAL_STRUCT_INIT_STATIC) {
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1196 // uninitialized part should be 0.
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1197 // local var init cannot postponed because of assign_expr0/type
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1198 nptr0=new_static_name("__lstruct",'_');
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
1199 nptr0->next = local_static_list; local_static_list = nptr0;
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1200 nptr0->sc = GVAR;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1201 e = size(type);
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1202 nptr0->ty = type;
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1203 mode=STADECL;
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1204 decl_data_field(type,nptr0,offset);
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1205 init_vars = list2(
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1206 list4(STASS,list2(LVAR,n->dsp+offset),
367
4efbb07f556b global variable offset
kono
parents: 363
diff changeset
1207 list3(RSTRUCT,list3(GVAR,0,(int)nptr0),e),e),
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1208 init_vars);
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1209 return;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1210 }
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1211 mode=SFDINIT;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1212 t1 = caddr(type); /* list of fields */
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1213 while(1) {
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1214 getsym(0);
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1215 if (sym==PERIOD) { /* struct/union field initializaer */
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1216 getsym(0);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1217 if (sym==IDENT) {
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1218 t1 = search_struct_type(type,nptr->nm,&foffset);
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1219 getsym(0);
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1220 if (sym==ASS) {
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1221 decl_data(t1,n,foffset,0);
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1222 } else
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1223 error(TYERR); /* should be initialization error */
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1224 } else
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1225 error(TYERR); /* should be initialization error */
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1226 } else {
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1227 if(!t1) {
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1228 // empty field case (it can happen...)
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1229 break;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1230 }
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1231 // next decl_data must skip getsym
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1232 offset = decl_data(car(t1),n,offset,1); /* alignment? */
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1233 t1 = cadr(t1);
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1234 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1235 if ( t1 && sym==COMMA) { conv->comma_(); continue; }
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1236 // if (!t1 && sym==COMMA) getsym(0); /* extra comma */
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1237 if (sym==RC) break; // premature end
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1238 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1239 mode = mode_save;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1240 offset = offset0;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1241 /*
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1242 decl_str_init
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1243 list4(offset,next,expression,type);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1244 */
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1245 while (decl_str_init) {
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1246 offset= car(decl_str_init);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1247 e=caddr(decl_str_init);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1248 type=cadddr(decl_str_init);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1249 if (offset!=offset0) {
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1250 // make space
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1251 assign_data(list2(CONST,offset-offset0),EMPTY,n,offset0);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1252 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1253 offset0 = assign_data(e,type,n,offset);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1254 decl_str_init = cadr(decl_str_init);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1255 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1256 decl_str_init = decl_str_init_save;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1257 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1258
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1259 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1260 data structure initialization
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1261 */
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
1262
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1263 static int
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1264 decl_data(int t, NMTBL *n,int offset,int skip)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1265 {
32
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1266 int t1,e,i,mode_save;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1267
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1268 if (offset==0 && n->sc==GVAR && n->dsp==-1) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1269 /* duplicate initialization */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1270 error(INERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1271 }
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1272 conv->decl_data_();
32
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1273 mode_save = mode;
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1274 mode=STAT;
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1275 if (!skip) getsym(0);
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1276 if (sym==RC) { /* premature end (not necessary?) */
179
fde8cb5d9254 *** empty log message ***
kono
parents: 178
diff changeset
1277 conv->decl_data_end_();
fde8cb5d9254 *** empty log message ***
kono
parents: 178
diff changeset
1278 mode = mode_save;
fde8cb5d9254 *** empty log message ***
kono
parents: 178
diff changeset
1279 return offset;
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1280 } else if (scalar(t)) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1281 e=expr1();
32
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1282 mode = mode_save;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1283 if(car(e)!=CONST && t==CHAR)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1284 error(TYERR);
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1285 offset = assign_data(e,t,n,offset);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1286 type=t;
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1287 return offset;
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1288 } else if (t==FLOAT||t==DOUBLE||t==LONGLONG||t==ULONGLONG) {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1289 e=expr1();
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1290 mode = mode_save;
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1291 offset = assign_data(e,t,n,offset);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1292 type=t;
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
1293 return offset;
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1294 } else if ((t1 = car(t)) && t1==ARRAY) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1295 if (sym==LC) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1296 conv->decl_data_begin_();
32
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1297 mode = mode_save;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1298 t1 = cadr(t);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1299 for(i=0;;i++) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1300 if (sym!=RC)
310
5ae5857ded2c struct partial init done.
kono
parents: 309
diff changeset
1301 offset=decl_data(t1,n,offset,0); /* array of some thing */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1302 if (sym==COMMA) {
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1303 conv->comma_();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1304 continue;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1305 } else if (sym==RC) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1306 conv->decl_data_end_();
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1307 if (caddr(t)==0) { /* size not defined */
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1308 caddr(t)=i+1; /* define array size */
179
fde8cb5d9254 *** empty log message ***
kono
parents: 178
diff changeset
1309 } else if (0 && caddr(t)!=i+1) { /* size match? */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1310 error(TYERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1311 }
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1312 getsym(0);
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1313 return offset;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1314 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1315 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1316 /* NOT REACHED */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1317 } else if (cadr(t)==CHAR) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1318 e=expr1();
32
b35787d8a442 macro initialization
kono
parents: 31
diff changeset
1319 mode = mode_save;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1320 if(car(e)!=STRING)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1321 error(TYERR);
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1322 offset=assign_data(e,list3(ARRAY,CHAR,size(type)),n,offset);
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1323 if (caddr(t)==0) { /* size not defined */
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1324 caddr(t)=size(type); /* define array size */
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1325 } else if (caddr(t)!=size(type)) { /* size match? */
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1326 error(TYERR);
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1327 }
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1328 return offset; /* not reached */
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1329 }
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1330 } else if (t1==BIT_FIELD) {
329
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1331 e=expr1();
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1332 mode = mode_save;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1333 offset = assign_data(e,t,n,offset);
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1334 type=t;
4c8f8ef8c0cf bit field continue...
kono
parents: 328
diff changeset
1335 return offset;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1336 } else if (t1==STRUCT) {
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1337 if (sym==LC) {
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1338 conv->lc_(); conv->decl_data_begin_();
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1339 mode = mode_save;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1340 decl_data_field(t,n,offset);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1341 conv->decl_data_end_(); conv->rc_();
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1342 checksym(RC);
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1343 return offset+size(t);
140
aac62d1e30a6 fix minor syntax error
kono
parents: 138
diff changeset
1344 } else if (sym==RC) { /* empty case */
aac62d1e30a6 fix minor syntax error
kono
parents: 138
diff changeset
1345 conv->lc_();
aac62d1e30a6 fix minor syntax error
kono
parents: 138
diff changeset
1346 return offset;
308
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1347 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1348 }
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1349 mode = mode_save;
e1d17d6adfcc struct field init (first try, no compile error)
kono
parents: 307
diff changeset
1350 error(TYERR); /* should be initialization error */
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
1351 return offset; /* not reached */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1352 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1353
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1354 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1355 declaration in struct/union
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1356 */
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1357 static void
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1358 sdecl_field()
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1359 {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1360 while (getsym(0) != RC) {
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1361 decl();
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1362 }
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1363 if (sdecl_f) conv->rc_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1364 getsym(0);
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1365 fields = reverse0(fields);
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1366 }
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1367
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1368 #if 0
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1369 static void
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1370 print_fields(int fields,char *s) {
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1371 for(;fields;fields=cadr(fields)) {
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1372 fprintf(stderr,"%s %s %d %d\n",s,(char*)caddr(fields),car(fields),cadddr(fields));
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1373 }
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1374 fprintf(stderr,"\n");
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1375 }
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1376 #endif
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1377
185
427008a06333 comment
kono
parents: 184
diff changeset
1378 /*
427008a06333 comment
kono
parents: 184
diff changeset
1379 struct/union
427008a06333 comment
kono
parents: 184
diff changeset
1380 tag ... struct/union name
427008a06333 comment
kono
parents: 184
diff changeset
1381 nptr0->sc = TAG;
427008a06333 comment
kono
parents: 184
diff changeset
1382 nptr0->ty = list4(...)
427008a06333 comment
kono
parents: 184
diff changeset
1383 type ... list4(STRUCT,disp,fields,(int)nptr0);
427008a06333 comment
kono
parents: 184
diff changeset
1384 filed ... assoc list defined in def();
427008a06333 comment
kono
parents: 184
diff changeset
1385 */
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1386 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1387 sdecl(int s)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1388 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1389 int smode,sdisp,sbit_field_disp,type0=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1390 NMTBL *nptr0,*gnptr0;
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1391 int sfields = fields;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1392
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1393 fields = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1394 smode=mode;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1395 if (mode==GDECL || mode==GSDECL || mode==GUDECL || mode==GTDECL)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1396 mode=(s==STRUCT?GSDECL:GUDECL);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1397 else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1398 mode=(s==STRUCT?LSDECL:LUDECL);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1399 sdisp=disp;
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1400 sbit_field_disp=bit_field_disp;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1401 disp=0;
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1402 bit_field_disp=0;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1403 if (sdecl_f) conv->sdecl_(s);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1404 if (getsym(TAG) == IDENT) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1405 nptr0 = nptr;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1406 gnptr0 = gnptr;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1407 if (sdecl_f) conv->id_(sym,nptr);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1408 if (getsym(0) == LC) {
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1409 if (sdecl_f) conv->lc_();
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
1410 if(nptr0->sc == EMPTY) nptr0=gnptr0;
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
1411 if (nptr0->sc!=TAG && nptr0->sc != EMPTY) error(DCERR);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1412 nptr0->sc = TAG;
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
1413 nptr0->ty = list4(s,-1,0,(int)nptr0);
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1414 sdecl_field();
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1415 caddr(nptr0->ty)=fields;
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1416 cadr((type0 = nptr0->ty))=disp;
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1417 /* type0 = list4(s,disp,fields,0); now ... */
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1418 } else {
13
a8a812dace23 struct local initialization
kono
parents: 7
diff changeset
1419 /* struct tag name */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1420 if(nptr0->sc == EMPTY) nptr0=gnptr0;
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
1421 if(nptr0->sc == EMPTY) nptr0->sc = TAG;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1422 if(nptr0->sc != TAG) error(TYERR);
323
d5cb084fc3f4 typedef struct tag before struct fields def.
kono
parents: 322
diff changeset
1423 if (nptr0->ty) {
d5cb084fc3f4 typedef struct tag before struct fields def.
kono
parents: 322
diff changeset
1424 fields = caddr(nptr0->ty);
d5cb084fc3f4 typedef struct tag before struct fields def.
kono
parents: 322
diff changeset
1425 disp = cadr(nptr0->ty);
d5cb084fc3f4 typedef struct tag before struct fields def.
kono
parents: 322
diff changeset
1426 }
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1427 conv->comment_(' ');
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1428 type0 = list4(s,disp,fields,(int)nptr0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1429 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1430 } else if(sym==LC) {
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1431 if (sdecl_f) conv->lc_();
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1432 sdecl_field();
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1433 type0 = list4(s,disp,fields,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1434 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1435 else error(DCERR);
161
cc2fc5c0dfe5 struct field fix
kono
parents: 160
diff changeset
1436
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1437 stypedecl=1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1438 disp=sdisp;
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1439 bit_field_disp=sbit_field_disp;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1440 mode=smode;
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
1441 fields = sfields;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1442 return type0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1443 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1444
185
427008a06333 comment
kono
parents: 184
diff changeset
1445 /*
427008a06333 comment
kono
parents: 184
diff changeset
1446 enum
427008a06333 comment
kono
parents: 184
diff changeset
1447 */
427008a06333 comment
kono
parents: 184
diff changeset
1448
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1449 static int
176
kono
parents: 174
diff changeset
1450 edecl()
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1451 {
176
kono
parents: 174
diff changeset
1452 int smode=mode;
kono
parents: 174
diff changeset
1453 int sdisp=disp;
kono
parents: 174
diff changeset
1454 NMTBL *nptr0;
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
1455
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
1456 if (mode==GDECL || mode==GTDECL)
176
kono
parents: 174
diff changeset
1457 mode=GEDECL;
kono
parents: 174
diff changeset
1458 else
kono
parents: 174
diff changeset
1459 mode=LEDECL;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1460 if (getsym(0) == IDENT) {
176
kono
parents: 174
diff changeset
1461 nptr->sc = TAG;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1462 getsym(0);
176
kono
parents: 174
diff changeset
1463 }
kono
parents: 174
diff changeset
1464 if(sym==LC) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1465 while (getsym(0) == IDENT) {
176
kono
parents: 174
diff changeset
1466 nptr->sc = ENUM;
kono
parents: 174
diff changeset
1467 nptr->ty = INT;
kono
parents: 174
diff changeset
1468 nptr0 = nptr;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1469 if (getsym(0) == ASS) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1470 getsym(0);
176
kono
parents: 174
diff changeset
1471 disp = cexpr(expr1());
kono
parents: 174
diff changeset
1472 }
kono
parents: 174
diff changeset
1473 nptr0->dsp = disp;
kono
parents: 174
diff changeset
1474 if (sym!=COMMA) break;
kono
parents: 174
diff changeset
1475 disp++;
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1476 }
176
kono
parents: 174
diff changeset
1477 checksym(RC);
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1478 }
176
kono
parents: 174
diff changeset
1479 type = ENUM;
kono
parents: 174
diff changeset
1480 disp=sdisp;
174
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1481 mode=smode;
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1482 return type;
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1483 }
8b0ffe9b933d enum first try
kono
parents: 173
diff changeset
1484
185
427008a06333 comment
kono
parents: 184
diff changeset
1485 /* code sgement
427008a06333 comment
kono
parents: 184
diff changeset
1486 simpler than fdecl, because it does not have return value.
427008a06333 comment
kono
parents: 184
diff changeset
1487 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1488 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1489 code_decl(NMTBL *n)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1490 {
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1491 int t,arglist;
53
64a4e3789fd2 parallel assign works.
kono
parents: 50
diff changeset
1492
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1493 if(!chk) gen_code_enter(n->nm);
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
1494 extrn_use(n);
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
1495 local_static_list = &null_nptr;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1496 fnptr=n;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1497 n->sc = CODE;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1498 n->ty = type;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1499 fcheck(n);
3
kono
parents: 2
diff changeset
1500 disp = -args;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1501 mode=ADECL;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1502 if (sym!=LC) {
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1503 arglist=fnptr->dsp;
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1504 args=fnptr->dsp=0;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1505 while (sym!=LC) { /* argument declaration !ANSI */
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1506 decl(); getsym(0);
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1507 }
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
1508 disp = -args;
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1509 fnptr->dsp = arg_reorder(arglist,fnptr->dsp);
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1510 // fnptr->dsp = reverse0(fnptr->dsp);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1511 }
53
64a4e3789fd2 parallel assign works.
kono
parents: 50
diff changeset
1512 /* reverse all argument offset (with size) */
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1513 arglist = fnptr->dsp;
53
64a4e3789fd2 parallel assign works.
kono
parents: 50
diff changeset
1514 for(t=arglist;t;t=cadr(t)) {
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1515 n=(NMTBL *)caddr(t);
53
64a4e3789fd2 parallel assign works.
kono
parents: 50
diff changeset
1516 if(n->sc==LVAR)
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1517 n->dsp = -n->dsp-cadddr(t);
53
64a4e3789fd2 parallel assign works.
kono
parents: 50
diff changeset
1518 }
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1519 arg_register(fnptr);
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1520 conv->code_(fnptr);
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
1521 typedefed=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1522 /* local variable declaration */
d35df41eac69 Initial revision
kono
parents:
diff changeset
1523 stmode=0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1524 mode=STAT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1525 init_vars=0;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1526 while (typeid(getsym(0)) || sym==STATIC || sym==EXTRN || sym==TYPEDEF) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1527 mode=LDECL;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1528 decl();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1529 mode=STAT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1530 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1531 conv->localvar_end_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1532 control=1;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1533 cslabel = -1;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1534 if(!chk) gen_code_enter1(args);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1535 emit_init_vars();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1536 while(sym!=RC) statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1537 if(control)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1538 error(STERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1539 control=0;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1540 conv->code_end_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1541 if(!chk) gen_code_leave(fnptr->nm);
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1542 args = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1543 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1544
45
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
1545 static NMTBL *tmp_struct;
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
1546
185
427008a06333 comment
kono
parents: 184
diff changeset
1547 /* local decl can be used, after {} */
427008a06333 comment
kono
parents: 184
diff changeset
1548 /* but it's lexical scope remains after {} */
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1549 /* my be in for(int i=....) not yet (fixed already?) */
185
427008a06333 comment
kono
parents: 184
diff changeset
1550
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1551 static void
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1552 local_decl()
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1553 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1554 enter_scope();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1555 init_vars=0;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1556 /* local variable declaration */
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1557 stmode=0;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1558 mode=STAT;
362
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
1559 while (typeid(getsym(0)) || sym==STATIC || sym==EXTRN || sym==LABEL
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1560 || sym==REGISTER || sym==TYPEDEF) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1561 mode=LDECL;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1562 stmode=0;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1563 decl();
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1564 mode=STAT;
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1565 }
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1566 conv->localvar_end_();
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1567 }
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1568
185
427008a06333 comment
kono
parents: 184
diff changeset
1569 /* function define */
427008a06333 comment
kono
parents: 184
diff changeset
1570
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1571
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1572 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1573 fdecl(NMTBL *n)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1574 {
75
92dcf107a837 c code output
kono
parents: 72
diff changeset
1575 int sd = stypedecl;
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1576 int arglist;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1577 if(!chk) gen_enter(n->nm);
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
1578 extrn_use(n);
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
1579 local_static_list = &null_nptr;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1580 fnptr=n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1581 retlabel=fwdlabel();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1582 retcont = 0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1583 if (tmp_struct) { tmp_struct->sc = 0; tmp_struct->nm = 0; }
185
427008a06333 comment
kono
parents: 184
diff changeset
1584 tmp_struct = 0; /* a = f().filed */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1585
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1586 n->ty = type;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1587 fcheck(n);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
1588 n->sc = FUNCTION;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1589 mode=ADECL;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1590 if (sym!=LC) {
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1591 arglist = fnptr->dsp;
186
6391432ca002 nkf binary fix
kono
parents: 185
diff changeset
1592 fnptr->dsp =args=0;
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
1593 while (sym!=LC) { /* argument declaration !ANSI */
254a0c576114 argument type list
kono
parents: 66
diff changeset
1594 stmode=0;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1595 decl(); getsym(0);
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
1596 }
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1597 // This order can be different from proto type. Proto type is correct.
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1598 // Recalculate offset using prototype list.
187
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1599 // arglist is set by adecl() and is reversed.
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1600 fnptr->dsp = arg_reorder(arglist,fnptr->dsp);
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1601 }
dffcccf8b1cb nested COND
kono
parents: 186
diff changeset
1602 fnptr->dsp=reverse0(fnptr->dsp);
185
427008a06333 comment
kono
parents: 184
diff changeset
1603 fdecl_struct(fnptr->ty); /* insert extra argument for struct passing */
111
7aa449aff3e6 floating point
kono
parents: 109
diff changeset
1604 disp=0;
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1605 arg_register(fnptr);
70
2e84590720a6 typedef name
kono
parents: 69
diff changeset
1606 typedefed=0;
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
1607 conv->function_(fnptr,sd); conv->lc_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1608 init_vars=0;
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
1609
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1610 /* local variable declaration */
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1611 local_decl();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1612 control=1;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1613 cslabel = -1;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1614 if(!chk) gen_enter1();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1615 emit_init_vars();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1616 while(sym!=RC) statement(0);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1617 leave_scope();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1618
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
1619 conv->function_end_(); conv->rc_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1620 if(!chk) gen_leave(control,n->nm);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1621 retpending = 0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1622 control=0;
75
92dcf107a837 c code output
kono
parents: 72
diff changeset
1623 arglist=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1624 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1625
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1626 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1627 basic C statement
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1628 */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1629
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1630 static void
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1631 statement(int use)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1632 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1633 int slfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1634
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1635 if(sym==SM) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1636 conv->sm_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1637 getsym(0); return;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1638 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1639 switch(sym) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1640 case IF:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1641 doif();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1642 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1643 case WHILE:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1644 dowhile();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1645 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1646 case DO:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1647 dodo();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1648 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1649 case FOR:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1650 dofor();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1651 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1652 case SWITCH:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1653 doswitch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1654 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1655 case LC:
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1656 docomp(use);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1657 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1658 case BREAK:
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1659 checkret();
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1660 conv->break_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1661 if (control) gen_jmp(blabel);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1662 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1663 checksym(SM);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1664 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1665 case CONTINUE:
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1666 checkret();
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1667 conv->continue_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1668 if (control) gen_jmp(clabel);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1669 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1670 checksym(SM);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1671 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1672 case CASE:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1673 docase();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1674 statement(use); return;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1675 case DEFAULT:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1676 dodefault();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1677 statement(use); return;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1678 case RETURN:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1679 doreturn();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1680 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1681 case GOTO:
d35df41eac69 Initial revision
kono
parents:
diff changeset
1682 dogoto();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1683 return;
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1684 #if ASM_CODE
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1685 case ASM:
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1686 doasm();
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1687 return;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1688 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1689 default:
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1690 checkret();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1691 if(sym==IDENT&&skipspc()==':') {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1692 dolabel();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1693 statement(use);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1694 } else {
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1695 if (use) {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1696 lastexp = expr(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1697 return;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1698 } else {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1699 slfree=lfree;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1700 gexpr(expr(0),use);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1701 lfree=slfree;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1702 conv->sm_();
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1703 checksym(SM);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1704 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1705 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1706 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1707 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1708
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1709 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1710 doif(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1711 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1712 int l1,l2,slfree;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1713 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1714 checksym(LPAR);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1715 conv->if_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1716 slfree=lfree;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1717 checkret();
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1718 bexpr(expr(0),0,l1=fwdlabel());
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1719 lfree=slfree;
71
be313430f90b *** empty log message ***
kono
parents: 70
diff changeset
1720 conv->if_then_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1721 checksym(RPAR);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1722 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1723 checkret();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1724 if(sym==ELSE) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1725 conv->if_else_();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1726 if ((l2 = control))
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1727 gen_jmp(l2=fwdlabel());
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1728 fwddef(l1);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1729 getsym(0);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1730 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1731 checkret();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1732 if (l2) fwddef(l2);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1733 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1734 else fwddef(l1);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1735 conv->if_endif_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1736 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1737
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1738 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1739 dowhile(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1740 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1741 int sbreak,scontinue,slfree,e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1742
d35df41eac69 Initial revision
kono
parents:
diff changeset
1743 sbreak=blabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1744 scontinue=clabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1745 blabel=fwdlabel();
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1746 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1747 checkret();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1748 clabel=backdef();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1749 conv->while_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1750 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1751 checksym(LPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1752 slfree=lfree;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1753 e=expr(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1754 checksym(RPAR);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1755 conv->while_body_();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1756 if(sym==SM) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1757 bexpr(e,1,clabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1758 lfree=slfree;
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1759 conv->sm_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1760 getsym(0);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1761 } else {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1762 bexpr(e,0,blabel);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1763 // lfree=slfree;
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1764 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1765 checkret();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1766 if(control)
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1767 gen_jmp(clabel);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1768 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1769 conv->while_end_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1770 fwddef(blabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1771 clabel=scontinue;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1772 blabel=sbreak;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1773 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1774
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1775 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1776 dodo(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1777 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
1778 int sbreak,scontinue,l,slfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1779
d35df41eac69 Initial revision
kono
parents:
diff changeset
1780 sbreak=blabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1781 scontinue=clabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1782 blabel=fwdlabel();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1783 clabel=fwdlabel();
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1784 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1785 checkret();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1786 l=backdef();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1787 conv->dowhile_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1788 getsym(0);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1789 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1790 checkret();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1791 fwddef(clabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1792 checksym(WHILE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1793 checksym(LPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1794 slfree=lfree;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1795 conv->dowhile_cond_();
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1796 bexpr(expr(0),1,l);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1797 lfree=slfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1798 checksym(RPAR);
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1799 conv->dowhile_end_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1800 checksym(SM);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1801 fwddef(blabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1802 clabel=scontinue;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1803 blabel=sbreak;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1804 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1805
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1806 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1807 dofor(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1808 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1809 int sbreak,scontinue,l,e,slfree,dflag=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1810
d35df41eac69 Initial revision
kono
parents:
diff changeset
1811 sbreak=blabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1812 scontinue=clabel;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1813 blabel=fwdlabel();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1814 conv->for_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1815 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1816 checksym(LPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1817 slfree=lfree;
362
5cf12c7a3274 local label first try
kono
parents: 360
diff changeset
1818 if (typeid(sym) || sym==REGISTER ) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1819 enter_scope(); dflag = 1;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1820 mode=LDECL;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1821 stmode=0;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1822 decl();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1823 mode=STAT;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1824 checkret();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1825 emit_init_vars();
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
1826 getsym(0);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1827 } else if(sym!=SM) {
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1828 checkret();
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1829 gexpr(expr(0),0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1830 checksym(SM);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1831 conv->for1_();
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1832 } else {
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1833 conv->for1_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1834 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1835 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1836 lfree=slfree;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1837 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1838 checkret();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1839 l=backdef();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1840 if(sym!=SM) {
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1841 bexpr(expr(0),0,blabel);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1842 checksym(SM);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1843 conv->for2_();
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1844 } else {
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
1845 conv->for2_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1846 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1847 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1848 lfree=slfree;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1849 if(sym==RPAR) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1850 clabel=l;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1851 conv->for_body_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1852 getsym(0);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1853 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1854 checkret();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
1855 } else {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1856 clabel=fwdlabel();
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
1857 e=expr(0);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1858 conv->for_body_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1859 checksym(RPAR);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1860 statement(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1861 checkret();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1862 fwddef(clabel);
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1863 gexpr(e,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1864 lfree=slfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1865 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1866 if (dflag) leave_scope();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1867 conv->for_end_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1868 gen_jmp(l);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1869 fwddef(blabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1870 clabel=scontinue;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1871 blabel=sbreak;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1872 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1873
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1874 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1875 compound statement {}
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1876 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
1877 static void
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1878 docomp(int use)
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1879 {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1880 conv->lc_();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1881 local_decl();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1882 emit_init_vars();
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1883 while(sym!=RC) statement(use);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1884 conv->rc_();
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
1885 leave_scope();
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1886 getsym(0);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1887 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1888
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1889 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1890 CASE_CODE generates table jump
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1891 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1892
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1893 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1894 doswitch(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1895 {
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1896 int sbreak,scase,sdefault,slfree,svalue,slist;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1897
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1898 checkret();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1899 slist = cslist;
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1900 cslist = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1901 sbreak=blabel; /* save parents break label */
d35df41eac69 Initial revision
kono
parents:
diff changeset
1902 blabel=fwdlabel();
d35df41eac69 Initial revision
kono
parents:
diff changeset
1903 sdefault=dlabel; /* save parents default label */
d35df41eac69 Initial revision
kono
parents:
diff changeset
1904 dlabel=0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1905 scase=cslabel; /* save parents next case label */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1906 conv->switch_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
1907 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1908 checksym(LPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1909 slfree=lfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1910 svalue=csvalue1; /* save parents switch value */
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
1911 gexpr(expr(0),1);
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1912 if (!scalar(type)) error(EXERR);
42
a89cf0d6904f regv assop
kono
parents: 40
diff changeset
1913 csvalue1=csvalue() ;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1914 lfree=slfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1915 checksym(RPAR);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1916 conv->switch_body_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1917 cslabel = control = 0;
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1918 /* next syntax should be a case statement but...
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1919 main() {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1920 int i=3,j=1,k=0;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1921 switch(i) {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1922 for(;j<10;j++) {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1923 case 3: k++; case 2: k++; case 1: k++; case 0: k++;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1924 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1925 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1926 printf("%d\n",k);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1927 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1928 In this case, we have to jump into the first case label.
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1929 Can be done in checkret();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1930 */
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
1931 statement(0);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
1932 conv->switch_end_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1933 checkret();
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1934 #if CASE_CODE
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
1935 if (control) gen_jmp(blabel);
299
3d260008c449 level 2 looks ok.
kono
parents: 297
diff changeset
1936 genswitch(cslist,cslabel);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1937 #else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1938 if(dlabel) def_label(cslabel,dlabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1939 else fwddef(cslabel);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1940 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1941 csvalue1=svalue;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1942 cslabel=scase;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1943 dlabel=sdefault;
d35df41eac69 Initial revision
kono
parents:
diff changeset
1944 fwddef(blabel);
d35df41eac69 Initial revision
kono
parents:
diff changeset
1945 blabel=sbreak;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1946 cslist = slist;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1947 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
1948
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1949 /* used in insert ascend */
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1950 static int
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1951 docase_eq()
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1952 {
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1953 error(-1); // duplicate case value
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
1954 return 0; // remove duplicate value
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1955 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1956
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1957 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1958 docase(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
1959 {
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1960 #if CASE_CODE
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1961 int l,clist=0,c;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1962 l = fwdlabel();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1963 while(sym==CASE) {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1964 conv->case_begin_(0,0);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1965 getsym(0);
311
38c9976863b7 swtich list fix. macro fix.
kono
parents: 310
diff changeset
1966 clist=glist3(cexpr(expr(1)),clist,l);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1967 conv->case_(0,0);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1968 checksym(COLON);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1969 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1970 if (retpending) { ret(); retpending=0; }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1971 if (!cslabel) {
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1972 if (!control) {
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1973 // immediate after switch(i) (usual case)
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1974 // use it for jump to table lookup
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1975
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1976 cmpdimm(car(clist),csvalue1,cslabel=fwdlabel(),1);
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1977
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1978 // Insert anyway to check duplicate case value.
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1979 // Mark it already used.
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1980
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1981 caddr(clist)=0;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1982
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1983 } else {
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1984 // checkret() sequence inconsistent
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1985 // This can't happen, because checkret() force table lookup jump
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
1986 // before any executable instruction in switch such as switch-for.
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1987 error(-1);
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1988 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1989 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1990 // Make ascend order list of case value
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1991 while(clist) {
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1992 clist = cadr(c=clist); cadr(c) = 0; // insert destroy cadr of clist
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
1993 cslist=insert_ascend(cslist,c,docase_eq);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1994 }
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1995 fwddef(l);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1996 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
1997 #else
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
1998 /* casading branch implementation */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
1999 int c,l,slfree;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2000 l = 0;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2001 if (retpending) ret();
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2002 slfree=lfree;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2003 c=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2004 while(sym==CASE) {
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
2005 conv->case_begin_(c,0);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2006 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2007 c=list2(cexpr(expr(1)),c);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2008 conv->case_(c,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2009 checksym(COLON);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2010 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2011 if (control) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2012 control=0;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2013 gen_jmp(l=fwdlabel());
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2014 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2015 if (cslabel) fwddef(cslabel);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2016 while(cadr(c)) {
287
a0779a414855 *** empty log message ***
kono
parents: 285
diff changeset
2017 cmpdimm(car(c),csvalue1,l,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2018 c=cadr(c);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2019 }
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2020 cmpdimm(car(c),csvalue1,cslabel=fwdlabel(),1);
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2021 if (l) fwddef(l);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2022 lfree=slfree;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2023 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2024 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2025
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2026 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2027 dodefault(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2028 {
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2029 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2030 checkret();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2031 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2032 checksym(COLON);
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2033 if (dlabel) error(STERR); // double default:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2034 dlabel = backdef();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2035 conv->case_(0,1);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2036 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2037
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2038 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2039 doreturn(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2040 {
39
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
2041 int slfree,e,e1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2042
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2043 if (!cslabel) gen_jmp(cslabel = fwdlabel());
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2044 if(getsym(0)==SM) {
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2045 // should check fnptr have no return value
71
be313430f90b *** empty log message ***
kono
parents: 70
diff changeset
2046 conv->return_();
be313430f90b *** empty log message ***
kono
parents: 70
diff changeset
2047 conv->return_end_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2048 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2049 retpending = 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2050 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2051 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2052 conv->return_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2053 slfree=lfree;
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2054 if (struct_return) {
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2055 e = expr(0);
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2056 if ((car(type)==STRUCT || car(type)==UNION)&&
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2057 size(type)==cadr(struct_return)) {
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2058 if(car(e)==RSTRUCT && car(cadr(e))==FUNCTION) {
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2059 /* pass the return pointer to the called function */
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2060 replace_return_struct(cadr(e),
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2061 rvalue_t(car(struct_return),caddr(struct_return)));
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2062 gexpr(cadr(e),0);
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2063 } else {
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2064 type = caddr(struct_return);
306
1ec915dcd2d1 struct return size error
kono
parents: 305
diff changeset
2065 // e1 = rvalue_t(cadr(struct_return),INT); /* size */
1ec915dcd2d1 struct return size error
kono
parents: 305
diff changeset
2066 e1 = cadr(struct_return); /* size */
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2067 gexpr(list4(STASS,rvalue(car(struct_return)),e,e1),0);
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
2068 }
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2069 } else {
39
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
2070 error(TYERR); /* should check compatible */
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2071 }
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2072 } else {
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
2073 gexpr(correct_type(expr(0),cadr(fnptr->ty)),1);
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
2074 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2075 lfree=slfree;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2076 conv->return_end_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2077 checksym(SM);
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2078 /* control = 0; still control continue until pending return emission */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2079 retpending = 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2080 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2081
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2082 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2083 dogoto(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2084 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2085 NMTBL *nptr0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2086 int t,e1,e2,env;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2087
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2088 checkret();
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2089 conv->goto_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2090 getsym(0);
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2091 e1 = expr(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2092 t=car(e1);
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2093 if (type==VOID) {
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2094 if (car(e1)==RINDIRECT) {
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2095 gen_indirect_goto(cadr(e1));
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2096 } else error(TYERR);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2097 checksym(SM);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2098 return;
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2099 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2100 if (t==FNAME) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2101 nptr0 = (NMTBL *)cadr(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2102 t = nptr0->sc;
223
1ac647873577 *** empty log message ***
kono
parents: 221
diff changeset
2103 if (t==EMPTY||t==EXTRN1||t==EXTRN) {
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2104 nptr0->sc=EMPTY;
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
2105 nptr0=l_top_search(nptr0->nm,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2106 nptr0->sc = FLABEL;
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2107 gen_jmp(nptr0->dsp = fwdlabel());
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2108 } else if (t==FLABEL||t==BLABEL) {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2109 gen_jmp(nptr0->dsp);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2110 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2111 control=0;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
2112 conv->sm_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2113 checksym(SM);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2114 conv->goto_label_(nptr0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2115 return;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2116 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2117 if (t==COMMA) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2118 env = caddr(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2119 e1 = cadr(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2120 t = car(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2121 } else {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2122 env = 0;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2123 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2124 if (t==FUNCTION) {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2125 /* CbC continuation */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2126 conv->jump_(env);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2127 e2 = cadr(e1);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2128 if (car(e2) == FNAME) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2129 nptr0=(NMTBL *)cadr(e2);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2130 if (nptr0->sc==EMPTY)
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2131 nptr0->sc = EXTRN1;
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2132 else if(nptr0->sc==FUNCTION)
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2133 nptr0->sc = CODE;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2134 if (nptr0->ty>0&&car(nptr0->ty)==FUNCTION)
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2135 car(nptr0->ty)=CODE;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2136 }
83
f3f75911d62c *** empty log message ***
kono
parents: 82
diff changeset
2137 gexpr(list3(CODE,e1,env),0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2138 control=0;
76
fb3fb9e9a462 *** empty log message ***
kono
parents: 75
diff changeset
2139 conv->sm_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2140 checksym(SM);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2141 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2142 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2143 error(STERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2144 return;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2145 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2146
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2147 static void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2148 dolabel(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2149 {
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
2150 NMTBL *nptr1;
292
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2151 control=1;
6d4231b6f9fe switch statement prepare
kono
parents: 287
diff changeset
2152 checkret();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2153 if(nptr->sc == FLABEL)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2154 fwddef(nptr->dsp);
201
3ae7e188416f *** empty log message ***
kono
parents: 197
diff changeset
2155 else if(nptr->sc != EMPTY && nptr->sc != EXTRN1)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2156 error(TYERR);
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2157 nptr->sc=EMPTY;
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
2158 nptr1=l_top_search(nptr->nm,0);
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
2159 nptr1->sc = BLABEL;
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
2160 nptr1->dsp = backdef();
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
2161 conv->label_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2162 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2163 checksym(COLON);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2164 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2165
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2166 #if ASM_CODE
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2167
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2168 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2169 asm( asm_string : output expr : input expr : option_string )
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2170 */
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2171 static void
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2172 doasm()
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2173 {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2174 int e1 = 0, asm0 = 0, input = 0, out = 0, opt = 0;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2175 int e;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2176
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2177 checkret();
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2178 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2179 if (sym==VOLATILE) getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2180 checksym(LPAR);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2181 // asm string
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2182 if (sym!=STRING) error(DCERR);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2183 asm0=list3(STRING,(int)nptr->nm,nptr->dsp);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2184 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2185 if (sym!=COLON) error(DCERR);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2186 do {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2187 // output expression
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2188 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2189 if (sym==COLON) break;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2190 if (sym!=STRING) error(DCERR);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2191 out=list2(list3(STRING,(int)nptr->nm,nptr->dsp),out);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2192 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2193 e1=list2(e=expr1(),e1);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2194 lcheck(e);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2195 } while(sym==COMMA);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2196 if (sym==COLON) {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2197 do {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2198 // input expression
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2199 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2200 if (sym==COLON) break;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2201 if (sym!=STRING) error(DCERR);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2202 input=list2(list3(STRING,(int)nptr->nm,nptr->dsp),input);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2203 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2204 e1=list2(expr1(),e1);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2205 } while(sym==COMMA);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2206 }
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2207 if (sym==COLON) {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2208 do {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2209 // option string
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2210 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2211 if (sym!=STRING) error(DCERR);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2212 opt=list2(list3(STRING,(int)nptr->nm,nptr->dsp),opt);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2213 getsym(0);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2214 } while(sym==COMMA);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2215 }
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2216 checksym(RPAR);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2217 gexpr(list3(ASM,list4(asm0,input,out,opt),e1),0);
324
575481408653 minor fix
kono
parents: 323
diff changeset
2218 checksym(SM);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2219 }
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2220 #endif
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2221
48
8575ec496cd4 jump with overrupped struct (first code)
kono
parents: 46
diff changeset
2222
185
427008a06333 comment
kono
parents: 184
diff changeset
2223 /* C expression */
427008a06333 comment
kono
parents: 184
diff changeset
2224
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2225 extern int
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2226 expr(int noconv)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2227 {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2228 int r;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2229 conv->noconv_(noconv);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2230 r=rvalue(expr0());
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2231 return r;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2232 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2233
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2234 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2235 expr0(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2236 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2237 int e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2238
d35df41eac69 Initial revision
kono
parents:
diff changeset
2239 e=expr1();
d35df41eac69 Initial revision
kono
parents:
diff changeset
2240 while(sym==COMMA) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2241 conv->op_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2242 getsym(0);e=list3(COMMA,e,rvalue(expr1()));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2243 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2244 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2245 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2246
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2247 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2248 expr1(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2249 {
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2250 int e1,e2,t,op,no_float;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2251 e1=expr2();
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2252 no_float = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2253 switch (sym) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2254 case ASS:
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2255 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2256 lcheck(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2257 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2258 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2259 e2=rvalue(expr1());
331
f25aa4f03198 bit-field continue...
kono
parents: 329
diff changeset
2260 e1 = assign_expr(e1,e2,t);
276
ebaec1ae566e MIPS double/longlong lib operand register conflict
kono
parents: 275
diff changeset
2261 return e1;
185
427008a06333 comment
kono
parents: 184
diff changeset
2262 case RSHIFT+AS: case LSHIFT+AS: case BAND+AS:
427008a06333 comment
kono
parents: 184
diff changeset
2263 case EOR+AS: case BOR+AS: case MOD+AS:
135
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2264 no_float = 1;
4cfd24d1b929 fix power-pc basic test
kono
parents: 133
diff changeset
2265 case ADD+AS: case SUB+AS: case MUL+AS: case DIV+AS:
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2266 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2267 op = sym-AS;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2268 lcheck(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2269 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2270 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2271 e2=rvalue(expr1());
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2272 return assop(e1,e2,op,t,no_float);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2273 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
2274 return(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2275 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2276 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2277
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2278 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2279 expr2(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2280 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2281 int e1,e2,e3,t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2282
d35df41eac69 Initial revision
kono
parents:
diff changeset
2283 e1=expr3();
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2284 if(sym==COND) { // e1?e2:e3
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2285 conv->cond_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2286 e1=rvalue(e1);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2287 getsym(0);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2288 if (sym==COLON) {
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2289 e2 = 0; // dumb extension of gcc
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2290 t=type;
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2291 getsym(0);
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2292 } else {
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2293 conv->cond1_();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2294 e2=rvalue(expr0());
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2295 t=type;
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2296 conv->cond2_();
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2297 checksym(COLON);
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
2298 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2299 e3=rvalue(expr2());
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2300 conv->cond_end_();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2301 return cond(t,e1,e2,e3);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2302 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2303 return(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2304 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2305
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2306 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2307 expr3(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2308 {
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2309 int e,e1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2310
d35df41eac69 Initial revision
kono
parents:
diff changeset
2311 e=expr4();
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2312 while(sym==LOR) { /* || */
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2313 conv->op_(sym);
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2314 e=rvalue(e);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2315 getsym(0);
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2316 e1=rvalue(expr4());
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2317 if(car(e)==CONST) e = cadr(e )?e:e1;
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2318 else if(car(e1)==CONST) e = cadr(e1)?e1:e;
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2319 else e=list3(LOR,e,e1);
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2320 type = INT;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2321 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2322 return(e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2323 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2324
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2325 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2326 expr4(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2327 {
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2328 int e,e1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2329
d35df41eac69 Initial revision
kono
parents:
diff changeset
2330 e=expr5();
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2331 while(sym==LAND) { /* && */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2332 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2333 e=rvalue(e);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2334 getsym(0);
132
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2335 e1=rvalue(expr5());
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2336 if(car(e)==CONST) e = cadr(e )?e1:e;
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2337 else if(car(e1)==CONST) e = cadr(e1)?e:e1;
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2338 else e=list3(LAND,e,e1);
07eb1249f07a *** empty log message ***
kono
parents: 128
diff changeset
2339 type = INT;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2340 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2341 return(e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2342 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2343
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2344 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2345 expr5(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2346 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2347 int e1,e2,t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2348
d35df41eac69 Initial revision
kono
parents:
diff changeset
2349 e1=expr6();
185
427008a06333 comment
kono
parents: 184
diff changeset
2350 while(sym==BOR) { /* | */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2351 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2352 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2353 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2354 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2355 e2=rvalue(expr6());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2356 e1=binop(BOR,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2357 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2358 return(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2359 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2360
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2361 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2362 expr6(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2363 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2364 int e1,e2,t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2365
d35df41eac69 Initial revision
kono
parents:
diff changeset
2366 e1=expr7();
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2367 while(sym==EOR) { /* ^ */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2368 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2369 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2370 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2371 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2372 e2=rvalue(expr7());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2373 e1=binop(EOR,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2374 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2375 return(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2376 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2377
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2378 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2379 expr7(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2380 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2381 int e1,e2,t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2382
d35df41eac69 Initial revision
kono
parents:
diff changeset
2383 e1=expr8();
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2384 while(sym==BAND) { /* & */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2385 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2386 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2387 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2388 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2389 e2=rvalue(expr8());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2390 e1=binop(BAND,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2391 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2392 return(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2393 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2394
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2395 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2396 expr8(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2397 {
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2398 int e1,e2,op,t;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2399
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2400 e1=expr9();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2401 while((op=sym)==EQ||op==NEQ) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2402 conv->op_(sym);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2403 e1=rvalue(e1);
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2404 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2405 getsym(0);
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2406 e2=rvalue(expr9());
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2407 e1=binop(op,e1,e2,t,type);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2408 type= INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2409 }
82
25654dc29ecc First Floating Point coding done.
kono
parents: 81
diff changeset
2410 return e1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2411 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2412
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2413 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2414 expr9(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2415 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2416 int e1,e2,t,op;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2417
d35df41eac69 Initial revision
kono
parents:
diff changeset
2418 e1=expr10();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2419 while((op=sym)==GT||op==GE||op==LT||op==LE) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2420 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2421 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2422 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2423 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2424 e2=rvalue(expr10());
231
f5efe15629d4 *** empty log message ***
kono
parents: 224
diff changeset
2425 e1=binop(op,e1,e2,t,type);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2426 type= INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2427 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2428 return e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2429 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2430
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2431 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2432 expr10(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2433 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2434 int e1,e2,t,op;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2435
d35df41eac69 Initial revision
kono
parents:
diff changeset
2436 e1=expr11();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2437 while((op=sym)==RSHIFT||op==LSHIFT) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2438 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2439 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2440 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2441 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2442 e2=rvalue(expr11());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2443 e1=binop(op,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2444 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2445 return e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2446 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2447
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2448 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2449 expr11(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2450 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2451 int e1,e2,t,op;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2452
d35df41eac69 Initial revision
kono
parents:
diff changeset
2453 e1=expr12();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2454 while((op=sym)==ADD||op==SUB) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2455 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2456 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2457 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2458 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2459 e2=rvalue(expr12());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2460 e1=binop(op,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2461 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2462 return e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2463 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2464
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2465 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2466 expr12(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2467 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2468 int e1,e2,t,op;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2469
d35df41eac69 Initial revision
kono
parents:
diff changeset
2470 e1=expr13();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2471 while((op=sym)==MUL||op==DIV||op==MOD) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2472 conv->op_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2473 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2474 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2475 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2476 e2=rvalue(expr13());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2477 e1=binop(op,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2478 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2479 return e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2480 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2481
185
427008a06333 comment
kono
parents: 184
diff changeset
2482 /* unary operators */
427008a06333 comment
kono
parents: 184
diff changeset
2483
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2484 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2485 expr13(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2486 {
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2487 int e,op,dir;
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2488 NMTBL *nptr1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2489
d35df41eac69 Initial revision
kono
parents:
diff changeset
2490 switch (op = sym) {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2491 case INC: case DEC:
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2492 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2493 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2494 lcheck(e=expr13());
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2495 dir = op==INC?1:-1;
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2496 switch(type) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2497 case CHAR:
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2498 type= INT; return(list4(PREINC,e,dir,1));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2499 case UCHAR:
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2500 type= UNSIGNED; return(list4(UPREINC,e,dir,1));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2501 case SHORT:
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2502 type= INT; return(list4(PREINC,e,dir,size_of_short));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2503 case USHORT:
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2504 type= UNSIGNED; return(list4(UPREINC,e,dir,size_of_short));
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2505 case INT:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2506 return(list4(PREINC,e,dir,size_of_int));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2507 case UNSIGNED:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2508 return(list4(UPREINC,e,dir,size_of_int));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2509 #if LONGLONG_CODE
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2510 case LONGLONG:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2511 return(list4(LPREINC,e,dir,size_of_longlong));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2512 case ULONGLONG:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2513 return(list4(LUPREINC,e,dir,size_of_longlong));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2514 #endif
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2515 #if FLOAT_CODE
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2516 case FLOAT:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2517 return(list3(FPREINC,e,dir));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2518 case DOUBLE:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2519 return(list3(DPREINC,e,dir));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2520 }
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2521 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2522 if(integral(type))
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2523 return(list4(PREINC,e,dir,size_of_int));
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2524 if(type>0 && car(type)==BIT_FIELD) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2525 e = list4(BPREINC,e,dir,type);
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 389
diff changeset
2526 type = cadr(type); /* value type */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2527 return e;
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2528 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2529 if(car(type)!=POINTER)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2530 error(TYERR);
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2531 return(list4(UPREINC,e,dir*size(cadr(type)),size_of_int ));
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2532 case MUL: /* *p */
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2533 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2534 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2535 e=rvalue(expr13());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2536 return(indop(e));
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2537 case BAND: /* &p */
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2538 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2539 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2540 switch(car(e=expr13())) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2541 case INDIRECT:
d35df41eac69 Initial revision
kono
parents:
diff changeset
2542 e=cadr(e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2543 break;
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
2544 case DREGISTER: /* should be error? */
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
2545 case FREGISTER:
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2546 case LREGISTER:
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2547 case REGISTER:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2548 case GVAR:
d35df41eac69 Initial revision
kono
parents:
diff changeset
2549 case LVAR:
d35df41eac69 Initial revision
kono
parents:
diff changeset
2550 e=list2(ADDRESS,e);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2551 break;
140
aac62d1e30a6 fix minor syntax error
kono
parents: 138
diff changeset
2552 case FNAME:
aac62d1e30a6 fix minor syntax error
kono
parents: 138
diff changeset
2553 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2554 default:error(LVERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2555 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2556 type=list2(POINTER,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2557 return e;
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2558 case SUB: /* -p */
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2559 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2560 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2561 e=rvalue(expr13());
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2562 #if FLOAT_CODE
271
e1a96bdbe527 MIPS continue...
kono
parents: 267
diff changeset
2563 if(type==FLOAT) {
379
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2564 return(car(e)==FCONST?dlist2(FCONST,-dcadr(e)):list2(FMINUS,e));
271
e1a96bdbe527 MIPS continue...
kono
parents: 267
diff changeset
2565 } else if(type==DOUBLE) {
118
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
2566 return(car(e)==DCONST?dlist2(DCONST,-dcadr(e)):list2(DMINUS,e));
07b91b625f84 assignment optimization
kono
parents: 117
diff changeset
2567 }
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2568 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2569 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2570 if(type==LONGLONG||type==ULONGLONG) {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2571 // return list2(LMINUS,e);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2572 return(car(e)==LCONST?llist2(LCONST,-lcadr(e)):list2(LMINUS,e));
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2573 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2574 #endif
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2575 if(!integral(type))
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2576 error(TYERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2577 return(car(e)==CONST?list2(CONST,-cadr(e)):list2(MINUS,e));
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2578 case BNOT: /* ~p */
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2579 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2580 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2581 e=rvalue(expr13());
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2582 // LONGLONG?
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2583 if(!integral(type))
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2584 error(TYERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2585 return(car(e)==CONST?list2(CONST,~cadr(e)):list2(BNOT,e));
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2586 case LNOT: /* !p */
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2587 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2588 getsym(0);
19
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
2589 e=rvalue(expr13());
252
1452eb0eab20 *** empty log message ***
kono
parents: 233
diff changeset
2590 type=INT;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2591 #if FLOAT_CODE
379
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2592 if (car(e)==DCONST||car(e)==FCONST) return list2(CONST,!dcadr(e));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2593 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2594 #if LONGLONG_CODE
252
1452eb0eab20 *** empty log message ***
kono
parents: 233
diff changeset
2595 if (car(e)==LCONST) return list2(CONST,!lcadr(e));
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2596 #endif
252
1452eb0eab20 *** empty log message ***
kono
parents: 233
diff changeset
2597 if (car(e)==CONST) return list2(CONST,!cadr(e));
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2598 if(!scalar(type))
19
b62230ea38f6 ifdef debug
kono
parents: 18
diff changeset
2599 error(TYERR);
252
1452eb0eab20 *** empty log message ***
kono
parents: 233
diff changeset
2600 return list2(LNOT,e);
313
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2601 case ALLOCA:
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2602 conv->prefix_(sym);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2603 type=POINTER;
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2604 getsym(0);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2605 checksym(LPAR);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2606 e=expr0();
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2607 checksym(RPAR);
f73b93de216a alloca done for ia32, powerpc, mips
kono
parents: 312
diff changeset
2608 return list2(ALLOCA,rvalue(e));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2609 case SIZEOF:
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2610 conv->prefix_(sym);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2611 if(getsym(0)==LPAR) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2612 if(typeid(getsym(0))) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2613 e=list2(CONST,size(typename()));
d35df41eac69 Initial revision
kono
parents:
diff changeset
2614 type=INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2615 checksym(RPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2616 return e;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2617 } else {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2618 e=expr0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
2619 checksym(RPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2620 expr16(e);
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2621 if(sym==INC||sym==DEC) {
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2622 /* after this operation, type is extended */
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2623 getsym(0);
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2624 switch(type) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2625 case CHAR: type=INT; break;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2626 case SHORT: type=INT; break;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2627 case UCHAR: type=UNSIGNED; break;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2628 case USHORT: type=UNSIGNED; break;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2629 case FLOAT:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2630 case DOUBLE: break;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2631 default:
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2632 if(!scalar(type))
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2633 error(TYERR);
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2634 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2635 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2636 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2637 } else
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2638 expr13();
d35df41eac69 Initial revision
kono
parents:
diff changeset
2639 e=list2(CONST,size(type));
d35df41eac69 Initial revision
kono
parents:
diff changeset
2640 type=INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2641 return e;
363
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2642 case LAND: /* &&p gcc extension label value */
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2643 getsym(0);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2644 e = expr13();
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2645 type = car(e);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2646 if (type!=FNAME) {
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2647 error(TYERR);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2648 }
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2649 nptr1 = (NMTBL *)cadr(e);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2650 type = nptr1->sc;
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2651 if (type==EMPTY||type==EXTRN1||type==EXTRN) {
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2652 nptr1->sc=EMPTY;
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2653 nptr1=l_top_search(nptr->nm,0);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2654 nptr1->sc = FLABEL;
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2655 nptr1->dsp = fwdlabel();
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2656 }
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2657 type = list2(POINTER,VOID);
f3f2b7906d50 label extension
kono
parents: 362
diff changeset
2658 return list2(LABEL,nptr1->dsp);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2659 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2660 e=expr14();
185
427008a06333 comment
kono
parents: 184
diff changeset
2661
427008a06333 comment
kono
parents: 184
diff changeset
2662 /* postfix unary operators */
427008a06333 comment
kono
parents: 184
diff changeset
2663
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2664 if((op=sym)==INC||op==DEC) {
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2665 conv->postfix_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2666 lcheck(e);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2667 getsym(0);
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2668
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2669 dir = op==INC?1:-1;
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2670 switch(type) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2671 case CHAR: type= INT; return(list4(POSTINC,e,dir,1));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2672 case UCHAR: type= UNSIGNED; return(list4(UPOSTINC,e,dir,1));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2673 case SHORT: type= INT; return(list4(POSTINC,e,dir,size_of_short));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2674 case USHORT: type= UNSIGNED; return(list4(UPOSTINC,e,dir,size_of_short));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2675 case INT: return(list4(POSTINC,e,dir,size_of_int));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2676 case UNSIGNED: return(list4(UPOSTINC,e,dir,size_of_int));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2677 #if FLOAT_CODE
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2678 case FLOAT: return(list3(FPOSTINC,e,dir));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2679 case DOUBLE: return(list3(DPOSTINC,e,dir));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2680 #endif
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2681 #if LONGLONG_CODE
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2682 case LONGLONG: return(list3(LPOSTINC,e,dir));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2683 case ULONGLONG: return(list3(LUPOSTINC,e,dir));
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
2684 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2685 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2686 if(integral(type))
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2687 return(list4(POSTINC,e,dir,size_of_int));
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2688 if(type>0 && car(type)==BIT_FIELD) {
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2689 e = list4(BPOSTINC,e,dir,type);
420
efbd420386c5 non aligned bitfield (not yet finished)
kono
parents: 389
diff changeset
2690 type = cadr(type); /* value type */
338
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2691 return e;
7fe7ce0a791f bit-field done for IA32, PowerPC, MIPS.
kono
parents: 336
diff changeset
2692 }
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2693 if(car(type)!=POINTER)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2694 error(TYERR);
168
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2695 return(list4(UPOSTINC,e,
b1297c82e926 cpostinc removal
kono
parents: 166
diff changeset
2696 op==INC?size(cadr(type)):-size(cadr(type)),size_of_int ));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2697 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2698 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2699 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2700
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2701 /* mark extern symbol is used */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2702
97
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2703 static void
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2704 extrn_use(NMTBL *nptr)
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2705 {
164
1c2a9232ea93 mc.h generation
kono
parents: 162
diff changeset
2706 /* EXTRN1 means that defined extern is used in this source */
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2707 if(nptr->sc==EXTRN) {
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2708 nptr->sc=EXTRN1;
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2709 }
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2710 if (!nptr->next) {
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2711 nptr->next = global_list; global_list = nptr;
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
2712 }
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2713 }
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2714
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2715 /* define function name as extern */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2716
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2717 static int
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2718 fname(NMTBL *nptr)
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2719 {
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2720 int e1;
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2721 e1=list2(FNAME,(int)nptr);
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
2722 // type=list3(FUNCTION,type,arg);
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
2723 type=list3(car(nptr->ty),cadr(nptr->ty),caddr(nptr->ty));
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2724 getsym(0);
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2725 extrn_use(nptr);
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2726 return expr16(e1);
97
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2727 }
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2728
185
427008a06333 comment
kono
parents: 184
diff changeset
2729 /* term */
427008a06333 comment
kono
parents: 184
diff changeset
2730
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2731 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2732 expr14(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2733 {
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2734 int e1=0,t,t1,smode;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2735 NMTBL *nptr0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2736
d35df41eac69 Initial revision
kono
parents:
diff changeset
2737 switch(sym) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
2738 case IDENT:
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
2739 conv->id_(sym,nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2740 switch(nptr->sc) {
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
2741 case EXTRN: case EXTRN1:
109
e09f9de6f5d3 *** empty log message ***
kono
parents: 108
diff changeset
2742 extrn_use(nptr);
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
2743 case STATIC:
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2744 if(is_code(nptr)||is_function(nptr)) {
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2745 return fname(nptr);
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2746 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2747 case GVAR:
367
4efbb07f556b global variable offset
kono
parents: 363
diff changeset
2748 e1=list3(GVAR,0,(int)nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2749 type=nptr->ty;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2750 getsym(0);
97
6d42fcac07af *** empty log message ***
kono
parents: 95
diff changeset
2751 extrn_use(nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2752 break;
98
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2753 case FLABEL: case BLABEL:
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2754 case FUNCTION: case CODE:
07c2554e1cfa *** empty log message ***
kono
parents: 97
diff changeset
2755 return fname(nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2756 case LVAR:
d35df41eac69 Initial revision
kono
parents:
diff changeset
2757 e1=list2(LVAR,nptr->dsp);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2758 type=nptr->ty;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2759 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2760 break;
219
6190d24e178c long long code generation level 4
kono
parents: 213
diff changeset
2761 case LREGISTER:
105
7e3d59e56a53 save register ( incomplete )
kono
parents: 104
diff changeset
2762 case DREGISTER:
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
2763 case FREGISTER:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2764 case REGISTER:
137
9fb09db54436 fix powerpc get_fregister_var's regs error.
kono
parents: 136
diff changeset
2765 e1=list3(nptr->sc,nptr->dsp,(int)nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2766 type=nptr->ty;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2767 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2768 break;
176
kono
parents: 174
diff changeset
2769 case ENUM:
kono
parents: 174
diff changeset
2770 e1=list2(CONST,nptr->dsp);
kono
parents: 174
diff changeset
2771 type=INT;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2772 getsym(0);
176
kono
parents: 174
diff changeset
2773 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2774 case EMPTY:
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2775 if(getsym(0)==LPAR) {
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2776 type= glist3(FUNCTION,INT,0);
184
4bf42b2df5d7 function extrn1
kono
parents: 183
diff changeset
2777 nptr->sc = EXTRN1;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2778 nptr->ty= type;
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
2779 extrn_use(nptr);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2780 e1=expr15(list2(FNAME,(int)nptr));
d35df41eac69 Initial revision
kono
parents:
diff changeset
2781 break;
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2782 } else if (in_macro_if) {
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2783 type = INT;
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2784 e1= list2(CONST,0);
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2785 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2786 } else {
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2787 nptr->sc = EXTRN1;
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2788 nptr->ty= glist3(FUNCTION,INT,0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2789 e1=list2(FNAME,(int)nptr);
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
2790 type=list3(nptr->sc,nptr->ty,nptr->dsp);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2791 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2792 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2793 default:error(UDERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2794 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2795 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2796 case STRING:
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
2797 conv-> string_(nptr->nm,nptr->dsp);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2798 e1=list3(STRING,(int)nptr->nm,nptr->dsp);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
2799 type=list3(ARRAY,CHAR,nptr->dsp);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2800 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2801 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2802 case CONST:
68
0266905063b5 *** empty log message ***
kono
parents: 67
diff changeset
2803 conv-> const_(symval);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2804 type= INT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2805 e1=list2(CONST,symval);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2806 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2807 break;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2808 #if FLOAT_CODE
379
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2809 case FCONST:
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2810 conv-> const_(symval);
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2811 type= FLOAT;
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2812 e1=dlist2(FCONST,dsymval);
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2813 getsym(0);
c7abd48191b3 ARM continue...
kono
parents: 377
diff changeset
2814 break;
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2815 case DCONST:
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2816 conv-> const_(symval);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2817 type= DOUBLE;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2818 e1=dlist2(DCONST,dsymval);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2819 getsym(0);
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
2820 break;
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2821 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2822 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2823 case LCONST:
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2824 conv-> const_(symval);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2825 type= LONGLONG;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2826 e1=llist2(LCONST,lsymval);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2827 getsym(0);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2828 break;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
2829 #endif
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2830 case RETURN:
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2831 conv-> return_f_();
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2832 if (!is_function(fnptr)) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2833 error(STERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2834 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2835 type=list2(POINTER,CODE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2836 e1=list2(RETURN,(int)fnptr);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2837 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2838 break;
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
2839 case DEFINED:
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2840 t = mode; mode = IFDEF;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2841 getsym(0);
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2842 if (sym==LPAR) { t1 = 1; getsym(0); } else t1 = 0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2843 conv-> defined_(nptr->nm);
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
2844 mode = t;
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
2845 type= INT;
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
2846 e1=list2(CONST,symval);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2847 getsym(0);
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2848 if (t1)
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
2849 checksym(RPAR);
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
2850 break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2851 case ENVIRONMENT:
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2852 conv-> environment_();
2
kono
parents: 1
diff changeset
2853 type=list2(POINTER,VOID);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2854 e1=list2(ENVIRONMENT,0);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2855 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2856 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2857 case LPAR:
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2858 conv->lpar_();
317
3dfac70ef7e1 asm statement, valued statement syntactically passed.
kono
parents: 316
diff changeset
2859 getsym(0);
3dfac70ef7e1 asm statement, valued statement syntactically passed.
kono
parents: 316
diff changeset
2860 if(sym==VOLATILE) getsym(0);
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2861
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2862 /* type cast */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2863
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2864 if(typeid(sym)) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2865 t=typename();
72
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
2866 conv->return_type_(t,0,0);
3b5d293cea36 type def etc
kono
parents: 71
diff changeset
2867 conv->rpar_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2868 checksym(RPAR);
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2869 if (sym==LC && (t>0 && (car(t)==STRUCT||car(t)==UNION))) {
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2870 // q->lock = (spinlock_t) { };
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2871 smode = mode;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2872 type = t;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
2873 nptr0=new_static_name("__lstruct",'_');
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
2874 nptr0->next = local_static_list; local_static_list = nptr0;
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2875 nptr0->sc = GVAR;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2876 e1 = size(type);
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2877 nptr0->ty = type;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2878 mode=STADECL;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2879 decl_data_field(type,nptr0,0);
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2880 checksym(RC);
367
4efbb07f556b global variable offset
kono
parents: 363
diff changeset
2881 e1 = list3(RSTRUCT,list3(GVAR,0,(int)nptr0),e1);
322
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2882 mode = smode;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2883 return e1;
46ac55e8b14c struct init by cast
kono
parents: 321
diff changeset
2884 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2885 e1=expr13();
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2886 return correct_type(e1,t);
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2887 } else if (sym==LC) {
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2888 // statement in expression (GNU extension)
316
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2889 docomp(1);
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2890 e1 = lastexp; lastexp = 0;
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2891 } else {
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2892 e1=expr0();
22d92986c7f7 asm, valued statement, local decls continue...
kono
parents: 313
diff changeset
2893 conv->rpar_();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2894 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2895 checksym(RPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2896 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2897 default:error(EXERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2898 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2899 return expr16(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2900 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2901
185
427008a06333 comment
kono
parents: 184
diff changeset
2902 /* post fix binary operator (struct . -> or array[] */
427008a06333 comment
kono
parents: 184
diff changeset
2903
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2904 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2905 expr16(int e1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2906 {
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2907 int e2,t,ind;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2908
d35df41eac69 Initial revision
kono
parents:
diff changeset
2909 while(1) {
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
2910 if(sym==LBRA) { /* a[3] */
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2911 conv->lbra_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2912 e1=rvalue(e1);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2913 t=type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2914 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2915 e2=rvalue(expr0());
d35df41eac69 Initial revision
kono
parents:
diff changeset
2916 checksym(RBRA);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2917 conv->rbra_(sym);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2918 e1=binop(ADD,e1,e2,t,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2919 e1=indop(e1);
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2920 } else if(sym==LPAR) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2921 e1=expr15(e1); /* f() */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2922 } else if(sym==PERIOD||sym==ARROW) {
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2923 ind = sym;
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2924 conv->op_(sym);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2925 getsym(0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2926 if (sym!=IDENT) error(TYERR);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2927 conv->id_(sym,nptr);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2928 e1=strop(e1,ind==ARROW);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2929 getsym(0);
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
2930 } else break;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2931 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2932 if(car(e1)==FNAME) type=list2(POINTER,type);
d35df41eac69 Initial revision
kono
parents:
diff changeset
2933 return e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
2934 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2935
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
2936 /* function call */
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2937
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
2938 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2939 expr15(int e1)
d35df41eac69 Initial revision
kono
parents:
diff changeset
2940 {
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
2941 int t,arglist,e,sz,argtypes,at,ftype;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2942
185
427008a06333 comment
kono
parents: 184
diff changeset
2943 /* function call target */
427008a06333 comment
kono
parents: 184
diff changeset
2944
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2945 if(car(type)==POINTER) {
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2946 if (car(cadr(type))==FUNCTION||car(cadr(type))==CODE) {
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2947 e1=rvalue(e1);
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2948 type=cadr(type);
103
f849af4b5ea9 *** empty log message ***
kono
parents: 102
diff changeset
2949 } /* else error */
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2950 }
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2951 if(integral(type)|| ((car(type)!=FUNCTION)&&(car(type)!=CODE))) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2952 error(TYERR);
79
82d0e30f61dd *** empty log message ***
kono
parents: 78
diff changeset
2953 }
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
2954 ftype = type;
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2955 conv->funcall_(type);
185
427008a06333 comment
kono
parents: 184
diff changeset
2956
427008a06333 comment
kono
parents: 184
diff changeset
2957 /* function argments */
427008a06333 comment
kono
parents: 184
diff changeset
2958
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2959 argtypes = caddr(type);
203
28baf6cd9ad1 *** empty log message ***
kono
parents: 202
diff changeset
2960 if ((t=cadr(type))>=0 && (car(t)==STRUCT||car(t)==UNION)) {
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2961 /* skip return struct pointer */
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2962 if (argtypes==0) error(-1);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2963 argtypes = cadr(argtypes);
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2964 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2965 arglist=0;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2966 getsym(0);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2967 while(sym!=RPAR) {
3
kono
parents: 2
diff changeset
2968 e=rvalue(expr1());
87
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2969 if(argtypes==0) at=DOTS;
1738f313f98b floating point (at most) done.
kono
parents: 86
diff changeset
2970 else if(car(argtypes)==DOTS) at=DOTS;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2971 else { at=car(argtypes); argtypes=cadr(argtypes); }
114
e6cb1e293b35 float/int passed.
kono
parents: 111
diff changeset
2972 e = correct_type(e,at);
3
kono
parents: 2
diff changeset
2973 arglist=list3(e,arglist,type);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2974 if(sym!=COMMA) break;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
2975 conv->comma_();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
2976 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
2977 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
2978 checksym(RPAR);
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
2979 conv->funcall_args_();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
2980 if(car(t)==CODE)
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
2981 return list4(FUNCTION,e1,arglist,ftype);
185
427008a06333 comment
kono
parents: 184
diff changeset
2982
427008a06333 comment
kono
parents: 184
diff changeset
2983 /* return type */
427008a06333 comment
kono
parents: 184
diff changeset
2984
427008a06333 comment
kono
parents: 184
diff changeset
2985 type = cadr(ftype);
39
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
2986 if(type==CHAR) type=INT;
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
2987 else if(car(type)==STRUCT||car(type)==UNION) {
326
e5d40f8c4cce bit-field continue.
kono
parents: 324
diff changeset
2988 /* make temporary struct for return value */
45
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2989 /* but it is better to see we can reuse old one */
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2990 if (tmp_struct) {
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2991 sz = size(tmp_struct->ty);
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2992 if (sz>=size(type)) {
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2993 /* reuse it */
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2994 } else if (tmp_struct->dsp-sz==disp) {
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2995 /* extendable */
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2996 disp -= tmp_struct->dsp-sz;
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2997 tmp_struct->dsp = disp;
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2998 } else {
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
2999 tmp_struct = def(0);
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3000 }
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3001 } else {
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3002 tmp_struct = def(0);
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3003 }
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3004 e = list2(LVAR,tmp_struct->dsp);
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3005
39
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
3006 /* pass the pointer as an argument */
c63c4fdeb9a7 struct done.
kono
parents: 38
diff changeset
3007 /* this is recognized by called function declaration */
160
1f440a2790fb *** empty log message ***
kono
parents: 156
diff changeset
3008 /* but I don't know this sequence is compatible with gcc */
45
b9266c88495c *** empty log message ***
kono
parents: 42
diff changeset
3009
223
1ac647873577 *** empty log message ***
kono
parents: 221
diff changeset
3010 arglist = append3(arglist,list2(ADDRESS,e),list2(POINTER,type));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3011 }
136
069960078249 remove redundant funcall argument for prototyped code in PowerPC case.
kono
parents: 135
diff changeset
3012 return list4(FUNCTION,e1,arglist,ftype);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3013 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3014
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3015 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3016 typeid(int s)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3017 {
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3018 switch(s) {
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3019 case CODE : case SHORT :
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3020 case LONG : case STRUCT : case UNION : case ENUM :
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3021 case LONGLONG : case FLOAT : case DOUBLE : case VOID :
354
32cd53208b79 type of fix.
kono
parents: 353
diff changeset
3022 case ULONGLONG : case TYPEOF : case KONST:
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3023 return 1;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3024 case IDENT: return nptr->sc==TYPE;
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3025 }
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3026 return (integral(s));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3027 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3028
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3029 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3030 typename(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3031 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3032 int t;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3033
d35df41eac69 Initial revision
kono
parents:
diff changeset
3034 type=t=typespec();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3035 ndecl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3036 reverse(t);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3037 return type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3038 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3039
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3040 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3041 type prefix in cast
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3042 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3043
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3044 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3045 ndecl0(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3046 {
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3047 if(sym==MUL) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3048 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3049 return type=list2(POINTER,ndecl0());
d35df41eac69 Initial revision
kono
parents:
diff changeset
3050 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3051 return ndecl1();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3052 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3053
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3054 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3055 type postfix in cast
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3056 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3057
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3058 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3059 ndecl1(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3060 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3061 int i,t,arglist;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3062
d35df41eac69 Initial revision
kono
parents:
diff changeset
3063 if(sym==LPAR) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3064 if(getsym(0)==RPAR) {
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3065 type=list3(FUNCTION,type,0); getsym(0);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3066 } else {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3067 ndecl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3068 checksym(RPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3069 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3070 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3071 while(1) {
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3072 if(sym==LBRA) {
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3073 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3074 t=type;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3075 i=cexpr(expr(1));
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3076 checksym(RBRA);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3077 type=list3(ARRAY,t,i);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3078 } else if(sym==LPAR) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3079 t = type;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3080 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3081 arglist=0;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3082 while(sym!=RPAR) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3083 ndecl0();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3084 arglist=list2(type,arglist);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3085 if(sym!=COMMA) break;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3086 getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3087 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3088 checksym(RPAR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3089 type=list3(FUNCTION,t,arglist);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3090 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3091 else return type;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3092 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3093 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3094
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3095 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3096 string heap management
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3097 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3098
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3099 static struct cheap *
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3100 new_cheap()
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3101 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3102 struct cheap *p = (struct cheap *)malloc(sizeof(struct cheap));
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3103 if (!p) error(MMERR); // fatal
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3104 p->ptr = p->first = (char *)malloc(CHEAPSIZE);
358
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3105 #if HEAP_REPORT
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3106 fprintf(stderr,"** new cheap %d\n",(int)CHEAPSIZE);
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3107 #endif
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3108 p->last = p->first + CHEAPSIZE;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3109 if (!p->ptr) error(MMERR); // fatal
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3110 p->next = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3111 return p;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3112 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3113
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3114 extern struct cheap *
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3115 increment_cheap(struct cheap *cheap,char **save)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3116 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3117 char *p,*q,*from,*to;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3118 int i;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3119 if (cheap->ptr == cheap->last) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3120 if (!cheap->next) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3121 cheap->next = new_cheap();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3122 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3123 if (save) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3124 cheap->ptr = from = *save;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3125 i = cheap->last - from;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3126 to = *save = cheap->next->first;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3127 if (i>CHEAPSIZE) error(NMERR);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3128 if (to<=chptr && chptr<=to+i) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3129 if (!cheap->next->next) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3130 cheap->next->next = new_cheap();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3131 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3132 q = chptr;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3133 p = chptr = cheap->next->next->ptr;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3134 while((*p++ = *q++));
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3135 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3136 while(i-->0) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3137 *to++ = *from++;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3138 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3139 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3140 cheap = cheap->next;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3141 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3142 cheap->ptr++;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3143 return cheap;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3144 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3145
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3146 /* mark string cheap */
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3147 extern void
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3148 save_cheap(struct cheap *scheap,struct cheap *cheap)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3149 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3150 // keep curret cheap pointer
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3151 scheap->ptr = cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3152 scheap->next = cheap;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3153 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3154
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3155 /* discard string heap until marked string */
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3156 extern struct cheap *
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3157 reset_cheap(struct cheap *scheap)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3158 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3159 // go back to the kept curret cheap pointer
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3160 if (cheap==scheap->next) {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3161 cheap->ptr = scheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3162 } else {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3163 cheap->ptr = cheap->first;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3164 cheap = scheap->next;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3165 cheap->ptr = scheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3166 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3167 return cheap;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3168 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3169
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3170 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3171 Symbol table handling
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3172 */
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3173
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3174 static int
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3175 neqnamel(char *p,char *q,int len)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3176 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3177 while(len-->0 && *p++ == *q++);
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3178 return len!=-1;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3179 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3180
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3181 static NMTBL *
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3182 hash_search(char *name,struct cheap *scheap,int len,unsigned int hash,int mode)
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3183 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3184 NMTBL *hptr,**iptr,**eptr;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3185
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3186 eptr = iptr= &htable[hash % GSYMS];
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3187 while((hptr=*iptr) && hptr->sc!=0 && neqnamel(hptr->nm,name,len)) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3188 if (++iptr== &htable[GSYMS])
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3189 iptr=&htable[0];
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3190 if (eptr==iptr) error(GSERR);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3191 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3192 if (!hptr) {
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3193 if (mode==NONDEF) return 0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3194 hptr = get_nptr();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3195 hptr->nm = name; /* name should be in the safe place (cheap) */
352
48aeb7379759 name table reconfig done except self compile.
kono
parents: 351
diff changeset
3196 *iptr = hptr;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3197 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3198 if (hptr->sc == 0) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3199 hptr->sc=EMPTY;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3200 } else {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3201 cheap = reset_cheap(scheap);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3202 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3203 return hptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3204 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3205
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3206 extern NMTBL *
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3207 get_name(char *name,int *len,int mode)
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3208 {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3209 /* no name copy */
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3210 unsigned int ch,i = 0;
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3211 unsigned int hash0 = 0;
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3212 unsigned char *n = name;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3213 struct cheap scheap;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3214
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3215 save_cheap(&scheap,cheap);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3216 ch = *n++;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3217 for(i=0;alpha(ch) || digit(ch);i++) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3218 hash_value(hash0,ch);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3219 ch = *n++;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3220 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3221 if (len) *len = i;
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3222 return hash_search(name,&scheap,i,hash0,mode);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3223 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3224
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3225 extern NMTBL *
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3226 get_name_from_chptr()
185
427008a06333 comment
kono
parents: 184
diff changeset
3227 {
427008a06333 comment
kono
parents: 184
diff changeset
3228 int i = 0;
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3229 unsigned int hash0 = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3230 char *name = cheap->ptr;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3231 struct cheap scheap;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3232
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3233 save_cheap(&scheap,cheap);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3234 for(i=0;alpha(ch) || digit(ch);i++) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3235 hash_value(hash0,*cheap->ptr = ch);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3236 cheap = increment_cheap(cheap,&name);
185
427008a06333 comment
kono
parents: 184
diff changeset
3237 getch();
427008a06333 comment
kono
parents: 184
diff changeset
3238 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3239 *cheap->ptr = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3240 cheap = increment_cheap(cheap,&name);
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3241 return hash_search(name,&scheap,i,hash0,DEF);
185
427008a06333 comment
kono
parents: 184
diff changeset
3242 }
427008a06333 comment
kono
parents: 184
diff changeset
3243
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3244 static void
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3245 getstring(void)
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3246 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3247 char *name = cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3248 int i= 0;
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3249 unsigned int hash = 0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3250 struct cheap scheap;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3251
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3252 save_cheap(&scheap,cheap);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3253 while (ch == '"') {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3254 in_quote = 1;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3255 getch();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3256 while (ch != '"') {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3257 if (i>STRSIZE) error(STRERR);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3258 hash_value(hash, *cheap->ptr = escape());
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3259 cheap = increment_cheap(cheap,&name);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3260 i++;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3261 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3262 in_quote = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3263 getch();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3264 skipspc(); // "aaa" "bbb" case
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3265 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3266 in_quote = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3267 *cheap->ptr = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3268 cheap = increment_cheap(cheap,&name);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3269 i++;
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3270 nptr = name_space_search(hash_search(name,&scheap,i,hash,DEF),STRING);
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3271 symval = i;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3272 }
185
427008a06333 comment
kono
parents: 184
diff changeset
3273
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3274 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3275 long long posfix (0ULL etc.)
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3276 */
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3277 static int
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3278 is_ll()
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3279 {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3280 if (ch=='U' || ch=='u') {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3281 getch();
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3282 }
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3283 if (ch=='L'||ch=='l') {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3284 if (getch()=='L'||ch=='l') {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3285 getch();
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3286 return 1;
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3287 }
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3288 }
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3289 return 0;
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3290 }
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3291
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3292 static int
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3293 get_numerical()
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3294 {
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3295 int d;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3296 struct cheap scheap;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3297 char *num;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3298
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3299 /* numerical */
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3300
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3301 save_cheap(&scheap,cheap);
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3302 symval=0; d=0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3303 num = cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3304 sym = 0;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3305 if(ch=='.') {
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3306 getch();
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3307 if(ch=='.') {
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3308 getch();
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3309 if (ch=='.') {
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3310 getch();
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3311 return sym=DOTS;
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3312 }
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3313 error(CHERR);
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3314 return getsym(0);
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3315 } else if (!digit(ch))
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3316 return sym=PERIOD;
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3317 d=1;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3318 *cheap->ptr = '.'; /* .0 case */
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3319 cheap = increment_cheap(cheap,&num);
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3320 } else if (ch == '0') {
372
81345636387d arm continue...
kono
parents: 367
diff changeset
3321 *cheap->ptr = ch; cheap = increment_cheap(cheap,&num);
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3322 if (getch() == 'x' || ch == 'X') {
372
81345636387d arm continue...
kono
parents: 367
diff changeset
3323 *cheap->ptr = ch; cheap = increment_cheap(cheap,&num);
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3324 /* hexadicimal */
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3325 while(1) {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3326 getch(); *cheap->ptr = ch;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3327 cheap = increment_cheap(cheap,&num);
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3328 if(digit(ch))
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3329 symval=symval*16+ch-'0';
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3330 else if('a'<=ch&&ch<='f')
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3331 symval=symval*16+ch-'a'+10;
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3332 else if('A'<=ch&&ch<='F')
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3333 symval=symval*16+ch-'A'+10;
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3334 else break;
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3335 }
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3336 if (is_ll()) {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3337 #if LONGLONG_CODE
372
81345636387d arm continue...
kono
parents: 367
diff changeset
3338 cheap->ptr[-1] = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3339 lsymval = strtoll(num,0,0);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3340 // we should keep this value? like string?
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3341 cheap = reset_cheap(&scheap);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3342 sym=LCONST;
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3343 #endif
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3344 } else
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3345 sym=CONST;
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3346 } else if (digit(ch)) {
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3347 /* octal */
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3348 while(1) {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3349 getch(); *cheap->ptr = ch;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3350 cheap = increment_cheap(cheap,&num);
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3351 if(digit(ch))
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3352 symval=symval*8+ch-'0';
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3353 else break;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3354 }
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3355 if (is_ll()) {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3356 #if LONGLONG_CODE
372
81345636387d arm continue...
kono
parents: 367
diff changeset
3357 cheap->ptr[-1] = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3358 cheap = increment_cheap(cheap,&num);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3359 lsymval = strtoll(num,0,0);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3360 cheap = reset_cheap(&scheap);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3361 sym=LCONST;
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3362 #endif
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3363 } else
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3364 sym=CONST;
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
3365 } else if (ch=='L'||ch=='U') { /* 0L or 0LL case */
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3366 if (is_ll()) {
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3367 #if LONGLONG_CODE
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3368 lsymval = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3369 sym=LCONST;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3370 #endif
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3371 }
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3372 } else if (ch=='.'||ch=='e') {
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3373 d=1;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3374 *cheap->ptr = '0'; /* 0. case */
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3375 cheap = increment_cheap(cheap,&num);
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3376 } else {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3377 cheap = reset_cheap(&scheap);
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3378 symval = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3379 sym=CONST;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3380 }
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3381 } else {
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3382 while(digit(ch)) {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3383 *cheap->ptr = ch;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3384 cheap = increment_cheap(cheap,&num);
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3385 symval=symval*10+ch-'0';getch();
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3386 }
321
80beb03e5b73 ULL,ull, 0x0ull etc.
kono
parents: 318
diff changeset
3387 if (ch=='.'||ch=='e') d=1;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3388 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3389 if (!sym) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3390 if (!d) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3391 if (is_ll()) {
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3392 #if LONGLONG_CODE
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3393 *cheap->ptr = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3394 cheap = increment_cheap(cheap,&num);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3395 lsymval = strtoll(num,0,0);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3396 sym=LCONST;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3397 #endif
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3398 } else
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3399 sym=CONST;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3400 } else {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3401 #if FLOAT_CODE
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3402 /* floating point case */
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3403 while(digit(ch)|| ch=='.'||ch=='e') {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3404 *cheap->ptr = ch;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3405 cheap = increment_cheap(cheap,&num);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3406 getch();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3407 if ((ch=='-' && cheap->ptr[-1]=='e')||
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3408 (ch=='+' && cheap->ptr[-1]=='e')) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3409 *cheap->ptr = ch;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3410 cheap = increment_cheap(cheap,&num);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3411 getch();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3412 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3413 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3414 *cheap->ptr = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3415 cheap = increment_cheap(cheap,&num);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3416 dsymval = strtod(num,0);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3417 sym=DCONST;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3418 #else
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3419 symval = 0;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3420 sym=CONST;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3421 #endif
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3422 }
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3423 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3424 cheap = reset_cheap(&scheap);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3425 return sym;
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3426 }
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3427
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3428 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3429 Tokenizer
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3430 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3431
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3432 extern int
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3433 getsym(int sc)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3434 {
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3435 NMTBL *nlist,*nptr0,*nptrm;
35
fd18d440f5ee macro function (works. but dirty. )
kono
parents: 34
diff changeset
3436 char c;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3437
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3438 if (alpha(skipspc())) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3439 nptrm=name_space_search(nlist = get_name_from_chptr(),MACRO);
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3440 if (mode==MDECL) {
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3441 nptr = nptrm;
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3442 return (sym==MACRO);
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3443 }
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3444 if (mode==IFDEF) {
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
3445 nptr = nptrm;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3446 if (nptrm->sc == MACRO||nptrm->sc==FMACRO) {
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
3447 return (symval=1);
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3448 } else {
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3449 return (symval=0);
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
3450 }
29
160e20394f80 macro function (imcomplete)
kono
parents: 28
diff changeset
3451 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3452 if ((nptrm->sc==MACRO&&neqname((char *)car(nptrm->dsp),nptrm->nm)) ||
183
1d80ad165831 recursive macros
kono
parents: 182
diff changeset
3453 (nptrm->sc==FMACRO&&skipspc()=='(')) {
185
427008a06333 comment
kono
parents: 184
diff changeset
3454 macro_expansion(nptrm);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3455 return getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3456 }
185
427008a06333 comment
kono
parents: 184
diff changeset
3457 /* global variable name table */
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3458 nptr0 = name_space_search(nlist,sc);
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
3459 if (nptr0->sc == RESERVE) return sym = nptr0->dsp;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3460 sym = IDENT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3461 gnptr=nptr=nptr0;
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3462
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3463 if (mode==ADECL && nptr0->sc ==TYPE) return sym;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3464 if (mode==GDECL || mode==GSDECL || mode==GUDECL ||
177
352feeae4b0a macro else/ccout
kono
parents: 176
diff changeset
3465 mode==GTDECL || mode==TOP || mode==GEDECL) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3466 return sym;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3467 }
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3468 if (nptr->sc == TYPE) return sym;
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3469 if (nptr->sc == TAG) return sym;
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
3470 if (mode==STAT) {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3471 /* can be undeclared global variable */
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3472 return sym;
18
df7fa8cee67b pass -Wall
kono
parents: 16
diff changeset
3473 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3474 /* define case */
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3475 nptr = make_local_scope(nlist,nptr,sc);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3476 return sym;
185
427008a06333 comment
kono
parents: 184
diff changeset
3477
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3478 } else if (digit(ch)||ch=='.') {
285
912b54949344 register assop const ( int/long )
kono
parents: 280
diff changeset
3479 return get_numerical();
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3480 } else if(ch=='\'') {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3481 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3482 symval=escape();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3483 if(ch!='\'') error(CHERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3484 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3485 return sym=CONST;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3486 } else if(ch=='"') {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3487 getstring();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3488 return sym= STRING;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3489 }
185
427008a06333 comment
kono
parents: 184
diff changeset
3490 /* 2 letters literal */
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3491 c=ch;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3492 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3493 switch(c) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3494 case '*':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3495 return postequ(MUL,MUL+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3496 case '&':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3497 if(ch=='&') {getch();return sym=LAND;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3498 return postequ(BAND,BAND+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3499 case '-':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3500 if(ch=='>') {getch();return sym=ARROW;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3501 if(ch=='-') {getch();return sym=DEC;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3502 return postequ(SUB,SUB+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3503 case '!':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3504 return postequ(LNOT,NEQ);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3505 case '~':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3506 return sym=BNOT;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3507 case '+':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3508 if(ch=='+') {getch();return sym=INC;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3509 return postequ(ADD,ADD+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3510 case '%':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3511 return postequ(MOD,MOD+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3512 case '^':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3513 return postequ(EOR,EOR+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3514 case '|':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3515 if(ch=='|') {getch();return sym=LOR;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3516 return postequ(BOR,BOR+AS);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3517 case '=':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3518 return postequ(ASS,EQ);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3519 case '>':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3520 if(ch=='>') {getch();return postequ(RSHIFT,RSHIFT+AS);}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3521 return postequ(GT,GE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3522 case '<':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3523 if(ch=='<') {getch();return postequ(LSHIFT,LSHIFT+AS);}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3524 return postequ(LT,LE);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3525 case '(':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3526 return sym=LPAR;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3527 case ')':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3528 return sym=RPAR;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3529 case '[':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3530 return sym=LBRA;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3531 case ']':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3532 return sym=RBRA;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3533 case '{':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3534 return sym=LC;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3535 case '}':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3536 return sym=RC;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3537 case ',':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3538 return sym=COMMA;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3539 case ':':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3540 return sym=COLON;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3541 case '?':
d35df41eac69 Initial revision
kono
parents:
diff changeset
3542 return sym=COND;
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3543 case ';':
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3544 return sym=SM;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3545 case '/':
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3546 if(ch=='/') {
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3547 in_comment = 1;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3548 conv->comment_('/'); conv->comment_('/');
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3549 while(ch!='\n') { getch(); conv->comment_(ch); }
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3550 in_comment = 0;
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3551 getch();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3552 return getsym(0);
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3553 }
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3554 if(ch!='*') return postequ(DIV,DIV+AS);
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
3555 in_comment = 1;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3556 conv->comment_('/'); conv->comment_('*');
66
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3557 do {
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3558 c=ch; getch(); conv->comment_(ch);
0b068058dd67 *** empty log message ***
kono
parents: 65
diff changeset
3559 } while(!(c=='*'&&ch=='/'));
20
8d3db5fc8a97 *** empty log message ***
kono
parents: 19
diff changeset
3560 in_comment = 0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3561 getch();
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3562 return getsym(0);
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3563 case 0:
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3564 case '\n':
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
3565 case '\f':
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
3566 case '\\':
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3567 return getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3568 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
3569 error(CHERR);
180
f00e3bfa1b45 nkf.c compile (not correct)
kono
parents: 179
diff changeset
3570 return getsym(0);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3571 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3572 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3573
179
fde8cb5d9254 *** empty log message ***
kono
parents: 178
diff changeset
3574
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3575 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3576 postequ(int s1, int s2)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3577 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3578 if(ch=='=') {getch();return sym=s2;}
d35df41eac69 Initial revision
kono
parents:
diff changeset
3579 return sym=s1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3580 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3581
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3582 extern int
318
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
3583 alpha(int c)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3584 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3585 return(('a'<=c&&c<='z')||('A'<=c&&c<='Z')||c=='_');
d35df41eac69 Initial revision
kono
parents:
diff changeset
3586 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3587
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3588 extern int
318
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
3589 digit(int c)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3590 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3591 return('0'<=c&&c<='9');
d35df41eac69 Initial revision
kono
parents:
diff changeset
3592 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3593
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3594 extern void
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3595 free_nptr(NMTBL *n)
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3596 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3597 n->dsp = (int)free_nptr_list;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3598 free_nptr_list = n;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3599 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3600
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3601 extern NMTBL *
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3602 get_nptr()
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3603 {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3604 NMTBL *ret;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3605 if (free_nptr_list) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3606 ret = free_nptr_list;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3607 free_nptr_list = (NMTBL *)free_nptr_list->dsp;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3608 ret->sc = 0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3609 ret->dsp = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3610 return ret;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3611 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3612 if (nptr_pool->ptr >= nptr_pool->last) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3613 if (nptr_pool->next) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3614 nptr_pool = nptr_pool->next;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3615 } else {
358
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3616 #if HEAP_REPORT
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3617 fprintf(stderr,"** nptr extended\n");
4f1fe3731ff0 realloc heap
kono
parents: 357
diff changeset
3618 #endif
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3619 nptr_pool->next = new_cheap();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3620 nptr_pool = nptr_pool->next;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3621 }
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3622 }
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3623 ret = ((NMTBL *)nptr_pool->ptr)++;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3624 ret->sc = 0;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3625 ret->dsp = 0;
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3626 return ret;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3627 }
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3628
426
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3629 /*
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3630 dummy name table element
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3631 */
fb136af3bf09 Bitfield reorganization.
kono
parents: 420
diff changeset
3632
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
3633 int dummy_count = 0;
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
3634
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3635 extern NMTBL *
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3636 anonymous_nptr()
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
3637 {
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3638 NMTBL *nptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3639 int i,j;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3640 nptr= get_nptr();
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3641 j = dummy_count++;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3642 for(i=0;j>0;j/=10);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3643 nptr->nm = cheap->ptr;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3644 cheap->ptr += i-1+3;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3645 increment_cheap(cheap,&nptr->nm);
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3646 nptr->nm[0]='_';
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3647 nptr->nm[1]='a';
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3648 nptr->nm[2]='n';
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3649 j = dummy_count;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3650 for(;i>=0;i--) {
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3651 nptr->nm[i+3]='0'+j%10;
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3652 j/=10;
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
3653 }
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
3654 nptr->sc=EMPTY;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3655 nptr->dsp=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3656 return nptr;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3657 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3658
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3659 extern NMTBL *
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3660 name_space_search(NMTBL *hash,int sc)
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3661 {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3662 int ns;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3663 NMTBL *n;
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3664
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3665 for(ns=hash->dsp;ns;ns=cadr(ns)) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3666 if (car(ns)==sc) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3667 return (NMTBL*)caddr(ns);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3668 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3669 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3670 if (ns==0) {
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3671 n = get_nptr();
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3672 hash->dsp = glist3(sc,hash->dsp,(int)n);
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3673 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3674 n->nm = hash->nm;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3675 n->sc = EMPTY;
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3676 n->dsp = 0;
349
b74b580c10f6 name table debug continue...
kono
parents: 348
diff changeset
3677 return n;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3678 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3679
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3680 // search local nptr by name and storage class
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3681 extern NMTBL *
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3682 lsearch(char *name,int sc)
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3683 {
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3684 NMTBL *nlist,*nptr1;
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3685 nptr1 = name_space_search(nlist=get_name(name,0,DEF),sc);
355
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3686 return make_local_scope(nlist,nptr1,sc);
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3687 }
6188f66c0c0b cond op, and arg scope.
kono
parents: 354
diff changeset
3688
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3689 // search top level local name (for label)
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3690 static NMTBL *
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3691 l_top_search(char *name,int sc)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3692 {
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3693 NMTBL *nlist,*nptr1;
360
d8190f815254 *** empty log message ***
kono
parents: 359
diff changeset
3694 nptr1 = name_space_search(nlist=get_name(name,0,DEF),sc);
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3695 return make_top_scope(nlist,nptr1,sc);
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3696 }
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3697
359
7ab4434ad869 macro scope
kono
parents: 358
diff changeset
3698 extern NMTBL *
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3699 make_local_scope(NMTBL *nlist,NMTBL *nptr1,int sc)
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3700 {
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3701 int ns;
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3702 for(ns=nlist->dsp;ns;ns=cadr(ns)) {
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3703 if (car(ns)==sc /* && nptr1->sc!=EMPTY */) {
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3704 // memorize previous nptr for this name for leave_scope
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3705 car(current_scope) = glist3(ns,car(current_scope),(int)nptr1);
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3706 caddr(ns) = (int)(nptr1 = get_nptr());
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3707 nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0;
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3708 }
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3709 }
351
000c509b663d name table reconfigure continue...
kono
parents: 350
diff changeset
3710 return nptr1;
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3711 }
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3712
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3713 static NMTBL *
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3714 make_top_scope(NMTBL *nlist,NMTBL *nptr1,int sc)
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3715 {
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3716 int ns;
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3717 int scope;
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3718 for(scope=current_scope;cadr(scope);scope=cadr(scope));
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3719 for(ns=nlist->dsp;ns;ns=cadr(ns)) {
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3720 // memorize previous nptr for this name for leave_scope
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3721 if (car(ns)==sc /* && nptr1->sc!=EMPTY */) {
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3722 car(scope) = glist3(ns,car(scope),(int)nptr1);
353
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3723 caddr(ns) = (int)(nptr1 = get_nptr());
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3724 nptr1->nm = nlist->nm; nptr1->sc=EMPTY; nptr1->dsp = 0;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3725 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3726 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3727 return nptr1;
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3728 }
41ed77cb9c67 name table reogranization, extendable cheap done.
kono
parents: 352
diff changeset
3729
359
7ab4434ad869 macro scope
kono
parents: 358
diff changeset
3730 extern void
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3731 enter_scope()
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3732 {
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3733 current_scope = glist2(0,current_scope);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3734 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3735
359
7ab4434ad869 macro scope
kono
parents: 358
diff changeset
3736 extern void
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3737 leave_scope()
346
969089695850 name reconfigure.... continue...
kono
parents: 343
diff changeset
3738 {
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3739 NMTBL *ns;
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3740 int scope,next;
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3741 if (!current_scope) error(-1);
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3742 // restore nptr of current scope name to the previous nptr
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3743 scope = car(current_scope);
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3744 while(scope) {
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3745 ns = (NMTBL *)caddr(car(scope));
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
3746 if (ns->sc != GVAR) free_nptr(ns);
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3747 caddr(car(scope)) = caddr(scope);
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3748 next = cadr(scope);
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3749 free_glist2(scope); // will destroy cadr
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3750 scope = next;
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3751 }
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3752 if ((next=cadr(current_scope))) {
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3753 free_glist2(current_scope);
347
cef4d8eb9a26 name table reconfigure continue...
kono
parents: 346
diff changeset
3754 current_scope = next;
356
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3755 } else
6818bd03767d *** empty log message ***
kono
parents: 355
diff changeset
3756 car(current_scope) = 0;
30
20ed2786a276 still macro
kono
parents: 29
diff changeset
3757 }
20ed2786a276 still macro
kono
parents: 29
diff changeset
3758
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3759 extern void
185
427008a06333 comment
kono
parents: 184
diff changeset
3760 extern_define(char *s,int d,int type,int use)
427008a06333 comment
kono
parents: 184
diff changeset
3761 {
427008a06333 comment
kono
parents: 184
diff changeset
3762 NMTBL *nptr0;
427008a06333 comment
kono
parents: 184
diff changeset
3763
350
43099915f4c2 name table reconfigure continue...
kono
parents: 349
diff changeset
3764 (nptr0 = name_space_search(get_name(s,0,DEF),0))->sc = EXTRN;
185
427008a06333 comment
kono
parents: 184
diff changeset
3765 nptr0->dsp = d; nptr0->ty=type;
427008a06333 comment
kono
parents: 184
diff changeset
3766 if (use) extrn_use(nptr0);
427008a06333 comment
kono
parents: 184
diff changeset
3767 }
427008a06333 comment
kono
parents: 184
diff changeset
3768
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3769 extern int
30
20ed2786a276 still macro
kono
parents: 29
diff changeset
3770 neqname(char *p,char *q)
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3771 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3772 if (!p)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3773 return 0;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3774 while(*p && *p!='.')
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3775 if(*p++ != *q++) return 1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3776 return (*q!=0);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3777 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3778
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3779 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3780 skipspc(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3781 {
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
3782 static int topspc = 0;
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3783
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
3784 while(ch=='\t'||ch=='\n'||ch==' '||ch=='\r') {
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3785 if (ch=='\n'||ch=='\r') topspc=1;
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3786 if (topspc)
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3787 conv->comment_(ch);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3788 getch();
67
254a0c576114 argument type list
kono
parents: 66
diff changeset
3789 }
69
dba8d111b7a0 c output
kono
parents: 68
diff changeset
3790 topspc=0;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3791 return ch;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3792 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3793
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3794 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3795 getch(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3796 {
275
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3797 int i,j;
115
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
3798 if(*chptr)
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
3799 return ch = *chptr++;
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3800 else if (chptrsave) {
115
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
3801 chptr = (char *)car(chptrsave);
ebac635814dc fix nested macro function
kono
parents: 114
diff changeset
3802 ch = car(chsave);
275
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3803 i = cadr(chptrsave);
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3804 j = cadr(chsave);
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3805 free_glist2(chptrsave);
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3806 free_glist2(chsave);
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3807 chptrsave = i;
8f09f8bbc494 MIPS switch statement. basic.c passed.
kono
parents: 273
diff changeset
3808 chsave = j;
34
0756caa79167 macro function recursive and copy method
kono
parents: 33
diff changeset
3809 return ch;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3810 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3811 getline();
182
e1e9ec8c96a7 some fix
kono
parents: 181
diff changeset
3812 if (in_macro_if) check_macro_eof();
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3813 return getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3814 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3815
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3816 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3817 escape(void)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3818 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3819 char c;
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3820 if ((c=ch) == '\\') {
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3821 if (digit(c=getch())) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3822 c = ch-'0';
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
3823 if (digit(getch())) {
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3824 c = c*8+ch-'0';
d35df41eac69 Initial revision
kono
parents:
diff changeset
3825 if (digit(getch())) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3826 c=c*8+ch-'0';getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3827 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3828 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3829 return c;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3830 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3831 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3832 switch(c) {
343
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3833 case 'n': return '\n';
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3834 case 't': return '\t';
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3835 case 'b': return '\b';
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3836 case 'r': return '\r';
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3837 case 'f': return '\f';
11f8f2e6bb72 fix eof and multi-file, mc-parse else-if switch
kono
parents: 338
diff changeset
3838 case '\\': return '\\';
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3839 case '\n':
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
3840 if (ch=='"') {
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
3841 return 0;
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
3842 }
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3843 return escape();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3844 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
3845 return c;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3846 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3847 }
304
9df8aa0497ea fix line continuation and #macro in string.
kono
parents: 303
diff changeset
3848 // if (c == '\n') error(EXERR);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3849 getch();
d35df41eac69 Initial revision
kono
parents:
diff changeset
3850 return c;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3851 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3852
185
427008a06333 comment
kono
parents: 184
diff changeset
3853 /* node management (cdr coding ) */
427008a06333 comment
kono
parents: 184
diff changeset
3854
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3855 #if LONGLONG_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3856
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3857 extern int
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3858 llist2(int e1, long long d1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3859 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3860 int e;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3861
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3862 e=getfree((size_of_int+size_of_longlong)/size_of_int);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3863 heap[e]=e1;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3864 lcadr(e)=d1;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3865 return e;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3866 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3867
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3868 extern int
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3869 llist3(int e1, int e2,long long d1)
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3870 {
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3871 int e;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3872
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3873 e=getfree((size_of_int+size_of_longlong)/size_of_int);
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3874 heap[e]=e1;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3875 heap[e+1]=e2;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3876 lcaddr(e)=d1;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3877 return e;
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3878 }
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3879
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3880 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3881
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3882 #if FLOAT_CODE
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3883
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3884 extern int
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3885 dlist2(int e1, double d1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3886 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3887 int e;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3888
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3889 e=getfree((size_of_int+size_of_double)/size_of_int);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3890 heap[e]=e1;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3891 dcadr(e)=d1;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3892 return e;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3893 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3894
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3895 extern int
81
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3896 dlist3(int e1, int e2,double d1)
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3897 {
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3898 int e;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3899
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3900 e=getfree((size_of_int*2+size_of_double)/size_of_int);
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3901 heap[e]=e1;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3902 heap[e+1]=e2;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3903 dcaddr(e)=d1;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3904 return e;
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3905 }
f94ca1168520 float first try...
kono
parents: 80
diff changeset
3906
195
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3907 #endif
c193120ee2a6 *** empty log message ***
kono
parents: 194
diff changeset
3908
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3909 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3910 list2(int e1, int e2)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3911 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3912 int e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3913
d35df41eac69 Initial revision
kono
parents:
diff changeset
3914 e=getfree(2);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3915 heap[e]=e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3916 heap[e+1]=e2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3917 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3918 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3919
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3920 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3921 list3(int e1, int e2, int e3)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3922 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3923 int e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3924
d35df41eac69 Initial revision
kono
parents:
diff changeset
3925 e=getfree(3);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3926 heap[e]=e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3927 heap[e+1]=e2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3928 heap[e+2]=e3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3929 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3930 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3931
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3932 extern int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3933 list4(int e1, int e2, int e3, int e4)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3934 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3935 int e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3936
d35df41eac69 Initial revision
kono
parents:
diff changeset
3937 e=getfree(4);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3938 heap[e]=e1;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3939 heap[e+1]=e2;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3940 heap[e+2]=e3;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3941 heap[e+3]=e4;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3942 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3943 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3944
61
8ffb8ca3fe34 separation of architecture dependent part.
kono
parents: 59
diff changeset
3945 static int
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3946 getfree(int n)
d35df41eac69 Initial revision
kono
parents:
diff changeset
3947 {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3948 int e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3949
d35df41eac69 Initial revision
kono
parents:
diff changeset
3950 switch (mode) {
d35df41eac69 Initial revision
kono
parents:
diff changeset
3951 case GDECL: case GSDECL: case GUDECL: case GTDECL:
178
0f395aa93438 gcc include file
kono
parents: 177
diff changeset
3952 case MDECL: case ADECL: case LSDECL: case LUDECL: case GEDECL:
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
3953 e=gfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3954 gfree+=n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3955 break;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3956 default:
d35df41eac69 Initial revision
kono
parents:
diff changeset
3957 lfree-=n;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3958 e=lfree;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3959 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3960 if(lfree<gfree) error(HPERR);
d35df41eac69 Initial revision
kono
parents:
diff changeset
3961 return e;
d35df41eac69 Initial revision
kono
parents:
diff changeset
3962 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
3963
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3964 static int free_glist2_list = 0;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3965 static int free_glist3_list = 0;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3966
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3967 extern int
33
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3968 glist2(int e1,int e2)
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3969 {
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3970 int smode,ret;
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3971 if (free_glist2_list) {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3972 ret = free_glist2_list;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3973 free_glist2_list = cadr(free_glist2_list);
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3974 car(ret)=e1; cadr(ret)=e2;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3975 return ret;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3976 }
33
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3977 smode = mode;
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3978 mode = GDECL;
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3979 ret = list2(e1,e2);
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3980 mode = smode;
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3981 return ret;
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3982 }
8500dbb69dd9 bad macro processing. give up this method.
kono
parents: 32
diff changeset
3983
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3984 extern void
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3985 free_glist2(int e1)
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3986 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 204
diff changeset
3987 if (e1>gfree) return; /* freeing local heap */
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3988 if (e1==gfree) {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3989 gfree-=2;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3990 } else {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3991 cadr(e1) = free_glist2_list;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3992 free_glist2_list = e1;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3993 }
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3994 }
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
3995
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
3996 extern int
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
3997 glist3(int e1,int e2,int e3)
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
3998 {
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
3999 int smode,ret;
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4000 if (free_glist3_list) {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4001 ret = free_glist3_list;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4002 free_glist3_list = cadr(free_glist3_list);
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4003 car(ret)=e1; cadr(ret)=e2; caddr(ret)=e3;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4004 return ret;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4005 }
95
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4006 smode = mode;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4007 mode = GDECL;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4008 ret = list3(e1,e2,e3);
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4009 mode = smode;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4010 return ret;
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4011 }
185d2cc6a3a9 *** empty log message ***
kono
parents: 94
diff changeset
4012
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4013 extern void
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4014 free_glist3(int e1)
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4015 {
206
4170cefb48f6 *** empty log message ***
kono
parents: 204
diff changeset
4016 if (e1>gfree) return; /* freeing local heap */
117
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4017 if (e1==gfree) {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4018 gfree-=3;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4019 } else {
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4020 cadr(e1) = free_glist3_list;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4021 free_glist3_list = e1;
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4022 }
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4023 }
2d5a203cc3a6 lvar reuse
kono
parents: 116
diff changeset
4024
377
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4025 extern void
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4026 free_glist3_a(int e1)
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4027 {
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4028 int next;
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4029 while(e1) {
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4030 if (e1>gfree) continue; /* freeing local heap */
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4031 next = cadr(e1);
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4032 if (e1==gfree) {
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4033 gfree-=3;
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4034 } else {
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4035 cadr(e1) = free_glist3_list;
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4036 free_glist3_list = e1;
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4037 }
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4038 e1 = next;
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4039 }
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4040 }
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4041
b23568be1155 ARM continue (const table)
kono
parents: 372
diff changeset
4042
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4043 extern int
318
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4044 length(int list)
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4045 {
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4046 int n=0;
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4047 for(;list;n++) {
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4048 list = cadr(list);
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4049 }
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4050 return n;
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4051 }
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4052
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4053 extern int
318
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4054 nth(int n, int list)
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4055 {
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4056 while(n-->0) {
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4057 list = cadr(list);
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4058 }
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4059 return list;
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4060 }
9fe0b32a7d57 asm continue...
kono
parents: 317
diff changeset
4061
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4062 extern int
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4063 insert_ascend(int p,int e,int eq())
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4064 {
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4065 int p1,p2,dup;
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4066 if(!p) return e;
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4067 if (car(p)==car(e)) {
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4068 if ((dup=eq())==0) // duplicate value is not override
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4069 return p;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4070 else if (dup==2) { // keep unique allow override
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4071 cadr(e) = cadr(p); // skip one
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4072 return e;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4073 } // any other value allows duplicate
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4074 } else if (car(p)>car(e)) {
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4075 cadr(e) = p;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4076 return e;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4077 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4078 p1=p;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4079 while(cadr(p)) {
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4080 p = cadr(p2=p);
309
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4081 if (car(p)==car(e)) {
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4082 if ((dup=eq())==0) // duplicate value is not override
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4083 return p1;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4084 else if (dup==2) { // keep unique allow override
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4085 cadr(e) = cadr(p); // skip one
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4086 cadr(p2) = e;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4087 return p1;
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4088 } // any other value allows duplicate
a86612cf1a19 struct partial initialization (local struct copy)
kono
parents: 308
diff changeset
4089 } else if (car(p)>=car(e)) {
293
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4090 cadr(e) = cadr(p2);
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4091 cadr(p2) = e;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4092 return p1;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4093 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4094 }
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4095 cadr(p) = e;
5bf2c3070d36 sort case value
kono
parents: 292
diff changeset
4096 return p1;
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4097 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
4098
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4099 extern int
55
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4100 append4(int p,int a1,int a2,int a3)
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4101 {
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4102 int p1;
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4103 if(!p) return list4(a1,0,a2,a3);
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4104 p1=p;
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4105 while(cadr(p)) p = cadr(p);
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
4106 cadr(p) = list4(a1,0,a2,a3);
55
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4107 return p1;
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4108 }
94564b45c4f3 all save implementation of parallel assignment
kono
parents: 53
diff changeset
4109
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4110 extern int
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4111 append3(int p,int a1,int a2)
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4112 {
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4113 int p1;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4114 if(!p) return list3(a1,0,a2);
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4115 p1=p;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4116 while(cadr(p)) p = cadr(p);
188
4303255fc3cf minor fix
kono
parents: 187
diff changeset
4117 cadr(p) = list3(a1,0,a2);
46
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4118 return p1;
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4119 }
b1c8ac8c308d fix cascading struct retrun. Now it should be compatible with gcc
kono
parents: 45
diff changeset
4120
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4121 extern void
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4122 display_ntable(NMTBL *n, char *s)
d35df41eac69 Initial revision
kono
parents:
diff changeset
4123 {
348
e77b3a7002ad name table reconfigure compiled. debug start.
kono
parents: 347
diff changeset
4124 fprintf(stderr,"\n%s ",s);
94
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
4125 fprintf(stderr,"nptr->sc %d ",n->sc);
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
4126 fprintf(stderr,"nptr->dsp %d ",n->dsp);
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
4127 fprintf(stderr,"nptr->ty %d ",n->ty);
1ad7045741a7 float dbinop fix
kono
parents: 87
diff changeset
4128 fprintf(stderr,"nptr->nm %s\n",n->nm);
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4129 }
d35df41eac69 Initial revision
kono
parents:
diff changeset
4130
327
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4131 /* for gdb... */
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4132
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4133 extern int c0(int d) { fprintf(stderr,"heap[%d]=",d);return car(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4134 extern int c1(int d) { fprintf(stderr,"heap[%d]=",d);return cadr(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4135 extern int c2(int d) { fprintf(stderr,"heap[%d]=",d);return caddr(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4136 extern int c3(int d) { fprintf(stderr,"heap[%d]=",d);return cadddr(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4137 extern char *cc0(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)car(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4138 extern char *cc1(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadr(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4139 extern char *cc2(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)caddr(d); }
da2e3f2d127d macro/codegen reorganization
kono
parents: 326
diff changeset
4140 extern char *cc3(int d) { fprintf(stderr,"heap[%d]=",d);return (char *)cadddr(d); }
37
412ad2e6c2a2 struct copy
kono
parents: 36
diff changeset
4141
0
d35df41eac69 Initial revision
kono
parents:
diff changeset
4142 /* end */