Skip to content

Commit 1305cda

Browse files
committed
Add new_temp
1 parent 6e290f2 commit 1305cda

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

gccjit_sys/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,4 +662,7 @@ extern {
662662
pub fn gcc_jit_version_major() -> c_int;
663663
pub fn gcc_jit_version_minor() -> c_int;
664664
pub fn gcc_jit_version_patchlevel() -> c_int;
665+
666+
#[cfg(feature="master")]
667+
pub fn gcc_jit_function_new_temp(func: *mut gcc_jit_function, loc: *mut gcc_jit_location, ty: *mut gcc_jit_type) -> *mut gcc_jit_lvalue;
665668
}

src/function.rs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,22 @@ impl<'ctx> Function<'ctx> {
213213
}
214214
}
215215

216+
#[cfg(feature="master")]
217+
pub fn new_temp(&self, loc: Option<Location<'ctx>>, ty: Type<'ctx>) -> LValue<'ctx> {
218+
unsafe {
219+
let loc_ptr = match loc {
220+
Some(loc) => location::get_ptr(&loc),
221+
None => ptr::null_mut()
222+
};
223+
let ptr = gccjit_sys::gcc_jit_function_new_temp(self.ptr, loc_ptr, types::get_ptr(&ty));
224+
#[cfg(debug_assertions)]
225+
if let Ok(Some(error)) = self.to_object().get_context().get_last_error() {
226+
panic!("{} ({:?})", error, self);
227+
}
228+
lvalue::from_ptr(ptr)
229+
}
230+
}
231+
216232
#[cfg(feature="master")]
217233
pub fn add_attribute<'a>(&self, attribute: FnAttribute<'a>) {
218234
let value = attribute.get_value();

0 commit comments

Comments
 (0)