}
fn map_type_ffi(&mut self, source: &Atom) -> *mut ffi_type {
- unsafe {
- match source {
- atom!("sint64") => addr_of_mut!(types::sint64),
- atom!("sint32") => addr_of_mut!(types::sint32),
- atom!("sint16") => addr_of_mut!(types::sint16),
- atom!("sint8") => addr_of_mut!(types::sint8),
- atom!("uint64") => addr_of_mut!(types::uint64),
- atom!("uint32") => addr_of_mut!(types::uint32),
- atom!("uint16") => addr_of_mut!(types::uint16),
- atom!("uint8") => addr_of_mut!(types::uint8),
- atom!("bool") => addr_of_mut!(types::sint8),
- atom!("void") => addr_of_mut!(types::void),
- atom!("cstr") => addr_of_mut!(types::pointer),
- atom!("ptr") => addr_of_mut!(types::pointer),
- atom!("f32") => addr_of_mut!(types::float),
- atom!("f64") => addr_of_mut!(types::double),
- struct_name => match self.structs.get_mut(&*struct_name.as_str()) {
- Some(ref mut struct_type) => &mut struct_type.ffi_type,
- None => unreachable!(),
- },
- }
+ match source {
+ atom!("sint64") => addr_of_mut!(types::sint64),
+ atom!("sint32") => addr_of_mut!(types::sint32),
+ atom!("sint16") => addr_of_mut!(types::sint16),
+ atom!("sint8") => addr_of_mut!(types::sint8),
+ atom!("uint64") => addr_of_mut!(types::uint64),
+ atom!("uint32") => addr_of_mut!(types::uint32),
+ atom!("uint16") => addr_of_mut!(types::uint16),
+ atom!("uint8") => addr_of_mut!(types::uint8),
+ atom!("bool") => addr_of_mut!(types::sint8),
+ atom!("void") => addr_of_mut!(types::void),
+ atom!("cstr") => addr_of_mut!(types::pointer),
+ atom!("ptr") => addr_of_mut!(types::pointer),
+ atom!("f32") => addr_of_mut!(types::float),
+ atom!("f64") => addr_of_mut!(types::double),
+ struct_name => match self.structs.get_mut(&*struct_name.as_str()) {
+ Some(ref mut struct_type) => &mut struct_type.ffi_type,
+ None => unreachable!(),
+ },
}
}
unifier.unify_atom(atom, value);
}
- pub fn unify_list(&mut self, l1: usize, value: HeapCellValue) {
- let mut unifier = DefaultUnifier::from(self);
- unifier.unify_list(l1, value);
- }
-
- pub fn unify_partial_string(&mut self, pstr_loc: usize, value: HeapCellValue) {
- let mut unifier = DefaultUnifier::from(self);
- unifier.unify_partial_string(pstr_loc, value);
- }
-
pub fn unify_char(&mut self, c: char, value: HeapCellValue) {
let mut unifier = DefaultUnifier::from(self);
unifier.unify_char(c, value);
#[inline(always)]
pub fn as_ptr(self) -> *mut u8 {
- let addr: u64 = self.ptr();
- addr as usize as *mut _
+ unsafe {
+ mem::transmute::<_, *mut u8>(self.ptr())
+ }
}
#[inline(always)]
}
#[inline]
- pub fn get_ptr(self) -> *const u8 {
- let addr: u64 = self.ptr();
- addr as usize as *const u8
+ pub fn get_ptr(self) -> *const ArenaHeader {
+ unsafe {
+ mem::transmute::<_, *const ArenaHeader>(self.ptr())
+ }
}
#[inline]
pub fn get_tag(self) -> ArenaHeaderTag {
unsafe {
- let header = *(self.get_ptr() as *const ArenaHeader);
+ let header = *self.get_ptr();
header.get_tag()
}
}
#[inline]
pub fn payload_offset(self) -> *const u8 {
- unsafe { self.get_ptr().add(mem::size_of::<ArenaHeader>()) }
+ unsafe { self.get_ptr().byte_add(mem::size_of::<ArenaHeader>()) as *const _ }
}
/// # Safety