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 Result: ======= ValueExpr: the imperative version of the value expression list ∗/ TRProductExpr : ValueExpr ∗ × ExpType ∗ × ExpType × FUNC × TRANS × TYPES → ValueExpr TRProductExpr(vel, etl, et, func, trans, types) ≡ let (b, vl) = makeLetBinding(len vel, 0, 〈〉, 〈〉), vel ′ = makeValueExprList(vel, etl, vl, trans, func) in LetExpr( 〈mk_LetDef( MakeBinding(makeBinding(b)), ProductExpr(vel))〉, makeAssignExpr(ProductExpr(vel ′ ), et, trans)) end, /∗Transforms a set expression.∗/ /∗ Arguments: ======= se: the set expression et: the expected type the components of the set expression Result: ======= SetExpr: the imperative version of the set expression ∗/ TRSetExpr : SetExpr × ExpType × FUNC × TRANS × TYPES → SetExpr × TYPES TRSetExpr(se, et, func, trans, types) ≡ case se of RangedSetExpr(fve, sve) → let (fve ′ , types ′ ) = TRValueExpr(fve, et, func, trans, types), (sve ′ , types ′′ ) = TRValueExpr(sve, et, func, trans, types ′ ) 200

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER in (RangedSetExpr(fve ′ , sve ′ ), types ′′ ) end, EnumeratedSetExpr(ovel) → let (ovel ′ , types ′ ) = TROptValueExprList( ovel, et, func, trans, types) in (EnumeratedSetExpr(ovel ′ ), types ′ ) end, ComprehendedSetExpr(ve, typlist, or) → let (ve ′ , types1) = TRValueExpr(ve, et, func, trans, types), (or ′ , types2) = TROptRestriction( or, Known(TypeLiteral(BOOL)), func, trans, types1) in (ComprehendedSetExpr(ve ′ , typlist, or ′ ), types2 ) end end, /∗Transforms a list expression.∗/ /∗ Arguments: ======= le: the list expression et: the expected type the components of the list expression Result: ======= ListExpr: the imperative version of the list expression ∗/ TRListExpr : ListExpr × ExpType × FUNC × TRANS × TYPES → ListExpr × TYPES TRListExpr(le, et, func, trans, types) ≡ case le of RangedListExpr(fve, sve) → let 201

APPENDIX C. FORMAL SPECIFICATIONS OF TRANSFORMATIONS<br />

Result:<br />

=======<br />

ValueExpr: the imperative version <strong>of</strong> the value<br />

expression list<br />

∗/<br />

TRProductExpr :<br />

ValueExpr ∗ × ExpType ∗ × ExpType × FUNC ×<br />

TRANS × TYPES →<br />

ValueExpr<br />

TRProductExpr(vel, etl, et, func, trans, types) ≡<br />

let<br />

(b, vl) = makeLetBinding(len vel, 0, 〈〉, 〈〉),<br />

vel ′ =<br />

makeValueExprList(vel, etl, vl, trans, func)<br />

in<br />

LetExpr(<br />

〈mk_LetDef(<br />

MakeBinding(makeBinding(b)),<br />

ProductExpr(vel))〉,<br />

makeAssignExpr(ProductExpr(vel ′ ), et, trans))<br />

end,<br />

/∗Transforms a set expression.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

se: the set expression<br />

et: the expected type the components <strong>of</strong> the set<br />

expression<br />

Result:<br />

=======<br />

SetExpr: the imperative version <strong>of</strong> the set expression<br />

∗/<br />

TRSetExpr :<br />

SetExpr × ExpType × FUNC × TRANS × TYPES →<br />

SetExpr × TYPES<br />

TRSetExpr(se, et, func, trans, types) ≡<br />

case se <strong>of</strong><br />

RangedSetExpr(fve, sve) →<br />

let<br />

(fve ′ , types ′ ) =<br />

TRValueExpr(fve, et, func, trans, types),<br />

(sve ′ , types ′′ ) =<br />

TRValueExpr(sve, et, func, trans, types ′ )<br />

200

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

Saved successfully!

Ooh no, something went wrong!