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 te: the type expression of the function argument fa: the function arrow rd: the result description of the function Result: ======= TypeExpr: the resulting imperative version of the function definition ∗/ TRFunctionDef : Id × TypeExpr × FunctionArrow × ResultDesc × FUNC × TRANS → TypeExpr TRFunctionDef(id, te, fa, rd, func, trans) ≡ let rl = read_list(func(id)), wl = write_list(func(id)), te ′ = TRTypeExpr(id, te, func, trans), rd ′ = TRTypeExpr(id, type_expr(rd), func, trans) in FunctionTypeExpr( truncate(te ′ ), fa, mk_ResultDesc( makeReadAccessDesc(rl, trans), makeWriteAccessDesc(wl, trans), truncate(rd ′ ))) end, /∗Transforms a formal function application.∗/ /∗ Arguments: ======= ffa: the formal function application Result: ======= FormalFunctionApplication: the imperative version of the formal function application LetDef_list: the resulting let expression ∗/ TRFormalFuncAppl : FormalFunctionApplication × FUNC × TRANS → Bool × FormalFunctionApplication × ENV × TYPES × LetDef ∗ TRFormalFuncAppl(ffa, func, trans) ≡ case ffa of 188

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER IdApplication(id, ffp) → case type_expr(func(id)) of FunctionTypeExpr(arg, fa, res) → let /∗Transforms the formal function parameter list. ∗/ (b, ffap, env, types, prlet) = TRFormalFuncParam( ffp, arg, trans, [ ], [ ], 〈〉) in (b, IdApplication(id, ffap), env, types, prlet) end end, → (true, ffa, [ ], [ ], 〈〉) end, /∗Transforms a formal function parameter.∗/ /∗ Arguments: ======= ffpl: the formal function parameter te: the type of the formal function parameter prlet: let expression used to access types of interests that are abbreviation types Result: ======= FormalFunctionParameter_list: the imperative version of the formal function parameter list LetDef_list: the resulting let expression ∗/ TRFormalFuncParam : FormalFunctionParameter × TypeExpr × TRANS × ENV × TYPES × LetDef ∗ → Bool × FormalFunctionParameter × ENV × TYPES × LetDef ∗ TRFormalFuncParam(ffpl, te, trans, env, types, prlet) ≡ if binding_list(ffpl) = 〈〉 then (true, mk_FormalFunctionParameter(〈〉), env, types, prlet) else case te of TypeLiteral(literal) → (true, ffpl, env, 189

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

te: the type expression <strong>of</strong> the function argument<br />

fa: the function arrow<br />

rd: the result description <strong>of</strong> the function<br />

Result:<br />

=======<br />

TypeExpr: the resulting imperative version <strong>of</strong><br />

the function definition<br />

∗/<br />

TRFunctionDef :<br />

Id × TypeExpr × FunctionArrow × ResultDesc ×<br />

FUNC × TRANS →<br />

TypeExpr<br />

TRFunctionDef(id, te, fa, rd, func, trans) ≡<br />

let<br />

rl = read_list(func(id)),<br />

wl = write_list(func(id)),<br />

te ′ = TRTypeExpr(id, te, func, trans),<br />

rd ′ = TRTypeExpr(id, type_expr(rd), func, trans)<br />

in<br />

FunctionTypeExpr(<br />

truncate(te ′ ), fa,<br />

mk_ResultDesc(<br />

makeReadAccessDesc(rl, trans),<br />

makeWriteAccessDesc(wl, trans),<br />

truncate(rd ′ )))<br />

end,<br />

/∗Transforms a formal function application.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

ffa: the formal function application<br />

Result:<br />

=======<br />

FormalFunctionApplication: the imperative version<br />

<strong>of</strong> the formal function application<br />

LetDef_list: the resulting let expression<br />

∗/<br />

TRFormalFuncAppl :<br />

FormalFunctionApplication × FUNC × TRANS →<br />

Bool × FormalFunctionApplication × ENV ×<br />

TYPES × LetDef ∗<br />

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

case ffa <strong>of</strong><br />

188

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

Saved successfully!

Ooh no, something went wrong!