mirror of
https://github.com/Noratrieb/dilaria.git
synced 2026-01-14 09:25:02 +01:00
more better working debug
This commit is contained in:
parent
08d1f01802
commit
01e6d7802e
5 changed files with 34 additions and 6 deletions
|
|
@ -142,6 +142,7 @@ impl dbg_pls::DebugPls for FnBlock<'_> {
|
|||
f.debug_struct("FnBlock")
|
||||
.field("arity", &self.arity)
|
||||
.field("code", &self.code.as_slice())
|
||||
.field("stack_sizes", &self.stack_sizes.as_slice())
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -473,10 +473,11 @@ impl<'bc, 'gc> Compiler<'bc, 'gc> {
|
|||
|
||||
for param in params.iter() {
|
||||
self.compile_expr(param)?;
|
||||
todo!("no params yet")
|
||||
}
|
||||
|
||||
self.push_instr(Instr::Load(offset), StackChange::Grow, call.span);
|
||||
self.push_instr(Instr::Call, StackChange::Grow, call.span);
|
||||
self.push_instr(Instr::Call, StackChange::None, call.span);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,9 +11,9 @@ use std::fmt::Debug;
|
|||
pub use span::Span;
|
||||
|
||||
mod span {
|
||||
use std::fmt::{Debug, Formatter};
|
||||
|
||||
#[derive(Debug, Default, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
|
||||
#[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))]
|
||||
#[derive(Default, Copy, Clone, PartialOrd, PartialEq, Ord, Eq, Hash)]
|
||||
pub struct Span {
|
||||
pub start: usize,
|
||||
pub end: usize,
|
||||
|
|
@ -66,6 +66,24 @@ mod span {
|
|||
self.end - self.start
|
||||
}
|
||||
}
|
||||
|
||||
impl Debug for Span {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
f.debug_tuple("Span")
|
||||
.field(&(self.start..self.end))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "_debug")]
|
||||
impl dbg_pls::DebugPls for Span {
|
||||
fn fmt(&self, f: dbg_pls::Formatter<'_>) {
|
||||
f.debug_tuple_struct("Span")
|
||||
// todo: wait for https://github.com/conradludgate/dbg-pls/pull/1
|
||||
.field(&format!("{:?}", (self.start..self.end)))
|
||||
.finish()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
|
|
|
|||
12
src/gc.rs
12
src/gc.rs
|
|
@ -54,7 +54,6 @@ 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(dbg_pls::DebugPls))]
|
||||
pub struct Symbol {
|
||||
gc: Gc<str>,
|
||||
}
|
||||
|
|
@ -74,11 +73,13 @@ pub struct Object {
|
|||
|
||||
#[derive(Debug)]
|
||||
#[repr(C)]
|
||||
#[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))]
|
||||
struct HeapObject {
|
||||
kind: HeapObjectKind,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "_debug", derive(dbg_pls::DebugPls))]
|
||||
enum HeapObjectKind {
|
||||
String(Gc<str>),
|
||||
Object(ObjectMap),
|
||||
|
|
@ -213,6 +214,13 @@ impl Debug for Symbol {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "_debug")]
|
||||
impl dbg_pls::DebugPls for Symbol {
|
||||
fn fmt(&self, f: dbg_pls::Formatter<'_>) {
|
||||
DebugPls::fmt(self.as_str(), f)
|
||||
}
|
||||
}
|
||||
|
||||
impl Deref for Object {
|
||||
type Target = ObjectMap;
|
||||
|
||||
|
|
@ -226,6 +234,6 @@ impl Deref for Object {
|
|||
|
||||
impl Debug for Object {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
self.gc.deref().fmt(f)
|
||||
Debug::fmt(self.gc.deref(), f)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ use std::fmt::Display;
|
|||
|
||||
#[cfg(feature = "_debug")]
|
||||
pub fn dbg(prefix: impl Display, x: impl dbg_pls::DebugPls) {
|
||||
eprintln!("{prefix}{}", dbg_pls::pretty(&x))
|
||||
eprintln!("{prefix}{}", dbg_pls::color(&x))
|
||||
}
|
||||
|
||||
#[cfg(not(feature = "_debug"))]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue