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 vdl: the value definition list Result: ======= ValueDef_list: the resulting imperative version of the value definition list ∗/ TRValueDefList : ValueDef ∗ × FUNC × TRANS → ValueDef ∗ TRValueDefList(vdl, func, trans) ≡ if vdl = 〈〉 then 〈〉 else 〈TRValueDef(hd vdl, func, trans)〉 TRValueDefList(tl vdl, func, trans) end, /∗Transforms a value definition.∗/ /∗ Arguments: ======= vd: the value definition Result: ======= ValueDef: the resulting imperative version of the value definition ∗/ TRValueDef : ValueDef × FUNC × TRANS → ValueDef TRValueDef(vd, func, trans) ≡ case vd of ExplicitValueDef(st, ve) → if includesTRANSName( Known(type_expr(st)), dom trans) then case binding(st) of IdBinding(id) → let (transve, types) = TRValueExpr( ve, Known(type_expr(st)), func, trans, [ ]) in ExplicitFunctionDef( TRSingleTyping( mk_SingleTyping( 184

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER end binding(st), FunctionTypeExpr( TypeLiteral(UNIT), TOTAL_FUNCTION_ARROW, mk_ResultDesc( NoReadAccessMode, NoWriteAccessMode, type_expr(st)))), func, trans), IdApplication( id, mk_FormalFunctionParameter(〈〉)), transve, NoPreCondition) end else vd end, ExplicitFunctionDef(st, ffa, ve, precond) → case type_expr(st) of FunctionTypeExpr(arg, fa, res) → let /∗Establishes ENV and TYPES.∗/ (b, ffap, env, types, prlet) = TRFormalFuncAppl(ffa, func, trans), types1 = alterTYPESMap(types, prlet), (precond ′ , types2) = TROptPreCondition( precond, Known(TypeLiteral(BOOL)), func, trans, types1), /∗Transforms the value expression.∗/ (transve, types3) = TRValueExpr( ve, Known(type_expr(res)), func, trans, types2) in if prlet = 〈〉 then ExplicitFunctionDef( TRSingleTyping(st, func, trans), ffap, transve, precond ′ ) else ExplicitFunctionDef( TRSingleTyping(st, func, trans), ffap, LetExpr(prlet, transve), precond ′ ) 185

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

end<br />

binding(st),<br />

FunctionTypeExpr(<br />

TypeLiteral(UNIT),<br />

TOTAL_FUNCTION_ARROW,<br />

mk_ResultDesc(<br />

NoReadAccessMode,<br />

NoWriteAccessMode,<br />

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

trans),<br />

IdApplication(<br />

id,<br />

mk_FormalFunctionParameter(〈〉)),<br />

transve, NoPreCondition)<br />

end<br />

else vd<br />

end,<br />

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

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

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

let<br />

/∗Establishes ENV and TYPES.∗/<br />

(b, ffap, env, types, prlet) =<br />

TRFormalFuncAppl(ffa, func, trans),<br />

types1 = alterTYPESMap(types, prlet),<br />

(precond ′ , types2) =<br />

TROptPreCondition(<br />

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

func, trans, types1),<br />

/∗Transforms the value expression.∗/<br />

(transve, types3) =<br />

TRValueExpr(<br />

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

trans, types2) in<br />

if prlet = 〈〉<br />

then<br />

ExplicitFunctionDef(<br />

TRSingleTyping(st, func, trans),<br />

ffap, transve, precond ′ )<br />

else<br />

ExplicitFunctionDef(<br />

TRSingleTyping(st, func, trans),<br />

ffap, LetExpr(prlet, transve),<br />

precond ′ )<br />

185

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

Saved successfully!

Ooh no, something went wrong!