-getRnStats :: [RenamedHsDecl] -> RnMG SDoc
-getRnStats all_decls
- = getIfacesRn `thenRn` \ ifaces ->
- let
- Ifaces this_mod mod_map decls_fm all_names imp_names (unslurped_insts,_) deferred_data_decls inst_mods = ifaces
- n_mods = sizeFM mod_map
-
- decls_imported = filter is_imported_decl all_decls
- decls_read = [decl | (name, (_, avail, decl)) <- fmToList decls_fm,
- name == availName avail,
- -- Data, newtype, and class decls are in the decls_fm
- -- under multiple names; the tycon/class, and each
- -- constructor/class op too.
- not (isLocallyDefined name)
- ]
-
- (cd_rd, dd_rd, add_rd, nd_rd, and_rd, sd_rd, vd_rd, _) = count_decls decls_read
- (cd_sp, dd_sp, add_sp, nd_sp, and_sp, sd_sp, vd_sp, id_sp) = count_decls decls_imported
-
- inst_decls_unslurped = length (bagToList unslurped_insts)
- inst_decls_read = id_sp + inst_decls_unslurped
-
- stats = vcat
- [int n_mods <> text " interfaces read",
- hsep [int cd_sp, text "class decls imported, out of",
- int cd_rd, text "read"],
- hsep [int dd_sp, text "data decls imported (of which", int add_sp, text "abstractly), out of",
- int dd_rd, text "read"],
- hsep [int nd_sp, text "newtype decls imported (of which", int and_sp, text "abstractly), out of",
- int nd_rd, text "read"],
- hsep [int sd_sp, text "type synonym decls imported, out of",
- int sd_rd, text "read"],
- hsep [int vd_sp, text "value signatures imported, out of",
- int vd_rd, text "read"],
- hsep [int id_sp, text "instance decls imported, out of",
- int inst_decls_read, text "read"]
- ]
- in
- returnRn (hcat [text "Renamer stats: ", stats])
-
-is_imported_decl (DefD _) = False
-is_imported_decl (ValD _) = False
-is_imported_decl decl = not (isLocallyDefined (hsDeclName decl))
-
-count_decls decls
- = -- pprTrace "count_decls" (ppr decls
- --
- -- $$
- -- text "========="
- -- $$
- -- ppr imported_decls
- -- ) $
- (class_decls,
- data_decls, abstract_data_decls,
- newtype_decls, abstract_newtype_decls,
- syn_decls,
- val_decls,
- inst_decls)
- where
- class_decls = length [() | ClD _ <- decls]
- data_decls = length [() | TyD (TyData DataType _ _ _ _ _ _ _) <- decls]
- newtype_decls = length [() | TyD (TyData NewType _ _ _ _ _ _ _) <- decls]
- abstract_data_decls = length [() | TyD (TyData DataType _ _ _ [] _ _ _) <- decls]
- abstract_newtype_decls = length [() | TyD (TyData NewType _ _ _ [] _ _ _) <- decls]
- syn_decls = length [() | TyD (TySynonym _ _ _ _) <- decls]
- val_decls = length [() | SigD _ <- decls]
- inst_decls = length [() | InstD _ <- decls]
+getInterfaceExports :: ModuleName -> WhereFrom -> RnMG (Module, Avails)
+getInterfaceExports mod_name from
+ = getHomeIfaceTableRn `thenRn` \ hit ->
+ case lookupModuleEnvByName hit mod_name of {
+ Just mi -> returnRn (mi_module mi, mi_exports mi) ;
+ Nothing ->
+
+ loadInterface doc_str mod_name from `thenRn` \ ifaces ->
+ case lookupModuleEnvByName (iPIT ifaces) mod_name of
+ Just mi -> returnRn (mi_module mi, mi_exports mi) ;
+ -- loadInterface always puts something in the map
+ -- even if it's a fake
+ Nothing -> pprPanic "getInterfaceExports" (ppr mod_name)
+ }
+ where
+ doc_str = sep [ppr mod_name, ptext SLIT("is directly imported")]
+\end{code}