add CompileError error type

This commit is contained in:
Luna 2019-09-22 18:26:00 -03:00
parent 4a2cc4b524
commit 469625d32a
1 changed files with 5 additions and 9 deletions

View File

@ -7,6 +7,8 @@ fn sliceify(non_slice: ?[*]const u8) []const u8 {
return non_slice.?[0..std.mem.len(u8, non_slice.?)];
}
pub const CompileError = error{LLVMError};
pub const Codegen = struct {
allocator: *std.mem.Allocator,
@ -89,9 +91,7 @@ pub const Codegen = struct {
if (llvm.LLVMWriteBitcodeToFile(mod, c"awoo.bc") != 0) {
std.debug.warn("error writing bitcode to file: {}\n", sliceify(err));
// TODO return error value
@panic("compile error");
return CompileError.LLVMError;
}
//llvm.InitializeAllTargetInfos();
@ -103,9 +103,7 @@ pub const Codegen = struct {
var engine: llvm.LLVMExecutionEngineRef = undefined;
if (llvm.LLVMCreateExecutionEngineForModule(&engine, mod, &err) != 0) {
std.debug.warn("failed to create execution engine: {}\n", sliceify(err));
// TODO return error value
@panic("compile error");
return CompileError.LLVMError;
}
var machine = llvm.LLVMGetExecutionEngineTargetMachine(engine);
@ -135,9 +133,7 @@ pub const Codegen = struct {
&err,
) != 0) {
std.debug.warn("failed to emit to file: {}\n", sliceify(err));
// TODO return error value
@panic("compile error");
return CompileError.LLVMError;
}
}
};