Commit 787f3286 authored by simonmar's avatar simonmar
Browse files

[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).
parent bb14c2af
......@@ -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
......
__interface RnHiFiles 1 0 where
__export RnHiFiles loadInterface;
1 loadInterface :: __forall d => Outputable.SDoc -> Module.ModuleName -> Module.WhereFrom -> RnMonad.RnM d HscTypes.ModIface;
Supports Markdown
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