From a404027b5b60da24a174b30889042c5559470227 Mon Sep 17 00:00:00 2001 From: Josselin Date: Wed, 5 Dec 2018 12:42:48 +0000 Subject: [PATCH] Add missing files --- slither/printers/summary/slithir_ssa.py | 44 +++++++++++++++++++++++++ slither/slithir/variables/variable.py | 14 ++++++++ 2 files changed, 58 insertions(+) create mode 100644 slither/printers/summary/slithir_ssa.py create mode 100644 slither/slithir/variables/variable.py diff --git a/slither/printers/summary/slithir_ssa.py b/slither/printers/summary/slithir_ssa.py new file mode 100644 index 000000000..8d032fb66 --- /dev/null +++ b/slither/printers/summary/slithir_ssa.py @@ -0,0 +1,44 @@ +""" + Module printing summary of the contract +""" + +from slither.printers.abstract_printer import AbstractPrinter +from slither.utils.colors import blue, green, magenta + +class PrinterSlithIRSSA(AbstractPrinter): + + ARGUMENT = 'slithir-ssa' + HELP = 'Print the slithIR representation of the functions' + + def output(self, _filename): + """ + _filename is not used + Args: + _filename(string) + """ + + txt = "" + for contract in self.contracts: + print('Contract {}'.format(contract.name)) + for function in contract.functions: + if function.contract == contract: + print('\tFunction {}'.format(function.full_name)) + for node in function.nodes: + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + if node.irs_ssa: + print('\t\tIRs:') + for ir in node.irs_ssa: + print('\t\t\t{}'.format(ir)) + for modifier in contract.modifiers: + if modifier.contract == contract: + print('\tModifier {}'.format(modifier.full_name)) + for node in modifier.nodes: + print(node) + if node.expression: + print('\t\tExpression: {}'.format(node.expression)) + if node.irs_ssa: + print('\t\tIRs:') + for ir in node.irs_ssa: + print('\t\t\t{}'.format(ir)) + self.info(txt) diff --git a/slither/slithir/variables/variable.py b/slither/slithir/variables/variable.py new file mode 100644 index 000000000..dfdbb7b59 --- /dev/null +++ b/slither/slithir/variables/variable.py @@ -0,0 +1,14 @@ +from slither.core.variables.variable import Variable + +class SlithIRVariable(Variable): + + def __init__(self): + super(SlithIRVariable, self).__init__() + self._index = 0 + + @property + def ssa_name(self): + return self.name + + def __str__(self): + return self.ssa_name