Use print to string instead of dump

This commit is contained in:
Sofia 2023-08-02 18:48:56 +03:00
parent 2ced45eb40
commit e9aab4f43e
2 changed files with 4 additions and 6 deletions

View File

@ -1,4 +1,4 @@
use std::ffi::CString; use std::ffi::{CStr, CString};
use std::mem; use std::mem;
use llvm_sys::{core::*, prelude::*, LLVMBuilder, LLVMContext, LLVMModule}; use llvm_sys::{core::*, prelude::*, LLVMBuilder, LLVMContext, LLVMModule};
@ -80,10 +80,8 @@ impl IRModule {
} }
} }
pub fn dump(&mut self) { pub fn print_to_string(&mut self) -> Result<&str, std::str::Utf8Error> {
unsafe { unsafe { CStr::from_ptr(LLVMPrintModuleToString(self.module)).to_str() }
LLVMDumpModule(self.module);
}
} }
} }

View File

@ -36,5 +36,5 @@ fn main() {
for statement in statements { for statement in statements {
statement.codegen(&mut module); statement.codegen(&mut module);
} }
module.dump(); println!("{}", module.print_to_string().unwrap());
} }