Created
October 5, 2017 11:50
-
-
Save martijnbastiaan/ed90bca69f3f43544886c966955cf93d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
case HashMap.lookup (nameOcc fun) normalized of | |
Just _ -> do | |
(_,Component compName compInps [snd -> compOutp] _) <- preserveVarEnv $ genComponent (nameOcc fun) | |
if length args == length compInps | |
then do argTys <- mapM (termType tcm) args | |
let dstId = Text.pack . name2String $ varName dst | |
(argExprs,argDecls) <- fmap (second concat . unzip) $! mapM (\(e,t) -> mkExpr False (Left dstId) t e) (zip args argTys) | |
(argExprs',argDecls') <- (second concat . unzip) <$> mapM (toSimpleVar dst) (zip argExprs argTys) | |
let inpAssigns = zipWith (\(i,t) e -> (Identifier i Nothing,In,t,e)) compInps argExprs' | |
outpAssign = (Identifier (fst compOutp) Nothing,Out,snd compOutp,Identifier dstId Nothing) | |
instLabel <- extendIdentifier Basic compName (Text.pack "_" `Text.append` dstId) | |
let instDecl = InstDecl compName instLabel (outpAssign:inpAssigns) | |
return (argDecls ++ argDecls' ++ [instDecl]) | |
else error $ $(curLoc) ++ "under-applied normalized function" | |
Nothing -> case args of | |
[] -> do | |
let dstId = Text.pack . name2String $ varName dst | |
return [Assignment dstId (Identifier (Text.pack $ name2String fun) Nothing)] | |
_ -> error $ $(curLoc) ++ "Unknown function: " ++ showDoc fun |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment