Skip to content

Commit 5f99da8

Browse files
committed
cleanup done
1 parent 339ffcb commit 5f99da8

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

slither/analyses/data_dependency/data_dependency.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -292,19 +292,21 @@ def get_all_dependencies_ssa(
292292
return context.context[KEY_SSA_UNPROTECTED]
293293
return context.context[KEY_SSA]
294294

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]
298300

299-
300-
def analyze_dependency(x):
301+
def compute_must_dependencies(x):
301302
if isinstance(x, SolidityVariableComposed) or isinstance(x, Constant) or \
302303
(x.function.visibility in ['public', 'external'] and x in x.function.parameters):
303304
return set([x])
304305

305306
function_dependencies = {}
306307
function_dependencies['context'] = {}
307308
lvalues = []
309+
308310
for node in x.function.nodes:
309311
for ir in node.irs_ssa:
310312
if isinstance(ir, OperationWithLValue) and ir.lvalue:
@@ -318,7 +320,6 @@ def analyze_dependency(x):
318320

319321
for lvalue_details in lvalues:
320322
lvalue = lvalue_details[0]
321-
function = lvalue_details[1]
322323
ir = lvalue_details[2]
323324

324325
if not lvalue in function_dependencies['context']:
@@ -332,21 +333,19 @@ def analyze_dependency(x):
332333
else:
333334
read = ir.read
334335
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)
337338
function_dependencies['context'] = convert_to_non_ssa(function_dependencies['context'])
338339

339340
must_dependencies = set()
340341
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:
347346
must_dependencies = must_dependencies.intersection(result)
348-
i +=1
349-
347+
else:
348+
must_dependencies = must_dependencies.union(result)
350349
return must_dependencies
351350

352351
# endregion

0 commit comments

Comments
 (0)