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
The session channels and functions are implemented as generic procedures in SPARK. They're called when the Run and Step procedures are called. However this also implies that the Run and Step procedures change that global state.
Let's assume a channel implementation:
withRFLX.RFLX_Builtin_Types;
withIO;
packageChannelwith
SPARK_Mode
isprocedureSend (Buffer : RFLX.RFLX_Builtin_Types.Bytes) with
Global => (Output => IO.State);
procedureReceive (Buffer : out RFLX.RFLX_Builtin_Types.Bytes;
Length : out RFLX.RFLX_Builtin_Types.Length) with
Global => (Input => IO.State);
functionHas_Datareturn Boolean with
Global => (Input => IO.State);
endChannel;
generic
...
packageRFLX.Test.SessionisprocedureRunwith
Global => null;
endRFLX.Test.Session;
Using this in a RecordFlux session looks as follows:
The problem here is that Session.Run modifies IO.State but this is not annotated.
Options
O1 Generate all states into the code
This would mean to generate all states that are used directly into the code:
withIO;
packageRFLX.Test.SessionisprocedureRunwith
Global => (In_Out => IO.State);
endRFLX.Test.Session;
+ No additional abstractions + Fine grained state descriptions
- Code has to be regenerated on every change in dependencies of the application - Possibly a large number of states - Requires an integration configuration for the code generation
O2 Create a global state for the Session and encapsulate all used states in private packages
This solution creates a separate package hierarchy that defines an abstract state that can be used to encapsulate other abstract states via private packages.
The Session implementation will then just use this state:
withRFLX_State;
packageRFLX.Test.SessionisprocedureRunwith
Global => (In_Out => RFLX_State.Session_State);
endRFLX.Test.Session;
To use the channel it has to be encapsulated by a private package:
packageRFLX_State.Channelwith
SPARK_Mode
isprocedureSend (Buffer : RFLX.RFLX_Builtin_Types.Bytes) with
Global => (Output => RFLX_State.Session_State);
procedureReceive (Buffer : out RFLX.RFLX_Builtin_Types.Bytes;
Length : out RFLX.RFLX_Builtin_Types.Length) with
Global => (Input => RFLX_State.Session_State);
functionHas_Datareturn Boolean with
Global => (Input => RFLX_State.Session_State);
endChannel;
withRFLX_State.IO_Channel;
packageRFLX_State.Channelwith
SPARK_Mode
isprocedureSend (Buffer : RFLX.RFLX_Builtin_Types.Bytes)
isbegin
RFLX_State.IO_Channel.Send (Buffer);
endSend;
procedureReceive (Buffer : out RFLX.RFLX_Builtin_Types.Bytes;
Length : out RFLX.RFLX_Builtin_Types.Length)
isbegin
RFLX_State.IO_Channel.Receive (Buffer, Length);
endReceive;
functionHas_Datareturn Boolean is (RFLX_State.IO_Channel.Has_Data);
endRFLX_State.Channel;
withRFLX.RFLX_Builtin_Types;
withIO;
privatepackageRFLX_State.IO_Channelwith
SPARK_Mode,
Abstract_State => (IO.State with Part_Of => RFLX_State.Session_State)
isprocedureSend (Buffer : RFLX.RFLX_Builtin_Types.Bytes) with
Global => (Output => IO.State);
procedureReceive (Buffer : out RFLX.RFLX_Builtin_Types.Bytes;
Length : out RFLX.RFLX_Builtin_Types.Length) with
Global => (Input => IO.State);
functionHas_Datareturn Boolean with
Global => (Input => IO.State);
endChannel;
The application has to use the channel implementation in RFLX_State then:
Context and Problem
The session channels and functions are implemented as generic procedures in SPARK. They're called when the
Run
andStep
procedures are called. However this also implies that theRun
andStep
procedures change that global state.Let's assume a channel implementation:
Using this in a RecordFlux session looks as follows:
The problem here is that
Session.Run
modifiesIO.State
but this is not annotated.Options
O1 Generate all states into the code
This would mean to generate all states that are used directly into the code:
+ No additional abstractions
+ Fine grained state descriptions
- Code has to be regenerated on every change in dependencies of the application
- Possibly a large number of states
- Requires an integration configuration for the code generation
O2 Create a global state for the Session and encapsulate all used states in private packages
This solution creates a separate package hierarchy that defines an abstract state that can be used to encapsulate other abstract states via private packages.
The root package will just define that state:
The Session implementation will then just use this state:
To use the channel it has to be encapsulated by a private package:
The application has to use the channel implementation in
RFLX_State
then:+ Simple implementation in the code generator
+ Flexible use of dependencies
+ No integration in the code generator required
- Additional abstraction layers
- More boiler plate code
- Coarse state descriptions
The text was updated successfully, but these errors were encountered: