Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
8de21056
Commit
8de21056
authored
Mar 09, 2018
by
Maxime Perrotin
Browse files
Fix issue with statechart renderer
parent
557c3e61
Changes
1
Hide whitespace changes
Inline
Side-by-side
opengeode/ogParser.py
View file @
8de21056
...
...
@@ -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
)}
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment