Tim Chevalier wrote:
On 6/28/07, Simon Marlow <[EMAIL PROTECTED]> wrote:
The right sequence would be
(a) setTarget to the desired filename
(b) depanal
(c) find the module name by searching in the ModGraph
(d) checkModule
and checkModule should optionally return the Core too.
Unfortunately, checkModule currently also does a depanal (it
shouldn't, I'll
remove it). Also checkModule doesn't return the Core (it should).
I've made these changes and checked in the code. This simplifies the
procedure for calling compileToCore even further:
----------
ghcBaseDir = -- whatever
coreFileName = -- whatever
main = defaultErrorHandler defaultDynFlags $ do
-- Set up flags...
s <- newSession (Just ghcBaseDir)
flags1 <- getSessionDynFlags s
(flags2, _) <- parseDynamicFlags flags1 ["-cpp"]
setSessionDynFlags s flags2
-- Compile to Core
ghc_core <- compileToCore s coreFileName
case ghc_core of
Just cb -> pprTrace "Core binds: " (ppr cb)
return ()
_ -> putStrLn "error compiling to Core"
----------
The call to setTarget is eliminated (compileToCore does that now.)
Ok, I'm not sure that the layering is quite right here - it doesn't seem right
for compileToCore to set the targets. compileToCore should really be a
higher-level API, built in terms of the GHC API.
Still, I don't suggest changing it until we've looked at #1467
http://hackage.haskell.org/trac/ghc/ticket/1467
Cheers,
Simon
_______________________________________________
Cvs-ghc mailing list
[email protected]
http://www.haskell.org/mailman/listinfo/cvs-ghc