Merge pull request #417 from crytic/dev-constructor-printer

Improve constructor printer output
pull/418/head
Feist Josselin 5 years ago committed by GitHub
commit 0c52bd585f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 22
      slither/printers/summary/constructor_calls.py

@ -20,11 +20,9 @@ class ConstructorPrinter(AbstractPrinter):
def output(self, _filename): def output(self, _filename):
info = '' info = ''
for contract in self.contracts: for contract in self.slither.contracts_derived:
stack_name = [] stack_name = []
stack_definition = [] stack_definition = []
info += "\n\nContact Name: " + contract.name + '\n'
info += " Constructor Call Sequence: " + '\n'
cst = contract.constructors_declared cst = contract.constructors_declared
if cst: if cst:
stack_name.append(contract.name) stack_name.append(contract.name)
@ -34,16 +32,20 @@ class ConstructorPrinter(AbstractPrinter):
if cst: if cst:
stack_name.append(inherited_contract.name) stack_name.append(inherited_contract.name)
stack_definition.append(self._get_soruce_code(cst)) stack_definition.append(self._get_soruce_code(cst))
if len(stack_name) > 0: if len(stack_name) > 0:
info += " " + ' '.join(stack_name[len(stack_name) - 1]) + '\n'
count = len(stack_name) - 2 info += '\n########' + "#" * len(contract.name) + "########\n"
while count >= 0: info += "####### " + contract.name + " #######\n"
info += "-->" + ' '.join(stack_name[count]) + '\n' info += '########' + "#" * len(contract.name) + "########\n\n"
count = count - 1 info += "## Constructor Call Sequence" + '\n'
info += "\n Constructor Definitions:" + '\n'
for name in stack_name[::-1]:
info += "\t- " + name + '\n'
info += "\n## Constructor Definitions" + '\n'
count = len(stack_definition) - 1 count = len(stack_definition) - 1
while count >= 0: while count >= 0:
info += "\n Contract name:" + str(stack_name[count]) + '\n' info += "\n### " + stack_name[count] + '\n'
info += "\n" + str(stack_definition[count]) + '\n' info += "\n" + str(stack_definition[count]) + '\n'
count = count - 1 count = count - 1

Loading…
Cancel
Save