+renameModule dflags hit hst pcs this_module rdr_module
+ = renameSource dflags hit hst pcs this_module $
+ rename this_module rdr_module
+\end{code}
+
+
+\begin{code}
+renameExpr :: DynFlags
+ -> HomeIfaceTable -> HomeSymbolTable
+ -> PersistentCompilerState
+ -> Module -> RdrNameHsExpr
+ -> IO ( PersistentCompilerState,
+ Maybe (PrintUnqualified, (RenamedHsExpr, [RenamedHsDecl]))
+ )
+
+renameExpr dflags hit hst pcs this_module expr
+ = do { renameSource dflags hit hst pcs this_module $
+ tryLoadInterface doc (moduleName this_module) ImportByUser
+ `thenRn` \ (iface, maybe_err) ->
+ case maybe_err of {
+ Just msg -> ioToRnM (printErrs alwaysQualify
+ (ptext SLIT("failed to load interface for")
+ <+> quotes (ppr this_module)
+ <> char ':' <+> msg)) `thenRn_`
+ returnRn Nothing;
+ Nothing ->
+
+ let rdr_env = mi_globals iface
+ print_unqual = unQualInScope rdr_env
+ in
+
+ initRnMS rdr_env emptyLocalFixityEnv SourceMode (rnExpr expr)
+ `thenRn` \ (e,fvs) ->
+
+ checkErrsRn `thenRn` \ no_errs_so_far ->
+ if not no_errs_so_far then
+ -- Found errors already, so exit now
+ doDump e [] `thenRn_`
+ returnRn Nothing
+ else
+
+ lookupOrigNames implicit_occs `thenRn` \ implicit_names ->
+ slurpImpDecls (fvs `plusFV` implicit_names) `thenRn` \ decls ->
+
+ doDump e decls `thenRn_`
+ returnRn (Just (print_unqual, (e, decls)))
+ }}
+ where
+ implicit_occs = string_occs
+ doc = text "context for compiling expression"
+
+ doDump :: RenamedHsExpr -> [RenamedHsDecl] -> RnMG (Either IOError ())
+ doDump e decls =
+ getDOptsRn `thenRn` \ dflags ->
+ ioToRnM (dumpIfSet_dyn dflags Opt_D_dump_rn "Renamer:"
+ (vcat (ppr e : map ppr decls)))
+\end{code}