%
% (c) The GRASP/AQUA Project, Glasgow University, 1992-1998
%
-% $Id: CLabel.lhs,v 1.53 2002/07/16 14:56:09 simonmar Exp $
+% $Id: CLabel.lhs,v 1.54 2002/07/18 09:16:12 simonmar Exp $
%
\section[CLabel]{@CLabel@: Information to make C Labels}
| ModuleInitLabel
Module -- the module name
- Version -- its version (same as the interface file ver)
String -- its "way"
+ -- at some point we might want some kind of version number in
+ -- the module init label, to guard against compiling modules in
+ -- the wrong order. We can't use the interface file version however,
+ -- because we don't always recompile modules which depend on a module
+ -- whose version has changed.
| PlainModuleInitLabel Module -- without the vesrion & way info
needsCDecl (CaseLabel _ CaseReturnPt) = True
needsCDecl (DataConLabel _ _) = True
needsCDecl (TyConLabel _) = True
-needsCDecl (ModuleInitLabel _ _ _) = True
+needsCDecl (ModuleInitLabel _ _) = True
needsCDecl (PlainModuleInitLabel _) = True
needsCDecl (CaseLabel _ _) = False
externallyVisibleCLabel (TyConLabel tc) = True
externallyVisibleCLabel (CaseLabel _ _) = False
externallyVisibleCLabel (AsmTempLabel _) = False
-externallyVisibleCLabel (ModuleInitLabel _ _ _)= True
+externallyVisibleCLabel (ModuleInitLabel _ _)= True
externallyVisibleCLabel (PlainModuleInitLabel _)= True
externallyVisibleCLabel (RtsLabel RtsModuleRegd) = False --hack
externallyVisibleCLabel (RtsLabel _) = True
labelType (CaseLabel _ CaseReturnPt) = CodeType
labelType (CaseLabel _ CaseVecTbl) = VecTblType
labelType (TyConLabel _) = ClosureTblType
-labelType (ModuleInitLabel _ _ _) = CodeType
+labelType (ModuleInitLabel _ _) = CodeType
labelType (PlainModuleInitLabel _) = CodeType
labelType (IdLabel _ info) =
DataConLabel n k -> isDllName n
TyConLabel tc -> isDllName (getName tc)
ForeignLabel _ d -> d
- ModuleInitLabel m _ _ -> (not opt_Static) && (not (isHomeModule m))
+ ModuleInitLabel m _ -> (not opt_Static) && (not (isHomeModule m))
PlainModuleInitLabel m -> (not opt_Static) && (not (isHomeModule m))
_ -> False
\end{code}
pprCLbl (CC_Label cc) = ppr cc
pprCLbl (CCS_Label ccs) = ppr ccs
-pprCLbl (ModuleInitLabel mod ver way)
+pprCLbl (ModuleInitLabel mod way)
= ptext SLIT("__stginit_") <> ftext (moduleNameFS (moduleName mod))
- <> char '_' <> int ver <> char '_' <> text way
+ <> char '_' <> text way
pprCLbl (PlainModuleInitLabel mod)
= ptext SLIT("__stginit_") <> ftext (moduleNameFS (moduleName mod))
\begin{code}
codeGen :: DynFlags
-> Module -- Module name
- -> Version -- Module version
- -> [(Module,Version)] -- Import names & versions
+ -> [Module] -- Import names
-> CollectedCCs -- (Local/global) cost-centres needing declaring/registering.
-> [Id] -- foreign-exported binders
-> [TyCon] -- Local tycons, including ones from classes
-> [(StgBinding,[Id])] -- Bindings to convert, with SRTs
-> IO AbstractC -- Output
-codeGen dflags mod_name mod_ver imported_modules cost_centre_info fe_binders
+codeGen dflags mod_name imported_modules cost_centre_info fe_binders
tycons stg_binds
= do
showPass dflags "CodeGen"
datatype_stuff = genStaticConBits cinfo data_tycons
code_stuff = initC cinfo (mapCs cgTopBinding stg_binds)
- init_stuff = mkModuleInit fe_binders mod_name mod_ver way
+ init_stuff = mkModuleInit fe_binders mod_name way
imported_modules cost_centre_info
abstractC = mkAbstractCs [ maybeSplitCode,
mkModuleInit
:: [Id] -- foreign exported functions
-> Module -- module name
- -> Version -- module version
-> String -- the "way"
- -> [(Module,Version)] -- import names & versions
+ -> [Module] -- import names
-> CollectedCCs -- cost centre info
-> AbstractC
-mkModuleInit fe_binders mod ver way imps cost_centre_info
+mkModuleInit fe_binders mod way imps cost_centre_info
= let
register_fes =
map (\f -> CMacroStmt REGISTER_FOREIGN_EXPORT [f]) fe_labels
(cc_decls, cc_regs) = mkCostCentreStuff cost_centre_info
-- we don't want/need to init GHC.Prim, so filter it out
- mk_import_register (imp,ver)
+ mk_import_register imp
| imp == gHC_PRIM = AbsCNop
| otherwise = CMacroStmt REGISTER_IMPORT [
- CLbl (mkModuleInitLabel imp ver way) AddrRep
+ CLbl (mkModuleInitLabel imp way) AddrRep
]
register_imports = map mk_import_register imps
mkAbstractCs [
cc_decls,
CModuleInitBlock (mkPlainModuleInitLabel mod)
- (mkModuleInitLabel mod ver way)
+ (mkModuleInitLabel mod way)
(mkAbstractCs (register_fes ++
cc_regs :
register_imports))
#else
import HscMain ( initPersistentCompilerState )
#endif
-import HscTypes
+import HscTypes hiding ( moduleNameToModule )
import Name ( Name, NamedThing(..), nameRdrName, nameModule,
isHomePackageName, isExternalName )
import NameEnv
import Parser
import Lex ( ParseResult(..), ExtFlags(..), mkPState )
import SrcLoc ( mkSrcLoc )
+import Finder ( findModule )
import Rename ( checkOldIface, renameModule, renameExtCore,
closeIfaceDecls, RnResult(..) )
import Rules ( emptyRuleBase )
import Name ( Name, nameModule, nameOccName, getName )
import NameEnv ( emptyNameEnv, mkNameEnv )
import Module ( Module )
-import BasicTypes ( Version )
import FastString
import Maybes ( expectJust )
import Util ( seqList )
import MkExternalCore ( emitExternalCore )
import ParserCore
import ParserCoreUtils
+
\end{code}
pcs_tc, ds_details, foreign_stuff) -> do {
let {
- imported_module_names :: [ModuleName];
imported_module_names =
filter (/= gHC_PRIM_Name) $
map ideclName (hsModuleImports rdr_module);
- imported_modules :: [(Module,Version)];
imported_modules =
- map (getModuleAndVersion hit (pcs_PIT pcs_tc))
+ map (moduleNameToModule hit (pcs_PIT pcs_tc))
imported_module_names;
}
final_iface <- _scc_ "MkFinalIface"
mkFinalIface ghci_mode dflags location
maybe_checked_iface new_iface tidy_details
-
- -- get this module's version
- version <- return $! vers_module (mi_version final_iface)
-
if toNothing
then do
return (False, False, Nothing, final_iface)
else do
------------------ Code generation ------------------
abstractC <- _scc_ "CodeGen"
- codeGen dflags this_mod version
- imported_modules
+ codeGen dflags this_mod imported_modules
cost_centre_info fe_binders
local_tycons stg_binds
HomeSymbolTable, emptySymbolTable,
PackageTypeEnv,
HomeIfaceTable, PackageIfaceTable, emptyIfaceTable,
- lookupIface, lookupIfaceByModName, getModuleAndVersion,
+ lookupIface, lookupIfaceByModName, moduleNameToModule,
emptyModIface,
InteractiveContext(..),
-- Use instead of Finder.findModule if possible: this way doesn't
-- require filesystem operations, and it is guaranteed not to fail
-- when the IfaceTables are properly populated (i.e. after the renamer).
-getModuleAndVersion :: HomeIfaceTable -> PackageIfaceTable -> ModuleName
- -> (Module,Version)
-getModuleAndVersion hit pit mod
- = ((,) $! mi_module iface) $! vers_module (mi_version iface)
- where iface = fromJust (lookupIfaceByModName hit pit mod)
+moduleNameToModule :: HomeIfaceTable -> PackageIfaceTable -> ModuleName
+ -> Module
+moduleNameToModule hit pit mod
+ = mi_module (fromJust (lookupIfaceByModName hit pit mod))
\end{code}