Commit 792f1313 authored by Sergio Costas's avatar Sergio Costas

Added comma operator support

parent 57d987a3
......@@ -527,11 +527,11 @@ class crust(object):
self._add_error(v["varlist"], self.MSG_ERROR, "Trying to assign the function '{:s}' to the function pointer '{:s}' at line {:d}, but they have a different number of parameters", orig_var["name"], dest_data["name"], statement.line)
else:
for c in range(len(orig_var["function_params"])):
if not self._compare_types(orig_var["function_params"][c],dest_data["function_params"][c]):
if not self._compare_types(orig_var["function_params"][c], dest_data["function_params"][c]):
if c == 0:
self._add_error(v["varlist"], self.MSG_ERROR, "Trying to assign the function '{:s}' to the function pointer '{:s}' at line {:d}, but the return types differ", orig_var["name"], dest_data["name"], statement.line)
else:
self._add_error(v["varlist"], self.MSG_ERROR, "Trying to assign the function '{:s}' to the function pointer '{:s}' at line {:d}, but parameter {:d} differs", orig_var["name"], dest_data["name"], statement.line,c)
self._add_error(v["varlist"], self.MSG_ERROR, "Trying to assign the function '{:s}' to the function pointer '{:s}' at line {:d}, but parameter {:d} differs", orig_var["name"], dest_data["name"], statement.line, c)
else:
# we are assigning the result of a function call
ret_value = orig_var["function_params"][0]
......@@ -819,7 +819,7 @@ class crust(object):
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"])
retval += self._eval_statement(statement.child2[0], value1["varlist"])
return retval
if statement.type == "OR_OP":
......@@ -829,7 +829,14 @@ class crust(object):
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"])
retval += self._eval_statement(statement.child2[0], value1["varlist"])
return retval
if statement.type == ",":
values1 = self._eval_statement(statement.child1[0], var_container, True)
retval = []
for value1 in values1:
retval += self._eval_statement(statement.child2[0], value1["varlist"])
return retval
print("statement type unknown '{:s}' at line {:d}".format(statement.type, statement.line))
......
This diff is collapsed.
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t function();
void main() {
crust_t param;
int b;
param = (b=6, function());
__crust_disable__
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t function();
void main() {
crust_t param;
int b;
param = (function(), b=6);
__crust_disable__
}
typedef __crust_t__ unsigned char *crust_t;
#define NULL ((void *)0)
crust_t function();
void main() {
crust_t param;
int b;
param = function(), b=6;
__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