definition:
|
executeAnalysis :: Eq a => Analysis a -> Prog -> ProgInfo a -> [(QName,a)]
-> String
-> ProgInfo a
-- The results of a module analysis for module `m` are encoded as
-- a `ProgInfo` with a single entry for the qualified name `m.m`.
executeAnalysis (SimpleModuleAnalysis _ anaFunc) prog _ _ _ =
let pname = progName prog
in lists2ProgInfo ([((pname,pname), anaFunc prog)], [])
executeAnalysis (DependencyModuleAnalysis _ anaFunc) prog impproginfos _ _ =
let pname = progName prog
importinfos = map (\ (qn,a) -> (fst qn,a))
(publicListFromProgInfo impproginfos)
in lists2ProgInfo ([((pname,pname), anaFunc prog importinfos)], [])
executeAnalysis (SimpleFuncAnalysis _ anaFunc) prog _ _ _ =
(lists2ProgInfo . map2 (\func -> (funcName func, anaFunc func))
. partition isVisibleFunc . progFuncs) prog
executeAnalysis (SimpleTypeAnalysis _ anaFunc) prog _ _ _ =
(lists2ProgInfo . map2 (\typ -> (typeName typ,anaFunc typ))
. partition isVisibleType . progTypes) prog
executeAnalysis (SimpleConstructorAnalysis _ anaFunc) prog _ _ _ =
(lists2ProgInfo
. map2 (\ (cdecl,tdecl) -> (consName cdecl, anaFunc cdecl tdecl))
. partition isVisibleCons
. concatMap (\t -> map (\c -> (c,t)) (consDeclsOfType t))
. progTypes) prog
where
isVisibleCons (consDecl,_) = consVisibility consDecl == Public
executeAnalysis (DependencyFuncAnalysis _ _ anaFunc) prog
importInfos startvals fpmethod = case fpmethod of
"simple" ->
let declsWithDeps = map2 addCalledFunctions
(partition isVisibleFunc (progFuncs prog))
startinfo = funcInfos2ProgInfo prog startvals
in simpleIteration anaFunc funcName declsWithDeps importInfos startinfo
"wlist" ->
let declsWithDeps = map addCalledFunctions (progFuncs prog)
in funcInfos2ProgInfo prog $ toList $
wlIteration anaFunc funcName declsWithDeps [] (Set.empty (<))
importInfos (fromList startvals)
"wlistscc" ->
let declsWithDeps = map addCalledFunctions (progFuncs prog)
-- compute strongly connected components w.r.t. func dependencies:
sccDecls = scc ((:[]) . funcName . fst) snd declsWithDeps
in funcInfos2ProgInfo prog $ toList $
foldr (\scc sccstartvals ->
wlIteration anaFunc funcName scc [] (Set.empty (<))
importInfos sccstartvals)
(fromList startvals)
(reverse sccDecls)
_ -> error unknownFixpointMessage
executeAnalysis (DependencyTypeAnalysis _ _ anaType) prog
importInfos startvals fpmethod = case fpmethod of
"simple" ->
let declsWithDeps = map2 addUsedTypes
(partition isVisibleType (progTypes prog))
startinfo = typeInfos2ProgInfo prog startvals
in simpleIteration anaType typeName declsWithDeps importInfos startinfo
"wlist" ->
let declsWithDeps = map addUsedTypes (progTypes prog)
in typeInfos2ProgInfo prog $ toList $
wlIteration anaType typeName declsWithDeps [] (Set.empty (<))
importInfos (fromList startvals)
"wlistscc" ->
let declsWithDeps = map addUsedTypes (progTypes prog)
-- compute strongly connected components w.r.t. type dependencies:
sccDecls = scc ((:[]) . typeName . fst) snd declsWithDeps
in typeInfos2ProgInfo prog $ toList $
foldr (\scc sccstartvals ->
wlIteration anaType typeName scc [] (Set.empty (<))
importInfos sccstartvals)
(fromList startvals)
(reverse sccDecls)
_ -> error unknownFixpointMessage
-- These cases are handled elsewhere:
executeAnalysis (CombinedSimpleFuncAnalysis _ _ _ _) _ _ _ _ =
error "Internal error in WorkerFunctions.executeAnalysis"
executeAnalysis (CombinedSimpleTypeAnalysis _ _ _ _) _ _ _ _ =
error "Internal error in WorkerFunctions.executeAnalysis"
executeAnalysis (CombinedDependencyFuncAnalysis _ _ _ _ _) _ _ _ _ =
error "Internal error in WorkerFunctions.executeAnalysis"
executeAnalysis (CombinedDependencyTypeAnalysis _ _ _ _ _) _ _ _ _ =
error "Internal error in WorkerFunctions.executeAnalysis"
|
iotype:
|
{(_,{SimpleModuleAnalysis},_,_,_,_) |-> {ProgInfo} || (_,{DependencyModuleAnalysis},_,_,_,_) |-> {ProgInfo} || (_,{SimpleFuncAnalysis},_,_,_,_) |-> _ || (_,{SimpleTypeAnalysis},_,_,_,_) |-> _ || (_,{SimpleConstructorAnalysis},_,_,_,_) |-> _ || (_,{DependencyFuncAnalysis},_,_,_,_) |-> _ || (_,{DependencyTypeAnalysis},_,_,_,_) |-> _}
|