From 78458e09a22499193eeb9ee6e852789187b1d044 Mon Sep 17 00:00:00 2001 From: Baitinq Date: Sun, 13 Jul 2025 17:50:08 +0200 Subject: Boostrap: Support struct instanciation --- src/bootstrap/codegen.pry | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/bootstrap/codegen.pry') diff --git a/src/bootstrap/codegen.pry b/src/bootstrap/codegen.pry index 9363265..858ebfa 100644 --- a/src/bootstrap/codegen.pry +++ b/src/bootstrap/codegen.pry @@ -170,6 +170,14 @@ let codegen_get_llvm_type = (c: *codegen, node: *Node) => *LLVMTypeRef { return r; }; + let v = environment_get_variable((*c).environment, simple_type.name); + if (v != cast(*Variable, null)) { + assert((*v).type != cast(LLVMTypeRef, null)); + let r = cast(*LLVMTypeRef, arena_alloc((*c).arena, sizeof(LLVMTypeRef))); + *r = (*v).type; + return r; + }; + printf("NO SIMPLE TYPE %s!\n", simple_type.name); assert(false); }; @@ -783,6 +791,13 @@ let codegen_generate_expression_value = (c: *codegen, expression: *Node, name: * v.node_type = simple_type_node; return codegen_create_variable(c, v); }; + + if ((*expression).type == NODE_STRUCT_INSTANCIATION) { + let struc_data = *cast(*NODE_STRUCT_INSTANCIATION_DATA, (*expression).data); + let v = environment_get_variable((*c).environment, struc_data.typ); + assert(v != cast(*Variable, null)); + return v; + }; printf("ASSERT 1: %d\n", (*expression).type); assert(false); -- cgit 1.4.1