diff --git a/build.zig b/build.zig index 020f6cf..cd24748 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,7 @@ pub fn build(b: *Builder) void { exe.install(); exe.linkSystemLibrary("c"); - exe.linkSystemLibrary("LLVM-8"); + exe.linkSystemLibrary("LLVM-9"); exe.linkSystemLibrary("stdc++"); const run_cmd = exe.run(); diff --git a/src/comp_ctx.zig b/src/comp_ctx.zig index afbe5e4..56d829c 100644 --- a/src/comp_ctx.zig +++ b/src/comp_ctx.zig @@ -139,6 +139,7 @@ const Using = enum { pub const VariableMetadata = struct { typ: SymbolUnderlyingType, + llvm_alloca: llvm.LLVMValueRef = null, using: Using, @@ -155,7 +156,7 @@ pub const VariableMetadata = struct { }; // TODO rm const? -pub const VariableMetadataMap = std.AutoHashMap(*const ast.Expr, VariableMetadata); +pub const VariableMetadataMap = std.AutoHashMap(*const ast.Expr, *VariableMetadata); /// Represents the context for a full compiler run. /// This is used to manage the symbol table for the compilation unit, etc. @@ -380,7 +381,10 @@ pub const CompilationContext = struct { } pub fn insertMetadata(self: *@This(), ptr: *const ast.Expr, metadata: VariableMetadata) !void { + var meta = try self.allocator.create(VariableMetadata); + meta.* = metadata; + std.debug.assert(ast.ExprType(ptr.*) == .Variable); - _ = try self.metadata_map.put(ptr, metadata); + _ = try self.metadata_map.put(ptr, meta); } };