Commit e5432245 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fixed Expr := NOT Expr in Ada backend

parent 6d7fdbaf
...@@ -671,7 +671,6 @@ def _task_forloop(task): ...@@ -671,7 +671,6 @@ def _task_forloop(task):
stop=stop_str)]) stop=stop_str)])
else: else:
# case of form: FOR x in SEQUENCE OF # case of form: FOR x in SEQUENCE OF
elem_type = loop['type'].ReferencedTypeName.replace('-', '_')
list_stmt, list_str, list_local = expression(loop['list']) list_stmt, list_str, list_local = expression(loop['list'])
basic_type = find_basic_type(loop['list'].exprType) basic_type = find_basic_type(loop['list'].exprType)
list_payload = list_str + string_payload(loop['list'], list_str) list_payload = list_str + string_payload(loop['list'], list_str)
...@@ -683,8 +682,8 @@ def _task_forloop(task): ...@@ -683,8 +682,8 @@ def _task_forloop(task):
stmt.extend(list_stmt) stmt.extend(list_stmt)
local_decl.extend(list_local) local_decl.extend(list_local)
stmt.extend(['declare', stmt.extend(['declare',
'{it} : asn1Scc{it_ty};'.format(it=loop['var'], '{} : {};'.format(loop['var'],
it_ty=elem_type), type_name(loop['type'])),
'', '',
'begin', 'begin',
'for {it}_idx in {rc} loop'.format(it=loop['var'], 'for {it}_idx in {rc} loop'.format(it=loop['var'],
...@@ -1142,10 +1141,12 @@ def _not_expression(expr): ...@@ -1142,10 +1141,12 @@ def _not_expression(expr):
code, local_decl = [], [] code, local_decl = [], []
expr_stmts, expr_str, expr_local = expression(expr.expr) expr_stmts, expr_str, expr_local = expression(expr.expr)
basic_type = find_basic_type(expr.exprType) bty = find_basic_type(expr.exprType)
if basic_type.kind != 'BooleanType': if bty.kind != 'BooleanType':
size_expr = ', Length => {}.Length'.format(expr_str) \
if bty.Min != bty.Max else ''
expr_payload = expr_str + string_payload(expr.expr, expr_str) expr_payload = expr_str + string_payload(expr.expr, expr_str)
ada_string = u'(Data => (not {expr}))'.format(expr=expr_payload) ada_string = u'(Data => (not {}.Data){})'.format(expr_str, size_expr)
else: else:
ada_string = u'(not {expr})'.format(expr=expr_str) ada_string = u'(not {expr})'.format(expr=expr_str)
...@@ -1763,6 +1764,20 @@ def find_basic_type(a_type): ...@@ -1763,6 +1764,20 @@ def find_basic_type(a_type):
return basic_type return basic_type
def type_name(a_type):
''' Check the type kind and return an Ada usable type name '''
if a_type.kind == 'ReferenceType':
return 'asn1Scc{}'.format(a_type.ReferencedTypeName.replace('-', '_'))
elif a_type.kind == 'BooleanType':
return 'Boolean'
elif a_type.kind.startswith('Integer'):
return 'Asn1Int'
elif a_type.kind == 'RealType':
return 'Long_Float'
else:
raise NotImplmentedError('Type name for {}'.format(a_type.kind))
def find_var(var): def find_var(var):
''' Return a variable from the scope, with proper case ''' ''' Return a variable from the scope, with proper case '''
for visible_var in VARIABLES.viewkeys(): for visible_var in VARIABLES.viewkeys():
......
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