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 truncate(te), fa, mk_ResultDesc( read_access_desc(rd), write_access_desc(rd), truncate(type_expr(rd)))), BracketedTypeExpr(te) → case truncate(te) of TypeLiteral(literal) → case literal of UNIT → truncate(te), → BracketedTypeExpr(truncate(te)) end, → BracketedTypeExpr(truncate(te)) end end, truncateTypeExprProduct : TypeExpr ∗ → TypeExpr ∗ truncateTypeExprProduct(tel) ≡ if tel = 〈〉 then 〈〉 else case hd tel of TypeLiteral(literal) → case literal of UNIT → truncateTypeExprProduct(tl tel), → 〈truncate(hd tel)〉 truncateTypeExprProduct(tl tel) end, → 〈truncate(hd tel)〉 truncateTypeExprProduct(tl tel) end end, equalsType : TypeExpr × ExpType → Bool equalsType(te, et) ≡ case et of Known(ete) → equalsTypes(te, ete), Unknown → false end, equalsTypes : TypeExpr × TypeExpr → Bool equalsTypes(te1, te2) ≡ 408

D.2. FORMAL SPECIFICATION OF THE TRANSFORMER IN RSL1 case te1 of TypeLiteral(literal1) → case te2 of TypeLiteral(literal2) → literal1 = literal2, → false end, TypeName(tn1) → case te2 of TypeName(tn2) → equalsText(getText(tn1), getText(tn2)), → false end, TypeExprProduct(tel1) → case te2 of TypeExprProduct(tel2) → and( lengthTE(tel1) = lengthTE(tel2), equalsTypesProduct(tel1, tel2)), → false end, TypeExprSet(tes1) → case te2 of TypeExprSet(tes2) → equalsTypesSet(tes1, tes2), → false end, TypeExprList(tel1) → case te2 of TypeExprList(tel2) → equalsTypesList(tel1, tel2), → false end, TypeExprMap(tem1) → case te2 of TypeExprMap(tem2) → equalsTypesMap(tem1, tem2), → false end, FunctionTypeExpr(fte1, fa1, rd1) → case te2 of FunctionTypeExpr(fte2, fa2, rd2) → and( and(equalsTypes(fte1, fte2), fa1 = fa2), equalsTypes( 409

APPENDIX D. SPECIFICATION OF TRANSFORMER IN RSL1<br />

truncate(te), fa,<br />

mk_ResultDesc(<br />

read_access_desc(rd),<br />

write_access_desc(rd),<br />

truncate(type_expr(rd)))),<br />

BracketedTypeExpr(te) →<br />

case truncate(te) <strong>of</strong><br />

TypeLiteral(literal) →<br />

case literal <strong>of</strong><br />

UNIT → truncate(te),<br />

→ BracketedTypeExpr(truncate(te))<br />

end,<br />

→ BracketedTypeExpr(truncate(te))<br />

end<br />

end,<br />

truncateTypeExprProduct :<br />

TypeExpr ∗ → TypeExpr ∗<br />

truncateTypeExprProduct(tel) ≡<br />

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

else<br />

case hd tel <strong>of</strong><br />

TypeLiteral(literal) →<br />

case literal <strong>of</strong><br />

UNIT → truncateTypeExprProduct(tl tel),<br />

→<br />

〈truncate(hd tel)〉 <br />

truncateTypeExprProduct(tl tel)<br />

end,<br />

→<br />

〈truncate(hd tel)〉 <br />

truncateTypeExprProduct(tl tel)<br />

end<br />

end,<br />

equalsType : TypeExpr × ExpType → Bool<br />

equalsType(te, et) ≡<br />

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

Known(ete) → equalsTypes(te, ete),<br />

Unknown → false<br />

end,<br />

equalsTypes : TypeExpr × TypeExpr → Bool<br />

equalsTypes(te1, te2) ≡<br />

408

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

Saved successfully!

Ooh no, something went wrong!