diff options
Diffstat (limited to 'lexer.c')
-rw-r--r-- | lexer.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -313,6 +313,8 @@ char *mk_scope_name(symbol *csym, int depth, const char *name, uint8_t dbg) { scopes = malloc(sizeof(char *)*depth); } + for (; s && s->depth > depth; s = s->up); + for (int i = depth; i && s; i--) { if (dbg) { printf("mk_scope_name(): s->depth: %i\n", s->depth); @@ -754,8 +756,9 @@ int get_expr_type(char **p, uint64_t address, void *val, int *found_reg, char st if (is_reg(tmp) >= 0) { *found_reg = 1; } else { - scope_name = (!scope_depth) ? mk_scope_name(cur_sym, depth, tmp, dbg) : tmp; - s = get_sym(scope_name, address, NULL, (scope_depth) ? scope_depth : depth, 1, dbg); + int total_depth = depth+scope_depth; + scope_name = (!scope_depth || total_depth) ? mk_scope_name(cur_sym, depth, tmp, dbg) : tmp; + s = get_sym(scope_name, address, NULL, total_depth, 1, dbg); isfixup += (s == NULL); type = EXPR_SYM; *(symbol **)val = s; @@ -1289,7 +1292,7 @@ uint64_t lex(char *str, uint64_t address, uint16_t bline, uint8_t dbg) { for (; isdelm(str[i+spaces], dbg) == 16; spaces++); uint8_t ret = get_ptok(str[i+spaces], dbg); if (ret == PTOK_COLON || ret == PTOK_EQU) { - depth = (lex_type == TOK_LOCAL); + depth = (lex_type != TOK_LOCAL) ? 0 : depth; } int is_expr = (!is_struct && str[i+spaces] != ':' && str[i+spaces] != '='); l->count++; |