Eliminate tuple field projections
This CIF to CIF transformation eliminates tuple field projections by replacing them with tuple index projections.
Implementation details
Obtaining the value of a field of a tuple is called tuple projection. There are two ways to project a tuple. That is, there are two ways to indicate from which field to obtain the value. The first way is to use the name of the field, the second way is to use the 0-based index of the field into the fields of the tuple’s type. For instance:
const tuple(int a; real b) t = (1, 2.0);
const int x = t[a];
const int y = t[0];
Here, both constants x
and y
have value 1
, obtained from field a
of the tuple value of constant t
.
This transformation replaces tuple field projections (using the name of the field), by tuple index projections (using the 0-based index of the field). For instance, for the example above, the result of this transformation is:
const tuple(int a; real b) t = (1, 2.0);
const int x = t[0];
const int y = t[0];