{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE CPP #-}
module Haxl.Core.CallGraph where
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as Map
#if __GLASGOW_HASKELL__ < 804
import Data.Monoid
#endif
import Data.Text (Text)
import qualified Data.Text as Text
type ModuleName = Text
type Function = Text
data QualFunction = QualFunction ModuleName Function deriving (QualFunction -> QualFunction -> Bool
(QualFunction -> QualFunction -> Bool)
-> (QualFunction -> QualFunction -> Bool) -> Eq QualFunction
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: QualFunction -> QualFunction -> Bool
$c/= :: QualFunction -> QualFunction -> Bool
== :: QualFunction -> QualFunction -> Bool
$c== :: QualFunction -> QualFunction -> Bool
Eq, Eq QualFunction
Eq QualFunction
-> (QualFunction -> QualFunction -> Ordering)
-> (QualFunction -> QualFunction -> Bool)
-> (QualFunction -> QualFunction -> Bool)
-> (QualFunction -> QualFunction -> Bool)
-> (QualFunction -> QualFunction -> Bool)
-> (QualFunction -> QualFunction -> QualFunction)
-> (QualFunction -> QualFunction -> QualFunction)
-> Ord QualFunction
QualFunction -> QualFunction -> Bool
QualFunction -> QualFunction -> Ordering
QualFunction -> QualFunction -> QualFunction
forall a.
Eq a
-> (a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
min :: QualFunction -> QualFunction -> QualFunction
$cmin :: QualFunction -> QualFunction -> QualFunction
max :: QualFunction -> QualFunction -> QualFunction
$cmax :: QualFunction -> QualFunction -> QualFunction
>= :: QualFunction -> QualFunction -> Bool
$c>= :: QualFunction -> QualFunction -> Bool
> :: QualFunction -> QualFunction -> Bool
$c> :: QualFunction -> QualFunction -> Bool
<= :: QualFunction -> QualFunction -> Bool
$c<= :: QualFunction -> QualFunction -> Bool
< :: QualFunction -> QualFunction -> Bool
$c< :: QualFunction -> QualFunction -> Bool
compare :: QualFunction -> QualFunction -> Ordering
$ccompare :: QualFunction -> QualFunction -> Ordering
$cp1Ord :: Eq QualFunction
Ord)
instance Show QualFunction where
show :: QualFunction -> String
show (QualFunction ModuleName
mn ModuleName
nm) = ModuleName -> String
Text.unpack (ModuleName -> String) -> ModuleName -> String
forall a b. (a -> b) -> a -> b
$ ModuleName
mn ModuleName -> ModuleName -> ModuleName
forall a. Semigroup a => a -> a -> a
<> String -> ModuleName
Text.pack String
"." ModuleName -> ModuleName -> ModuleName
forall a. Semigroup a => a -> a -> a
<> ModuleName
nm
type FunctionCall = (QualFunction, QualFunction)
type CallGraph = ([FunctionCall], Map QualFunction Text)
mainFunction :: QualFunction
mainFunction :: QualFunction
mainFunction = ModuleName -> ModuleName -> QualFunction
QualFunction ModuleName
"MAIN" ModuleName
"main"
emptyCallGraph :: CallGraph
emptyCallGraph :: CallGraph
emptyCallGraph = ([], Map QualFunction ModuleName
forall k a. Map k a
Map.empty)