@@ -292,19 +292,21 @@ def get_all_dependencies_ssa(
292
292
return context .context [KEY_SSA_UNPROTECTED ]
293
293
return context .context [KEY_SSA ]
294
294
295
- def always_depends_on (x , must_depend_on_value ):
296
- must_dependencies = analyze_dependency (x )
297
- print ("" )
295
+ def get_must_depends_on (x ):
296
+ must_dependencies = compute_must_dependencies (x )
297
+ if len (must_dependencies ) > 1 or len (must_dependencies ) == 0 :
298
+ return None
299
+ return list (must_dependencies )[0 ]
298
300
299
-
300
- def analyze_dependency (x ):
301
+ def compute_must_dependencies (x ):
301
302
if isinstance (x , SolidityVariableComposed ) or isinstance (x , Constant ) or \
302
303
(x .function .visibility in ['public' , 'external' ] and x in x .function .parameters ):
303
304
return set ([x ])
304
305
305
306
function_dependencies = {}
306
307
function_dependencies ['context' ] = {}
307
308
lvalues = []
309
+
308
310
for node in x .function .nodes :
309
311
for ir in node .irs_ssa :
310
312
if isinstance (ir , OperationWithLValue ) and ir .lvalue :
@@ -318,7 +320,6 @@ def analyze_dependency(x):
318
320
319
321
for lvalue_details in lvalues :
320
322
lvalue = lvalue_details [0 ]
321
- function = lvalue_details [1 ]
322
323
ir = lvalue_details [2 ]
323
324
324
325
if not lvalue in function_dependencies ['context' ]:
@@ -332,21 +333,19 @@ def analyze_dependency(x):
332
333
else :
333
334
read = ir .read
334
335
for v in read :
335
- if not isinstance (v , Constant ):
336
- function_dependencies ['context' ][lvalue ].add (v )
336
+ # if not isinstance(v, Constant):
337
+ function_dependencies ['context' ][lvalue ].add (v )
337
338
function_dependencies ['context' ] = convert_to_non_ssa (function_dependencies ['context' ])
338
339
339
340
must_dependencies = set ()
340
341
if x in function_dependencies ['context' ]:
341
- i = 0
342
- for dep_value in list (function_dependencies ['context' ][x ]):
343
- result = analyze_dependency (dep_value )
344
- if i == 0 :
345
- must_dependencies = must_dependencies .union (result )
346
- else :
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 :
347
346
must_dependencies = must_dependencies .intersection (result )
348
- i += 1
349
-
347
+ else :
348
+ must_dependencies = must_dependencies . union ( result )
350
349
return must_dependencies
351
350
352
351
# endregion
0 commit comments