refactor a bit

This commit is contained in:
Yehowshua Immanuel 2025-03-20 13:27:01 -04:00
parent 5f2d9456ae
commit 7ad812d3da

View file

@ -1,4 +1,6 @@
package TagEngine(TagEngine(..), mkTagEngine) where
package TagEngine(
TagEngine(..),
mkTagEngine) where
import Vector
import Util
@ -31,14 +33,14 @@ initTagTail = do
initTagVec :: Module(Vector numTags (Reg (Tag numTags)))
initTagVec =
do
tagVecSequential :: Vector numTags (Reg (Tag numTags))
tagVecSequential <- mapM (\idx -> initTagNext (idx+1)) genVector
let idxLast :: Integer = (fromInteger |> valueOf numTags) - 1
tailTag <- initTagTail
-- the tail of our TagVec should be `Tail` not `Next`
let finalTagVec = update tagVecSequential idxLast tailTag
return finalTagVec
let
lastIdx :: Integer = (fromInteger |> valueOf numTags) - 1
initByIdx currIdx =
if (currIdx < lastIdx)
then initTagNext (currIdx + 1)
else initTagTail
in
mapM initByIdx genVector
mkTagEngine :: Module (TagEngine numTags)
mkTagEngine =
@ -46,8 +48,6 @@ mkTagEngine =
tagVec :: Vector numTags (Reg (Tag numTags))
tagVec <- initTagVec
fileHandle :: Handle <- openFile "compile.log" WriteMode
debugOnce <- mkReg True
addRules $