Commit 1a60340a authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix various 32bits/64bits conversion issues

parent 837f0333
......@@ -141,9 +141,10 @@ The background pattern was downloaded from www.subtlepatterns.com
Changelog
=========
1.5.30 (04/2017)
1.5.31 (04/2017)
- Unicode bugfixes in Ada backend
- Bugfix with SEQUENCE OF literals in Ada backend
- Various bugfixes with mixed int32/64 bits
1.5.28 (03/2017)
- Added preliminary support for PROCESS TYPE and instances
......
......@@ -1373,13 +1373,13 @@ def _task_forloop(task, **kwargs):
else:
# Step is not directly supported in Ada, we need to use 'while'
stmt.extend(['declare',
u'{it} : Asn1Int := {start};'
u'{it} : Integer := Integer({start});'
.format(it=loop['var'],
start=start_str),
'',
'begin',
u'while {it} < {stop} loop'.format(it=loop['var'],
stop=stop_str)])
u'while {it} < Integer({stop}) loop'
.format(it=loop['var'], stop=stop_str)])
else:
# case of form: FOR x in SEQUENCE OF
# Add iterator to the list of local variables
......@@ -1450,9 +1450,9 @@ def _primary_variable(prim):
ada_string = u'{sep}{name}'.format(sep=sep, name=prim.value[0])
if prim.exprType.__name__ == 'for_range':
# Ada iterator in FOR loops is an Integer - we must cast to 64 bits
ada_string = u'Asn1Int({})'.format(ada_string)
# if prim.exprType.__name__ == 'for_range':
# # Ada iterator in FOR loops is an Integer - we must cast to 64 bits
# ada_string = u'Asn1Int({})'.format(ada_string)
return [], unicode(ada_string), []
......@@ -1722,10 +1722,26 @@ def _primary_state_reference(prim):
def _basic_operators(expr):
''' Expressions with two sides '''
code, local_decl = [], []
left_stmts, left_str, left_local = expression(expr.left)
left_stmts, left_str, left_local = expression(expr.left)
right_stmts, right_str, right_local = expression(expr.right)
##
lbty = find_basic_type(expr.left.exprType)
rbty = find_basic_type(expr.right.exprType)
if rbty.kind != lbty.kind and 'Integer32Type' in (lbty.kind, rbty.kind) \
and "PrInt" not in (expr.left.exprType.__name__,
expr.right.exprType.__name__):
if lbty.kind == 'IntegerType':
right_str = u'Asn1Int({})'.format(right_str)
else:
left_str = u'Asn1Int({})'.format(left_str)
##
ada_string = u'({left} {op} {right})'.format(
left=left_str, op=expr.operand, right=right_str)
code.extend(left_stmts)
code.extend(right_stmts)
local_decl.extend(left_local)
......
......@@ -1316,9 +1316,14 @@ def arithmetic_expression(root, context):
# Expressions returning a numerical type must have their range defined
# accordingly with the kind of opration used between operand:
basic = find_basic_type(expr.left.exprType)
left = find_basic_type(expr.left.exprType)
right = find_basic_type(expr.right.exprType)
# 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
try:
if isinstance(expr, ogAST.ExprPlus):
attrs = {'Min': str(float(left.Min) + float(right.Min)),
......@@ -4232,8 +4237,8 @@ def for_loop(root, context):
# basic may be UNKNOWN_TYPE if the expression is a
# reference to an ASN.1 constant - their values are not
# currently visible to the SDL parser
result_type = type('for_range', (INTEGER,), {'Min': r_min,
'Max': r_max})
result_type = type('for_range', (INT32,), {'Min': r_min,
'Max': r_max})
context.variables[forloop['var']] = (result_type, 0)
forloop['transition'], err, warn = transition(
......
......@@ -138,7 +138,7 @@ except ImportError:
__all__ = ['opengeode', 'SDL_Scene', 'SDL_View', 'parse']
__version__ = '1.5.30'
__version__ = '1.5.31'
if hasattr(sys, 'frozen'):
# Detect if we are running on Windows (py2exe-generated)
......
......@@ -22,13 +22,20 @@ TEST_DATA = '''
endconnection;
'''
def test_1(qtbot):
''' Test the parsing of numbers '''
''' Test objective is to check the Paste function on horizontal items
Render a floating label followed by a decision and 2 answers
Check the relative position of the answers
then Copy-Paste the floating labels (including children)
and verify that the relative position of the children is kept
'''
# Need an Automaton to render the scene with "render_everything"
ast = Automaton()
floating, _, _, _, _ = parseSingleElement('floating_label', TEST_DATA)
ast.floating_labels = [floating]
ast.parent = Process()
scene = SDL_Scene(context="process")
scene.render_everything(ast)
assert (len(list(scene.floating_symb)) == 1)
......
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