Diffstat (limited to 'src/build/builders/debug.rs')
| -rw-r--r-- | src/build/builders/debug.rs | 86 |
1 files changed, 59 insertions, 27 deletions
diff --git a/src/build/builders/debug.rs b/src/build/builders/debug.rs index 4a51281..cd144d8 100644 --- a/src/build/builders/debug.rs +++ b/src/build/builders/debug.rs @@ -10,8 +10,8 @@ use crate::{ visitor::{ request_hint::{DynRequestHint, RequestHint}, sequence::{DynSequence, Sequence}, - tag::{Dyn, DynTag, Tag, DynFlow}, - value::{DynValue, Value}, + tag::{DynTag, Tag, TagDyn}, + value::{DynValue, Value}, Status, }, }, DynWalker, Flow, @@ -22,7 +22,8 @@ pub struct Visitor<E>(usize, PhantomData<fn() -> E>); any_trait! { impl['a, 'ctx, E] Visitor<E> = [ DynRequestHint<'a, 'ctx, E>, - DynTag<'a, 'ctx, Dyn, E>, + // DynRecoverable<'a, 'ctx, E>, + DynTag<'a, 'ctx, TagDyn, E>, DynValue<'a, 'ctx, OwnedStatic<&'static str>, E>, DynValue<'a, 'ctx, OwnedStatic<TypeId>, E>, DynValue<'a, 'ctx, OwnedStatic<usize>, E>, @@ -42,8 +43,11 @@ impl<'ctx, E: Effect<'ctx>> Visitor<E> { } fn tab(&self) { - for _ in 0..self.0 { - print!(" "); + if self.0 > 0 { + for _ in 0..self.0 - 1 { + print!(" | "); + } + print!(" |-"); } } } @@ -53,27 +57,53 @@ impl<'ctx, E: Effect<'ctx>> RequestHint<'ctx, E> for Visitor<E> { &'a mut self, _walker: crate::protocol::Walker<'a, 'ctx>, ) -> Future<'a, 'ctx, Flow, E> { - self.tab(); - println!("Visit request hint (no hint given)"); + // self.tab(); + // println!("Visit request hint (no hint given)"); + // println!("Visit request hint (hint for recoverable)"); E::ready(Flow::Continue) } } -impl<'ctx, E: Effect<'ctx>> Tag<'ctx, Dyn, E> for Visitor<E> { +impl<'ctx, E: Effect<'ctx>> Tag<'ctx, TagDyn, E> for Visitor<E> { fn visit<'a>( &'a mut self, - kind: Dyn, + kind: TagDyn, walker: DynWalker<'a, 'ctx, E>, - ) -> Future<'a, 'ctx, DynFlow, E> { - self.tab(); - println!("Visit tag: {}", kind.0); - - E::wrap(async { - self.0 += 1; - let result = walker.walk(self).await; - self.0 -= 1; - // DynFlow::Flow(result) - DynFlow::Skipped + ) -> Future<'a, 'ctx, Status, E> { + E::wrap(async move { + match kind.0 { + crate::TAG_TYPE_NAME => { + self.tab(); + println!("type name:"); + + self.0 += 1; + walker.walk(self).await; + self.0 -= 1; + + Status::r#continue() + }, + crate::TAG_KEY => { + self.tab(); + println!("key:"); + + self.0 += 1; + walker.walk(self).await; + self.0 -= 1; + + Status::r#continue() + }, + crate::TAG_VALUE => { + self.tab(); + println!("value:"); + + self.0 += 1; + walker.walk(self).await; + self.0 -= 1; + + Status::r#continue() + }, + _ => Status::skipped() + } }) } } @@ -87,7 +117,7 @@ impl<'a, 'ctx: 'a, E: Effect<'ctx>> Value<'a, 'ctx, OwnedStatic<&'static str>, E Self: 'a, { self.tab(); - println!("Visit static str: {:?}", value); + println!("{:?}", value); E::ready(Flow::Continue) } } @@ -98,7 +128,7 @@ impl<'a, 'ctx: 'a, E: Effect<'ctx>> Value<'a, 'ctx, OwnedStatic<usize>, E> for V Self: 'a, { self.tab(); - println!("Visit usize: {}", value); + println!("{}", value); E::ready(Flow::Continue) } } @@ -109,7 +139,7 @@ impl<'a, 'ctx: 'a, E: Effect<'ctx>> Value<'a, 'ctx, OwnedStatic<bool>, E> for Vi Self: 'a, { self.tab(); - println!("Visit bool: {}", value); + println!("{}", value); E::ready(Flow::Continue) } } @@ -125,7 +155,7 @@ impl<'a, 'ctx: 'a, E: Effect<'ctx>> Value<'a, 'ctx, OwnedStatic<&'static [&'stat Self: 'a, { self.tab(); - println!("Visit static slice of static str: {:?}", value); + println!("{:?}", value); E::ready(Flow::Continue) } } @@ -146,20 +176,22 @@ impl<'ctx, E: Effect<'ctx>> Sequence<'ctx, E> for Visitor<E> { &'a mut self, scope: protocol::visitor::sequence::DynSequenceScope<'a, 'ctx, E>, ) -> Future<'a, 'ctx, Flow, E> { - self.tab(); E::wrap(async { - println!("Visit sequence, size hint: {:?}", scope.size_hint().await); + self.tab(); + println!("sequence{:?}", scope.size_hint().await); + self.0 += 1; let mut index = 0; let flow = loop { self.tab(); - println!("Calling next: {}", index); + println!("{}:", index); + self.0 += 1; match scope.next(self).await { Flow::Done => { self.tab(); - println!("Sequence done"); + println!("<end>"); break Flow::Continue; } Flow::Continue => {} |