module demo::lang::Pico::UseDef
rascal-0.40.17
Usage
import demo::lang::Pico::UseDef;
Dependencies
import demo::lang::Pico::Abstract;
function usesExp
set[Occurrence] usesExp(EXP e, STATEMENT s) = ❶
u:id(PicoId Id1) := e ? {< u.src, Id1, s>}
: {< u.src, Id2, s> | /u:id(PicoId Id2) <- e };
function usesStat
set[Occurrence] usesStat(s:asgStat(PicoId Id, EXP e)) = usesExp(e, s);
set[Occurrence] usesStat(s: ifElseStat(EXP e,
list[STATEMENT] s1,
list[STATEMENT] s2)) =
usesExp(e, s) + usesStats(s1) + usesStats(s2);
set[Occurrence] usesStat(s: whileStat(EXP e,
list[STATEMENT] s1)) =
usesExp(e, s) + usesStats(s1);
function usesStats
set[Occurrence] usesStats(list[STATEMENT] stats) =
{*usesStat(s) | s <- stats};
function uses
public set[Occurrence] uses(PROGRAM p) = usesStats(p.stats);
function defs
public set[Occurrence] defs(PROGRAM p) = ❹
{ < stat.src, v, stat > | /stat:asgStat(PicoId v, EXP _) <- p.stats};