Child pages
  • Migration of stucture's enumeration declarations

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Node's property access operations for enumeration properties represents one such situation where the migration changes the code a lot, since the typing rules of these expressions are different between the old and the new enumerations. As an example, consider the following enumeration's classic declaration and smodel code that reads a property of this enumeration's datatype and stores it in a local variable. 

Old declaration of “WeekDays” enumeration


Property declaration “dayOfWeek” of enumeration type “WeekDays”

Image Modified

Usage of “dayOfWeek” property in smodel code


After the migration is applied, we get the following enumeration's declaration:

Image Modified

 

 

Migrated declaration of “WeekDays” enumeration

If naive migration of smodel code was applied, it would merely lead to a type mismatch error between the "string" and the "enummember<WeekDays>" types. Instead, to prevent a typing error, the migration wraps each property access with additional code that restores code's original semantics. In this particular case, migration produces a call to the "name" operation on enum member returned by the property read operation:

Migrated usage of “dayOfWeek” property in smodel code


In the described situation, the produced code might differ depending on the particular old enumeration declaration. There are general rules which migration follows when handling smodel code:

...