summaryrefslogtreecommitdiff
path: root/compiler/iface/IfaceEnv.hs
diff options
context:
space:
mode:
authorEdward Z. Yang <ezyang@cs.stanford.edu>2015-10-10 12:01:14 -0700
committerEdward Z. Yang <ezyang@cs.stanford.edu>2016-10-08 00:20:34 -0700
commit00b530d5402aaa37e4085ecdcae0ae54454736c1 (patch)
tree2d2963db4abdbcba9c12aea13a26e29e718e4778 /compiler/iface/IfaceEnv.hs
parent887485a45ae55e81b26b6412b6f9dcf6a497f044 (diff)
downloadhaskell-00b530d5402aaa37e4085ecdcae0ae54454736c1.tar.gz
The Backpack patch.
Summary: This patch implements Backpack for GHC. It's a big patch but I've tried quite hard to keep things, by-in-large, self-contained. The user facing specification for Backpack can be found at: https://github.com/ezyang/ghc-proposals/blob/backpack/proposals/0000-backpack.rst A guide to the implementation can be found at: https://github.com/ezyang/ghc-proposals/blob/backpack-impl/proposals/0000-backpack-impl.rst Has a submodule update for Cabal, as well as a submodule update for filepath to handle more strict checking of cabal-version. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, austin, simonmar, bgamari, goldfire Subscribers: thomie, mpickering Differential Revision: https://phabricator.haskell.org/D1482
Diffstat (limited to 'compiler/iface/IfaceEnv.hs')
-rw-r--r--compiler/iface/IfaceEnv.hs28
1 files changed, 26 insertions, 2 deletions
diff --git a/compiler/iface/IfaceEnv.hs b/compiler/iface/IfaceEnv.hs
index ff2f648a4a..96bd36ff33 100644
--- a/compiler/iface/IfaceEnv.hs
+++ b/compiler/iface/IfaceEnv.hs
@@ -11,6 +11,7 @@ module IfaceEnv (
extendIfaceIdEnv, extendIfaceTyVarEnv,
tcIfaceLclId, tcIfaceTyVar, lookupIfaceVar,
lookupIfaceTyVar, extendIfaceEnvs,
+ setNameModule,
ifaceExportNames,
@@ -174,6 +175,12 @@ externaliseName mod name
ns' = ns { nsNames = extendNameCache (nsNames ns) mod occ name' }
in (ns', name') }
+-- | Set the 'Module' of a 'Name'.
+setNameModule :: Maybe Module -> Name -> TcRnIf m n Name
+setNameModule Nothing n = return n
+setNameModule (Just m) n =
+ newGlobalBinder m (nameOccName n) (nameSrcSpan n)
+
{-
************************************************************************
* *
@@ -330,8 +337,25 @@ extendIfaceEnvs tcvs thing_inside
lookupIfaceTop :: OccName -> IfL Name
-- Look up a top-level name from the current Iface module
-lookupIfaceTop occ
- = do { env <- getLclEnv; lookupOrig (if_mod env) occ }
+lookupIfaceTop occ = do
+ lcl_env <- getLclEnv
+ -- NB: this is a semantic module, see
+ -- Note [Identity versus semantic module]
+ mod <- getIfModule
+ case if_nsubst lcl_env of
+ -- NOT substNameShape because 'getIfModule' returns the
+ -- renamed module (d'oh!)
+ Just nsubst ->
+ case lookupOccEnv (ns_map nsubst) occ of
+ Just n' ->
+ -- I thought this would be help but it turns out
+ -- n' doesn't have any useful information. Drat!
+ -- return (setNameLoc n' (nameSrcSpan n))
+ return n'
+ -- This case can occur when we encounter a DFun;
+ -- see Note [Bogus DFun renamings]
+ Nothing -> lookupOrig mod occ
+ _ -> lookupOrig mod occ
newIfaceName :: OccName -> IfL Name
newIfaceName occ