(self)
| 889 | return targets |
| 890 | |
| 891 | def build_statement_indices(self): |
| 892 | code = self.code |
| 893 | start = 0 |
| 894 | end = codelen = len(code) |
| 895 | |
| 896 | # Compose preliminary list of indices with statements, |
| 897 | # using plain statement opcodes |
| 898 | prelim = self.inst_matches(start, end, self.statement_opcodes) |
| 899 | |
| 900 | # Initialize final container with statements with |
| 901 | # preliminary data |
| 902 | stmts = self.stmts = set(prelim) |
| 903 | |
| 904 | # Same for opcode sequences |
| 905 | pass_stmts = set() |
| 906 | for sequence in self.statement_opcode_sequences: |
| 907 | for i in self.op_range(start, end - (len(sequence) + 1)): |
| 908 | match = True |
| 909 | for elem in sequence: |
| 910 | if elem != code[i]: |
| 911 | match = False |
| 912 | break |
| 913 | i += instruction_size(code[i], self.opc) |
| 914 | |
| 915 | if match is True: |
| 916 | i = self.prev_op[i] |
| 917 | stmts.add(i) |
| 918 | pass_stmts.add(i) |
| 919 | |
| 920 | # Initialize statement list with the full data we've gathered so far |
| 921 | if pass_stmts: |
| 922 | stmt_offset_list = list(stmts) |
| 923 | stmt_offset_list.sort() |
| 924 | else: |
| 925 | stmt_offset_list = prelim |
| 926 | # 'List-map' which contains offset of start of |
| 927 | # next statement, when op offset is passed as index |
| 928 | self.next_stmt = slist = [] |
| 929 | last_stmt_offset = -1 |
| 930 | i = 0 |
| 931 | # Go through all statement offsets |
| 932 | for stmt_offset in stmt_offset_list: |
| 933 | # Process absolute jumps, but do not remove 'pass' statements |
| 934 | # from the set |
| 935 | if ( |
| 936 | code[stmt_offset] == self.opc.JUMP_ABSOLUTE |
| 937 | and stmt_offset not in pass_stmts |
| 938 | ): |
| 939 | # If absolute jump occurs in forward direction or it takes off from the |
| 940 | # same line as previous statement, this is not a statement |
| 941 | # FIXME: 0 isn't always correct |
| 942 | target = self.get_target(stmt_offset) |
| 943 | if ( |
| 944 | target > stmt_offset |
| 945 | or self.lines[last_stmt_offset].l_no == self.lines[stmt_offset].l_no |
| 946 | ): |
| 947 | stmts.remove(stmt_offset) |
| 948 | continue |
no test coverage detected