From 3ed88b6c20eb6d456b6ff9a30ef67026817b001f Mon Sep 17 00:00:00 2001 From: Josselin Date: Tue, 23 Oct 2018 11:05:21 +0100 Subject: [PATCH] Add missing file --- slither/slithir/utils/variable_number.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 slither/slithir/utils/variable_number.py diff --git a/slither/slithir/utils/variable_number.py b/slither/slithir/utils/variable_number.py new file mode 100644 index 000000000..d1ebc5b65 --- /dev/null +++ b/slither/slithir/utils/variable_number.py @@ -0,0 +1,23 @@ +from slither.slithir.variables import (Constant, ReferenceVariable, + TemporaryVariable, TupleVariable) +from slither.slithir.operations import OperationWithLValue + +def transform_slithir_vars_to_ssa(function): + """ + Transform slithIR vars to SSA + """ + variables = [] + for node in function.nodes: + for ir in node.irs: + if isinstance(ir, OperationWithLValue) and not ir.lvalue in variables: + variables += [ir.lvalue] + + tmp_variables = [v for v in variables if isinstance(v, TemporaryVariable)] + for idx in range(len(tmp_variables)): + tmp_variables[idx].index = idx + ref_variables = [v for v in variables if isinstance(v, ReferenceVariable)] + for idx in range(len(ref_variables)): + ref_variables[idx].index = idx + tuple_variables = [v for v in variables if isinstance(v, TupleVariable)] + for idx in range(len(tuple_variables)): + tuple_variables[idx].index = idx