Transformation of Applicative Specifications into Imperative ...
Transformation of Applicative Specifications into Imperative ... Transformation of Applicative Specifications into Imperative ...
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
- Page 154 and 155: APPENDIX A. USING AND EXTENDING THE
- Page 156 and 157: APPENDIX B. CONTENTS OF CD-ROM 140
- Page 158 and 159: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 160 and 161: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 162 and 163: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 164 and 165: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 166 and 167: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 168 and 169: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 170 and 171: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 172 and 173: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 174 and 175: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 176 and 177: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 178 and 179: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 180 and 181: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 182 and 183: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 184 and 185: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 186 and 187: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 188 and 189: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 190 and 191: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 192 and 193: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 194 and 195: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 196 and 197: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 198 and 199: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 200 and 201: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 202 and 203: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 206 and 207: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 208 and 209: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 210 and 211: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 212 and 213: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 214 and 215: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 216 and 217: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 218 and 219: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 220 and 221: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 222 and 223: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 224 and 225: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 226 and 227: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 228 and 229: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 230 and 231: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 232 and 233: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 234 and 235: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 236 and 237: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 238 and 239: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 240 and 241: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 242 and 243: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 244 and 245: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 246 and 247: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 248 and 249: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 250 and 251: APPENDIX C. FORMAL SPECIFICATIONS O
- Page 252 and 253: APPENDIX C. FORMAL SPECIFICATIONS O
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