Commit 6907f111 authored by Sergio Costas's avatar Sergio Costas

Added generic EQ_OP and NE_OP, and AND_OP and OR_OP

parent f65c96aa
......@@ -705,8 +705,34 @@ class crust(object):
var2 = self._copy_container(var_container)
self._set_var_value(var1, param1.name, crust.STATUS_NULL, 0, True)
self._set_var_value(var2, param1.name, crust.STATUS_NOT_NULL, 0, True)
return [ {"varlist":var1, "status":self.STATUS_NULL, "type":self.TYPE_NO_CRUST, "condition":cd2, "node":None}, {"varlist":var2, "status":self.STATUS_NOT_NULL, "type":self.TYPE_NO_CRUST, "condition":cd1, "node":None}]
return [ {"varlist":var1, "status":self.STATUS_NULL, "type":self.TYPE_NO_CRUST, "condition":cd2, "node":None}, {"varlist":var2, "status":self.STATUS_NOT_NULL, "type":self.TYPE_NO_CRUST, "condition":cd1, "node":None} ]
if (statement.type == "EQ_OP") or (statement.type == "NE_OP"):
# this block manages the cases different to CRUST_VARIABLE == NULL and CRUST_VARIABLE != NULL
retvals = []
values1 = self._eval_statement(statement.child1[0], var_container)
if statement.type == "EQ_OP":
sts1 = self.STATUS_NOT_NULL
cnd1 = self.CONDITION_TRUE
sts2 = self.STATUS_NULL
cnd2 = self.CONDITION_FALSE
else:
sts2 = self.STATUS_NOT_NULL
cnd2 = self.CONDITION_TRUE
sts1 = self.STATUS_NULL
cnd1 = self.CONDITION_FALSE
for value1 in values1:
values2 = self._eval_statement(statement.child2[0], value1["varlist"])
for value2 in values2:
variables = self._copy_container(value2["varlist"])
if (value1["status"] == self.STATUS_NULL) and (value2["status"] == self.STATUS_NULL):
retvals.append( {"varlist":variables, "status":sts1, "type":self.TYPE_NO_CRUST, "condition":cnd1, "node":None} )
elif (((value1["status"] == self.STATUS_NULL) and (value2["status"] == self.STATUS_NOT_NULL)) or
((value1["status"] == self.STATUS_NOT_NULL) and (value2["status"] == self.STATUS_NULL))):
retvals.append( {"varlist":variables, "status":sts2, "type":self.TYPE_NO_CRUST, "condition":cnd2, "node":None} )
else:
retvals.append( {"varlist":variables, "status":self.STATUS_NOT_NULL_OR_NULL, "type":self.TYPE_NO_CRUST, "condition":self.CONDITION_FALSE_TRUE, "node":None} )
return retvals
if statement.type == "!":
values = self._eval_statement(statement.child1[0], var_container)
......@@ -786,6 +812,26 @@ class crust(object):
retvals += [ {"varlist":value2["varlist"], "status":new_status, "type":self.TYPE_NO_CRUST, "condition":crust.CONDITION_FALSE_TRUE, "node":None} ]
return retvals
if statement.type == "AND_OP":
values1 = self._eval_statement(statement.child1[0], var_container)
retval = []
for value1 in values1:
if (value1["condition"] == self.CONDITION_FALSE) or (value1["condition"] == self.CONDITION_FALSE_TRUE):
retval.append(value1)
if (value1["condition"] == self.CONDITION_TRUE) or (value1["condition"] == self.CONDITION_FALSE_TRUE):
retval += self._eval_statement(statement.child2[0],value1["varlist"])
return retval
if statement.type == "OR_OP":
values1 = self._eval_statement(statement.child1[0], var_container)
retval = []
for value1 in values1:
if (value1["condition"] == self.CONDITION_TRUE) or (value1["condition"] == self.CONDITION_FALSE_TRUE):
retval.append(value1)
if (value1["condition"] == self.CONDITION_FALSE) or (value1["condition"] == self.CONDITION_FALSE_TRUE):
retval += self._eval_statement(statement.child2[0],value1["varlist"])
return retval
print("statement type unknown '{:s}' at line {:d}".format(statement.type, statement.line))
return [ {"varlist":var_container, "status":self.STATUS_NOT_NULL_OR_NULL, "type":self.TYPE_NO_CRUST, "condition":self.CONDITION_FALSE_TRUE, "node":None} ]
#assignment
......
......@@ -9,6 +9,6 @@ void main(crust_t param1, crust_t param2) {
if ((param1 != NULL) && (param2 == NULL)) {
param1 = function();
param2 = function();
}
} // All fine
__crust_disable__
}
......@@ -9,6 +9,6 @@ void main(crust_t param1, crust_t param2) {
if (!((param1 != NULL) || (param2 == NULL))) {
param1 = function();
param2 = function();
}
} // All fine
__crust_disable__
}
......@@ -9,5 +9,5 @@ void main(crust_t param) {
while(b == 0) {
main(param);
}
// ERROR: since b is zero, param will never be freed
}
......@@ -9,6 +9,6 @@ void main(crust_t param1, crust_t param2) {
if ((param1 == NULL) && (param2 == NULL)) {
param1 = function();
param2 = function();
}
} // All fine
__crust_disable__
}
......@@ -9,6 +9,6 @@ void main(crust_t param1, crust_t param2) {
if (!((param1 != NULL) || (param2 != NULL))) {
param1 = function();
param2 = function();
}
} // All fine
__crust_disable__
}
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