Commit 07737569 authored by Finn Teegen's avatar Finn Teegen
Browse files

Refactor some code

parent 60f13520
......@@ -346,22 +346,22 @@ matchInterface ifn i = do
writeFlat :: Options -> CompilerEnv -> CS.Module Type -> IL.Module -> CYIO ()
writeFlat opts env mdl il = do
(_, afcy) <- dumpWith opts show (pPrint . genFlatCurry) DumpTypedFlatCurry (env, afcyProg)
dumpWith opts show (pPrint . genFlatCurry) DumpTypedFlatCurry (env, afcy)
when afcyTarget $ liftIO $ FC.writeFlatCurry (useSubDir afcyName) afcy
when tfcyTarget $ liftIO $ FC.writeFlatCurry (useSubDir tfcyName) tfcyProg
when tfcyTarget $ liftIO $ FC.writeFlatCurry (useSubDir tfcyName) tfcy
when fcyTarget $ do
(_, fcy) <- dumpWith opts show pPrint DumpFlatCurry (env, fcyProg)
dumpWith opts show pPrint DumpFlatCurry (env, fcy)
liftIO $ FC.writeFlatCurry (useSubDir fcyName) fcy
writeFlatIntf opts env fcyProg
writeFlatIntf opts env fcy
where
afcy = genAnnotatedFlatCurry env mdl il
afcyName = annotatedFlatName (filePath env)
afcyProg = genAnnotatedFlatCurry env mdl il
afcyTarget = AnnotatedFlatCurry `elem` optTargetTypes opts
tfcy = genTypedFlatCurry afcy
tfcyName = typedFlatName (filePath env)
tfcyProg = genTypedFlatCurry afcyProg
tfcyTarget = TypedFlatCurry `elem` optTargetTypes opts
fcy = genFlatCurry afcy
fcyName = flatName (filePath env)
fcyProg = genFlatCurry afcyProg
fcyTarget = FlatCurry `elem` optTargetTypes opts
useSubDir = addOutDirModule (optUseOutDir opts) (optOutDir opts) (moduleIdent env)
......
......@@ -422,7 +422,7 @@ trExpr _ env (Variable _ ty v)
| otherwise = do
tcEnv <- getTCEnv
case Map.lookup (unqualify v) env of
Nothing -> fun tcEnv
Nothing -> error $ "unexpected variable" ++ show v --TODO: Replace case by fromJust?
Just v' -> return $ IL.Variable (transType tcEnv ty) v' -- apply renaming
where
fun tcEnv = IL.Function (transType tcEnv ty) v <$> getArity v
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment