diff --git a/src/codegen.zig b/src/codegen.zig index ccf191f..c728c0a 100644 --- a/src/codegen.zig +++ b/src/codegen.zig @@ -210,22 +210,16 @@ pub const Codegen = struct { ); }, - // TODO finish this .Assign => |assign| { - // TODO find assign.name on the "parent context", we should have - // a way to do name resolution that is completely relative to - // where we currently are, and go up in scope. so that we find - // the LLVMValueRef. - - // we will also need to repeat the step for the type resolver - - //var typ = self.findCurrent(assign.name); - @panic("TODO finish Assign emitting"); - + const name = assign.name.lexeme; + var meta = self.ctx.current_scope.?.meta_map.get(name).?.value; var assign_expr = try self.emitExpr(builder, assign.value); + var llvm_alloca: llvm.LLVMValueRef = switch (meta.using) { + .Function => meta.from_function.?.parameters.get(name).?.value.llvm_alloca.?, + .Scope => meta.llvm_alloca.?, + }; - // TODO rm null - return llvm.LLVMBuildStore(builder, null, assign_expr); + return llvm.LLVMBuildStore(builder, assign_expr, llvm_alloca); }, .Variable => |vari| {