1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
------------------------------------------------------------------------------
--- Auxiliary operations to compile additionally imported modules
--- with the front end.

module CPP.CompileWithFrontend
 where

import Distribution ( curryCompiler )

import System.FrontendExec

------------------------------------------------------------------------------
--- If a module is added as a new import to the transformed program,
--- we have to compile it in order to avoid a compilation error
--- of the front end, since the front end assumes,
-- if the preprocessor is called, that all imported modules are
-- already compiled.
compileImportedModule :: Int -> String -> IO ()
compileImportedModule verb modname = do
  mapM (compileModuleTo verb modname) [ACY, UACY]
  compileSetFunctions2Flat
 where
  compileSetFunctions2Flat
    | curryCompiler == "kics2"
    = compileModuleTo verb modname TFCY
    | curryCompiler == "pakcs"
    = compileModuleTo verb modname FCY
    | otherwise
    = error $ "compileSetFunctions: unknown Curry compiler '" ++
              curryCompiler ++ "'!"

compileModuleTo :: Int -> String -> FrontendTarget -> IO ()
compileModuleTo verb modname target = do
  when (verb > 2) $ putStrLn $
    "Compiling '" ++ modname ++ "' to '" ++ showFrontendTarget target ++ "'..."
  callFrontendWithParams target (setQuiet True defaultParams) modname

------------------------------------------------------------------------------