mkTopLevEnv hpt mod
= case lookupModuleEnv hpt (mkModule mod) of
Nothing -> throwDyn (ProgramError ("mkTopLevEnv: not a home module " ++ mod))
- Just details -> case hm_globals details of
+ Just details -> case mi_globals (hm_iface details) of
Nothing -> throwDyn (ProgramError ("mkTopLevEnv: not interpreted " ++ mod))
Just env -> return env
cmModuleIsInterpreted :: CmState -> String -> IO Bool
cmModuleIsInterpreted cmstate str
= case lookupModuleEnv (cmHPT cmstate) (mkModule str) of
- Just details -> return (isJust (hm_globals details))
+ Just details -> return (isJust (mi_globals (hm_iface details)))
_not_a_home_module -> return False
-----------------------------------------------------------------------------
-- Compilation "succeeded", and may or may not have returned a new
-- linkable (depending on whether compilation was actually performed
-- or not).
- CompOK new_details new_globals new_iface maybe_new_linkable
+ CompOK new_details new_iface maybe_new_linkable
-> do let
new_linkable = maybe_new_linkable `orElse` old_linkable
new_info = HomeModInfo { hm_iface = new_iface,
- hm_globals = new_globals,
hm_details = new_details,
hm_linkable = new_linkable }
return (Just new_info)
mi_fixities = fixities,
mi_deprecs = deprecs,
mi_decls = decls,
+ mi_globals = Nothing,
mi_insts = insts,
mi_rules = rules,
mi_rule_vers = rule_vers,
mg_usages = usages,
mg_deps = deps,
mg_exports = exports,
+ mg_rdr_env = rdr_env,
mg_fix_env = fix_env,
mg_deprecs = src_deprecs,
mg_insts = insts,
mi_rules = iface_rules,
mi_fixities = fixities,
mi_deprecs = deprecs,
-
+ mi_globals = Just rdr_env,
+
-- Left out deliberately: filled in by addVersionInfo
mi_mod_vers = initialVersion,
mi_exp_vers = initialVersion,
data CompResult
= CompOK ModDetails -- New details
- (Maybe GlobalRdrEnv) -- Lexical environment for the module
- -- (Maybe because we may have loaded it from
- -- its precompiled interface)
ModIface -- New iface
(Maybe Linkable) -- New code; Nothing => compilation was not reqd
-- (old code is still valid)
case hsc_result of
HscFail -> return CompErrs
- HscNoRecomp details iface -> return (CompOK details Nothing iface Nothing)
+ HscNoRecomp details iface -> return (CompOK details iface Nothing)
- HscRecomp details rdr_env iface
+ HscRecomp details iface
stub_h_exists stub_c_exists maybe_interpreted_code
| isHsBoot src_flavour -- No further compilation to do
- -> return (CompOK details rdr_env iface Nothing)
+ -> return (CompOK details iface Nothing)
| otherwise -- Normal Haskell source files
-> do
let linkable = LM unlinked_time this_mod
(hs_unlinked ++ stub_unlinked)
- return (CompOK details rdr_env iface (Just linkable))
+ return (CompOK details iface (Just linkable))
-----------------------------------------------------------------------------
-- stub .h and .c files (for foreign export support)
SysTools.touch dflags' "Touching object file" o_file
return (StopLn, dflags', Just location4, o_file)
- HscRecomp _details _rdr_env _iface
+ HscRecomp _details _iface
stub_h_exists stub_c_exists
_maybe_interpreted_code -> do
-- Did recompilation
| HscRecomp ModDetails -- new details (HomeSymbolTable additions)
- (Maybe GlobalRdrEnv)
ModIface -- new iface (if any compilation was done)
Bool -- stub_h exists
Bool -- stub_c exists
mkIface hsc_env (ms_location mod_summary)
maybe_checked_iface ds_result
- ; let { final_globals = Just $! (mg_rdr_env ds_result)
- ; final_details = ModDetails { md_types = mg_types ds_result,
+ ; let { final_details = ModDetails { md_types = mg_types ds_result,
md_insts = mg_insts ds_result,
md_rules = mg_rules ds_result } }
-- And the answer is ...
; dumpIfaceStats hsc_env
; return (HscRecomp final_details
- final_globals
final_iface
False False Nothing)
}
; final_iface <-
if one_shot then return (error "no final iface")
else return new_iface
- ; let { final_globals | one_shot = Nothing
- | otherwise = Just $! (mg_rdr_env tidy_result) }
- ; final_globals `seq` return ()
-- Build the final ModDetails (except in one-shot mode, where
-- we won't need this information after compilation).
; dumpIfaceStats hsc_env
; return (HscRecomp final_details
- final_globals
final_iface
stub_h_exists stub_c_exists
maybe_bcos)
data HomeModInfo
= HomeModInfo { hm_iface :: ModIface,
- hm_globals :: Maybe GlobalRdrEnv, -- Its top level environment
- -- Nothing <-> compiled module
hm_details :: ModDetails,
hm_linkable :: Linkable }
\end{code}
-- the version of the parent class/tycon changes
mi_decls :: [(Version,IfaceDecl)], -- Sorted
+ mi_globals :: !(Maybe GlobalRdrEnv),
+ -- Its top level environment or Nothing if we read this
+ -- interface from an interface file. (We need the source
+ -- file to figure out the top-level environment.)
+
-- Instance declarations and rules
mi_insts :: [IfaceInst], -- Sorted
mi_rules :: [IfaceRule], -- Sorted
mi_insts = [],
mi_rules = [],
mi_decls = [],
+ mi_globals = Nothing,
mi_rule_vers = initialVersion,
mi_dep_fn = emptyIfaceDepCache,
mi_fix_fn = emptyIfaceFixCache,