diff --git a/src/call.py b/src/call.py index 0e647eb4c60bb116fbe70db2bce04cd6e8fd43b5..def00263a1dd89c28237effa3188e6a999669d47 100644 --- a/src/call.py +++ b/src/call.py @@ -76,7 +76,16 @@ class Call(Executor): tag_to_add = "//AREA TO ADD PARAMS" code = f"{tag_to_add}\n{code}" index = 1 + + #We do this so that the longest parameters are rewritten first in the code -> to avoid problems + parameters_2_length = {} for param in self.parameters: + #TODO -> make sure of you change the parameters of the get_code -> you do the same below + temp_code = param.get_code(get_OG=True) + parameters_2_length[param] = len(temp_code) + sorted_parameters_2_length = {k: v for k, v in sorted(parameters_2_length.items(), key=lambda item: item[1], reverse=True)} + + for param in sorted_parameters_2_length: param_new_name = f"{self.get_first_element_called().get_alias_and_id()}_param_{index}" #Case the param is a call @@ -84,6 +93,7 @@ class Call(Executor): #If it's not a function -> then we rewrite it if(param.get_first_element_called().get_type()!="Function"): temp = code + #TODO -> make sure of you change the parameters of the get_code -> you do the same above code = replace_group1(code, fr"[^\w]({re.escape(param.get_code(get_OG=True))})", param_new_name) if(temp==code): raise Exception("This souldn't happen")