1ffc525d23a7 — Leonard Ritter 18 days ago
* cosmetic source fixes
1 files changed, 43 insertions(+), 40 deletions(-)

M testing/test_node4.sc
M testing/test_node4.sc +43 -40
@@ 237,51 237,54 @@ struct Module
         swap (view oldref) self.ref
 
         let p ref = self.p self.ref
-        fold (rc startpos = 0 (nullof WordType)) for wordword in (range bitwordcount)
+        fold (rc startpos = 0 (nullof WordType))
+            \ for wordword in (range bitwordcount)
             lw := (copy (usedl @ wordword))
             rw := (copy (usedr @ wordword))
-            fold (rc startpos = rc startpos) for bit in (itermaskbits (| lw rw))
+            fold (rc startpos = rc startpos)
+                \ for bit in (itermaskbits (| lw rw))
                 let started? = ((lw & bit) != 0)
                 let stopped? = ((rw & bit) != 0)
                 rc := rc + (? started? 1 0)
-                let startpos =
-                    if (rc == 1)
-                        let startpos =
-                            if started?
-                                let id = (bitpos2id wordword (findlsb bit))
-                                report "start" id
-                                id as integer
-                            else startpos
-                        if stopped?
-                            let endpos = (bitpos2id wordword (findlsb bit))
-                            report "end" endpos
-                            endpos := endpos as integer + 1
-                            # copy over region
-                            size := endpos - startpos
-                            let regval = ('alloc self size)
-                            let offset = (unpack regval)
-                            for i in (range size)
-                                srcoffset := (startpos + i)
-                                dstoffset := (offset + i)
-                                srcval := oldp @ srcoffset
-                                destval := p @ dstoffset
-                                let bitwordofs bitofs = (id2bitpos srcoffset)
-                                let value = (copy srcval)
-                                # write new address to previous location
-                                srcval = dstoffset
-                                if ((oldref @ bitwordofs) & ((1 as BitWordType) << bitofs))
-                                    let oldofs oldsz = (decaddr value)
-                                    let newofs = (copy (oldp @ oldofs))
-                                    # new offset should be aligned
-                                    assert ((newofs & (oldsz - 1)) == 0)
-                                    destval = (encaddr newofs oldsz)
-                                    bitwordofs := (dstoffset // BitWordWidth)
-                                    bitofs := dstoffset & (BitWordWidth - 1)
-                                    ref @ bitwordofs |= (1 as BitWordType) << bitofs
-                                else
-                                    destval = value
-                        startpos
-                    else startpos
+                vvv bind startpos
+                if (rc == 1)
+                    let startpos =
+                        if started?
+                            let id = (bitpos2id wordword (findlsb bit))
+                            report "start" id
+                            id as integer
+                        else startpos
+                    if stopped?
+                        let endpos = (bitpos2id wordword (findlsb bit))
+                        report "end" endpos
+                        endpos := endpos as integer + 1
+                        # copy over region
+                        size := endpos - startpos
+                        let regval = ('alloc self size)
+                        let offset = (unpack regval)
+                        for i in (range size)
+                            srcoffset := (startpos + i)
+                            dstoffset := (offset + i)
+                            srcval := oldp @ srcoffset
+                            destval := p @ dstoffset
+                            let bitwordofs bitofs = (id2bitpos srcoffset)
+                            let value = (copy srcval)
+                            # write new address to previous location
+                            srcval = dstoffset
+                            if ((oldref @ bitwordofs)
+                                & ((1 as BitWordType) << bitofs))
+                                let oldofs oldsz = (decaddr value)
+                                let newofs = (copy (oldp @ oldofs))
+                                # new offset should be aligned
+                                assert ((newofs & (oldsz - 1)) == 0)
+                                destval = (encaddr newofs oldsz)
+                                bitwordofs := (dstoffset // BitWordWidth)
+                                bitofs := dstoffset & (BitWordWidth - 1)
+                                ref @ bitwordofs |= (1 as BitWordType) << bitofs
+                            else
+                                destval = value
+                    startpos
+                else startpos
                 _ (rc + (? stopped? -1 0)) startpos
         let newofs = (copy (oldp @ offset))
         assert ((newofs & (size - 1)) == 0)