2.12. Thread and Function Declarations

Figure 2.20. Concrete Syntax for Thread and Function Declarations

[81] <fsm> ::= <thread> | <function>  
[82] <thread> ::= ("active" ("[" <num-active> "]")?)? "thread" <thread-id> "(" <params>? ")" "{" <local-var>* (<low-level-body> | <high-level-body>) "}"  
[83] <num-active> ::= <int-lit> | <const-id> "." <const-elem-positive-int-id>  
[84] <function> ::= "function" <thread-id> "(" <params>? ")" ("returns" <basic-type>)? "{" <local-var>* (<low-level-body> | <high-level-body>) "}"  
[85] <params> ::= <basic-type> <local-id> ("," <basic-type> <local-id>)*  
[86] <local-var> ::= "transient"? <basic-type> <local-id> <local-var-init>? ";"  
[87] <local-var-init> ::= ":=" <local-var-init-cast>? <lit>  
[88] <local-var-init-cast> ::= "(" <basic-type> ")"  

Figure 2.20, “Concrete Syntax for Thread and Function Declarations” presents the concrete syntax for thread and function declarations. Threads and functions are similar, except that functions can return values. If the "active" modifier is used, then the thread is alive in the initial state of the system; one can optionally put the multiplicities for an active thread to specify the number of instances of that thread in the initial state.

There are two kinds of thread and function bodies in BIR: (1) low-level body, and (2) high-level body. Low-level body is unstructured (similar to Java bytecode), while high-level body is structured (similar to Java sourcecode). Bogor actually works on the low-level body; it first translates high-level bodies to their low-level equivalents.

Namespace. The namespace for threads and functions is the global namespace that is shared with constants, enumerations, records, extensions, type-aliases, virtual tables, and functional expressions.

Abstract Syntax Tree. 

Figure 2.21. Java AST for Threads and Functions

Java AST for Threads and Functions
[ .gif, .svg ]

The Java AST class for both thread and function declarations is the FSM class.

2.12.1. Parameters and Local Variables

Namespace. Each thread and function has its own namespace for parameters and local variables (i.e., parameters and local variables share the same namespace), but hiding the name in the global namespace is disallowed.

Abstract Syntax Tree. The Java AST class for parameters is the TypedId class. The Java AST class for local is the Local class.