Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Unified Diff: tools/telemetry/third_party/coverage/coverage/bytecode.py

Issue 1366913004: Add coverage Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: tools/telemetry/third_party/coverage/coverage/bytecode.py
diff --git a/third_party/pycoverage/coverage/bytecode.py b/tools/telemetry/third_party/coverage/coverage/bytecode.py
similarity index 77%
copy from third_party/pycoverage/coverage/bytecode.py
copy to tools/telemetry/third_party/coverage/coverage/bytecode.py
index 85360638528e6bece33b1f5a1e4dd08e5c2ac3d0..82929cef8a7b980a6d33512d83e67392fddac087 100644
--- a/third_party/pycoverage/coverage/bytecode.py
+++ b/tools/telemetry/third_party/coverage/coverage/bytecode.py
@@ -1,9 +1,14 @@
+# Licensed under the Apache License: http://www.apache.org/licenses/LICENSE-2.0
+# For details: https://bitbucket.org/ned/coveragepy/src/default/NOTICE.txt
+
"""Bytecode manipulation for coverage.py"""
-import opcode, types
+import opcode
+import types
from coverage.backward import byte_to_int
+
class ByteCode(object):
"""A single bytecode."""
def __init__(self):
@@ -26,10 +31,12 @@ class ByteCode(object):
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.
"""
- # pylint: disable=R0924
def __init__(self, code):
self.code = code
@@ -38,6 +45,7 @@ class ByteCodes(object):
def __iter__(self):
offset = 0
+ ext_arg = 0
while offset < len(self.code):
bc = ByteCode()
bc.op = self[offset]
@@ -45,7 +53,7 @@ class ByteCodes(object):
next_offset = offset+1
if bc.op >= opcode.HAVE_ARGUMENT:
- bc.arg = self[offset+1] + 256*self[offset+2]
+ bc.arg = ext_arg + self[offset+1] + 256*self[offset+2]
next_offset += 2
label = -1
@@ -56,7 +64,11 @@ class ByteCodes(object):
bc.jump_to = label
bc.next_offset = offset = next_offset
- yield bc
+ if bc.op == opcode.EXTENDED_ARG:
+ ext_arg = bc.arg * 256*256
+ else:
+ ext_arg = 0
+ yield bc
class CodeObjects(object):
« no previous file with comments | « tools/telemetry/third_party/coverage/coverage/backward.py ('k') | tools/telemetry/third_party/coverage/coverage/cmdline.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698