Commit 95d69280 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fixed Expr := not { seqof } in Ada backend and added testcase

parent 1a1b1cb4
......@@ -1139,14 +1139,26 @@ def _bitwise_operators(expr):
def _not_expression(expr):
''' Generate the code for a not expression '''
code, local_decl = [], []
if isinstance(expr.expr, ogAST.PrimSequenceOf):
# Raw sequence of boolean (e.g. not "{true, false}") -> flip values
for each in expr.expr.value:
each.value[0] = 'true' if each.value[0] == 'false' else 'false'
expr_stmts, expr_str, expr_local = expression(expr.expr)
bty = find_basic_type(expr.exprType)
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)
ada_string = u'(Data => (not {}.Data){})'.format(expr_str, size_expr)
bty_inner = find_basic_type(expr.expr.exprType)
bty_outer = find_basic_type(expr.exprType)
if bty_outer.kind != 'BooleanType':
if bty_outer.Min == bty_outer.Max:
size_expr = ''
elif bty_inner.Min == bty_inner.Max:
size_expr = ', Length => {}'.format(bty_inner.Min)
else:
size_expr = ', Length => {}.Length'.format(expr_str)
if isinstance(expr.expr, ogAST.PrimSequenceOf):
ada_string = array_content(expr.expr, expr_str, bty_outer)
else:
ada_string = u'(Data => (not {}.Data){})'.format(expr_str,
size_expr)
else:
ada_string = u'(not {expr})'.format(expr=expr_str)
......
......@@ -2,7 +2,7 @@
PROCESS orchestrator
/* CIF COMMENT (405, 192), (71, 35) */
COMMENT 'Hello';
/* CIF TEXT (89, 94), (293, 203) */
/* CIF TEXT (39, 94), (293, 203) */
dcl seq tastE_Peek_id_list;
dcl fixed FixedString := 'Hello';
......@@ -19,43 +19,46 @@ dcl seqen2 SeqEnumFix := { hello, world };
/* CIF ENDTEXT */
/* CIF START (428, 223), (100, 45) */
START;
/* CIF TASK (396, 283), (164, 53) */
/* CIF TASK (366, 283), (223, 38) */
TASK seqboolean := {true, false},
seqboolean := not {true, false};
/* CIF TASK (396, 336), (164, 53) */
TASK for x in seqen:
call writeln(num(x));
endfor;
/* CIF TASK (396, 351), (164, 53) */
/* CIF TASK (396, 404), (164, 53) */
TASK for x in seqen2:
call writeln(num(x));
endfor;
/* CIF TASK (397, 419), (162, 53) */
/* CIF TASK (397, 472), (162, 53) */
TASK for x in seqboolean:
call writeln(x);
endfor
/* CIF COMMENT (579, 428), (168, 38) */
/* CIF COMMENT (579, 481), (168, 38) */
COMMENT 'FOR with a basic type';
/* CIF TASK (367, 487), (222, 35) */
/* CIF TASK (367, 540), (222, 35) */
TASK seqboolean := not seqboolean
/* CIF COMMENT (609, 487), (279, 35) */
/* CIF COMMENT (609, 540), (279, 35) */
COMMENT 'check NOT on a SEQUENCE of BOOLEAN';
/* CIF TASK (397, 537), (162, 53) */
/* CIF TASK (397, 590), (162, 53) */
TASK for x in seqboolean:
call writeln(x);
endfor;
/* CIF TASK (415, 605), (126, 38) */
/* CIF TASK (415, 658), (126, 38) */
TASK fixed := 'hello';
/* CIF TASK (403, 658), (149, 35) */
/* CIF TASK (403, 711), (149, 35) */
TASK variable := 'HELLO';
/* CIF PROCEDURECALL (390, 708), (176, 35) */
/* CIF PROCEDURECALL (390, 761), (176, 35) */
CALL writeln(variable // '!!!');
/* CIF PROCEDURECALL (342, 758), (272, 35) */
/* CIF PROCEDURECALL (342, 811), (272, 35) */
CALL writeln(variable // variable // variable);
/* CIF TASK (432, 808), (91, 35) */
/* CIF TASK (432, 861), (91, 35) */
TASK seq := {1};
/* CIF TASK (401, 858), (153, 35) */
/* CIF TASK (401, 911), (153, 35) */
TASK seq := {1} // {2} // {3};
/* CIF TASK (392, 908), (172, 35) */
/* CIF TASK (392, 961), (172, 35) */
TASK seq := seq // {2} // {1};
/* CIF NEXTSTATE (419, 958), (118, 50) */
/* CIF NEXTSTATE (419, 1011), (118, 50) */
NEXTSTATE Wait_for_GUI;
/* CIF STATE (423, 163), (118, 50) */
STATE Wait_for_GUI;
......
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