diff --git a/slither/printers/summary/evm.py b/slither/printers/summary/evm.py index d8ca25c0a..5e540474f 100644 --- a/slither/printers/summary/evm.py +++ b/slither/printers/summary/evm.py @@ -30,7 +30,7 @@ class PrinterEVM(AbstractPrinter): """ evm_info = self._extract_evm_info(self.slither) - + for contract in self.slither.contracts_derived: print('Contract {}'.format(contract.name)) @@ -95,7 +95,10 @@ class PrinterEVM(AbstractPrinter): for idx, mapping in enumerate(srcmap_runtime): # Parse srcmap_runtime according to its format # See https://solidity.readthedocs.io/en/v0.5.9/miscellaneous.html#source-mappings - + # In order to compress these source mappings especially for bytecode, the following rules are used: + # If a field is empty, the value of the preceding element is used. + # If a : is missing, all following fields are considered empty. + mapping_item = mapping.split(':') mapping_item += prev_mapping[len(mapping_item):] @@ -104,6 +107,7 @@ class PrinterEVM(AbstractPrinter): mapping_item[i] = int(prev_mapping[i]) offset, length, file_id, _ = mapping_item + prev_mapping = mapping_item if file_id == '-1': # Internal compiler-generated code snippets to be ignored @@ -118,6 +122,4 @@ class PrinterEVM(AbstractPrinter): # Note: The order depends on how solc creates the srcmap_runtime source_to_evm_mapping.setdefault(line_number, []).append(evm_instructions[idx].pc) - prev_mapping = mapping_item - return(source_to_evm_mapping)