add stack depth

This commit is contained in:
Rowan Torbitzky-Lane 2025-01-19 00:40:46 -06:00
parent af258b538a
commit 448b71dab1
4 changed files with 12 additions and 0 deletions

View File

@ -32,6 +32,9 @@ instructionExecFlush state = instructionFlush state exec
instructionExecEq :: State -> State
instructionExecEq state = instructionEq state exec
instructionExecStackDepth :: State -> State
instructionExecStackDepth state = instructionStackDepth state exec
instructionExecDoRange :: State -> State
instructionExecDoRange state@(State {_exec = (e1 : es), _int = (i0 : i1 : is)}) =
if increment i0 i1 /= 0

View File

@ -71,3 +71,6 @@ instructionFloatFlush state = instructionFlush state float
instructionFloatEq :: State -> State
instructionFloatEq state = instructionEq state float
instructionFloatStackDepth :: State -> State
instructionFloatStackDepth state = instructionStackDepth state float

View File

@ -63,3 +63,6 @@ instructionEq state accessor =
where
stackTop :: [a]
stackTop = take 2 $ view accessor state
instructionStackDepth :: State -> Lens' State [a] -> State
instructionStackDepth state accessor = state & int .~ (length (view accessor state) : view int state)

View File

@ -76,3 +76,6 @@ instructionIntFlush state = instructionFlush state int
instructionIntEq :: State -> State
instructionIntEq state = instructionEq state int
instructionIntStackDepth :: State -> State
instructionIntStackDepth state = instructionStackDepth state int