Commit 20666c3c authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Fix Helper/Model flatten function

rename everything did not cover variable indexes
parent 4a1ca33e
......@@ -1443,11 +1443,11 @@ def expression(expr):
def _primary_variable(prim):
''' Single variable reference '''
var = find_var(prim.value[0])
#print prim.inputString, prim.value[0].encode('utf-8')
if not var or is_local(var):
sep = ''
else:
sep = LPREFIX + '.'
#sep = (LPREFIX + '.') if find_var(prim.value[0]) else u''
ada_string = u'{sep}{name}'.format(sep=sep, name=prim.value[0])
......@@ -1619,19 +1619,19 @@ def _prim_index(prim):
receiver = prim.value[0]
receiver_stms, reciver_string, receiver_decl = expression(receiver)
ada_string = reciver_string
receiver_stms, ada_string, receiver_decl = expression(receiver)
stmts.extend(receiver_stms)
local_decl.extend(receiver_decl)
idx_stmts, idx_string, idx_var = expression(prim.value[1]['index'][0])
index = prim.value[1]['index'][0]
idx_stmts, idx_string, idx_var = expression(index)
if unicode.isnumeric(idx_string):
idx_string = int(idx_string) + 1
else:
idx_string = '1+Integer({idx})'.format(idx=idx_string)
idx_string = u'1 + Integer({idx})'.format(idx=idx_string)
if not isinstance(receiver, ogAST.PrimSubstring):
ada_string += '.Data'
ada_string += '({idx})'.format(idx=idx_string)
ada_string += u'.Data'
ada_string += u'({idx})'.format(idx=idx_string)
stmts.extend(idx_stmts)
local_decl.extend(idx_var)
......
......@@ -367,6 +367,7 @@ def rename_everything(ast, from_name, to_name):
in the scope of a composite state, so that they do not overwrite
a variable with the same name declared at a higher scope.
'''
LOG.debug ('rename_everything - ' + str(ast))
_, _, _ = ast, from_name, to_name
......@@ -499,6 +500,13 @@ def _rename_expr(ast, from_name, to_name):
rename_everything(ast.right, from_name, to_name)
@rename_everything.register(ogAST.PrimIndex)
def _rename_index(ast, from_name, to_name):
''' Index of an array '''
for each in ast.value[1]['index']:
rename_everything(each, from_name, to_name)
@rename_everything.register(ogAST.PrimVariable)
def _rename_path(ast, from_name, to_name):
''' Ultimate seek point for the renaming: primary path/variables '''
......
......@@ -4017,8 +4017,8 @@ def transition(root, parent, context):
trans.actions.append(proc_call)
parent = proc_call
elif child.type == lexer.LABEL:
term_count = len(context.terminators)
lab, err, warn = label(child, parent=parent)
term_count = len(context.terminators)
lab, err, warn = label(child, parent=parent)
terminators[lab] = term_count
errors.extend(err)
warnings.extend(warn)
......
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