Commit 929656d2 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Add code in the STG file

parent af43aed0
......@@ -101,12 +101,8 @@ def _process(process, simu=False, stgfile='ada_source.st', **kwargs):
# Initialize array of strings containing all local declarations
process_decl, process_vars = dcl(process, simu)
# Generate the code to declare process-level variables
process_level_decl = []
# Set the DCL declarations variable in the process template
process_template['decl'] = process_decl
process_template['dcl'] = process_decl
process_template['vars'] = process_vars
......@@ -136,17 +132,16 @@ def _process(process, simu=False, stgfile='ada_source.st', **kwargs):
return
# Generate the the code of the procedures
inner_procedures_decl = []
inner_procedures_code = []
for proc in process.content.inner_procedures:
proc_code, proc_local = generate(proc)
process_level_decl.extend(proc_local)
inner_procedure_decl.extend(proc_local)
inner_procedures_code.extend(proc_code)
# Generate the code for the process-level variable declarations
taste_template.extend(process_level_decl)
# Add the code of the procedures definitions
taste_template.extend(inner_procedures_code)
process_template['pdecl'] = inner_procedure_decl
process_template['pcode'] = inner_procedures_code
# Generate the code for each input signal (provided interface) and timers
for signal in process.input_signals + [
......
......@@ -2,14 +2,16 @@ group adb;
/* top-level: template for the code of a process
* name: process name
* decl: list of local declarations
* vars: list of local variables and sort:dictionnary { name: str, sort: str })
* dcl: list of local declarations
* pdecl : inner procedure declarations (array)
* pcode : inner procedure code (array)
* vars: list of local variables and sort: { name: str, sort: str })
* constants: list of start named start transitions (when using substates)
* states: list of states
* asn1_mod : list of ASN.1 modules
* simu, dll : flags set by the user for generation of optional code
*/
process(name, decl, vars, constants, states, asn1_mod, simu, dll) ::= <<
process(name, decl, pdecl, pcode vars, constants, states, asn1_mod, simu, dll) ::= <<
-- This file was generated automatically: DO NOT MODIFY !
<if(asn1_mod)>
......@@ -42,14 +44,18 @@ use Interfaces.C.Strings;
<endif>
package body <name> is
<if(decl)>
<if(dcl)>
-- Local variables declared in textboxes
<decl; separator="\n">
<dcl; separator="\n">
<endif>
---------------------------------------------------------------------------
-- List of SDL states, and variable holding the current state
type States is (<states; separator=", ">);
state: States;
<if(pdecl)>
-- Declaration of inner procedures
<pdecl; separator="\n">
<endif>
<if(simu)>
-- External API to get/set the SDL state from a remote C application
......@@ -82,6 +88,7 @@ end dll_set_l_<each.name>;
}; separator="\n">
---------------------------------------------------------------------------
<endif>
<pcode; separator="\n">
-- Process initialization: execute the START transition)
begin
......@@ -103,6 +110,34 @@ pragma Export(C, dll_set_l_<var.name>, "_set_<var.name>");
>>
/* Code for a provided interface */
pi_definition(header, name, cases) ::= <<
-- Provided interface <name>
<header> is
begin
case state is
<code; separator="\n">
when others =>
null;
end case;
end <name>;
>>
/* Provided interface declaration, to be used in header/source file */
pi_declaration(header, process, name) ::= <<
<header>;
pragma Export(C, <name>, "<process>_<name>");
>>
/* Provided interface header, used in declaration and definition */
pi_signature(name, param_name, param_sort) ::= <<
procedure <name>
<if(param_sort)>
(<if(param_name)><param_name><else><name>_param<endif>: access <param_sort>)
<endif>
>>
/* Code for a (stateless) procedure */
procedure_definition(header, name, dcl, other_decl, start, labels) ::= <<
<header> is
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment