Verified Commit 685a073e authored by Camil Staps's avatar Camil Staps 🚀

Added usages of classes

parent 8c2ced00
Subproject commit 7b19dd97362054a8d1dc71381b09b2f1c82eb704
Subproject commit 2bbfe562f0645de570b511f8a8b161bb08e685da
......@@ -138,6 +138,7 @@ derive JSONDecode CloogleEntry
, ce_members :: [Index] //* Class members (FunctionEntries; must be lazy for CloogleDBFactory to work)
, ce_instances :: ![Index] //* All instances of the class
, ce_derivations :: ![Index] //* Derivations of generic meta-classes like iTask
, ce_usages :: ![Index] //* FunctionEntries, TypeDefEntries and ClassEntries using this class
}
/**
......
......@@ -211,16 +211,17 @@ mergeTypeDefEntries a=:{tde_typedef={td_rhs=TDRAbstract Nothing}} b = case b.tde
mergeTypeDefEntries a b = b
toClass :: Location [String] Bool TypeContext (Maybe ClassDoc) -> ClassEntry
toClass loc vs meta cc doc
= { ce_loc = loc
, ce_vars = vs
, ce_is_meta = meta
, ce_context = cc
, ce_documentation = doc
, ce_members = []
, ce_instances = []
, ce_derivations = []
}
toClass loc vs meta cc doc =
{ ce_loc = loc
, ce_vars = vs
, ce_is_meta = meta
, ce_context = cc
, ce_documentation = doc
, ce_members = []
, ce_instances = []
, ce_derivations = []
, ce_usages = []
}
classContext :: ClassEntry -> [TypeRestriction]
classContext ce = ce.ce_context
......@@ -452,6 +453,7 @@ where
getUsages :: !(CloogleEntry, a) -> [Index]
getUsages (e,_) = case e of
TypeDefEntry tde -> tde.tde_usages
ClassEntry ce -> ce.ce_usages
_ -> []
allTypeSynonyms :: !*CloogleDB -> *(Map Name [TypeDef], *CloogleDB)
......
......@@ -76,7 +76,7 @@ from CloogleDB import
:: ModuleEntry{me_loc,me_is_core,me_is_app,me_documentation},
:: FunctionEntry{..},
:: TypeDefEntry{tde_loc,tde_instances,tde_derivations,tde_usages},
:: ClassEntry{ce_loc,ce_instances,ce_is_meta,ce_members},
:: ClassEntry{ce_loc,ce_instances,ce_is_meta,ce_members,ce_usages},
classContext, :: TypeRestriction,
:: SyntaxEntry, :: DeriveEntry,
:: InstanceEntry{ie_class,ie_types,ie_locations},
......@@ -150,25 +150,36 @@ where
link _ (TypeDefEntry tde) = TypeDefEntry
{ tde
& tde_instances=idxfilter \e -> case e of
InstanceEntry ie -> not $ isEmpty [() \\ 'T'.Type t _ <- concatMap ('T'.subtypes o fst) ie.ie_types | t == name]
InstanceEntry ie -> or [t == name \\ 'T'.Type t _ <- concatMap ('T'.subtypes o fst) ie.ie_types]
_ -> False
, tde_derivations=idxfilter \e -> case e of
DeriveEntry {de_type='T'.Type t _} -> t == name
_ -> False
, tde_usages=idxfilter \e -> case e of
FunctionEntry {fe_type=Just t} -> or [True \\ 'T'.Type t _ <- 'T'.subtypes t | t == name]
FunctionEntry {fe_type=Just t} -> or [t == name \\ 'T'.Type t _ <- 'T'.subtypes t]
_ -> False
}
with name = 'T'.td_name $ 'CDB'.getTypeDef tde
link i (ClassEntry ce) = ClassEntry
{ ce
& ce_instances=idxfilter \e -> case e of
InstanceEntry ie -> ie.ie_class == 'CDB'.getName ce.ce_loc
InstanceEntry ie -> ie.ie_class == name
_ -> False
, ce_members=idxfilter \e -> case e of
FunctionEntry fe -> fe.fe_class == Just (Index i)
_ -> False
, ce_usages=idxfilter` \e -> or [cls == name \\ 'T'.Instance cls _ <- context e]
}
with
name = 'CDB'.getName ce.ce_loc
context :: 'CDB'.CloogleEntry -> ['T'.TypeRestriction]
context (FunctionEntry {fe_type=Just t}) = 'T'.allRestrictions t
context (TypeDefEntry tde) = 'T'.typeRhsRestrictions $ 'T'.td_rhs $ 'CDB'.getTypeDef tde
context (ClassEntry ce)
| name == 'CDB'.getName ce.ce_loc = []
| otherwise = classContext ce
context _ = []
link _ (FunctionEntry fe=:{fe_derivations=Just _}) = FunctionEntry
{ fe
& fe_derivations=Just $ idxfilter \e -> case e of
......@@ -243,6 +254,9 @@ where
idxfilter f = [idx \\ (idx,e) <- entridxs | f e]
idxhd = hd o idxfilter
// WARNING: indexes may be wrong after meta-instances due to the use of Left
idxfilter` f = [idx \\ (idx,Right e) <- zip2 [Index i \\ i <- [0..]] entries` | f e]
coreidxs = idxfilter \e -> case 'CDB'.getLocation e of
Nothing -> False
Just l -> case ('CDB'.getLibrary l, 'CDB'.getModule l) of
......
Markdown is supported
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