userspace/memory/stack/auxiliary/
entry.rs1use super::atype;
2
3ample::r#struct!(
4 #[repr(C)]
5 pub struct Entry {
6 pub prev: *mut Entry,
7 pub next: *mut Entry,
8 pub pointer: crate::target::arch::Pointer, }
10);
11
12impl Entry {
13 pub fn from_pointer(pointer: crate::target::arch::Pointer) -> Entry {
14 Entry {
15 prev: core::ptr::null_mut(),
16 next: core::ptr::null_mut(),
17 pointer: pointer,
18 }
19 }
20
21 pub fn key(&self) -> atype::TypeUnit {
22 use atype::FromDiscriminant;
23 atype::TypeUnit::from_discriminant(unsafe { *self.pointer.0 as usize })
24 }
25
26 pub fn value(&self) -> atype::Type {
27 use atype::TypeTrait;
28 unsafe {
29 atype::Type::from_pair(
30 self.pointer.0 as *mut usize,
31 (self.pointer.0 as *mut usize).add(1) as *const u8,
32 )
33 }
34 }
35}
36
37impl core::fmt::Debug for Entry {
38 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
39 let _ = write!(f, "Entry: {{ ");
44 let _ = write!(f, "{:?}, ", self.prev);
45 let _ = write!(f, "{:?}, ", self.next);
46 let _ = write!(f, "{:?}, ", self.pointer);
47 let _ = write!(f, " }}");
48
49 return Ok(());
50 }
52}