Commit 16255b5d authored by Maxime Perrotin's avatar Maxime Perrotin

Improve parsing of FPAR at process level

parent 8967ea74
......@@ -112,6 +112,7 @@ def external_ri_list(process):
Used for the formal parameters of generic packages when using process type
'''
result = []
#print process.fpar
for signal in process.output_signals:
param_name = signal.get('param_name') \
or u'{}_param'.format(signal['name'])
......@@ -518,6 +519,9 @@ package body {process_name} is'''.format(
if instance:
instance_decl = u"with {};".format(process.instance_of_name)
# print process.fpar
# FPAR could be set for Context Parameters. They are available here
# Generate the source file (.ads) header
ads_template = [u'''\
-- This file was generated automatically: DO NOT MODIFY IT !
......
......@@ -5122,11 +5122,29 @@ def pr_file(root):
return non_ref_processes, process_types
non_ref_p, p_types = find_processes(system)
def find_ref_processes_with_fpar(block):
''' Recursively find referenced processes having FPAR '''
# They may contain FPAR sections that must not be lost...
try:
ref_processes = [proc for proc in block.processes
if proc.referenced and proc.fpar]
except AttributeError:
ref_processes = []
for nested in block.blocks:
add_p = find_ref_processes_with_fpar(nested)
ref_processes.extend(add_p)
return ref_processes
ref_p_with_fpar = find_ref_processes_with_fpar(system)
ast.processes.extend(non_ref_p)
ast.process_types.extend(p_types)
for child in processes:
# process definition at root level (can be a process type)
process, err, warn = process_definition(child, parent=ast)
# check if the process was declared as referenced with FPAR
for each in ref_p_with_fpar:
if each.processName == process.processName:
process.fpar = each.fpar
ast.processes.append(process)
process.dataview = types()
process.asn1Modules = ast.asn1Modules
......
include ../shared.mk
ROOT_MODEL=system_structure.pr
edit:
$(OPENGEODE) function_in_sdl.pr system_structure.pr
test-parse:
$(OPENGEODE) function_in_sdl.pr system_structure.pr --check
test-qgen-parse:
$(TESTQGEN_PARSE) $(ROOT_MODEL)
test-qgen-ada:
$(TESTQGEN_ADA) $(ROOT_MODEL)
test-qgen-c:
$(TESTQGEN_C) $(ROOT_MODEL)
test-qgen-gt-ada:
$(TESTQGEN_GT_ADA) $(ROOT_MODEL)
test-qgen-gt-c:
$(TESTQGEN_GT_C) $(ROOT_MODEL)
test-ada: function_in_sdl.ali dataview-uniq.o
test-c: function_in_sdl.c test_c.o dataview-uniq.o
$(CC) function_in_sdl.c -c -o function_in_sdl.o
$(CC) test_c.o function_in_sdl.c dataview-uniq.o -lm -o test_c
./test_c
test-llvm: function_in_sdl.o
coverage:
coverage run -p $(OPENGEODE) function_in_sdl.pr system_structure.pr --toAda
.PHONY: edit test-parse test-qgen-parse test-ada test-llvm coverage
In this system a FPAR section is added to the referenced process in system_structure.pr
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
END
DataView DEFINITIONS AUTOMATIC TAGS ::= BEGIN
T-INTEGER ::= INTEGER (0..255)
--T-BOOL ::= BOOLEAN
--
--T-ENUM ::= ENUMERATED { one(1), two(2), three(3) }
--
--T-REAL ::= REAL (0.0 .. 7.7)
T-SEQUENCE ::= SEQUENCE {
x T-INTEGER,
y T-INTEGER
}
--T-SEQOF ::= SEQUENCE (SIZE (0..5)) OF T-INTEGER
--
--T-CHOICE ::= CHOICE {
-- boolchoice T-BOOL,
-- enumchoice T-ENUM,
-- intchoice T-INTEGER
--}
--
--T-SET ::= SET {
-- ii T-INTEGER,
-- jj T-BOOL
--}
--
--T-SETOF ::= SET (SIZE(0..5)) OF T-INTEGER
--
--T-OCTSTR ::= OCTET STRING (SIZE(0..5))
--
--T-NESTED ::= SEQUENCE {
-- myint T-INTEGER,
-- mybool T-BOOL,
-- myenum T-ENUM,
-- myreal T-REAL,
-- myseq T-SEQUENCE,
-- myseqof T-SEQOF,
-- mychoice T-CHOICE,
-- myset T-SET,
-- mysetof T-SETOF,
-- myoctstr T-OCTSTR
--}
END
Context-function-in-sdl DEFINITIONS ::=
BEGIN
IMPORTS
T-INTEGER FROM DataView;
-- Group all context parameters of this function in a record
Context-function-in-sdl ::= SEQUENCE {
abc T-INTEGER
}
-- Declare a constant with the values set by the user in the interface view
function-in-sdl-ctxt Context-function-in-sdl ::= {
abc 42
}
END
process Function_In_Sdl;
/* CIF START (320, 10), (70, 35) */
start;
nextstate Wait;
/* CIF STATE (450, 10), (70, 35) */
state Wait;
endstate;
endprocess;
-- Header file for function Function_in_SDL in SDL language
-- Component type : FALSE
-- Instance of :
-- Generated by TASTE on 2019-10-24 15:06:02
-- Context Parameters present : YES
-- Provided interfaces : pulse
-- Required interfaces :
-- User-defined properties for this function:
-- * Taste::Active_Interfaces = any
-- * Taste::coordinates = 346 270 539 424
-- DO NOT EDIT THIS FILE, IT WILL BE OVERWRITTEN DURING THE BUILD
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
use Datamodel;
system Function_In_Sdl;
signal pulse;
channel c
from env to Function_In_Sdl with pulse;
endchannel;
block Function_In_Sdl;
signalroute r
from env to Function_In_Sdl with pulse;
connect c and r;
process Function_In_Sdl referenced;
fpar toto T_Integer;
endblock;
endsystem;
......@@ -27,7 +27,9 @@ val2 := {9, 10, 11, 12};
/* CIF output (429, 1217), (119, 35) */
output response (val1);
/* CIF task (407, 1272), (162, 35) */
task val1 (0, 1) := val2 (3, 4);
task 'val1 (0, 1) := val2 (3, 4)'
/* CIF comment (589, 1272), (285, 35) */
comment 'Cannot do that, because Seq size is variable';
/* CIF NEXTSTATE (453, 1322), (70, 35) */
NEXTSTATE Wait;
endstate;
......@@ -49,7 +51,7 @@ val2 := {9, 10, 11, 12};
/* CIF output (429, 777), (119, 35) */
output response (val1);
/* CIF task (411, 832), (155, 35) */
task val1 (0, 1) := {42, 43};
task 'val1 (0, 1) := {42, 43}';
/* CIF NEXTSTATE (453, 887), (70, 35) */
NEXTSTATE Step3;
endstate;
......
......@@ -16,7 +16,7 @@ void myfunction_RI_result_data(long long *val)
printf("[C] result_data: %lld\n", *val);
}
void myfunction_RI_set_mytimer(asn1SccT_Int32 *val)
void myfunction_RI_SET_mytimer(asn1SccT_Int32 *val)
{
printf("[C] SET MyTimer: %lld\n", *val);
alarm(((int)*val) / 1000);
......@@ -30,7 +30,7 @@ void timer_expired()
}
void myfunction_RI_reset_mytimer()
void myfunction_RI_RESET_mytimer()
{
printf("RESET MyTimer\n");
}
......
Markdown is supported
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