You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Duplicated from old SF ticket 9, originally posted by Karol Desnos
If a constant state variable of an actor gets its value from an actor parameter, then :
Orcc requires the definition of a default value for the actor parameter in the actor code. (else, "error: Cannot use the variable par in this context because it has no initial value").
In the generated C code, the parameter and the const state variable have different values if the actor is instanciated with a non-default parameter value.
Is this a desired behavior ?
Actor Example:
actor toto(int par = 3) int in ==> int out :
int CONST_VAR = par;
process: action in:[ x ] ==> out:[ y ]
var
int y,
do
y := x + par;
end
end
If the actor is instanciated with parameter value "par=7", C Backend will generate:
/////////////////////////////////////////////////////////////////////////// Parameter values of the instance#definepar 7
/////////////////////////////////////////////////////////////////////////// State variables of the actor#defineCONST_VAR 3
The text was updated successfully, but these errors were encountered:
Mickael Raulet said :
yes!
I believe for 1 you can use int CONST_VAR := par; this will let you initialize the variable
for 2 it is normal.
Karol Desnos said :
Using CONST_VAR := par; instead of CONST_VAR = par; did not impact the value taken by CONST_VAR nor removed the error if "par" has no default value.
When CONST_VAR := par; is used, instead of a #define, CONST_VAR is now a non-const global variable that still takes the default value of "par" instead of the value given in the parameter list of the actor instance.
This following generated code implies that an actor parameter keeps its default value during the actor initialization and takes the instance-specific value afterward.
voidToto_initialize(unsigned intfifo_input_id) {
/* Set initial value to global variable */CONST_VAR=3;
[...]
}
(I just want to confirm this behavior before implementing it in the embedded C backend)
Duplicated from old SF ticket 9, originally posted by Karol Desnos
If a constant state variable of an actor gets its value from an actor parameter, then :
Is this a desired behavior ?
Actor Example:
If the actor is instanciated with parameter value "par=7", C Backend will generate:
The text was updated successfully, but these errors were encountered: