From: simonmar Date: Tue, 6 Feb 2001 17:31:00 +0000 (+0000) Subject: [project @ 2001-02-06 17:31:00 by simonmar] X-Git-Tag: Approximately_9120_patches~2728 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=787f32866ccf115271f8eafb22f44b0f4b13e7b6;p=ghc-hetmet.git [project @ 2001-02-06 17:31:00 by simonmar] Qualified names on the command line may now refer to any exported entity from any module, not just entities from the "original" defining module. eg. "IO.hFlush IO.stdout" now works. There's still a problem in that home interfaces may be demand-loaded if they're aren't already in memory, which is wrong (you can refer to a module which isn't loaded, causing things to fall over at link time). --- diff --git a/ghc/compiler/rename/RnEnv.lhs b/ghc/compiler/rename/RnEnv.lhs index b835791..fc262ed 100644 --- a/ghc/compiler/rename/RnEnv.lhs +++ b/ghc/compiler/rename/RnEnv.lhs @@ -8,6 +8,9 @@ module RnEnv where -- Export everything #include "HsVersions.h" +import {-# SOURCE #-} RnHiFiles + +import HscTypes ( ModIface(..) ) import HsSyn import RdrHsSyn ( RdrNameIE ) import RdrName ( RdrName, rdrNameModule, rdrNameOcc, isQual, isUnqual, isOrig, @@ -27,7 +30,9 @@ import Name ( Name, import Name ( extendNameEnv_C, plusNameEnv_C, nameEnvElts ) import NameSet import OccName ( OccName, occNameUserString, occNameFlavour ) -import Module ( ModuleName, moduleName, mkVanillaModule, mkSysModuleNameFS, moduleNameFS ) +import Module ( ModuleName, moduleName, mkVanillaModule, + mkSysModuleNameFS, moduleNameFS, + WhereFrom(..) ) import FiniteMap import UniqSupply import SrcLoc ( SrcLoc, noSrcLoc ) @@ -238,9 +243,23 @@ lookupGlobalOccRn rdr_name | otherwise -> case lookupRdrEnv global_env rdr_name of Just _ -> lookupSrcName global_env rdr_name - Nothing -> newGlobalName (rdrNameModule rdr_name) - (rdrNameOcc rdr_name) - + Nothing -> lookupQualifiedName rdr_name + +-- a qualified name on the command line can refer to any module at all: we +-- try to load the interface if we don't already have it. +lookupQualifiedName :: RdrName -> RnM d Name +lookupQualifiedName rdr_name + = let + mod = rdrNameModule rdr_name + occ = rdrNameOcc rdr_name + in + loadInterface (ppr rdr_name) mod ImportBySystem `thenRn` \ iface -> + case [ name | (_,avails) <- mi_exports iface, + avail <- avails, + name <- availNames avail, + nameOccName name == occ ] of + (n:ns) -> ASSERT (null ns) returnRn n + _ -> failWithRn (mkUnboundName rdr_name) (unknownNameErr rdr_name) lookupSrcName :: GlobalRdrEnv -> RdrName -> RnM d Name -- NB: passed GlobalEnv explicitly, not necessarily in RnMS monad diff --git a/ghc/compiler/rename/RnHiFiles.hi-boot-5 b/ghc/compiler/rename/RnHiFiles.hi-boot-5 new file mode 100644 index 0000000..98d4308 --- /dev/null +++ b/ghc/compiler/rename/RnHiFiles.hi-boot-5 @@ -0,0 +1,3 @@ +__interface RnHiFiles 1 0 where +__export RnHiFiles loadInterface; +1 loadInterface :: __forall d => Outputable.SDoc -> Module.ModuleName -> Module.WhereFrom -> RnMonad.RnM d HscTypes.ModIface;