Transformation of Applicative Specifications into Imperative ...

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

26.09.2013 Views

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS if vdl = 〈〉 then func else makeFuncMap( tl vdl, func † getMapEntrance(hd vdl, trans), trans) end, /∗Estalishes an entrance in the FUNC map based on a value definition.∗/ /∗ Arguments: ======= vd: the value definition ∗/ getMapEntrance : ValueDef × TRANS → FUNC getMapEntrance(vd, trans) ≡ case vd of ExplicitValueDef(st, ve) → if includesTRANSName( Known(type_expr(st)), dom trans) then case binding(st) of IdBinding(id) → [ id ↦→ mk_FuncSpec( FunctionTypeExpr( TypeLiteral(UNIT), TOTAL_FUNCTION_ARROW, mk_ResultDesc( NoReadAccessMode, NoWriteAccessMode, type_expr(st)) ), ve, 〈〉, 〈〉) ], Make_ProductBinding(pb) → [ ] end else [ ] end, ExplicitFunctionDef(st, ffa, ve, precond) → case binding(st) of IdBinding(id) → [ id ↦→ mk_FuncSpec(type_expr(st), ve, 〈〉, 〈〉) ] end end, 290

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER /∗Expands the FUNC map with read and write lists. ∗/ /∗ Arguments: ======= vdl: the value definition list ∗/ expandFuncMap : ValueDef ∗ × FUNC × TRANS → FUNC expandFuncMap(vdl, func, trans) ≡ if vdl = 〈〉 then func else expandFuncMap( tl vdl, func † expandMapEntrance(hd vdl, func, trans), trans) end, /∗Expands the an entrance in the FUNC map with read and write lists.∗/ /∗ Arguments: ======= vd: the value definition ∗/ expandMapEntrance : ValueDef × FUNC × TRANS → FUNC expandMapEntrance(vd, func, trans) ≡ case vd of ExplicitValueDef(st, ve) → if includesTRANSName( Known(type_expr(st)), dom trans) then case binding(st) of IdBinding(id) → [ id ↦→ mk_FuncSpec( FunctionTypeExpr( TypeLiteral(UNIT), TOTAL_FUNCTION_ARROW, mk_ResultDesc( NoReadAccessMode, NoWriteAccessMode, type_expr(st)) ), ve, 〈〉, 291

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER<br />

/∗Expands the FUNC map with read and write lists.<br />

∗/<br />

/∗<br />

Arguments:<br />

=======<br />

vdl: the value definition list<br />

∗/<br />

expandFuncMap : ValueDef ∗ × FUNC × TRANS → FUNC<br />

expandFuncMap(vdl, func, trans) ≡<br />

if vdl = 〈〉 then func<br />

else<br />

expandFuncMap(<br />

tl vdl,<br />

func † expandMapEntrance(hd vdl, func, trans),<br />

trans)<br />

end,<br />

/∗Expands the an entrance in the FUNC map with<br />

read and write lists.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

vd: the value definition<br />

∗/<br />

expandMapEntrance : ValueDef × FUNC × TRANS → FUNC<br />

expandMapEntrance(vd, func, trans) ≡<br />

case vd <strong>of</strong><br />

ExplicitValueDef(st, ve) →<br />

if<br />

includesTRANSName(<br />

Known(type_expr(st)), dom trans)<br />

then<br />

case binding(st) <strong>of</strong><br />

IdBinding(id) →<br />

[ id ↦→<br />

mk_FuncSpec(<br />

FunctionTypeExpr(<br />

TypeLiteral(UNIT),<br />

TOTAL_FUNCTION_ARROW,<br />

mk_ResultDesc(<br />

NoReadAccessMode,<br />

NoWriteAccessMode, type_expr(st))<br />

), ve, 〈〉,<br />

291

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

Saved successfully!

Ooh no, something went wrong!