StgExpr AST
Victor Nazarov
asviraspossible at gmail.com
Thu Feb 10 11:28:31 CET 2011
On Thu, Feb 10, 2011 at 1:09 PM, Chris Nicholls
<chrisnicholls1 at gmail.com> wrote:
> Hello,
>
> Is there a way to get access to the STG syntax tree of a program using
> the GHC api? i.e. a function that returns something of type `StgExpr'
> that can be used in a way similar to this:
>
> example module =
> defaultErrorHandler defaultDynFlags $ do
> runGhc (Just libdir) $ do
> dflags <- getSessionDynFlags
> setSessionDynFlags dflags
> target <- guessTarget targetFile Nothing
> setTargets [target]
> load LoadAllTargets
> modSum <- getModSummary $ mkModuleName module
> p <- parseModule modSum
> t <- typecheckModule p
> d <- desugarModule t
> c <- return $ coreModule d
> s <- coreToStg c
> return s
>
I've written Haskell to Javascript translator using GHC API. And I've
ended with the following code to access STG:
https://github.com/sviperll/ghcjs/blob/master/src/Compiler/Main.hs
--
Victor Nazarov
More information about the Glasgow-haskell-users
mailing list