Commit b3a72935 authored by Sergio Costas's avatar Sergio Costas

Removed default parameter

parent a8df0130
......@@ -270,7 +270,7 @@ It also recognizes the following syntax extensions (but are managed as stubs):
# CONTACTING THE AUTHOR
Sergio Costas-Rodriguez (Raster Software Vigo)
http://www.rastersoft.com
https://github.com/rastersoft/crust
rastersoft@gmail.com
Sergio Costas Rodriguez
rastersoft@gmail.com
http://www.rastersoft.com
https://gitlab.com/rastersoft/crust
......@@ -466,7 +466,7 @@ class crust(object):
return True
def _eval_statement(self, statement, thread_status, first = False):
def _eval_statement(self, statement, thread_status, first):
""" Evaluates an statement recursively.
@params:
statement -- the node with the statement to evaluate
......@@ -528,7 +528,7 @@ class crust(object):
if statement.type == "TYPECAST":
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
if self._check_statement_is_crust(statement):
valuetype = self.TYPE_CRUST
else:
......@@ -540,16 +540,16 @@ class crust(object):
if statement.type == "?":
threads = self._eval_statement(statement.condition[0], thread_status)
threads = self._eval_statement(statement.condition[0], thread_status, False)
retvals = []
for thread in threads:
if thread["condition"] == crust.CONDITION_FALSE_TRUE:
retvals += self._eval_statement(statement.child1[0], self._copy_status(thread["thread_status"]))
retvals += self._eval_statement(statement.child2[0], thread["thread_status"])
retvals += self._eval_statement(statement.child1[0], self._copy_status(thread["thread_status"]), False)
retvals += self._eval_statement(statement.child2[0], thread["thread_status"], False)
elif thread["condition"] == crust.CONDITION_TRUE:
retvals += self._eval_statement(statement.child1[0], thread["thread_status"])
retvals += self._eval_statement(statement.child1[0], thread["thread_status"], False)
else: # thread["condition"] == crust.CONDITION_FALSE:
retvals += self._eval_statement(statement.child2[0], thread["thread_status"])
retvals += self._eval_statement(statement.child2[0], thread["thread_status"], False)
return retvals
......@@ -559,9 +559,9 @@ class crust(object):
# static initialization of this struct
threads = [{ "thread_status": thread_status, "value": self.VALUE_NOT_NULL, "type": self.TYPE_NO_MATTER, "condition":self.CONDITION_TRUE, "node": statement.child1[0], "pure": True}]
else:
threads = self._eval_statement(statement.child2[0], self._copy_status(thread_status)) # evaluate the right part of the assignment
threads = self._eval_statement(statement.child2[0], self._copy_status(thread_status), False) # evaluate the right part of the assignment
dest_eval = self._eval_statement(statement.child1[0], thread_status)[0]
dest_eval = self._eval_statement(statement.child1[0], thread_status, False)[0]
dest_var = dest_eval["node"]
dest_data = self._find_variable(thread_status, dest_var.name, statement.line)
......@@ -759,7 +759,7 @@ class crust(object):
nparam = -1
for rval in retvals:
nparam += 1
threads = self._eval_statement(variable, rval["thread_status"])
threads = self._eval_statement(variable, rval["thread_status"], False)
for thread in threads:
# Update the state of the variables
passed_is_crust = (thread["type"] == self.TYPE_CRUST)
......@@ -835,6 +835,7 @@ class crust(object):
if (statement.type == "EQ_OP") or (statement.type == "NE_OP"):
# check CRUST_POINTER == NULL, CRUST_POINTER != NULL
param1 = statement.child1[0]
param2 = statement.child2[0]
if param1.t_null and (param2.type == "IDENTIFIER"):
......@@ -873,7 +874,7 @@ class crust(object):
self._check_is_freed(thread_status, statement.child1[0])
self._check_is_freed(thread_status, statement.child2[0])
retvals = []
threads1 = self._eval_statement(statement.child1[0], thread_status)
threads1 = self._eval_statement(statement.child1[0], thread_status, False)
if statement.type == "EQ_OP":
sts1 = self.VALUE_NOT_NULL
cnd1 = self.CONDITION_TRUE
......@@ -885,7 +886,7 @@ class crust(object):
sts1 = self.VALUE_NULL
cnd1 = self.CONDITION_FALSE
for thread1 in threads1:
threads2 = self._eval_statement(statement.child2[0], thread1["thread_status"])
threads2 = self._eval_statement(statement.child2[0], thread1["thread_status"], False)
var_used = False
for thread2 in threads2:
if var_used:
......@@ -903,7 +904,7 @@ class crust(object):
return retvals
if (statement.type == "!") or (statement.type == "~"):
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
for thread in threads:
if thread["value"] == self.VALUE_NULL:
thread["value"] = self.VALUE_NOT_NULL
......@@ -918,7 +919,7 @@ class crust(object):
if (statement.type == "&") and (statement.child2 is None): # &variable
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
for thread in threads:
thread["type"] = self.TYPE_NO_CRUST
thread["pure"] = False
......@@ -926,7 +927,7 @@ class crust(object):
if (statement.type == "*") and (statement.child2 is None): # *variable
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
for thread in threads:
thread["type"] = self.TYPE_NO_CRUST
thread["pure"] = False
......@@ -1027,9 +1028,9 @@ class crust(object):
child1 = statement.child1
child2 = statement.child2
retvals = []
threads1 = self._eval_statement(statement.child1[0], thread_status)
threads1 = self._eval_statement(statement.child1[0], thread_status, False)
for thread1 in threads1:
threads2 = self._eval_statement(statement.child2[0], thread1["thread_status"])
threads2 = self._eval_statement(statement.child2[0], thread1["thread_status"], False)
for thread2 in threads2:
if ((thread1["value"] == self.VALUE_FREED) or
(thread2["value"] == self.VALUE_FREED) or
......@@ -1042,30 +1043,30 @@ class crust(object):
return retvals
if statement.type == "AND_OP":
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
retval = []
for thread in threads:
if (thread["condition"] == self.CONDITION_FALSE) or (thread["condition"] == self.CONDITION_FALSE_TRUE):
retval.append(thread)
if (thread["condition"] == self.CONDITION_TRUE) or (thread["condition"] == self.CONDITION_FALSE_TRUE):
retval += self._eval_statement(statement.child2[0], self._copy_status(thread["thread_status"]))
retval += self._eval_statement(statement.child2[0], self._copy_status(thread["thread_status"]), False)
return retval
if statement.type == "OR_OP":
threads = self._eval_statement(statement.child1[0], thread_status)
threads = self._eval_statement(statement.child1[0], thread_status, False)
retval = []
for thread in threads:
if (thread["condition"] == self.CONDITION_TRUE) or (thread["condition"] == self.CONDITION_FALSE_TRUE):
retval.append(thread)
if (thread["condition"] == self.CONDITION_FALSE) or (thread["condition"] == self.CONDITION_FALSE_TRUE):
retval += self._eval_statement(statement.child2[0], self._copy_status(thread["thread_status"]))
retval += self._eval_statement(statement.child2[0], self._copy_status(thread["thread_status"]), False)
return retval
if statement.type == ",":
threads = self._eval_statement(statement.child1[0], thread_status, True)
retval = []
for thread in threads:
retval += self._eval_statement(statement.child2[0], thread["thread_status"])
retval += self._eval_statement(statement.child2[0], thread["thread_status"], False)
return retval
print("statement type unknown '{:s}' at line {:d}".format(statement.type, statement.line))
......@@ -1617,7 +1618,7 @@ class crust(object):
else:
block_true += block_other
block_false = block_other
options = self._eval_statement(node.condition[0], thread_status)
options = self._eval_statement(node.condition[0], thread_status, False)
retvals = []
status_true = {}
status_false = {}
......@@ -1639,7 +1640,7 @@ class crust(object):
if node.type == "RETURN":
if node.child1 is not None:
thread_status["returned_something"] = True
threads = self._eval_statement(node.child1[0], thread_status)
threads = self._eval_statement(node.child1[0], thread_status, False)
else:
thread_status["returned_something"] = False
threads = [ {"thread_status":thread_status, "value":self.VALUE_NOT_NULL_OR_NULL, "type":self.TYPE_NO_MATTER, "condition":self.CONDITION_FALSE_TRUE, "node":None} ]
......@@ -1825,7 +1826,7 @@ class crust(object):
return threads
if (node.type == "EVAL_TRUE") or (node.type == "EVAL_FALSE"):
threads = self._eval_statement(node.condition, self._copy_status(thread_status))
threads = self._eval_statement(node.condition, self._copy_status(thread_status), False)
retvals = []
for thread in threads:
if (node.type == "EVAL_TRUE") and (thread["condition"] == self.CONDITION_FALSE):
......
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