chiark / gitweb /
fix zcoord debug
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Nov 2020 23:04:58 +0000 (23:04 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Fri, 20 Nov 2020 23:04:58 +0000 (23:04 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
templates/script.ts
wasm/wasm.rs
zcoord/zcoord.rs

index 5d672a77a569efaa198a0d0eb5c4aa4e9d8a36c8..8c58edbabd177438cd060d1fe76b66f563bd273a 100644 (file)
@@ -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 });
index 0872d41b5d1731fc3be3675dbdcb6ba636e5db89..5e7d634177f38398a1d4a8506afe39b4f291208f 100644 (file)
@@ -84,6 +84,9 @@ impl ZCoordIterator {
     };
     packed.to_string().into()
   }
+  pub fn debug(&self) -> JsValue {
+    format!("ZCoordIterator({:?})", &self.0).into()
+  }
 }
 
 #[wasm_bindgen]
index 7ec1e7979a2b44373634a81b16f7ae3f4482c1bd..03ca0e1e4dade9de24bd7eeac3392811fbb4c839 100644 (file)
@@ -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<IteratorCore<AddSubRangeDelta>>;
 
+#[derive(Debug)]
 pub struct IteratorCore<ASO> {
   current: Mutable,
   aso: ASO,
 }
 
+#[derive(Debug)]
 pub struct AddSubRangeDelta {
   i: usize,
   step: LimbVal,
@@ -365,7 +369,9 @@ impl ExactSizeIterator for IteratorCore<AddSubRangeDelta> {
   fn len(&self) -> usize { return usize::MAX }
 }
 
-pub type BoxedIterator = Box<dyn Iterator<Item=ZCoord>>;
+pub trait BoxedIteratorTrait : Iterator<Item=ZCoord> + Debug { }
+pub type BoxedIterator = Box<dyn BoxedIteratorTrait>;
+impl<T> BoxedIteratorTrait for T where T : Iterator<Item=ZCoord> + Debug { }
 
 impl Mutable {
   pub fn iter<ASO:AddSubOffset>(self, aso: ASO) -> IteratorCore<ASO> {
@@ -374,7 +380,7 @@ impl Mutable {
   #[throws(LogicError)]
   pub fn some_range(a: Option<&Mutable>, b: Option<&Mutable>,
                     count: RangeCount) -> BoxedIterator {
-    fn mk<T:'static + Iterator<Item=ZCoord>>(x: T) -> BoxedIterator
+    fn mk<T:'static + Debug + Iterator<Item=ZCoord>>(x: T) -> BoxedIterator
         { Box::new(x) }
     match (a, b) {
       (None,    None   ) => throw!(TotallyUnboundedRange),