Copyright | (c) Galois Inc 2018 |
---|---|
License | BSD3 |
Maintainer | Rob Dockins <rdockins@galois.com> |
Stability | provisional |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
Synopsis
- globalAliases :: (?lc :: TypeContext, HasPtrWidth wptr) => Module -> Map Symbol (Set GlobalAlias)
- functionAliases :: (?lc :: TypeContext, HasPtrWidth wptr) => Module -> Map Symbol (Set GlobalAlias)
- reverseAliases :: (Ord a, Ord l, Show a, Show l) => (a -> l) -> (a -> Maybe l) -> Seq a -> Map a (Set a)
Documentation
globalAliases :: (?lc :: TypeContext, HasPtrWidth wptr) => Module -> Map Symbol (Set GlobalAlias) Source #
Get all the aliases that alias (transitively) to a certain global.
functionAliases :: (?lc :: TypeContext, HasPtrWidth wptr) => Module -> Map Symbol (Set GlobalAlias) Source #
Get all the aliases that alias (transitively) to a certain function.
:: (Ord a, Ord l, Show a, Show l) | |
=> (a -> l) | "Label of" |
-> (a -> Maybe l) | "Alias of" |
-> Seq a | |
-> Map a (Set a) |
Reverse a set of alias/aliasee relationships
Given a list of values l : List A
and a function aliasOf : A -> A
,
compute a map Map A (Set A)
which records the set of things that are
transitive aliases of a given a : A
.
The keys in the resulting map should be only terminals, e.g. those a
which aren't aliases of another a'
in l
.
Requires that the elements of the input sequence are unique.
Outline:
* Initialize the empty map M : Map A (Set A)
* Initialize an auxilary map N : Map A A
which records the final aliasee
of each key (the last one in the chain of aliases).
* For each a : A
in l,
1. If aliasOf a
is in N
as aliasee
,
a. insert aliasee
at key a
in N
(memoize the result)
b. insert a
into the set at key aliasee
in M
(record the result)
c. recurse on s
minus aliasee
and a
.
2. If aliasOf a
is in s
, recurse on l ++ [a]
3. Otherwise,
a. insert a
at key a
in N
(memoize the result)
b. return the map as-is
For the sake of practical concerns, the implementation uses "labels" for
comparison and aliasOf
, and uses sequences rather than lists.