|
definition: |
choiceOfDemand :: State -> NodeID -> Maybe IExpr
choiceOfDemand st nid =
case lookupNode nid (graph st) of
FuncNode f _ -> choiceOfBody (bodyOf f (program st))
_ -> error "choiceOfDemand: no function node in control"
where
choiceOfBody (IFuncBody (IBlock _ _ stm)) = choiceOfStmt stm
choiceOfBody (IExternal _) = Nothing
choiceOfStmt stm = case stm of
ICaseCons _ bs ->
if null bs
then Nothing
else Just (foldr1 (\e1 e2 -> IOr e1 e2) (map branchesToConsFree bs))
_ -> error "choiceOfDemand: function without constructor demand in control"
where
branchesToConsFree (IConsBranch c ar _) =
ICCall c (map (\_ -> IFCall ("Prelude","unknown",0) []) [1 .. ar])
|
|
demand: |
argument 1 |
|
deterministic: |
deterministic operation |
|
documentation: |
Computes an expression representing the choice structure demanded by the function of the given node id. |
|
failfree: |
(_, _) |
|
indeterministic: |
referentially transparent operation |
|
infix: |
no fixity defined |
|
iotype: |
{(_,_) |-> _}
|
|
name: |
choiceOfDemand |
|
precedence: |
no precedence defined |
|
result-values: |
{Just,Nothing}
|
|
signature: |
State -> Prelude.Int -> Prelude.Maybe ICurry.Types.IExpr |
|
solution-complete: |
operation might suspend on free variables |
|
terminating: |
possibly non-terminating |
|
totally-defined: |
possibly non-reducible on same data term |