Replace Data Values with Record
- You have a set of variables that altogether constitute a record.
Replace the variables by a single record and replace the variable references by references to the record members.
int x; int y; = ...; = ...;
⇓
struct point p; p.x = ...; p.y = ...;
Motivation
During the compilation the record unity is lost, as record members are replaced by mere memory offsets. It is necessary to re-join the record members back in order to recover the original records.
Mechanics
- Define a new record with the appropriate members, if one is not defined already.
- Replace the specified variables declarations by a single record declaration.
- Replace the variables by members of the newly declared record.