Adding User-Written Code : Mapping Rational Statemate Types into C

Mapping Rational Statemate Types into C

The following table shows how Rational Statemate maps primitive types into corresponding C types:

Note: All Rational Statemate elements of type string are translated into allocated C elements.
 
Records become C constructs. For example, a record INVOICE_TYPE might become a structure defined as:
typedef struct INVOICE_TYPE {
char NAME[80+1];
char ITEM[80+1];
real AMOUNT;
} INVOICE_TYPE;
Note that the name INVOICE_TYPE is normally named the same as the User-Defined Type name. If, however, the Rational Statemate model contains multiple textual elements with the same name, the C code names will be modified to make all the names unique. This name mapping information is listed in the .info file.
Enumerated values and other textual items cannot have the same name within the same scope. For example, data-item SUN cannot be declared in the same chart where an enumerated value SUN is declared.
Enumerated range and indices of arrays are not supported in C. The C code generator shall approximate this capability in the generated code.
en_succ([T’]VAL)

en_pred([T’]VAL)

Parameters to these operators are either enumerated values (literals) or variables. The T’VAL notation is used for non-unique literals.
Bit-arrays are stored in unsigned ints. Since unsigned ints can hold a maximum of 32 bits, bit-arrays larger than 32 bits are stored in arrays of unsigned ints. Arrays of bit-arrays are stored in two dimensional arrays of unsigned ints. Notice that multiple bit-arrays smaller than 32 bits are NOT packed into the unsigned int.

 

 

* In $STM_ROOT/etc/prt/c/types.h you will find the statement: typedef unsigned int bit_array