Type system¶
RBL is statically typed, i.e., every constant, variable, parameter and expression has a fixed type. During translation, rbsc type checks the whole model, such that all generated PRISM models are free from type errors.
Types¶
The following types are available in RBL:
boolValues of type
boolcan be eithertrueorfalse.intSigned integers.
doubleDouble-precision floating point values.
actionThe type of action labels which are used for synchronization between components.
- component types
Each type declaration creates a type. Multiple component types can be combined into a type set, for instance
{Type1, Type2}. The predefined type setsnatural,roleandcompartmentcontain all natural types, role types and compartment types defined in the model, respectively. The type setcomponentcomprises all component types defined in the model.array <n> of <type>An array of
typewith sizen. The sizenis part of the type, i.e.,array 2 of intandarray 3 of intare distinct types. Note thattypecan also be anarraytype itself, which allows the definition of multi-dimensional arrays:const squares : array 3 of array 2 of int = [ [1, 1], [2, 4], [3, 9] ];
Component arrays defined in the system block also have an array type:
system { w[3] : Worker; }Here,
whas the typearray 3 of Worker.- function types
A one-argument function has type
<arg-type> -> <return-type>. Functions with multiple arguments are represented by multiple applications of the->type operator (->is left-associative). For example, theminfunction has typeint -> int -> int.
Variable types¶
The type of local and global variables is limited to:
boolbounded integers:
[lower .. upper]arrays of
boolor bounded integers, possibly multi-dimensional
Note that the bounded integer type is equivalent to the int type.
Implicit conversions¶
Values of some types can be automatically converted into values with a different type. The following list contains all implicit conversions allowed in RBL:
inttodoublearray <n> of inttoarray <n> of double<type>toarray <n> of <type>
The last conversion can be used to initialize all elements of an array with the same value, for example:
const ones : array 3 of int = 1;
This definition is equivalent to:
const ones : array 3 of int = [1, 1, 1];