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