hscCompileCoreExpr' :: HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue
hscCompileCoreExpr' hsc_env _srcspan ds_expr
    = do { let dflags = hsc_dflags hsc_env

           {- Simplify it -}
         ; simpl_expr <- simplifyExpr dflags ds_expr

           {- Tidy it (temporary, until coreSat does cloning) -}
         ; let tidy_expr = tidyExpr emptyTidyEnv simpl_expr

           {- Prepare for codegen -}
         ; prepd_expr <- corePrepExpr dflags hsc_env tidy_expr

           {- Lint if necessary -}
         ; lintInteractiveExpr "hscCompileExpr" hsc_env prepd_expr

         ; exprNo <- icExprCounterInc (hsc_IC hsc_env)

         -----------------  Convert to STG ------------------
         ; let exprFS = fsLit "$expr"
               this_mod0 = icInteractiveModule (hsc_IC hsc_env)
               this_mod =
                   this_mod0 { moduleName =
                               mkModuleName $ moduleNameString (moduleName this_mod0)
                                           ++ "_" ++ show exprNo }

               exprName = mkExternalName (getUnique exprFS)
                            this_mod (mkVarOccFS exprFS)
                            noSrcSpan
               -- Create an id to keep the codegen happy
               exprId = mkVanillaGlobal exprName
                          (exprType prepd_expr)
               prepd_binds = [NonRec exprId prepd_expr]
               -- Stub location to keep the codegen happy
               mod_location =
                 ModLocation { ml_hs_file = Just "Interactive.hs"
                             , ml_hi_file = "Interactive.hi"
                             , ml_obj_file = "Interactive.jar" }

         ; (stg_binds, _cost_centre_info)
             <- {-# SCC "CoreToStg" #-}
                myCoreToStg dflags this_mod prepd_binds

           {- link it -}
         ; modClasses <- codeGen hsc_env this_mod mod_location
                           [] stg_binds (panic "hpcInfo") Nothing

         ; hval <- linkExpr hsc_env (T.unpack $ moduleJavaClass this_mod)
                                    (T.unpack $ idNameText dflags exprId) modClasses

         ; return hval }
hscCompileCoreExpr' :: HscEnv -> SrcSpan -> CoreExpr -> IO ForeignHValue
hscCompileCoreExpr' hsc_env _srcspan ds_expr
    = do { let dflags = hsc_dflags hsc_env

           {- Simplify it -}
         ; simpl_expr <- simplifyExpr dflags ds_expr

           {- Tidy it (temporary, until coreSat does cloning) -}
         ; let tidy_expr = tidyExpr emptyTidyEnv simpl_expr

           {- Prepare for codegen -}
         ; prepd_expr <- corePrepExpr dflags hsc_env tidy_expr

           {- Lint if necessary -}
         ; lintInteractiveExpr "hscCompileExpr" hsc_env prepd_expr

         ; exprNo <- icExprCounterInc (hsc_IC hsc_env)

         -----------------  Convert to STG ------------------
         ; let exprFS = fsLit "$expr"
               this_mod0 = icInteractiveModule (hsc_IC hsc_env)
               this_mod =
                   this_mod0 { moduleName =
                               mkModuleName $ moduleNameString (moduleName this_mod0)
                                           ++ "_" ++ show exprNo }

               exprName = mkExternalName (getUnique exprFS)
                            this_mod (mkVarOccFS exprFS)
                            noSrcSpan
               -- Create an id to keep the codegen happy
               exprId = mkVanillaGlobal exprName
                          (exprType prepd_expr)
               prepd_binds = [NonRec exprId prepd_expr]
               -- Stub location to keep the codegen happy
               mod_location =
                 ModLocation { ml_hs_file = Just "Interactive.hs"
                             , ml_hi_file = "Interactive.hi"
                             , ml_obj_file = "Interactive.jar" }

         ; (stg_binds, _cost_centre_info)
             <- {-# SCC "CoreToStg" #-}
                myCoreToStg dflags this_mod prepd_binds

           {- link it -}
         ; modClasses <- codeGen hsc_env this_mod mod_location
                           [] stg_binds (panic "hpcInfo") Nothing

         ; hval <- linkExpr hsc_env (T.unpack $ moduleJavaClass this_mod)
                                    (T.unpack $ idNameText dflags exprId) modClasses

         ; return hval }
hscCompileCoreExpr' hsc_env _srcspan ds_expr
    = do { let dflags = hsc_dflags hsc_env

           {- Simplify it -}
         ; simpl_expr <- simplifyExpr dflags ds_expr

           {- Tidy it (temporary, until coreSat does cloning) -}
         ; let tidy_expr = tidyExpr emptyTidyEnv simpl_expr

           {- Prepare for codegen -}
         ; prepd_expr <- corePrepExpr dflags hsc_env tidy_expr

           {- Lint if necessary -}
         ; lintInteractiveExpr "hscCompileExpr" hsc_env prepd_expr

         ; exprNo <- icExprCounterInc (hsc_IC hsc_env)

         -----------------  Convert to STG ------------------
         ; let exprFS = fsLit "$expr"
               this_mod0 = icInteractiveModule (hsc_IC hsc_env)
               this_mod =
                   this_mod0 { moduleName =
                               mkModuleName $ moduleNameString (moduleName this_mod0)
                                           ++ "_" ++ show exprNo }

               exprName = mkExternalName (getUnique exprFS)
                            this_mod (mkVarOccFS exprFS)
                            noSrcSpan
               -- Create an id to keep the codegen happy
               exprId = mkVanillaGlobal exprName
                          (exprType prepd_expr)
               prepd_binds = [NonRec exprId prepd_expr]
               -- Stub location to keep the codegen happy
               mod_location =
                 ModLocation { ml_hs_file = Just "Interactive.hs"
                             , ml_hi_file = "Interactive.hi"
                             , ml_obj_file = "Interactive.jar" }

         ; (stg_binds, _cost_centre_info)
             <- {-# SCC "CoreToStg" #-}
                myCoreToStg dflags this_mod prepd_binds

           {- link it -}
         ; modClasses <- codeGen hsc_env this_mod mod_location
                           [] stg_binds (panic "hpcInfo") Nothing

         ; hval <- linkExpr hsc_env (T.unpack $ moduleJavaClass this_mod)
                                    (T.unpack $ idNameText dflags exprId) modClasses

         ; return hval }