diff options
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 38 |
1 files changed, 23 insertions, 15 deletions
@@ -243,7 +243,7 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) { uint8_t k = 0; union reg ch; - ch.u64 =0; + ch.u64 = 0; uint8_t rs = 0; uint8_t of = 0; uint8_t base = 0; @@ -359,21 +359,15 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) { if ((k == DIR_ENDSTRUCT || k == DIR_ENDUNION)) { int skip = 0; if ((int)is_anon > 0) { - if ((cur_sym->up && !cur_sym->up->isanon) || (struct_sym && struct_sym->isanon)) { + if ((cur_sym && cur_sym->isanon) || (cur_sym->up && !cur_sym->up->isanon) || (struct_sym && struct_sym->isanon)) { is_anon--; + } else if ((int)is_struct <= 0) { + is_anon = 0; } skip = (!is_anon); } - if ((int)(is_struct-is_anon) > 0 && !skip && cur_sym->up) { - symbol *s = cur_sym; - for (; s->prev; s = s->prev) { - if (s->up == NULL && cur_sym->up) { - s->up = cur_sym->up; - } - if (dbg) { - printf("s: %p, s->up: %p, cur_sym->up: %p, last_loc: %p\n", s, s->up, cur_sym->up, last_loc); - } - } + if (((int)(is_struct-is_anon) > 0 && !skip) || ((int)is_anon <= 0 && (int)is_struct <= 0)) { + symbol *s; for (s = locals; s; s = s->next) { if (s->up == NULL) { s->up = cur_sym; @@ -385,11 +379,25 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) { if (cur_sym->down == NULL) { cur_sym->down = locals; } - cur_sym = cur_sym->up; - for (struct_sym = locals->up; struct_sym->prev && !struct_sym->isanon; struct_sym = struct_sym->prev); + } + if (((int)is_anon <= 0 || (int)is_struct <= 0)) { + for (struct_sym = cur_sym; struct_sym->prev && !struct_sym->isanon; struct_sym = struct_sym->prev); + } + if ((int)(is_struct-is_anon) > 0 && !skip) { + symbol *s = cur_sym; + for (; s->prev; s = s->prev) { + if (s->up == NULL && cur_sym->up) { + s->up = cur_sym->up; + } + if (dbg) { + printf("s: %p, s->up: %p, cur_sym->up: %p, last_loc: %p\n", s, s->up, cur_sym->up, last_loc); + } + } + if (cur_sym->up) { + cur_sym = cur_sym->up; + } for (locals = locals->up; locals->prev; locals = locals->prev); for (last_loc = locals; last_loc->next; last_loc = last_loc->next); - } else if (!is_struct) { } } break; |