, moduleString -- :: Module -> EncodedString
, moduleUserString -- :: Module -> UserString
- , mkVanillaModule -- :: ModuleName -> Module
- , isVanillaModule -- :: Module -> Bool
- , mkPrelModule -- :: UserString -> Module
+ , mkModule
+ , mkBasePkgModule -- :: UserString -> Module
, mkHomeModule -- :: ModuleName -> Module
, isHomeModule -- :: Module -> Bool
, mkPackageModule -- :: ModuleName -> Module
#include "HsVersions.h"
import OccName
import Outputable
-import Packages ( PackageName, preludePackage )
+import Packages ( PackageName, basePackage )
import CmdLineOpts ( opt_InPackage )
-import FastString ( FastString )
import Unique ( Uniquable(..) )
import Maybes ( expectJust )
import UniqFM
\begin{code}
data Module = Module ModuleName !PackageInfo
-instance Binary Module where
- put_ bh (Module m p) = put_ bh m
- get bh = do m <- get bh; return (Module m DunnoYet)
-
data PackageInfo
= ThisPackage -- A module from the same package
-- as the one being compiled
| AnotherPackage -- A module from a different package
- | DunnoYet -- This is used when we don't yet know
- -- Main case: we've come across Foo.x in an interface file
- -- but we havn't yet opened Foo.hi. We need a Name for Foo.x
- -- Later on (in RnEnv.newTopBinder) we'll update the cache
- -- to have the right PackageName
-
packageInfoPackage :: PackageInfo -> PackageName
packageInfoPackage ThisPackage = opt_InPackage
-packageInfoPackage DunnoYet = FSLIT("<?>")
packageInfoPackage AnotherPackage = FSLIT("<pkg>")
instance Outputable PackageInfo where
data ModLocation
= ModLocation {
ml_hs_file :: Maybe FilePath,
- ml_hspp_file :: Maybe FilePath, -- path of preprocessed source
- ml_hi_file :: FilePath,
- ml_obj_file :: Maybe FilePath
+
+ ml_hspp_file :: Maybe FilePath, -- Path of preprocessed source
+
+ ml_hi_file :: FilePath, -- Where the .hi file is, whether or not it exists
+ -- Always of form foo.hi, even if there is an hi-boot
+ -- file (we add the -boot suffix later)
+
+ ml_obj_file :: FilePath -- Where the .o file is, whether or not it exists
+ -- (might not exist either because the module
+ -- hasn't been compiled yet, or because
+ -- it is part of a package with a .a file)
}
deriving Show
mod_str ++ replicate (max 0 (16 - length mod_str)) ' '
++" ( " ++ expectJust "showModMsg" (ml_hs_file location) ++ ", "
++ (if use_object
- then expectJust "showModMsg" (ml_obj_file location)
+ then ml_obj_file location
else "interpreted")
++ " )"
where mod_str = moduleUserString mod
\begin{code}
-mkPrelModule :: ModuleName -> Module
-mkPrelModule mod_nm
- = Module mod_nm pack_info
+mkModule :: PackageName -> ModuleName -> Module
+mkModule pkg_name mod_name
+ = Module mod_name pkg_info
where
- pack_info
- | opt_InPackage == preludePackage = ThisPackage
- | otherwise = AnotherPackage
+ pkg_info
+ | opt_InPackage == pkg_name = ThisPackage
+ | otherwise = AnotherPackage
+
+mkBasePkgModule :: ModuleName -> Module
+mkBasePkgModule mod_nm = mkModule basePackage mod_nm
mkHomeModule :: ModuleName -> Module
mkHomeModule mod_nm = Module mod_nm ThisPackage
mkPackageModule :: ModuleName -> Module
mkPackageModule mod_nm = Module mod_nm AnotherPackage
--- Used temporarily when we first come across Foo.x in an interface
--- file, but before we've opened Foo.hi.
--- (Until we've opened Foo.hi we don't know what the Package is.)
-mkVanillaModule :: ModuleName -> Module
-mkVanillaModule name = Module name DunnoYet
-
-isVanillaModule :: Module -> Bool
-isVanillaModule (Module nm DunnoYet) = True
-isVanillaModule _ = False
-
moduleString :: Module -> EncodedString
moduleString (Module (ModuleName fs) _) = unpackFS fs