On Thu, Feb 10, 2011 at 1:09 PM, Chris Nicholls <chrisnichol...@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 _______________________________________________ Glasgow-haskell-users mailing list Glasgow-haskell-users@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-users