all repos — xyw @ 1604791df81ab008bafa876304f3e82fcb4e74c7

A minimal virtual machine and assembler for terminals.

Now storing references.
h3rald h3rald@h3rald.com
Fri, 28 Nov 2025 07:41:02 +0100
commit

1604791df81ab008bafa876304f3e82fcb4e74c7

parent

11d84a5f8d6577f6daddf8f31299a2cd6baa423f

1 files changed, 22 insertions(+), 0 deletions(-)

jump to
M xywasm.cxywasm.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; }