ox

The Ox programming language, compiler and tools (WIP)
Log | Files | Refs | README | LICENSE

commit b67ee1e46dc27deaea607aa0d7f8a8107a2127ac
parent 558c983480e3d02deba8a76e37959dee6db9ed44
Author: citbl <citbl@citbl.org>
Date:   Mon, 20 Oct 2025 20:28:29 +1000

clean up

Diffstat:
Msrc/gen/gen.c | 17+----------------
Msrc/types.h | 5+++++
2 files changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/gen/gen.c b/src/gen/gen.c @@ -91,7 +91,7 @@ gen_init(Scope* scope, const char* src, Node* node, bool quiet) static gcc_jit_rvalue* handle_ident_call(Gen* gen, Node* node) { - // Look up the symbol in the current scope + // Look up the symbol in the current scope // TODO look up in parent scope with utility function and recursion for (size_t i = 0; i < gen->scope->len; i++) { Symbol* sym = gen->scope->symbols[i]; const char* sym_name = span_str(gen->src, sym->name, (char[IDENTSZ]) { 0 }); @@ -105,21 +105,6 @@ handle_ident_call(Gen* gen, Node* node) printf("found %s\n", sym_name); return gcc_jit_lvalue_as_rvalue(sym->d.lvalue); } - - // TODO @next right now we get the first one, which isn't good. - // we need to get the right one by name - // need to research what the best way is to store that and use it, right now, symbols are a mess - // and their relation between each other and the rest of the compiler is a mess. - // return gcc_jit_lvalue_as_rvalue(sym->d.lvalue); - - // if (sym->name.start == node->data.var_decl.name.start && sym->name.end == node->data.var_decl.name.end) { - // gcc_jit_rvalue *p_r = gcc_jit_lvalue_as_rvalue(sym->d.lvalue); - // // dereference pointer -> lvalue of the pointee: - // gcc_jit_lvalue *pointee_lv = gcc_jit_rvalue_dereference(p_r, NULL); - // // read the pointee as an rvalue (e.g., for arithmetic): - // gcc_jit_rvalue *pointee_r = gcc_jit_lvalue_as_rvalue(pointee_lv); - // return pointee_r; - // } } softpanic("undefined variable: %s\n", span_str(gen->src, node->data.ident.name, (char[IDENTSZ]) { 0 })); diff --git a/src/types.h b/src/types.h @@ -283,6 +283,11 @@ typedef struct Symbol { } d; } Symbol; +// @later NOTE: our symbols are a list, there is an argument to be made to change to a linked list; +// as a linked list will outperform an allocated list up to 12-16 elements, or so. + +// @later NOTE: also consider their relation between each other and the rest of the compiler is a bit of a circulas mess; +// which is fine as long as we're boostrapping and getting it off the ground. typedef struct Scope { struct Node* owner; struct Scope* parent;