Commit 26e941fa authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Ada backend ExprEq fix

parent ee83d9b7
...@@ -898,8 +898,6 @@ def _prim_selector(prim): ...@@ -898,8 +898,6 @@ def _prim_selector(prim):
@expression.register(ogAST.ExprPlus) @expression.register(ogAST.ExprPlus)
@expression.register(ogAST.ExprMul) @expression.register(ogAST.ExprMul)
@expression.register(ogAST.ExprMinus) @expression.register(ogAST.ExprMinus)
@expression.register(ogAST.ExprEq)
@expression.register(ogAST.ExprNeq)
@expression.register(ogAST.ExprGt) @expression.register(ogAST.ExprGt)
@expression.register(ogAST.ExprGe) @expression.register(ogAST.ExprGe)
@expression.register(ogAST.ExprLt) @expression.register(ogAST.ExprLt)
...@@ -921,6 +919,33 @@ def _basic_operators(expr): ...@@ -921,6 +919,33 @@ def _basic_operators(expr):
return code, unicode(ada_string), local_decl return code, unicode(ada_string), local_decl
@expression.register(ogAST.ExprEq)
@expression.register(ogAST.ExprNeq)
def _equality(expr):
code, left_str, local_decl = expression(expr.left)
right_stmts, right_str, right_local = expression(expr.right)
code.extend(right_stmts)
local_decl.extend(right_local)
actual_type = getattr(expr.left.exprType,
'ReferencedTypeName',
None) or expr.left.exprType.kind
basic = find_basic_type(expr.left.exprType) in ('IntegerType',
'Integer32Type',
'BooleanType',
'RealType',
'EnumeratedType',
'ChoiceEnumeratedType')
if basic:
ada_string = u'({left} {op} {right})'.format(
left=left_str, op=expr.operand, right=right_str)
else:
ada_string = u'asn1Scc{asn1}_Equal({left}, {right})'.format(
asn1=actual_type, left=left_str, right=right_str)
if isinstance(expr, ogAST.ExprNeq):
ada_string = u'not {}'.format(ada_string)
return code, unicode(ada_string), local_decl
@expression.register(ogAST.ExprAssign) @expression.register(ogAST.ExprAssign)
def _assign_expression(expr): def _assign_expression(expr):
''' Assignment: almost the same a basic operators, except for strings ''' ''' Assignment: almost the same a basic operators, except for strings '''
...@@ -1361,7 +1386,7 @@ def _decision(dec): ...@@ -1361,7 +1386,7 @@ def _decision(dec):
exp = u'asn1Scc{actType}_Equal(tmp{idx}, {ans})'.format( exp = u'asn1Scc{actType}_Equal(tmp{idx}, {ans})'.format(
actType=actual_type, idx=dec.tmpVar, ans=ans_str) actType=actual_type, idx=dec.tmpVar, ans=ans_str)
if a.openRangeOp == ogAST.ExprNeq: if a.openRangeOp == ogAST.ExprNeq:
exp = 'not ' + exp exp = u'not {}'.format(exp)
else: else:
exp = u'tmp{idx} {op} {ans}'.format(idx=dec.tmpVar, exp = u'tmp{idx} {op} {ans}'.format(idx=dec.tmpVar,
op=a.openRangeOp.operand, ans=ans_str) op=a.openRangeOp.operand, ans=ans_str)
......
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