| Safe Haskell | None |
|---|---|
| Language | Haskell98 |
ExCF
Contents
Description
- This module calculates the exact control graph by evaluating a CPSScheme
- program, following the definitions in Olin Shivers' "Control-Flow
- Analysis of Higher-Order Languages".
- type Closure = (Lambda, BEnv)
- type Contour = Integer
- type BEnv = Label :⇀ Contour
- type VEnv = (Var :× Contour) :⇀ D
- data D
- type CCtxt = Label :× BEnv
- type CCache = CCtxt :⇀ D
- type Ans = CCache
- evalCPS :: Prog -> Ans
- evalV :: Val -> BEnv -> VEnv -> D
- evalF :: D -> [D] -> VEnv -> Contour -> Ans
- evalC :: Call -> BEnv -> VEnv -> Contour -> Ans
Types
A contour is an identifier for the contours (or dynamic frames) generated at each call of a lambda expression
type VEnv = (Var :× Contour) :⇀ D Source
A variable environment maps variable names together with a contour to a value. The second parameter is required to allow for different, shadowed bindings of the same variable to coexist.
A semantical value can either be
type CCtxt = Label :× BEnv Source
The origin of an edge in the control graph is a call position bundled with the binding environment at that point.
type CCache = CCtxt :⇀ D Source
The resulting control flow graph has edges from call sites (annotated by
the current binding environment) to functions (e.g. lambdas with closure,
primitive operations, or Stop)
Evaluation functions
evalCPS evaluates a whole program, by initializing the envirnoments and passing the Stop continuation to the outermost lambda
evalV :: Val -> BEnv -> VEnv -> D Source
evalC (called A by Shivers) evaluates a syntactical value to a semantical piece of data.