-
Notifications
You must be signed in to change notification settings - Fork 6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplify code generation caused by generic buffer type #659
Comments
After the refactoring I get a bug box now:
The error points to the function Path_Condition (Ctx : Context; Fld : Field) return Boolean with
Pre =>
Valid_Predecessor (Ctx, Fld); There were no direct changes related to |
Context and Problem Statement
In #46 we added a generic package
Types
to allow the use of custom buffer types in the generated SPARK code.Types
must be a formal parameter of all packages which use the buffer type. Also all packages which depend onTypes
and are used by another package depending onTypes
must be also passed as formal parameter. This leads to complex dependencies between this packages and instantiating them can be very cumbersome. Here is an example related to sessions (cf. #650):A session
S
has a functionF1
with messageM1
as return type.M1
contains a sequenceS1
with messageM2
as sequence element. The generic packages need the following formal parameters:S
Types
M2
Types
S1
Types
M2
Types
M1
Types
M2
Types
S1
Types
M2
Types
F1
M1
Types
M2
Types
S1
Types
M2
Types
Each indentation level represents the formal parameters required to instantiate the corresponding package (e.g,
M1
has the formal parametersTypes
,M2
andS1
). Even this relatively simple example requires a user to instantiate five generic packages to instantiate the generic session packageS
. In realistic cases, the number is likely to be much higher.Considered Options
O1 Use just one instantiation of
Types
All generated code could expect to find an instantiation of
Types
at a specified place (e.g.,{PREFIX}.RFLX_Types
) instead of getting it as formal parameter. A user could customize this instantiation by additional arguments forrflx
or by editing the generated source code directly ({PREFIX}.RFLX_Types
is already generated with predefined types). As a consequence generic packages would not be needed for messages anymore. Generic packages for sessions would only need formal parameters for channels and external functions.+ Much simpler code; no need for many formal parameters and generic packages anymore
− Generated code is fixed to one buffer type, using two different buffer types in one application would not be possible anymore (without duplicating generated code)
− Derived messages cannot be realized by message instantiation when message is not generic package
Decision Outcome
O1
The text was updated successfully, but these errors were encountered: