Commit d4b5ab7a authored by Sergio Costas's avatar Sergio Costas

Now supports typecasts at assignments

parent b91f4019
......@@ -358,18 +358,19 @@ class crusty(object):
if assignment is None:
return [ (crusty.STATUS_UNINITIALIZED, self._copy_container(var_container), self.TYPE_NO_MATTER) ]
assignment = assignment[0]
valuetype = self.TYPE_CRUST if assignment.t_crusty else self.TYPE_NO_CRUST
if assignment.type == "CONSTANT":
if (assignment.t_null) or (assignment.intval == 0):
return [ (self.STATUS_NULL, self._copy_container(var_container), self.TYPE_NO_MATTER) ]
else:
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), self.TYPE_NO_CRUST) ]
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), valuetype) ]
elif assignment.type == "FCONSTANT":
if assignment.floatval == 0.0:
return [ (self.STATUS_NULL, self._copy_container(var_container), self.TYPE_NO_MATTER) ]
else:
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), self.TYPE_NO_CRUST) ]
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), valuetype) ]
elif assignment.type == "STRING_LITERAL":
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), self.TYPE_NO_CRUST) ]
return [ (self.STATUS_NOT_NULL, self._copy_container(var_container), valuetype) ]
elif assignment.type == "?":
states = self._eval_condition(assignment.condition,var_container,function_container)
retvals = []
......@@ -386,7 +387,10 @@ class crusty(object):
return self._eval_function_call(assignment,var_container,function_container)
elif assignment.type == "IDENTIFIER":
vardata = self._find_variable(var_container,assignment.name,assignment.line)
retval_type = self.TYPE_CRUST if ((vardata["properties"] & self.PROPERTY_CRUST_VARIABLE) != 0) else self.TYPE_NO_CRUST
if valuetype == self.TYPE_NO_CRUST:
retval_type = self.TYPE_CRUST if ((vardata["properties"] & self.PROPERTY_CRUST_VARIABLE) != 0) else self.TYPE_NO_CRUST
else:
retval_type = valuetype
if vardata["status"] == self.STATUS_UNINITIALIZED:
self._add_error(self.MSG_ERROR,"Using the value of '{:s}' at line {:d} in an assignment, but it is uninitialized",assignment.name,assignment.line)
return [ (self.STATUS_UNINITIALIZED, self._copy_container(var_container), retval_type) ]
......
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