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

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

8.3. SPECIFICATION OF THE TRANSFORMER<br />

The TRANS map maps each type <strong>of</strong> interest to the corresponding variable<br />

name. This map is established from the user input and is used both<br />

during the check for transformability and during the transformation phase<br />

in order to figure out what the type names <strong>of</strong> the types <strong>of</strong> interest are and<br />

in order to do proper variable replacements.<br />

The TYPINGS Map<br />

The map TYPINGS is defined as follows:<br />

TYPINGS = Id →m Id ∗<br />

The TYPINGS map maps type name identifiers to the list <strong>of</strong> type identifiers<br />

obtained by recursively expanding the right hand side <strong>of</strong> the type definitions.<br />

This means that the type definition:<br />

results in the TYPINGS map:<br />

A = B × C,<br />

B = D,<br />

C = A,<br />

D = Int<br />

TYPINGS =<br />

[ A ↦→ 〈B, C, D, A〉,<br />

B ↦→ 〈D〉,<br />

C ↦→ 〈A, B, C, D〉,<br />

D ↦→ 〈〉 ]<br />

The TYPINGS map is used to check that types <strong>of</strong> interests are not recursively<br />

defined and that they are not part <strong>of</strong> sets, lists and maps. The<br />

RSL type checker only checks that types are not recursively defined through<br />

abbreviation type definitions, while recursion through union, short record<br />

and variant type definitions is allowed. For example, a type definition <strong>of</strong> the<br />

form:<br />

Elem,<br />

Collection == empty | add(Elem, Collection)<br />

is allowed in RSL but not allowed when using the transformer.<br />

The value <strong>of</strong> the TYPINGS map is computed in the beginning <strong>of</strong> the<br />

transformation in the function TRClassExpr and this value is not altered<br />

during the transformation.<br />

75

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

Saved successfully!

Ooh no, something went wrong!