Compare commits

..

No commits in common. "5771877457d50ab2802f54221e612af2b2b74572" and "5713df2a8b4d97756d505ab76a354d79d073a91b" have entirely different histories.

2 changed files with 5 additions and 8 deletions

View file

@ -7,7 +7,7 @@ pub fn build(b: *Builder) void {
exe.install();
exe.linkSystemLibrary("c");
exe.linkSystemLibrary("LLVM-10");
exe.linkSystemLibrary("LLVM-9");
exe.linkSystemLibrary("stdc++");
const run_cmd = exe.run();

View file

@ -176,14 +176,12 @@ pub const Codegen = struct {
.Call => |call| {
const name = call.callee.*.Variable.lexeme;
var llvm_func_entry = self.llvm_table.getEntry(name);
if (llvm_func_entry == null) {
var llvm_func = self.llvm_table.get(name);
if (llvm_func == null) {
std.debug.warn("Function '{}' not found\n", .{name});
return CompileError.EmitError;
}
const llvm_func = llvm_func_entry.?.value;
var args = LLVMValueList.init(self.allocator);
errdefer args.deinit();
@ -196,7 +194,7 @@ pub const Codegen = struct {
return llvm.LLVMBuildCall(
builder,
llvm_func,
llvm_func.?,
args_slice.ptr,
@intCast(c_uint, args_slice.len),
"call",
@ -434,8 +432,7 @@ pub const Codegen = struct {
);
var func = llvm.LLVMAddFunction(mod, name_cstr.ptr, llvm_ret_type);
std.debug.warn("inserting function '{}' to llvm table\n", .{name});
try self.llvm_table.put(name, func);
_ = try self.llvm_table.put(name, func);
var buf = try self.allocator.alloc(u8, 512);
var entry_lbl = try std.fmt.bufPrint(buf, "fn_{}_entry", .{name});