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 FunctionTypeExpr(arg, fa, res) → getNonTOIReturnsList( type_expr(res), trans) = 〈〉 end, → true end, → case et of Known(te) → case te of TypeName(tn) → ∼ (tn ∈ dom trans), TypeExprProduct(tel) → getNonTOIReturnsList(te, trans) = 〈〉, FunctionTypeExpr(arg, fa, res) → getNonTOIReturnsList( type_expr(res), trans) = 〈〉, → true end, Unknown → true end end, /∗Gets a list of types that are not of a type of interest from a type expression.∗/ /∗ Arguments: ======= te: the type expression Result: ======= TypeExpr_list: the list of types that are not of a type of interest ∗/ getNonTOIReturnsList : TypeExpr × TRANS → TypeExpr ∗ getNonTOIReturnsList(te, trans) ≡ case te of TypeLiteral(literal) → 〈te〉, TypeName(id) → if (id ∈ dom trans) then 〈〉 else 〈te〉 end, TypeExprProduct(tep) → getNonTOIProduct(tep, trans), TypeExprSet(tes) → 〈te〉, TypeExprList(tel) → 〈te〉, 242

C.1. FORMAL SPECIFICATION OF THE TRANSFORMER TypeExprMap(tem) → 〈te〉, FunctionTypeExpr(arg, fa, res) → getNonTOIReturnsList(type_expr(res), trans), BracketedTypeExpr(bte) → getNonTOIReturnsList(bte, trans) end, /∗Gets a list of types that are not of a type of interest from a type expression list.∗/ /∗ Arguments: ======= tel: the type expression list Result: ======= TypeExpr_list: the list of types that are not of a type of interest ∗/ getNonTOIProduct : TypeExpr ∗ × TRANS → TypeExpr ∗ getNonTOIProduct(tel, trans) ≡ if tel = 〈〉 then 〈〉 else getNonTOIReturnsList(hd tel, trans) getNonTOIProduct(tl tel, trans) end, /∗Gets the variables corresponding to the type expression.∗/ /∗ Arguments: ======= te: the type expression Result: ======= ValueExpr_list: the return values ∗/ getTOIReturnsList : TypeExpr × TRANS → ValueExpr ∗ getTOIReturnsList(te, trans) ≡ case te of TypeLiteral(literal) → 〈〉, TypeName(id) → if id ∈ dom trans 243

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

TypeExprMap(tem) → 〈te〉,<br />

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

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

BracketedTypeExpr(bte) →<br />

getNonTOIReturnsList(bte, trans)<br />

end,<br />

/∗Gets a list <strong>of</strong> types that are not <strong>of</strong> a type<br />

<strong>of</strong> interest from a type expression list.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

tel: the type expression list<br />

Result:<br />

=======<br />

TypeExpr_list: the list <strong>of</strong> types that are not<br />

<strong>of</strong> a type <strong>of</strong> interest<br />

∗/<br />

getNonTOIProduct :<br />

TypeExpr ∗ × TRANS → TypeExpr ∗<br />

getNonTOIProduct(tel, trans) ≡<br />

if tel = 〈〉 then 〈〉<br />

else<br />

getNonTOIReturnsList(hd tel, trans) <br />

getNonTOIProduct(tl tel, trans)<br />

end,<br />

/∗Gets the variables corresponding to the type<br />

expression.∗/<br />

/∗<br />

Arguments:<br />

=======<br />

te: the type expression<br />

Result:<br />

=======<br />

ValueExpr_list: the return values<br />

∗/<br />

getTOIReturnsList :<br />

TypeExpr × TRANS → ValueExpr ∗<br />

getTOIReturnsList(te, trans) ≡<br />

case te <strong>of</strong><br />

TypeLiteral(literal) → 〈〉,<br />

TypeName(id) →<br />

if id ∈ dom trans<br />

243

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

Saved successfully!

Ooh no, something went wrong!