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 removeDuplets( getAccess(type_expr(st), trans) accessList( getAccessGen( {id}, ve, Known(type_expr(st)), func, trans)))) ], Make_ProductBinding(pb) → [ ] end else [ ] end, ExplicitFunctionDef(st, ffa, ve, precond) → case binding(st) of IdBinding(id) → case type_expr(st) of FunctionTypeExpr(arg, fa, res) → [ id ↦→ mk_FuncSpec( type_expr(st), ve, removeDuplets( getAccess(arg, trans) accessList( getAccessObs( {id}, ve, Known(type_expr(res)), func, trans)) accessList( getAccessObsOptPreCondition( {id}, precond, Known(TypeLiteral(BOOL)), func, trans))), removeDuplets( getAccess(type_expr(res), trans) accessList( getAccessGen( {id}, ve, Known(type_expr(res)), func, trans)))) ] end end end, /∗**** FUNC end ****∗/ 292

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER /∗**** ENV ****∗/ /∗Updates the environment. Types of interests that have been written to must be removed from the ENV.∗/ /∗ Arguments: ======= te: the expected type of the value expression ∗/ updateENV : ENV × ExpType × TRANS → ENV updateENV(env, et, trans) ≡ case et of Known(te) → case te of TypeName(tn) → if tn ∈ dom trans then /∗Type of interest.∗/ env \ {tn} else /∗Not type of interest.∗/ env end, → env end, Unknown → env end, /∗Sets ENV.∗/ /∗ Arguments: ======= al: the list of types of interest written to ∗/ setEnv : Access ∗ × ENV → ENV setEnv(al, env) ≡ if al = 〈〉 then env else case hd al of AccessValueOrVariableName(vn) → setEnv(tl al, env \ {id(vn)}), → setEnv(tl al, env) end 293

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

removeDuplets(<br />

getAccess(type_expr(st), trans) <br />

accessList(<br />

getAccessGen(<br />

{id}, ve,<br />

Known(type_expr(st)), func,<br />

trans)))) ],<br />

Make_ProductBinding(pb) → [ ]<br />

end<br />

else [ ]<br />

end,<br />

ExplicitFunctionDef(st, ffa, ve, precond) →<br />

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

IdBinding(id) →<br />

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

FunctionTypeExpr(arg, fa, res) →<br />

[ id ↦→<br />

mk_FuncSpec(<br />

type_expr(st), ve,<br />

removeDuplets(<br />

getAccess(arg, trans) <br />

accessList(<br />

getAccessObs(<br />

{id}, ve,<br />

Known(type_expr(res)),<br />

func, trans)) <br />

accessList(<br />

getAccessObsOptPreCondition(<br />

{id}, precond,<br />

Known(TypeLiteral(BOOL)),<br />

func, trans))),<br />

removeDuplets(<br />

getAccess(type_expr(res), trans) <br />

accessList(<br />

getAccessGen(<br />

{id}, ve,<br />

Known(type_expr(res)),<br />

func, trans)))) ]<br />

end<br />

end<br />

end,<br />

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

292

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

Saved successfully!

Ooh no, something went wrong!