Figure 2.18. Concrete Syntax for Global Variable Declaration
|
Figure 2.18, “Concrete Syntax for Global Variable Declaration” presents the concrete syntax for global variable declarations. Global variables are accessible by any thread, function, or functional expression. If the global initialization is specified in a global variable declaration, then the global variable has the value specified by the literal in the initial state of the model. If the transient modifier is used, then the global variable is not stored in the state vector.
Namespace. The namespace for global variables is the global namespace that is shared with constants, enumerations, records, extensions, type-aliases, threads and functions, virtual tables, and functional expressions.
Examples.
int n1; // int global variable
int n2 := 5; // int global variable
int wrap (0, 255) m1; // int wrap (0, 255) global variable
int wrap (0, 255) m2 := (int wrap (0, 255)) 5; // int wrap (0, 255) global variable
long l1; // long global variable
long l2 := 5L; // long global variable
long l3 := 5l; // long global variable
long l4 := -5L; // long global variable
long l5 := -5l; // long global variable
float f1; // float global variable
float f2 := 1.0F; // float global variable
float f3 := 1.0f; // float global variable
float f4 := -1.0F; // float global variable
float f5 := -1.0f; // float global variable
float f6 := 1F; // float global variable
float f7 := 1f; // float global variable
float f8 := -1F; // float global variable
float f9 := -1f; // float global variable
double d1; // double global variable
double d2 := 1.0; // double global variable
double d3 := 1.0D; // double global variable
double d4 := 1.0d; // double global variable
double d5 := -1.0; // double global variable
double d6 := -1.0D; // double global variable
double d7 := -1.0d; // double global variable
double d8 := 1D; // double global variable
double d9 := 1d; // double global variable
double d10 := -1D; // double global variable
double d11 := -1d; // double global variable
int c := 'c'; // char/int global variable
boolean b1 := true; // boolean global variable
boolean b2 := false; // boolean global variable
string s1 := null; // string global variable
string s2 := "s"; // string global variable
Abstract Syntax Tree.
The Java AST class for global variable declaration is the Global class.