Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1 getTextIdFUNC : Id → Text getTextIdFUNC(id) ≡ getText(id), getFUNCMapEntranceList : FUNC → FUNCMapEntrance ∗ getFUNCMapEntranceList(func) ≡ map(func), /∗**** FUNC end ****∗/ /∗**** ENV ****∗/ updateENV : ENV × ExpType × TRANS → ENV updateENV(env, et, trans) ≡ case et of Known(te) → case te of TypeName(tn) → if isinId(tn, domainTRANS(trans)) then /∗Type of interest.∗/ removeENV(env, tn) else /∗Not type of interest.∗/ env end, → env end, Unknown → env end, setEnv : Access ∗ × ENV → ENV setEnv(al, env) ≡ if al = 〈〉 then env else case hd al of AccessValueOrVariableName(vn) → setEnv(tl al, removeENV(env, id(vn))), → setEnv(tl al, env) end end, makeENV : LetBinding × TypeExpr × TRANS → ENV makeENV(lb, te, trans) ≡ case lb of 460

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1 MakeBinding(b) → makeENVBinding(b, te, trans), → mk_ENV(〈〉) end, makeENVBinding : Binding × TypeExpr × TRANS → ENV makeENVBinding(b, te, trans) ≡ case b of IdBinding(idb) → case te of TypeName(tn) → if isinId(tn, domainTRANS(trans)) then mk_ENV(〈mk_ENVMapEntrance(tn, b)〉) else mk_ENV(〈〉) end, → mk_ENV(〈〉) end, Make_ProductBinding(pb) → makeENVBindingList( binding_list(pb), typeExprToList(te), trans) end, makeENVBindingList : Binding ∗ × TypeExpr ∗ × TRANS → ENV makeENVBindingList(bl, tel, trans) ≡ if bl = 〈〉 then mk_ENV(〈〉) else overrideENV( makeENVBinding(hd bl, hd tel, trans), makeENVBindingList(tl bl, tl tel, trans)) end, /∗**** ENV map ****∗/ domainENV : ENV → Id ∗ domainENV(env) ≡ if getENVMapEntranceList(env) = 〈〉 then 〈〉 else 〈getFirstENV(hd getENVMapEntranceList(env))〉 domainENV(mk_ENV(tl getENVMapEntranceList(env))) end, rangeENV : ENV → Binding ∗ rangeENV(env) ≡ if getENVMapEntranceList(env) = 〈〉 then 〈〉 461

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1<br />

getTextIdFUNC : Id → Text<br />

getTextIdFUNC(id) ≡ getText(id),<br />

getFUNCMapEntranceList : FUNC → FUNCMapEntrance ∗<br />

getFUNCMapEntranceList(func) ≡ map(func),<br />

/∗**** FUNC end ****∗/<br />

/∗**** ENV ****∗/<br />

updateENV : ENV × ExpType × TRANS → ENV<br />

updateENV(env, et, trans) ≡<br />

case et <strong>of</strong><br />

Known(te) →<br />

case te <strong>of</strong><br />

TypeName(tn) →<br />

if isinId(tn, domainTRANS(trans))<br />

then<br />

/∗Type <strong>of</strong> interest.∗/<br />

removeENV(env, tn)<br />

else<br />

/∗Not type <strong>of</strong> interest.∗/<br />

env<br />

end,<br />

→ env<br />

end,<br />

Unknown → env<br />

end,<br />

setEnv : Access ∗ × ENV → ENV<br />

setEnv(al, env) ≡<br />

if al = 〈〉 then env<br />

else<br />

case hd al <strong>of</strong><br />

AccessValueOrVariableName(vn) →<br />

setEnv(tl al, removeENV(env, id(vn))),<br />

→ setEnv(tl al, env)<br />

end<br />

end,<br />

makeENV : LetBinding × TypeExpr × TRANS → ENV<br />

makeENV(lb, te, trans) ≡<br />

case lb <strong>of</strong><br />

460

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!