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 end end, removeDuplets( accessList(ar) accessList(ar ′ )), idSet(ar ′ )) /∗Returns an access list of the values of types of interest read from during evaluation of a case branch list.∗/ /∗ Arguments: ======= idset: the functions already evaluated cbl: the case branch list Result: ======= AccessResult: the corresponding access result ∗/ getAccessGenCaseBranch : Id-set × CaseBranch ∗ × ExpType × FUNC × TRANS → AccessResult getAccessGenCaseBranch(idset, cbl, et, func, trans) ≡ if cbl = 〈〉 then mk_AccessResult(〈〉, idset) else let ar = getAccessGen( idset, value_expr(hd cbl), et, func, trans), ar ′ = getAccessGenCaseBranch( idSet(ar), tl cbl, et, func, trans) in mk_AccessResult( removeDuplets( accessList(ar) accessList(ar ′ )), idSet(ar ′ )) end end, /∗**** Access end ****∗/ /∗**** Bindings ****∗/ /∗Makes a product binding from a list of bindings. 272

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER ∗/ /∗ Arguments: ======= bl: the binding list Result: ======= Binding: the corresponding binding ∗/ makeBinding : Binding ∗ → Binding makeBinding(bl) ≡ if len bl = 1 then hd bl else Make_ProductBinding(mk_ProductBinding(bl)) end, /∗Makes a binding list from a value expression list.∗/ /∗ Arguments: ======= length: length of the binding list counter: the number of bindings made so far bl: the binding list vel: the value expression list Results: ===== Binding_list: the resulting binding list ValueExpr_list: the corresponding value expression list ∗/ makeLetBinding : Nat × Nat × Binding ∗ × ValueExpr ∗ → Binding ∗ × ValueExpr ∗ makeLetBinding(length, counter, bl, vel) ≡ if length = 0 then (bl, vel) else let id = makeId(counter) in makeLetBinding( length − 1, counter + 1, bl 〈IdBinding(id)〉, vel 〈Make_ValueOrVariableName( mk_ValueOrVariableName(id))〉) end 273

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

end<br />

end,<br />

removeDuplets(<br />

accessList(ar) accessList(ar ′ )),<br />

idSet(ar ′ ))<br />

/∗Returns an access list <strong>of</strong> the values <strong>of</strong> types<br />

<strong>of</strong> interest read from during evaluation <strong>of</strong> a<br />

case branch list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

idset: the functions already evaluated<br />

cbl: the case branch list<br />

Result:<br />

=======<br />

AccessResult: the corresponding access result<br />

∗/<br />

getAccessGenCaseBranch :<br />

Id-set × CaseBranch ∗ × ExpType × FUNC × TRANS →<br />

AccessResult<br />

getAccessGenCaseBranch(idset, cbl, et, func, trans) ≡<br />

if cbl = 〈〉 then mk_AccessResult(〈〉, idset)<br />

else<br />

let<br />

ar =<br />

getAccessGen(<br />

idset, value_expr(hd cbl), et, func, trans),<br />

ar ′ =<br />

getAccessGenCaseBranch(<br />

idSet(ar), tl cbl, et, func, trans)<br />

in<br />

mk_AccessResult(<br />

removeDuplets(<br />

accessList(ar) accessList(ar ′ )),<br />

idSet(ar ′ ))<br />

end<br />

end,<br />

/∗**** Access end ****∗/<br />

/∗**** Bindings ****∗/<br />

/∗Makes a product binding from a list <strong>of</strong> bindings.<br />

272

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

Saved successfully!

Ooh no, something went wrong!