30 lines
537 B
Haskell
30 lines
537 B
Haskell
module Gyehoek.Stack.Lower
|
|
( lowerProgram
|
|
) where
|
|
|
|
import Gyehoek.Stack.Syntax
|
|
import Gyehoek.Wasm qualified as Wasm
|
|
import Gyehoek.Prelude
|
|
import Gyehoek.Wasm (wat, watM)
|
|
|
|
|
|
lowerRoutine :: Routine -> Wasm.Function
|
|
lowerRoutine rt = _
|
|
|
|
lowerBlock :: Block -> Wasm.Expr
|
|
lowerBlock = _
|
|
|
|
lowerInstr :: Instr -> Wasm.Expr
|
|
lowerInstr = \case
|
|
PopCont ktail -> [wat|
|
|
|
|
|]
|
|
|
|
lowerProgram :: Program -> Eff es Wasm.Module
|
|
lowerProgram p = pure [watM|
|
|
(module
|
|
##{rs})
|
|
|]
|
|
where
|
|
rs = p ^.. #routines . each . to lowerRoutine
|