[project @ 1999-09-15 13:48:25 by sof]
authorsof <unknown>
Wed, 15 Sep 1999 13:48:26 +0000 (13:48 +0000)
committersof <unknown>
Wed, 15 Sep 1999 13:48:26 +0000 (13:48 +0000)
When constructing vanilla modules from ModuleNames, consult the HiMaps
to make sure we're using the 'right' kind of Module (i.e., it has got
the DLL flag correctly set.)

ghc/compiler/rename/RnEnv.lhs
ghc/compiler/rename/RnMonad.lhs

index 9387aee..df7ad7f 100644 (file)
@@ -63,7 +63,7 @@ newImportedGlobalName mod_name occ mod
     in
     case lookupFM cache key of
        Just name -> returnRn name
-       Nothing   -> setNameSupplyRn (us', inst_ns, new_cache)          `thenRn_`
+       Nothing   -> setNameSupplyRn (us', inst_ns, new_cache)  `thenRn_`
                     returnRn name
                  where
                     (us', us1) = splitUniqSupply us
@@ -90,7 +90,8 @@ newImportedBinder mod rdr_name
 -- Make an imported global name, checking first to see if it's in the cache
 mkImportedGlobalName :: ModuleName -> OccName -> RnM d Name
 mkImportedGlobalName mod_name occ
-  = newImportedGlobalName mod_name occ (mkVanillaModule mod_name)
+  = lookupModuleRn mod_name `thenRn` \ mod ->
+    newImportedGlobalName mod_name occ mod --(mkVanillaModule mod_name)
        
 mkImportedGlobalFromRdrName rdr_name
   | isQual rdr_name
index e44f8be..5fe5d08 100644 (file)
@@ -40,11 +40,11 @@ import Name         ( Name, OccName, NamedThing(..),
                          decode, mkLocalName
                        )
 import Module          ( Module, ModuleName, ModuleHiMap, SearchPath, WhereFrom,
-                         mkModuleHiMaps, moduleName
+                         mkModuleHiMaps, moduleName, mkVanillaModule, mkSearchPath
                        )
 import NameSet         
 import RdrName         ( RdrName, dummyRdrVarName, rdrNameOcc )
-import CmdLineOpts     ( opt_D_dump_rn_trace, opt_IgnoreIfacePragmas )
+import CmdLineOpts     ( opt_D_dump_rn_trace, opt_IgnoreIfacePragmas, opt_HiMap )
 import PrelInfo                ( builtinNames )
 import TysWiredIn      ( boolTyCon )
 import SrcLoc          ( SrcLoc, mkGeneratedSrcLoc )
@@ -445,11 +445,12 @@ renameSourceCode mod_name name_supply m
        -- only do any I/O if we need to read in a fixity declaration;
        -- and that doesn't happen in pragmas etc
 
+        mkModuleHiMaps (mkSearchPath opt_HiMap) >>= \ himaps ->
        newIORef name_supply            >>= \ names_var ->
        newIORef (emptyBag,emptyBag)    >>= \ errs_var ->
        let
            rn_down = RnDown { rn_loc = mkGeneratedSrcLoc, rn_ns = names_var,
-                              rn_errs = errs_var,
+                              rn_errs = errs_var, rn_hi_maps = himaps,
                               rn_mod = mod_name }
            s_down = SDown { rn_mode = InterfaceMode,
                               -- So that we can refer to PrelBase.True etc
@@ -726,3 +727,13 @@ getHiMaps :: RnM d (ModuleHiMap, ModuleHiMap)
 getHiMaps (RnDown {rn_hi_maps = himaps}) _ 
   = return himaps
 \end{code}
+
+\begin{code}
+lookupModuleRn :: ModuleName -> RnM d Module
+lookupModuleRn x = 
+  getHiMaps `thenRn` \ (himap, _) ->
+  case lookupFM himap x of
+    Nothing    -> returnRn (mkVanillaModule x)
+    Just (_,x) -> returnRn x
+
+\end{code}