Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
curry
curry-frontend
Commits
f77d4cd9
Commit
f77d4cd9
authored
Jun 25, 2013
by
Björn Peemöller
Browse files
Frontend now also writes Curry interfaces
parent
94094d0f
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/Modules.hs
View file @
f77d4cd9
...
...
@@ -91,8 +91,10 @@ writeOutput opts fn (env, modul) = do
let
(
env2
,
il
,
dumps
)
=
transModule
opts
env
modul
-- dump intermediate results
mapM_
(
doDump
opts
)
dumps
-- generate
target cod
e
-- generate
interface fil
e
let
intf
=
exportInterface
env2
modul
writeInterface
opts
fn
intf
-- generate target code
let
modSum
=
summarizeModule
(
tyConsEnv
env2
)
intf
modul
writeFlat
opts
fn
env2
modSum
il
where
...
...
@@ -238,13 +240,29 @@ writeParsed opts fn modul = when srcTarget $
targetFile
=
fromMaybe
(
sourceRepName
fn
)
(
optOutput
opts
)
source
=
CS
.
showModule
modul
writeInterface
::
Options
->
FilePath
->
CS
.
Interface
->
IO
()
writeInterface
opts
fn
intf
|
not
(
optInterface
opts
)
=
return
()
-- TODO: reasonable?
|
optForce
opts
=
outputInterface
|
otherwise
=
do
mbOldIntf
<-
readModule
interfaceFile
case
mbOldIntf
of
Nothing
->
outputInterface
Just
src
->
case
runMsg
(
CS
.
parseInterface
interfaceFile
src
)
of
Left
_
->
outputInterface
Right
(
i
,
_
)
->
unless
(
i
==
intf
)
outputInterface
where
interfaceFile
=
interfName
fn
outputInterface
=
writeModule
(
optUseSubdir
opts
)
interfaceFile
(
show
$
CS
.
ppInterface
intf
)
writeFlat
::
Options
->
FilePath
->
CompilerEnv
->
ModuleSummary
->
IL
.
Module
->
IO
()
writeFlat
opts
fn
env
modSum
il
=
do
when
(
extTarget
||
fcyTarget
)
$
do
writeFlatCurry
opts
fn
env
modSum
il
write
Interface
opts
fn
env
modSum
il
when
(
xmlTarget
)
$
write
XML
opts
fn
modSum
il
write
FlatIntf
opts
fn
env
modSum
il
when
(
xmlTarget
)
$
write
FlatXml
opts
fn
modSum
il
where
extTarget
=
ExtendedFlatCurry
`
elem
`
optTargetTypes
opts
fcyTarget
=
FlatCurry
`
elem
`
optTargetTypes
opts
...
...
@@ -264,15 +282,15 @@ writeFlatCurry opts fn env modSum il = do
(
prog
,
msgs
)
=
genFlatCurry
opts
modSum
env
il
-- |Export an 'IL.Module' into an XML file
write
XML
::
Options
->
FilePath
->
ModuleSummary
->
IL
.
Module
->
IO
()
write
XML
opts
fn
modSum
il
=
writeModule
useSubDir
(
xmlName
fn
)
curryXml
write
FlatXml
::
Options
->
FilePath
->
ModuleSummary
->
IL
.
Module
->
IO
()
write
FlatXml
opts
fn
modSum
il
=
writeModule
useSubDir
(
xmlName
fn
)
curryXml
where
useSubDir
=
optUseSubdir
opts
curryXml
=
shows
(
IL
.
xmlModule
(
interface
modSum
)
(
infixDecls
modSum
)
il
)
"
\n
"
write
Interface
::
Options
->
FilePath
->
CompilerEnv
->
ModuleSummary
->
IL
.
Module
->
IO
()
write
Interface
opts
fn
env
modSum
il
write
FlatIntf
::
Options
->
FilePath
->
CompilerEnv
->
ModuleSummary
->
IL
.
Module
->
IO
()
write
FlatIntf
opts
fn
env
modSum
il
|
not
(
optInterface
opts
)
=
return
()
|
optForce
opts
=
outputInterface
|
otherwise
=
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment