case exprs!
This commit is contained in:
@@ -406,7 +406,7 @@ Core Transition Rules
|
|||||||
|
|
||||||
.. math::
|
.. math::
|
||||||
\gmrule
|
\gmrule
|
||||||
{ \mathtt{CaseJump} \begin{bmatrix} t \to c \end{bmatrix} : i
|
{ \mathtt{CaseJump} \begin{bmatrix} t : c \end{bmatrix} : i
|
||||||
& a : s
|
& a : s
|
||||||
& d
|
& d
|
||||||
& h
|
& h
|
||||||
|
|||||||
16
src/GM.hs
16
src/GM.hs
@@ -144,8 +144,6 @@ isFinal st = null $ st ^. gmCode
|
|||||||
|
|
||||||
step :: GmState -> GmState
|
step :: GmState -> GmState
|
||||||
step st = case head (st ^. gmCode) of
|
step st = case head (st ^. gmCode) of
|
||||||
-- TODO: clean this up. let transition functions use the 'state' parameter
|
|
||||||
-- instead of passing it to them.
|
|
||||||
Unwind -> unwindI
|
Unwind -> unwindI
|
||||||
PushGlobal n -> pushGlobalI n
|
PushGlobal n -> pushGlobalI n
|
||||||
PushConstr t n -> pushConstrI t n
|
PushConstr t n -> pushConstrI t n
|
||||||
@@ -164,8 +162,22 @@ step st = case head (st ^. gmCode) of
|
|||||||
Div -> divI
|
Div -> divI
|
||||||
Split n -> splitI n
|
Split n -> splitI n
|
||||||
Pack t n -> packI t n
|
Pack t n -> packI t n
|
||||||
|
CaseJump as -> caseJumpI as
|
||||||
where
|
where
|
||||||
|
|
||||||
|
caseJumpI :: [(Tag, Code)] -> GmState
|
||||||
|
caseJumpI as = st
|
||||||
|
& advanceCode
|
||||||
|
& gmCode %~ (i'++)
|
||||||
|
where
|
||||||
|
h = st ^. gmHeap
|
||||||
|
s = st ^. gmStack
|
||||||
|
NConstr t ss = head s
|
||||||
|
& hViewUnsafe h
|
||||||
|
i' = fromMaybe
|
||||||
|
(error $ "unmatched tag: " <> show t)
|
||||||
|
(lookup t as)
|
||||||
|
|
||||||
packI :: Tag -> Int -> GmState
|
packI :: Tag -> Int -> GmState
|
||||||
packI t n = st
|
packI t n = st
|
||||||
& advanceCode
|
& advanceCode
|
||||||
|
|||||||
Reference in New Issue
Block a user