From 6c344d2862261a25509499fce51201af791bb2aa Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Fri, 20 Nov 2020 23:04:58 +0000 Subject: [PATCH] fix zcoord debug Signed-off-by: Ian Jackson --- templates/script.ts | 2 +- wasm/wasm.rs | 3 +++ zcoord/zcoord.rs | 10 ++++++++-- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/templates/script.ts b/templates/script.ts index 5d672a77..8c58edba 100644 --- a/templates/script.ts +++ b/templates/script.ts @@ -533,7 +533,7 @@ function lower_pieces(targets_todo: LowerTodoList): let z_bot = pe.z_bot; let zrange = wasm_bindgen.range(z_bot, z_top, pe.content.length); console.log('LOQER PLAN PE', - pe, z_bot, z_top, pe.content.length, zrange); + pe, z_bot, z_top, pe.content.length, zrange.debug()); for (const e of pe.content) { let z = zrange.next(); api_piece(api, "setz", e.piece, e.p, { z }); diff --git a/wasm/wasm.rs b/wasm/wasm.rs index 0872d41b..5e7d6341 100644 --- a/wasm/wasm.rs +++ b/wasm/wasm.rs @@ -84,6 +84,9 @@ impl ZCoordIterator { }; packed.to_string().into() } + pub fn debug(&self) -> JsValue { + format!("ZCoordIterator({:?})", &self.0).into() + } } #[wasm_bindgen] diff --git a/zcoord/zcoord.rs b/zcoord/zcoord.rs index 7ec1e797..03ca0e1e 100644 --- a/zcoord/zcoord.rs +++ b/zcoord/zcoord.rs @@ -168,6 +168,7 @@ pub trait AddSubOffset { pub struct Sealed(()); +#[derive(Debug)] pub struct Increment; impl AddSubOffset for Increment { fn init_delta(&self) -> LimbVal { DELTA } @@ -179,6 +180,7 @@ impl AddSubOffset for Increment { const SEALED_TRAIT : Sealed = Sealed(()); } +#[derive(Debug)] pub struct Decrement; impl AddSubOffset for Decrement { fn init_delta(&self) -> LimbVal { -DELTA } @@ -259,11 +261,13 @@ impl Mutable { pub type RangeIterator = std::iter::Take>; +#[derive(Debug)] pub struct IteratorCore { current: Mutable, aso: ASO, } +#[derive(Debug)] pub struct AddSubRangeDelta { i: usize, step: LimbVal, @@ -365,7 +369,9 @@ impl ExactSizeIterator for IteratorCore { fn len(&self) -> usize { return usize::MAX } } -pub type BoxedIterator = Box>; +pub trait BoxedIteratorTrait : Iterator + Debug { } +pub type BoxedIterator = Box; +impl BoxedIteratorTrait for T where T : Iterator + Debug { } impl Mutable { pub fn iter(self, aso: ASO) -> IteratorCore { @@ -374,7 +380,7 @@ impl Mutable { #[throws(LogicError)] pub fn some_range(a: Option<&Mutable>, b: Option<&Mutable>, count: RangeCount) -> BoxedIterator { - fn mk>(x: T) -> BoxedIterator + fn mk>(x: T) -> BoxedIterator { Box::new(x) } match (a, b) { (None, None ) => throw!(TotallyUnboundedRange), -- 2.30.2