comparison lwasm/struct.c @ 46:534bfa3389b0

Fixed multiple symbol error with nested structs
author lost@l-w.ca
date Mon, 04 Apr 2011 22:10:16 -0600
parents 127e5b1e01c0
children 1d6a31a2586b
comparison
equal deleted inserted replaced
45:c42d6dc7df68 46:534bfa3389b0
208 208
209 l -> len = s -> size; 209 l -> len = s -> size;
210 210
211 if (as -> instruct) 211 if (as -> instruct)
212 { 212 {
213 len = strlen(as -> cstruct -> name) + strlen(l -> sym) + 9; 213 // len = strlen(as -> cstruct -> name) + strlen(l -> sym) + 9;
214 t = lw_alloc(len + 1); 214 // t = lw_alloc(len + 1);
215 sprintf(t, "sizeof{%s.%s}", as -> cstruct -> name, l -> sym); 215 // sprintf(t, "sizeof{%s.%s}", as -> cstruct -> name, l -> sym);
216 } 216 }
217 else 217 else
218 { 218 {
219 len = strlen(l -> sym) + 8; 219 len = strlen(l -> sym) + 8;
220 t = lw_alloc(len + 1); 220 t = lw_alloc(len + 1);
221 sprintf(t, "sizeof{%s}", l -> sym); 221 sprintf(t, "sizeof{%s}", l -> sym);
222 } 222 te = lw_expr_build(lw_expr_type_int, s -> size);
223 te = lw_expr_build(lw_expr_type_int, s -> size); 223 register_symbol(as, l, t, te, symbol_flag_nocheck);
224 register_symbol(as, l, t, te, symbol_flag_nocheck); 224 lw_expr_destroy(te);
225 lw_expr_destroy(te); 225 lw_free(t);
226 lw_free(t); 226 }
227 227
228 if (as -> instruct) 228 if (as -> instruct)
229 { 229 {
230 len = strlen(as -> cstruct -> name) + strlen(l -> sym) + 1; 230 // len = strlen(as -> cstruct -> name) + strlen(l -> sym) + 1;
231 t = lw_alloc(len + 1); 231 // t = lw_alloc(len + 1);
232 sprintf(t, "%s.%s", as -> cstruct -> name, l -> sym); 232 // sprintf(t, "%s.%s", as -> cstruct -> name, l -> sym);
233 } 233 }
234 else 234 else
235 {
235 t = lw_strdup(l -> sym); 236 t = lw_strdup(l -> sym);
236 pseudo_endstruct_aux(as, l, s -> fields, t, &addr); 237 pseudo_endstruct_aux(as, l, s -> fields, t, &addr);
237 lw_free(t); 238 lw_free(t);
239 }
240
238 l -> symset = 1; 241 l -> symset = 1;
239 if (as -> instruct) 242 if (as -> instruct)
240 register_struct_entry(as, l, s -> size, s); 243 register_struct_entry(as, l, s -> size, s);
241 return 0; 244 return 0;
242 } 245 }