Now storing references.
h3rald h3rald@h3rald.com
Fri, 28 Nov 2025 07:41:02 +0100
1 files changed,
22 insertions(+),
0 deletions(-)
jump to
M
xywasm.c
→
xywasm.c
@@ -287,6 +287,20 @@ sym->address = ptr;
return 0; } +static int ref(xyw_context *ctx, char *name) +{ + if (refcount >= MAX_REFS) + { + error("Too many symbol references"); + return -1; + } + xyw_symbol *sym = &refs[refcount++]; + sym->type = SYMBOL_TYPE_REF; + sym->name = dict_add(name); + sym->address = ptr; + return 0; +} + //// Processing functions static int process_comment(xyw_context *ctx)@@ -505,6 +519,14 @@ }
// TODO: Remove printf("Symbol:\t\t%s\n", token); token_type = TOKEN_TYPE_SYMBOL; + if (!directive) + { + printf("-> Ref:\t%s\n", token); + if (ref(ctx, token) != 0) + { + return -1; + } + } return 0; }