26.09.2013 Views

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

Transformation of Applicative Specifications into Imperative ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

CHAPTER 8. SPECIFICATIONS<br />

8.4.1 More Than One Return Value<br />

As the RSL2Java tool can only handle functions with one return value, it<br />

is necessary to change functions with more than one return value. This is<br />

achieved by introducing short record definitions consisting <strong>of</strong> fields representing<br />

all the types returned by the function. An example <strong>of</strong> such a change<br />

is shown in Example 8.2.<br />

Example 8.2 – From many return values to one return value<br />

RSL specification:<br />

value<br />

CheckOptValueExprPairList :<br />

OptionalValueExprPairList × MapType × TYPINGS ×<br />

FUNC × TRANS × ENV × TYPES →<br />

Bool × ENV × TYPES<br />

CheckOptValueExprPairList(<br />

ovel, et, typings, func, trans, env, types) ≡<br />

case ovel <strong>of</strong><br />

ValueExprPairList(vel) →<br />

CheckValueExprPairList(<br />

vel, et, typings, func, trans, env, types),<br />

NoValueExprPairList → (true, env, types)<br />

end<br />

RSL1 specification:<br />

type<br />

BOOL_ENV_TYPES ::<br />

bool : Bool envMap : ENV typesMap : TYPES<br />

value<br />

CheckOptValueExprPairList :<br />

OptionalValueExprPairList × MapType × TYPINGS ×<br />

FUNC × TRANS × ENV × TYPES →<br />

BOOL_ENV_TYPES<br />

CheckOptValueExprPairList(<br />

ovel, et, typings, func, trans, env, types) ≡<br />

case ovel <strong>of</strong><br />

ValueExprPairList(vel) →<br />

CheckValueExprPairList(<br />

82

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

Saved successfully!

Ooh no, something went wrong!