Commit ae3ba7ec authored by David Himmelstrup's avatar David Himmelstrup
Browse files

Rather large refactoring of RnNames.

This restructoring makes the renamed export and import lists
available in IDE mode.
parent d9979e94
......@@ -730,7 +730,7 @@ data CheckedModule =
-- fields within CheckedModule.
type ParsedSource = Located (HsModule RdrName)
type RenamedSource = HsGroup Name
type RenamedSource = (HsGroup Name, [LImportDecl Name], Maybe [LIE Name])
type TypecheckedSource = LHsBinds Id
-- NOTE:
......
......@@ -40,7 +40,7 @@ import VarEnv ( emptyTidyEnv )
import Var ( Id )
import Module ( emptyModuleEnv, ModLocation(..) )
import RdrName ( GlobalRdrEnv, RdrName )
import HsSyn ( HsModule, LHsBinds, HsGroup )
import HsSyn ( HsModule, LHsBinds, HsGroup, LIE, LImportDecl )
import SrcLoc ( Located(..) )
import StringBuffer ( hGetStringBuffer, stringToStringBuffer )
import Parser
......@@ -133,9 +133,12 @@ data HscResult
-- In IDE mode: we just do the static/dynamic checks
| HscChecked
(Located (HsModule RdrName)) -- parsed
(Maybe (HsGroup Name)) -- renamed
(Maybe (LHsBinds Id, GlobalRdrEnv, ModDetails)) -- typechecked
-- parsed
(Located (HsModule RdrName))
-- renamed
(Maybe (HsGroup Name,[LImportDecl Name],Maybe [LIE Name]))
-- typechecked
(Maybe (LHsBinds Id, GlobalRdrEnv, ModDetails))
-- Concluded that it wasn't necessary
| HscNoRecomp ModDetails -- new details (HomeSymbolTable additions)
......@@ -339,8 +342,12 @@ hscFileCheck hsc_env mod_summary = do {
md_rules = [panic "no rules"] }
-- Rules are CoreRules, not the
-- RuleDecls we get out of the typechecker
rnInfo = do decl <- tcg_rn_decls tc_result
imports <- tcg_rn_imports tc_result
let exports = tcg_rn_exports tc_result
return (decl,imports,exports)
return (HscChecked rdr_module
(tcg_rn_decls tc_result)
rnInfo
(Just (tcg_binds tc_result,
tcg_rdr_env tc_result,
md)))
......
This diff is collapsed.
......@@ -53,6 +53,7 @@ import TcSimplify ( tcSimplifyTop )
import TcTyClsDecls ( tcTyAndClassDecls )
import LoadIface ( loadOrphanModules )
import RnNames ( importsFromLocalDecls, rnImports, rnExports,
mkRdrEnvAndImports, mkExportNameSet,
reportUnusedNames, reportDeprecations )
import RnEnv ( lookupSrcOcc_maybe )
import RnSource ( rnSrcDecls, rnTyClDecls, checkModDeprec )
......@@ -149,7 +150,7 @@ tcRnModule :: HscEnv
-> Located (HsModule RdrName)
-> IO (Messages, Maybe TcGblEnv)
tcRnModule hsc_env hsc_src save_rn_decls
tcRnModule hsc_env hsc_src save_rn_syntax
(L loc (HsModule maybe_mod export_ies
import_decls local_decls mod_deprec))
= do { showPass (hsc_dflags hsc_env) "Renamer/typechecker" ;
......@@ -161,8 +162,9 @@ tcRnModule hsc_env hsc_src save_rn_decls
initTc hsc_env hsc_src this_mod $
setSrcSpan loc $
do {
-- Deal with imports; sets tcg_rdr_env, tcg_imports
(rdr_env, imports) <- rnImports import_decls ;
-- Deal with imports;
rn_imports <- rnImports import_decls ;
(rdr_env, imports) <- mkRdrEnvAndImports rn_imports ;
let { dep_mods :: ModuleEnv (Module, IsBootInterface)
; dep_mods = imp_dep_mods imports
......@@ -189,7 +191,11 @@ tcRnModule hsc_env hsc_src save_rn_decls
gbl { tcg_rdr_env = rdr_env,
tcg_inst_env = extendInstEnvList (tcg_inst_env gbl) home_insts,
tcg_imports = tcg_imports gbl `plusImportAvails` imports,
tcg_rn_decls = if save_rn_decls then
tcg_rn_imports = if save_rn_syntax then
Just rn_imports
else
Nothing,
tcg_rn_decls = if save_rn_syntax then
Just emptyRnGroup
else
Nothing })
......@@ -223,7 +229,8 @@ tcRnModule hsc_env hsc_src save_rn_decls
reportDeprecations tcg_env ;
-- Process the export list
exports <- rnExports (isJust maybe_mod) export_ies ;
rn_exports <- rnExports export_ies ;
exports <- mkExportNameSet (isJust maybe_mod) rn_exports ;
-- Check whether the entire module is deprecated
-- This happens only once per module
......@@ -231,6 +238,9 @@ tcRnModule hsc_env hsc_src save_rn_decls
-- Add exports and deprecations to envt
let { final_env = tcg_env { tcg_exports = exports,
tcg_rn_exports = if save_rn_syntax then
rn_exports
else Nothing,
tcg_dus = tcg_dus tcg_env `plusDU` usesOnly exports,
tcg_deprecs = tcg_deprecs tcg_env `plusDeprecs`
mod_deprecs }
......
......@@ -98,6 +98,8 @@ initTc hsc_env hsc_src mod do_this
tcg_imports = init_imports,
tcg_home_mods = home_mods,
tcg_dus = emptyDUs,
tcg_rn_imports = Nothing,
tcg_rn_exports = Nothing,
tcg_rn_decls = Nothing,
tcg_binds = emptyLHsBinds,
tcg_deprecs = NoDeprecs,
......
......@@ -43,7 +43,8 @@ module TcRnTypes(
#include "HsVersions.h"
import HsSyn ( PendingSplice, HsOverLit, LRuleDecl, LForeignDecl,
ArithSeqInfo, DictBinds, LHsBinds, HsGroup )
ArithSeqInfo, DictBinds, LHsBinds, LImportDecl, HsGroup,
IE )
import HscTypes ( FixityEnv,
HscEnv, TypeEnv, TyThing,
GenAvailInfo(..), AvailInfo, HscSource(..),
......@@ -62,7 +63,7 @@ import OccName ( OccEnv )
import Var ( Id, TyVar )
import VarEnv ( TidyEnv )
import Module
import SrcLoc ( SrcSpan, SrcLoc, srcSpanStart )
import SrcLoc ( SrcSpan, SrcLoc, Located, srcSpanStart )
import VarSet ( IdSet )
import ErrUtils ( Messages, Message )
import UniqSupply ( UniqSupply )
......@@ -217,6 +218,8 @@ data TcGblEnv
-- collected initially in un-zonked form and are
-- finally zonked in tcRnSrcDecls
tcg_rn_imports :: Maybe [LImportDecl Name],
tcg_rn_exports :: Maybe [Located (IE Name)],
tcg_rn_decls :: Maybe (HsGroup Name), -- renamed decls, maybe
-- Nothing <=> Don't retain renamed decls
......@@ -726,6 +729,7 @@ cmpInst (LitInst _ lit1 ty1 _) (LitInst _ lit2 ty2 _) = (lit1 `compare` lit2) `
%************************************************************************
\begin{code}
-- FIXME: Rename this. It clashes with (Located (IE ...))
type LIE = Bag Inst
isEmptyLIE = isEmptyBag
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment