Commit 8de21056 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix issue with statechart renderer

parent 557c3e61
......@@ -1349,30 +1349,32 @@ def arithmetic_expression(root, context):
# accordingly with the kind of operation used between operands:
left = find_basic_type(expr.left.exprType)
right = find_basic_type(expr.right.exprType)
minL = float(left.Min)
maxL = float(left.Max)
minR = float(right.Min)
maxR = float(right.Max)
# Constants defined in ASN.1 : take their value for the range
if isinstance(expr.left, ogAST.PrimConstant):
minL = maxL = float (expr.left.constant_value)
if isinstance(expr.right, ogAST.PrimConstant):
minR = maxR = float (expr.right.constant_value)
# Type of the resulting expression depends on whether there are raw numbers
# on one side of the expression (PrInt). By default when they are parsed,
# they are set to 64 bits integers ; but if they are in an expression where
# the other side is 32 bits (Length or for loop range) then the resulting
# expression is 32 bits.
basic = right if left.__name__ == 'PrInt' else left
# When one side of the expression is a raw (universal) number, in backends
# the type is inherited from the other side of the expression
# e.g. x - 1 is of type x. Keep track of this resulting type in
# "expected_type" to make sure that backends know if the type is signed
# or unsigned, even if the computed range is lower than 0
expr.expected_type = expr.left.exprType if right.__name__ == 'PrInt' \
else expr.right.exprType if left.__name__ == 'PrInt' \
else None
try:
minL = float(left.Min)
maxL = float(left.Max)
minR = float(right.Min)
maxR = float(right.Max)
# Constants defined in ASN.1 : take their value for the range
if isinstance(expr.left, ogAST.PrimConstant):
minL = maxL = float (expr.left.constant_value)
if isinstance(expr.right, ogAST.PrimConstant):
minR = maxR = float (expr.right.constant_value)
# Type of the resulting expression depends on whether there are raw
# numbers on one side of the expression (PrInt). By default when they
# are parsed, they are set to 64 bits integers ; but if they are in an
# expression where the other side is 32 bits (Length or for loop range)
# then the resulting expression is 32 bits.
basic = right if left.__name__ == 'PrInt' else left
# When one side of the expression is a raw (universal) number,
# in backends the type is inherited from the other side of the
# expression
# e.g. x - 1 is of type x. Keep track of this resulting type in
# "expected_type" to make sure that backends know if the type is signed
# or unsigned, even if the computed range is lower than 0
expr.expected_type = expr.left.exprType if right.__name__ == 'PrInt' \
else expr.right.exprType if left.__name__ == 'PrInt' \
else None
if isinstance(expr, ogAST.ExprPlus):
attrs = {'Min': str(minL + minR),
'Max': str(maxL + maxR)}
......
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