Commit a1ec972a authored by Sergio Costas's avatar Sergio Costas

Now does a deep comparison when comparing two thread states, because variables from

outer blocks, or global variables, can have changed.

Now compares the thread state also before doing an IF, to avoid multiplying the number
of execution threads when not needed.
parent bf32ccbe
......@@ -1459,15 +1459,27 @@ class crust(object):
TRUE if the status has been already checked; FALSE if not
"""
current_vars = status["variables"][0]
current_vars = status["variables"]
if not ex_point in status_list:
status_list[ex_point] = [ current_vars.copy() ]
copyvars = []
for element in current_vars:
vargroup = {}
for varname in element:
vargroup[varname] = element[varname].copy()
copyvars.append(vargroup)
status_list[ex_point] = [ copyvars ]
return False
for old_expoint in status_list[ex_point]:
if old_expoint == current_vars:
return True
status_list[ex_point].append(current_vars.copy())
copyvars = []
for element in current_vars:
vargroup = {}
for varname in element:
vargroup[varname] = element[varname].copy()
copyvars.append(vargroup)
status_list[ex_point].append(copyvars)
return False
......@@ -1559,8 +1571,7 @@ class crust(object):
# this fake node will be processed by the next 'if'
if node.type == "IF":
tree = tree[1:]
block_true, block_other = self._get_next_block(tree)
block_true, block_other = self._get_next_block(tree[1:])
if block_other[0].type == "ELSE":
block_false, block_other = self._get_next_block(block_other[1:])
block_true += block_other
......@@ -1570,14 +1581,20 @@ class crust(object):
block_false = block_other
options = self._eval_statement(node.condition[0], thread_status)
retvals = []
status_true = {}
status_false = {}
for option in options:
if option["condition"] == self.CONDITION_FALSE_TRUE:
retvals += self._check_return_block(block_true, self._copy_status(option["thread_status"]))
retvals += self._check_return_block(block_false, option["thread_status"])
if not self._compare_status(node.uid, option["thread_status"], status_true):
retvals += self._check_return_block(block_true, self._copy_status(option["thread_status"]))
if not self._compare_status(node.uid, option["thread_status"], status_false):
retvals += self._check_return_block(block_false, option["thread_status"])
elif option["condition"] == self.CONDITION_TRUE:
retvals += self._check_return_block(block_true, option["thread_status"])
if not self._compare_status(node.uid, option["thread_status"], status_true):
retvals += self._check_return_block(block_true, option["thread_status"])
else: # option["condition"] == self.CONDITION_FALSE:
retvals += self._check_return_block(block_false, option["thread_status"])
if not self._compare_status(node.uid, option["thread_status"], status_false):
retvals += self._check_return_block(block_false, option["thread_status"])
return retvals
if thread_status["find_label"] is None:
......
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