summaryrefslogtreecommitdiff
path: root/coverage/bytecode.py
diff options
context:
space:
mode:
authorNed Batchelder <ned@nedbatchelder.com>2016-01-06 16:27:24 -0500
committerNed Batchelder <ned@nedbatchelder.com>2016-01-06 16:27:24 -0500
commit8b7c4c1bf2bd0ea40c6da1c9d09f4f978835fa3b (patch)
tree4b6ff883159689534ea612ff68f7d4bf09bb4727 /coverage/bytecode.py
parentbadf53c6cb26118cfdf3388a6eb09fd21e6c7428 (diff)
downloadpython-coveragepy-git-8b7c4c1bf2bd0ea40c6da1c9d09f4f978835fa3b.tar.gz
Remove the old bytecode-based branch analyzer
--HG-- branch : ast-branch
Diffstat (limited to 'coverage/bytecode.py')
-rw-r--r--coverage/bytecode.py65
1 files changed, 0 insertions, 65 deletions
diff --git a/coverage/bytecode.py b/coverage/bytecode.py
index 82929cef..d823c67c 100644
--- a/coverage/bytecode.py
+++ b/coverage/bytecode.py
@@ -3,73 +3,8 @@
"""Bytecode manipulation for coverage.py"""
-import opcode
import types
-from coverage.backward import byte_to_int
-
-
-class ByteCode(object):
- """A single bytecode."""
- def __init__(self):
- # The offset of this bytecode in the code object.
- self.offset = -1
-
- # The opcode, defined in the `opcode` module.
- self.op = -1
-
- # The argument, a small integer, whose meaning depends on the opcode.
- self.arg = -1
-
- # The offset in the code object of the next bytecode.
- self.next_offset = -1
-
- # The offset to jump to.
- self.jump_to = -1
-
-
-class ByteCodes(object):
- """Iterator over byte codes in `code`.
-
- This handles the logic of EXTENDED_ARG byte codes internally. Those byte
- codes are not returned by this iterator.
-
- Returns `ByteCode` objects.
-
- """
- def __init__(self, code):
- self.code = code
-
- def __getitem__(self, i):
- return byte_to_int(self.code[i])
-
- def __iter__(self):
- offset = 0
- ext_arg = 0
- while offset < len(self.code):
- bc = ByteCode()
- bc.op = self[offset]
- bc.offset = offset
-
- next_offset = offset+1
- if bc.op >= opcode.HAVE_ARGUMENT:
- bc.arg = ext_arg + self[offset+1] + 256*self[offset+2]
- next_offset += 2
-
- label = -1
- if bc.op in opcode.hasjrel:
- label = next_offset + bc.arg
- elif bc.op in opcode.hasjabs:
- label = bc.arg
- bc.jump_to = label
-
- bc.next_offset = offset = next_offset
- if bc.op == opcode.EXTENDED_ARG:
- ext_arg = bc.arg * 256*256
- else:
- ext_arg = 0
- yield bc
-
class CodeObjects(object):
"""Iterate over all the code objects in `code`."""