From 55c8c08150c4fb03563dc5ce271cbbf6c01df51a Mon Sep 17 00:00:00 2001 From: Lukas Krickl Date: Sat, 2 Dec 2023 11:52:30 +0100 Subject: [PATCH] WIP: symbol definition --- include/ulas.h | 6 ++++-- src/ulas.c | 5 +++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/include/ulas.h b/include/ulas.h index 83d9028..6ca65e5 100644 --- a/include/ulas.h +++ b/include/ulas.h @@ -414,9 +414,11 @@ char *ulas_strndup(const char *src, unsigned long n); struct ulas_sym *ulas_symbolresolve(const char *name, int *rc); // define a new symbol -// scope 0 indicates global scope +// scope 0 indicates global scope. a scope of -1 instructs +// the function to auto-detect the scope +// if a label starts with @ the current scope is used, otherwise 0 is used // if the symbol already exists -1 is returned -int ulas_symbolset(const char *name, int scope, struct ulas_tok token); +int ulas_symbolset(int scope, struct ulas_sym symbol); // tokenisze according to pre-defined rules // returns the amount of bytes of line that were diff --git a/src/ulas.c b/src/ulas.c index c2d79cf..ad101e6 100644 --- a/src/ulas.c +++ b/src/ulas.c @@ -223,9 +223,10 @@ struct ulas_sym *ulas_symbolresolve(const char *name, int *rc) { return NULL; } -int ulas_symbolset(const char *name, int scope, struct ulas_tok token) { +int ulas_symbolset(int scope, struct ulas_sym symbol) { int rc = 0; int resolve_rc = 0; + const char *name = symbol.name; struct ulas_sym *exisitng = ulas_symbolresolve(name, &resolve_rc); // define new if (!exisitng) { @@ -2059,7 +2060,7 @@ int ulas_asmline(FILE *dst, FILE *src, const char *line, unsigned long n) { ulas_asmlst(start, outbuf, towrite); return 0; } - // ulas_symbolset(ulas.tok.buf, ulas.scope, + // ulas_symbolset(ulas.tok.buf, -1, line = prev; } else { // start over for the next step... -- 2.30.2