Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- preDeclFunctions :: forall (m :: * -> *) => [TopDef] -> TypeEnv -> m TypeEnv
- preDeclFunctions [] env = return env
- preDeclFunctions (FnDef t (Ident f) args block:funcs) env = do
- let mt = M.lookup f env
- if isNothing mt
- then preDeclFunctions funcs (M.insert f (typeFromArgs args (transType t)) env)
- else trace ("error in preDeclFunctions") $ throwError defaultErr
- typeFromArgs :: [Arg] -> Types -> Types
- typeFromArgs [] t = t
- typeFromArgs (ArgByVal a _:args) t = transType a :->: typeFromArgs args t
- typeFromArgs (ArgByVar a _:args) t = transType a :->: typeFromArgs args t
- checkTopDef :: TopDef -> S ()
- checkTopDef (FnDef t (Ident f) args block) = do
- env <- ask
- let mt = M.lookup f env
- if isNothing mt
- then trace ("error in checkTopDef") $ throwError defaultErr
- else local (M.insert "" (transType t)) funcWithDecls
- where
- funcWithDecls = checkBlock (concatBlocks (declFromArgs args) block)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement