mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-16 02:15:01 +01:00
test out better debugging
This commit is contained in:
parent
6a8eb89381
commit
5f9ca90fd5
13 changed files with 422 additions and 145 deletions
28
src/gc.rs
28
src/gc.rs
|
|
@ -18,6 +18,13 @@ pub struct Gc<T: ?Sized> {
|
|||
ptr: NonNull<T>,
|
||||
}
|
||||
|
||||
#[cfg(feature = "_debug")]
|
||||
impl<T: ?Sized> dbg_pls::DebugPls for Gc<T> {
|
||||
fn fmt(&self, f: dbg_pls::Formatter<'_>) {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: ?Sized> Deref for Gc<T> {
|
||||
type Target = T;
|
||||
|
||||
|
|
@ -30,21 +37,6 @@ impl<T: ?Sized> Deref for Gc<T> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "_debug")]
|
||||
impl<T: debug2::Debug> debug2::Debug for Gc<T> {
|
||||
fn fmt(&self, f: &mut debug2::Formatter<'_>) -> std::fmt::Result {
|
||||
T::fmt(&*self, f)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "_debug")]
|
||||
impl debug2::Debug for Gc<str> {
|
||||
fn fmt(&self, f: &mut debug2::Formatter<'_>) -> std::fmt::Result {
|
||||
let str = self.deref();
|
||||
debug2::Debug::fmt(&str, f)
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: Debug + ?Sized> Debug for Gc<T> {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
T::fmt(self, f)
|
||||
|
|
@ -61,7 +53,7 @@ impl<T: ?Sized> Copy for Gc<T> {}
|
|||
|
||||
/// An reference to an interned String. Hashing and Equality are O(1) and just look at the pointer address
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "_debug", derive(debug2::Debug))]
|
||||
#[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))]
|
||||
pub struct Symbol {
|
||||
gc: Gc<str>,
|
||||
}
|
||||
|
|
@ -74,20 +66,18 @@ type ObjectMap = HashMap<Symbol, Value>;
|
|||
/// ```
|
||||
/// This is inside the local x now.
|
||||
#[derive(Clone, Copy)]
|
||||
#[cfg_attr(feature = "_debug", derive(debug2::Debug))]
|
||||
#[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))]
|
||||
pub struct Object {
|
||||
gc: Gc<HeapObject>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "_debug", derive(debug2::Debug))]
|
||||
struct HeapObject {
|
||||
kind: HeapObjectKind,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "_debug", derive(debug2::Debug))]
|
||||
enum HeapObjectKind {
|
||||
String(Gc<str>),
|
||||
Object(ObjectMap),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue