blob: e8737117c4ee764e052e5a4537462869238f28f5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module Env where
import Code (Interp(..), PrlgEnv)
import Control.Monad.Trans.State.Lazy (gets, modify)
import qualified IR
withStrTable :: (IR.StrTable -> (IR.StrTable, a)) -> Env.PrlgEnv a
withStrTable f = do
st <- gets strtable
let (st', x) = f st
modify (\s -> s {strtable = st'})
return x
findStruct :: String -> Int -> Env.PrlgEnv IR.Id
findStruct str arity = do
stri <- findAtom str
return IR.Id {IR.str = stri, IR.arity = arity}
findAtom :: String -> Env.PrlgEnv Int
findAtom = withStrTable . flip IR.strtablize
type PrlgEnv a = Code.PrlgEnv a
|