Store a SrcSpan instead of a SrcLoc inside a Name
[ghc-hetmet.git] / compiler / iface / TcIface.lhs
index 2e3c8ed..0ee3e00 100644 (file)
@@ -8,8 +8,8 @@ Type checking of type signatures in interface files
 \begin{code}
 module TcIface ( 
        tcImportDecl, checkWiredInTyCon, tcHiBootIface, typecheckIface, 
-       tcIfaceDecl, tcIfaceInst, tcIfaceFamInst, tcIfaceRules, tcIfaceGlobal, 
-       tcExtCoreBindings
+       tcIfaceDecl, tcIfaceInst, tcIfaceFamInst, tcIfaceRules,
+       tcIfaceVectInfo, tcIfaceGlobal, tcExtCoreBindings
  ) where
 
 #include "HsVersions.h"
@@ -38,6 +38,7 @@ import DataCon
 import TysWiredIn
 import Var              ( TyVar )
 import qualified Var
+import VarEnv
 import Name
 import NameEnv
 import OccName
@@ -198,6 +199,10 @@ typecheckIface iface
        ; fam_insts <- mapM tcIfaceFamInst (mi_fam_insts iface)
        ; rules     <- tcIfaceRules ignore_prags (mi_rules iface)
 
+                -- Vectorisation information
+        ; vect_info <- tcIfaceVectInfo (mi_module iface) type_env 
+                                       (mi_vect_info iface)
+
                -- Exports
        ; exports <- ifaceExportNames (mi_exports iface)
 
@@ -208,6 +213,7 @@ typecheckIface iface
                              , md_insts     = insts
                              , md_fam_insts = fam_insts
                              , md_rules     = rules
+                              , md_vect_info = vect_info
                              , md_exports   = exports
                               , md_modBreaks = emptyModBreaks
                              }
@@ -572,6 +578,34 @@ tcIfaceRule (IfaceRule {ifRuleName = name, ifActivation = act, ifRuleBndrs = bnd
 
 %************************************************************************
 %*                                                                     *
+               Vectorisation information
+%*                                                                     *
+%************************************************************************
+
+\begin{code}
+tcIfaceVectInfo :: Module -> TypeEnv  -> IfaceVectInfo -> IfL VectInfo
+tcIfaceVectInfo mod typeEnv (IfaceVectInfo names)
+  = do { ccVars <- mapM ccMapping names
+       ; return $ VectInfo (mkVarEnv ccVars)
+       }
+  where
+    ccMapping name 
+      = do { ccName <- lookupOrig mod (mkCloOcc (nameOccName name))
+           ; let { var   = lookup name
+                 ; ccVar = lookup ccName
+                 }
+           ; return (var, (var, ccVar))
+           }
+    lookup name = case lookupTypeEnv typeEnv name of
+                    Just (AnId var) -> var
+                    Just _          -> 
+                      panic "TcIface.tcIfaceVectInfo: wrong TyThing"
+                    Nothing         ->
+                      panic "TcIface.tcIfaceVectInfo: unknown name"
+\end{code}
+
+%************************************************************************
+%*                                                                     *
                        Types
 %*                                                                     *
 %************************************************************************
@@ -998,7 +1032,7 @@ tcIfaceLetBndr (IfLetBndr fs ty info)
 newExtCoreBndr :: IfaceLetBndr -> IfL Id
 newExtCoreBndr (IfLetBndr var ty _)    -- Ignoring IdInfo for now
   = do { mod <- getIfModule
-       ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcLoc
+       ; name <- newGlobalBinder mod (mkVarOccFS var) noSrcSpan
        ; ty' <- tcIfaceType ty
        ; return (mkLocalId name ty') }