Skip to content

Commit af31863

Browse files
authored
Merge pull request #28 from tempdragon/master
feat(RValue): Allow Setting Locations after Creation
2 parents 4581640 + 96fb948 commit af31863

File tree

4 files changed

+22
-1
lines changed

4 files changed

+22
-1
lines changed

gccjit_sys/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -666,4 +666,8 @@ extern {
666666

667667
#[cfg(feature="master")]
668668
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;
669+
670+
#[cfg(feature="master")]
671+
pub fn gcc_jit_rvalue_set_location(rvalue: *mut gcc_jit_rvalue,
672+
loc: *mut gcc_jit_location);
669673
}

src/context.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1215,7 +1215,6 @@ pub unsafe fn from_ptr<'ctx>(ptr: *mut gccjit_sys::gcc_jit_context) -> Context<'
12151215
#[cfg(test)]
12161216
mod tests {
12171217
use super::super::*;
1218-
use std::default::Default;
12191218
use std::mem;
12201219

12211220
#[test]

src/location.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ impl<'ctx> fmt::Debug for Location<'ctx> {
2626
}
2727
}
2828

29+
impl<'ctx> Location<'ctx> {
30+
pub fn null() -> Self {
31+
Location {
32+
marker: std::marker::PhantomData,
33+
ptr: core::ptr::null_mut(),
34+
}
35+
}
36+
}
37+
2938
pub unsafe fn from_ptr<'ctx>(ptr: *mut gccjit_sys::gcc_jit_location) -> Location<'ctx> {
3039
Location {
3140
marker: PhantomData,

src/rvalue.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,15 @@ impl<'ctx> RValue<'ctx> {
101101
}
102102
}
103103

104+
/// Sets the location of this RValue.
105+
#[cfg(feature="master")]
106+
pub fn set_location(&self, loc: Location) {
107+
unsafe {
108+
let loc_ptr = location::get_ptr(&loc);
109+
gccjit_sys::gcc_jit_rvalue_set_location(self.ptr, loc_ptr);
110+
}
111+
}
112+
104113
/// Given an RValue x and a Field f, returns an RValue representing
105114
/// C's x.f.
106115
pub fn access_field(&self,

0 commit comments

Comments
 (0)