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