Commit c28ad6a2 authored by Maxime Perrotin's avatar Maxime Perrotin

Add prefix to RIs

parent a55e4067
......@@ -142,9 +142,11 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.4.5 (07/2016): fixed related to the simulator mode
1.4.5 (07/2016):
- Context variable was not prefixed properly
- Callback function for timers use 64bits integer
- RIs use prefix with unicode separation to avoid name clashes
1.4.4 (06/2016)
- Minor bugfix in Ada backend to support typeless systems
......
......@@ -580,13 +580,13 @@ package {process_name} is'''.format(process_name=process_name,
# When generating a shared library, we need a callback mechanism
ads_template.append(u'type {}_T is access procedure{};'
.format(signal['name'], param_spec))
ads_template.append('pragma Convention(Convention => C,'
' Entity => {}_T);'.format(signal['name']))
ads_template.append('{sig} : {sig}_T;'
ads_template.append(u'pragma Convention(Convention => C,'
u' Entity => {}_T);'.format(signal['name']))
ads_template.append(u'RI{sep}{sig} : {sig}_T;'
.format(sep=UNICODE_SEP, sig=signal['name']))
ads_template.append(u'procedure Register_{sig}(Callback: {sig}_T);'
.format(sig=signal['name']))
ads_template.append('procedure Register_{sig}(Callback: {sig}_T);'
.format(sig=signal['name']))
ads_template.append('pragma Export(C, Register_{sig},'
ads_template.append(u'pragma Export(C, Register_{sig},'
' "register_{sig}");'
.format(sig=signal['name']))
......@@ -595,22 +595,30 @@ package {process_name} is'''.format(process_name=process_name,
'IN')] if 'type' in signal else []
minicv.append(aadl_template(signal['name'], params, 'PI'))
taste_template.append('procedure Register_{sig}'
'(Callback:{sig}_T) is'
taste_template.append(u'procedure Register_{sig}'
u'(Callback:{sig}_T) is'
.format(sig=signal['name']))
taste_template.append('begin')
taste_template.append('{} := Callback;'.format(signal['name']))
taste_template.append('end Register_{};'.format(signal['name']))
taste_template.append('')
taste_template.append(u'begin')
taste_template.append(u'RI{sep}{sig} := Callback;'
.format(sep=UNICODE_SEP, sig=signal['name']))
taste_template.append(u'end Register_{};'.format(signal['name']))
taste_template.append(u'')
else:
ads_template.append(u'procedure {}{};'
.format(signal['name'], param_spec))
ads_template.append(u'pragma import(C, {sig}, "{proc}_RI_{sig}");'
.format(sig=signal['name'], proc=process_name))
ads_template.append(u'procedure RI{}{}{};'
.format(UNICODE_SEP,
signal['name'],
param_spec))
ads_template.append(u'pragma import(C, RI{sep}{sig},'
u' "{proc}_RI_{sig}");'
.format(sep=UNICODE_SEP,
sig=signal['name'],
proc=process_name))
# for the .ads file, generate the declaration of the external procedures
for proc in (proc for proc in process.procedures if proc.external):
ri_header = u'procedure {sig_name}'.format(sig_name=proc.inputString)
ri_header = u'procedure RI{sep}{sig_name}'.format(
sep=UNICODE_SEP,
sig_name=proc.inputString)
params = []
params_spec = u""
if simu:
......@@ -633,27 +641,32 @@ package {process_name} is'''.format(process_name=process_name,
# As for async TM, generate a callback mechanism
ads_template.append(u"type {}_T is access procedure{};"
.format(proc.inputString, params_spec))
ads_template.append('pragma Convention(Convention => C,'
' Entity => {}_T);'.format(proc.inputString))
ads_template.append('{sig} : {sig}_T;'
ads_template.append(u'pragma Convention(Convention => C,'
u' Entity => {}_T);'.format(proc.inputString))
ads_template.append(u'RI{sep}{sig} : {sig}_T;'
.format(sep=UNICODE_SEP, sig=proc.inputString))
ads_template.append(u'procedure Register_{sig}(Callback: {sig}_T);'
.format(sig=proc.inputString))
ads_template.append('procedure Register_{sig}(Callback: {sig}_T);'
.format(sig=proc.inputString))
ads_template.append('pragma Export(C, Register_{sig},'
' "register_{sig}");'
ads_template.append(u'pragma Export(C, Register_{sig},'
u' "register_{sig}");'
.format(sig=proc.inputString))
taste_template.append('procedure Register_{sig}'
taste_template.append(u'procedure Register_{sig}'
'(Callback:{sig}_T) is'
.format(sig=proc.inputString))
taste_template.append('begin')
taste_template.append('{} := Callback;'.format(proc.inputString))
taste_template.append('end Register_{};'.format(proc.inputString))
taste_template.append('')
taste_template.append(u'begin')
taste_template.append(u'RI{sep}{sig} := Callback;'
.format(sep=UNICODE_SEP,
sig=proc.inputString))
taste_template.append(u'end Register_{};'.format(proc.inputString))
taste_template.append(u'')
else:
ads_template.append(ri_header + u';')
ads_template.append(u'pragma import(C, {sig}, "{proc}_RI_{sig}");'
.format(sig=proc.inputString, proc=process_name))
ads_template.append(u'pragma import(C, RI{sep}{sig},'
u' "{proc}_RI_{sig}");'
.format(sep=UNICODE_SEP,
sig=proc.inputString,
proc=process_name))
# for the .ads file, generate the declaration of timers set/reset functions
for timer in process.timers:
......@@ -1066,15 +1079,19 @@ def _call_external_function(output, **kwargs):
shared=", {}'Size".format(p_id)
if is_out_sig else ""))
if list_of_params:
code.append(u'{RI}({params});'
.format(RI=out['outputName'],
code.append(u'RI{sep}{RI}({params});'
.format(sep=UNICODE_SEP,
RI=out['outputName'],
params=', '.join(list_of_params)))
else:
if not SHARED_LIB:
code.append(u'{RI};'.format(RI=out['outputName']))
code.append(u'RI{sep}{RI};'
.format(sep=UNICODE_SEP,
RI=out['outputName']))
else:
code.append(u'{RI}(New_String("{RI}"));'
.format(RI=out['outputName']))
code.append(u'RI{sep}{RI}(New_String("{RI}"));'
.format(sep=UNICODE_SEP,
RI=out['outputName']))
else:
# inner procedure call
list_of_params = []
......@@ -2315,7 +2332,8 @@ def _inner_procedure(proc, **kwargs):
if not proc.return_type
else 'function',
sep=(u'p' + UNICODE_SEP)
if not proc.external else '',
if not proc.external
else u'RI' + UNICODE_SEP,
proc_name=proc.inputString)
if proc.fpar:
......@@ -2343,7 +2361,10 @@ def _inner_procedure(proc, **kwargs):
# Inner procedures declared external by the user: pragma import
# the C symbol with the same name. Overrules the pragma import from
# taste for required interfaces.
local_decl.append(u'pragma import(C, {});'.format(proc.inputString))
local_decl.append(u'pragma import(C, RI{sep}{proc_name}, '
u'"{proc_name}");'
.format(sep=UNICODE_SEP,
proc_name=proc.inputString))
else:
# Generate the code for the procedure itself
# local variables and code of the START transition
......
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