diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-07-01 20:00:00 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-07-01 20:00:00 +0200 |
commit | 155dec506b8f2cf381f08139017c3650f6ab7394 (patch) | |
tree | 4c6da530fad01fda581b55dcea36735277c9ef22 /src | |
parent | 325db44028d817942861ca98d6ed06c320fb39ae (diff) |
Evaluate identifiers in other scopes
Diffstat (limited to 'src')
-rw-r--r-- | src/codegen.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/codegen.c b/src/codegen.c index f81e9b9..246c176 100644 --- a/src/codegen.c +++ b/src/codegen.c @@ -198,8 +198,7 @@ codegentypedexpr(struct cgctx ctx, idx_t i, type_t type, LLVMValueRef *outv) case ASTIDENT: { strview_t sv = ctx.toks.strs[ctx.ast.lexemes[i]]; LLVMTypeRef t = type2llvm(ctx, ctx.types[i]); - LLVMValueRef ptrval = - symtab_insert(&ctx.scps[ctx.scpi].map, sv, NULL)->v; + LLVMValueRef ptrval = symtab_get_from_scopes(ctx, sv)->v; *outv = LLVMBuildLoad2(ctx.bob, t, ptrval, "load"); return fwdnode(ctx.ast, i); } @@ -414,6 +413,7 @@ codegendecl(struct cgctx ctx, idx_t i) char *name = tmpalloc(ctx.s, sv.len + 1, 1); LLVMTypeRef t = type2llvm(ctx, ctx.types[i]); LLVMValueRef globl = LLVMAddGlobal(ctx.mod, t, svtocstr(name, sv)); + symtab_insert(&ctx.scps[ctx.scpi].map, sv, NULL)->v = globl; LLVMValueRef v; if (p.rhs == AST_EMPTY) { |