|
definition: |
readERDFromProgram :: String -> IO ERD
readERDFromProgram progfile = do
putStr $ "Processing ERD in program `" ++ progfile ++ "'..."
let progname = stripCurrySuffix progfile
prog <- runModuleActionQuiet readFlatCurry progname
let funcs = progFuncs prog
erdfuncs = filter hasERDType funcs
case erdfuncs of
[] -> error $ "No definition of ER model found in program " ++ progfile
[fd] -> do currypath <- getEnv "CURRYPATH"
pid <- getPID
let tmpfile = "/tmp/ERD2CURRY_tmp_" ++ show pid
let cmd = installDir </> "bin" </> "curry"
args = [ "--nocypm"
, ":set","v0" ]
input = unlines $
(if null currypath
then []
else [":set path " ++ currypath] ) ++
[ ":load " ++ progname
, ":add " ++ "Database.ERD"
, ":eval writeFileWithERDTerm " ++
show tmpfile ++ snd (funcName fd)
, ":quit"]
(ecode,_,errstr) <- evalCmd cmd args input
putStrLn "done"
if ecode > 0
then error $ "ERROR in program defining ERD:\n" ++ errstr
else do erdtermfile <- readCompleteFile tmpfile
removeFile tmpfile
return (read erdtermfile)
_ -> error $ "Multiple ER model definitions found in program " ++ progfile
|
|
demand: |
no demanded arguments |
|
deterministic: |
deterministic operation |
|
documentation: |
Reads the ERD defined in a Curry program (as a top-level operation of type `Database.ERD.ERD`). This is done by compiling the Curry program with an auxiliary operation and processing the output of the program. |
|
failfree: |
<FAILING> |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_) |-> _}
|
|
name: |
readERDFromProgram |
|
precedence: |
no precedence defined |
|
result-values: |
_ |
|
signature: |
String -> Prelude.IO Database.ERD.ERD |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |