Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...

26.09.2013 Views

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1 makeValueExprList( tl vel, tl etl, tl vl, trans, func) else 〈hd vl〉 makeValueExprList( tl vel, tl etl, tl vl, trans, func) end end, makeSequencingExpr : ValueExpr × TypeExpr × ExpType × TRANS × FUNC → ValueExpr makeSequencingExpr(ve, te, et, trans, func) ≡ if and( and( isGen(ve, et, trans, func), not(returnsNonTOI(ve, et, trans, func))), not(equalsType(te, et))) then BracketedExpr( SequencingExpr( ve, toValueExpr(getTOIReturnsList(te, trans)))) else ve end, /∗**** ValueExpr end ****∗/ /∗**** Generators and observers ****∗/ containsGen : ValueExpr ∗ × ExpType ∗ × TRANS × FUNC → Bool containsGen(vel, etl, trans, func) ≡ if vel = 〈〉 then false else if and( isGen(hd vel, hd etl, trans, func), not( returnsNonTOI(hd vel, hd etl, trans, func)) ) then true 416

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1 else containsGen(tl vel, tl etl, trans, func) end end, isGen : ValueExpr × ExpType × TRANS × FUNC → Bool isGen(ve, et, trans, func) ≡ case ve of ApplicationExpr(vea, vel) → case vea of Make_ValueOrVariableName(vn) → not( lengthAccess( write_list( getMapValueFUNC(func, id(vn)))) = 0), → false end, → case et of Known(te) → case te of TypeName(tn) → isinId(tn, domainTRANS(trans)), TypeExprProduct(tel) → isGenProduct(ve, tel, trans, func), FunctionTypeExpr(arg, fa, res) → isGen( ve, Known(type_expr(res)), trans, func ), BracketedTypeExpr(bte) → isGen(ve, Known(bte), trans, func), → false end, Unknown → false end end, isGenProduct : ValueExpr × TypeExpr ∗ × TRANS × FUNC → Bool isGenProduct(ve, tel, trans, func) ≡ if tel = 〈〉 then false else if isGen(ve, Known(hd tel), trans, func) then true else isGenProduct(ve, tl tel, trans, func) end 417

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1<br />

else containsGen(tl vel, tl etl, trans, func)<br />

end<br />

end,<br />

isGen : ValueExpr × ExpType × TRANS × FUNC → Bool<br />

isGen(ve, et, trans, func) ≡<br />

case ve <strong>of</strong><br />

ApplicationExpr(vea, vel) →<br />

case vea <strong>of</strong><br />

Make_ValueOrVariableName(vn) →<br />

not(<br />

lengthAccess(<br />

write_list(<br />

getMapValueFUNC(func, id(vn)))) = 0),<br />

→ false<br />

end,<br />

→<br />

case et <strong>of</strong><br />

Known(te) →<br />

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

TypeName(tn) →<br />

isinId(tn, domainTRANS(trans)),<br />

TypeExprProduct(tel) →<br />

isGenProduct(ve, tel, trans, func),<br />

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

isGen(<br />

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

),<br />

BracketedTypeExpr(bte) →<br />

isGen(ve, Known(bte), trans, func),<br />

→ false<br />

end,<br />

Unknown → false<br />

end<br />

end,<br />

isGenProduct :<br />

ValueExpr × TypeExpr ∗ × TRANS × FUNC → Bool<br />

isGenProduct(ve, tel, trans, func) ≡<br />

if tel = 〈〉 then false<br />

else<br />

if isGen(ve, Known(hd tel), trans, func) then true<br />

else isGenProduct(ve, tl tel, trans, func)<br />

end<br />

417

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

Saved successfully!

Ooh no, something went wrong!