Commit 50e6c9c5 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Proper handling of the num() predefined operator in Ada

parent 444184c6
...@@ -174,6 +174,8 @@ def _process(process): ...@@ -174,6 +174,8 @@ def _process(process):
with System.IO; with System.IO;
use System.IO; use System.IO;
with Ada.Unchecked_Conversion;
{dataview} {dataview}
with Interfaces; with Interfaces;
...@@ -201,13 +203,6 @@ package {process_name} is'''.format(process_name=process_name, ...@@ -201,13 +203,6 @@ package {process_name} is'''.format(process_name=process_name,
# Generate the code for the process-level variable declarations # Generate the code for the process-level variable declarations
taste_template.extend(process_level_decl) taste_template.extend(process_level_decl)
# Generate the code for the start procedure
#taste_template.extend([
# 'procedure state_start is',
# 'begin',
# 'null;',
# 'end state_start;', ''])
# Add the code of the procedures definitions # Add the code of the procedures definitions
taste_template.extend(inner_procedures_code) taste_template.extend(inner_procedures_code)
...@@ -355,7 +350,7 @@ package {process_name} is'''.format(process_name=process_name, ...@@ -355,7 +350,7 @@ package {process_name} is'''.format(process_name=process_name,
# Declare the local variables needed by the transitions in the template # Declare the local variables needed by the transitions in the template
decl = [u'{line}'.format(line=l) decl = [u'{line}'.format(line=l)
for l in local_decl_transitions] for l in set(local_decl_transitions)]
taste_template.extend(decl) taste_template.extend(decl)
taste_template.append('begin') taste_template.append('begin')
...@@ -798,10 +793,11 @@ def _prim_call(prim): ...@@ -798,10 +793,11 @@ def _prim_call(prim):
(getattr(exp.exprType, 'ReferencedTypeName', None) (getattr(exp.exprType, 'ReferencedTypeName', None)
or exp.exprType.kind).replace('-', '_') or exp.exprType.kind).replace('-', '_')
param_stmts, param_str, local_var = expression(exp) param_stmts, param_str, local_var = expression(exp)
local_decl.append('function num_{t} is new Ada.Unchecked_Conversion'
'(asn1scc{t}, Asn1Int);'.format(t=exp_typename))
stmts.extend(param_stmts) stmts.extend(param_stmts)
local_decl.extend(local_var) local_decl.extend(local_var)
ada_string += ("asn1Scc{t}'Pos({e})".format(t=exp_typename, ada_string += ('num_{t}({p})'.format(t=exp_typename, p=param_str))
e=param_str))
else: else:
ada_string += '(' ada_string += '('
# Take all params and join them with commas # Take all params and join them with commas
......
...@@ -18,7 +18,7 @@ Hello! ...@@ -18,7 +18,7 @@ Hello!
-2 is FALSE -2 is FALSE
2 2 1 2 2 1
FALSE TRUE FALSE TRUE
1 2 13 14
OK OK
[C] result_data: 6 [C] result_data: 6
Hello Toto 5 Hello Toto 5
......
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