@@ -292,19 +292,22 @@ def get_all_dependencies_ssa(
292
292
return context .context [KEY_SSA_UNPROTECTED ]
293
293
return context .context [KEY_SSA ]
294
294
295
+
295
296
def get_must_depends_on (x ):
296
297
must_dependencies = compute_must_dependencies (x )
297
298
if len (must_dependencies ) > 1 or len (must_dependencies ) == 0 :
298
299
return None
299
300
return list (must_dependencies )[0 ]
300
301
302
+
301
303
def compute_must_dependencies (x ):
302
- if isinstance (x , SolidityVariableComposed ) or isinstance (x , Constant ) or \
303
- (x .function .visibility in ['public' , 'external' ] and x in x .function .parameters ):
304
+ if isinstance (x , (SolidityVariableComposed , Constant )) or (
305
+ x .function .visibility in ["public" , "external" ] and x in x .function .parameters
306
+ ):
304
307
return set ([x ])
305
308
306
309
function_dependencies = {}
307
- function_dependencies [' context' ] = {}
310
+ function_dependencies [" context" ] = {}
308
311
lvalues = []
309
312
310
313
for node in x .function .nodes :
@@ -322,8 +325,8 @@ def compute_must_dependencies(x):
322
325
lvalue = lvalue_details [0 ]
323
326
ir = lvalue_details [2 ]
324
327
325
- if not lvalue in function_dependencies [' context' ]:
326
- function_dependencies [' context' ][lvalue ] = set ()
328
+ if not lvalue in function_dependencies [" context" ]:
329
+ function_dependencies [" context" ][lvalue ] = set ()
327
330
read : Union [List [Union [LVALUE , SolidityVariableComposed ]], List [SlithIRVariable ]]
328
331
329
332
if isinstance (ir , Index ):
@@ -333,21 +336,25 @@ def compute_must_dependencies(x):
333
336
else :
334
337
read = ir .read
335
338
for v in read :
336
- #if not isinstance(v, Constant):
337
- function_dependencies [' context' ][lvalue ].add (v )
338
- function_dependencies [' context' ] = convert_to_non_ssa (function_dependencies [' context' ])
339
+ # if not isinstance(v, Constant):
340
+ function_dependencies [" context" ][lvalue ].add (v )
341
+ function_dependencies [" context" ] = convert_to_non_ssa (function_dependencies [" context" ])
339
342
340
343
must_dependencies = set ()
341
- if x in function_dependencies ['context' ]:
342
- dependencies = list (function_dependencies ['context' ][x ])
343
- for i in range (0 , len (dependencies )):
344
- result = compute_must_dependencies (dependencies [i ])
345
- if i > 0 :
346
- must_dependencies = must_dependencies .intersection (result )
347
- else :
348
- must_dependencies = must_dependencies .union (result )
344
+ data_dependencies = (
345
+ list (function_dependencies ["context" ][x ])
346
+ if function_dependencies ["context" ] is not None
347
+ else []
348
+ )
349
+ for i , data_dependency in enumerate (data_dependencies ):
350
+ result = compute_must_dependencies (data_dependency )
351
+ if i > 0 :
352
+ must_dependencies = must_dependencies .intersection (result )
353
+ else :
354
+ must_dependencies = must_dependencies .union (result )
349
355
return must_dependencies
350
356
357
+
351
358
# endregion
352
359
###################################################################################
353
360
###################################################################################
0 commit comments