summaryrefslogtreecommitdiffstats
path: root/Lib/dis.py
diff options
context:
space:
mode:
authorFred Drake <fdrake@acm.org>2000-08-24 00:32:09 (GMT)
committerFred Drake <fdrake@acm.org>2000-08-24 00:32:09 (GMT)
commitef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d (patch)
tree799778ef59de6c384636792eb8f1e2ddc1e918a8 /Lib/dis.py
parente266e42c9c1d20b24d18def1c4398e75fe1620f0 (diff)
downloadcpython-ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d.zip
cpython-ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d.tar.gz
cpython-ef8ace3a6f6cf8396fa92ae62352e8a29ddfca1d.tar.bz2
Charles G. Waldman <cgw@fnal.gov>:
Add the EXTENDED_ARG opcode to the virtual machine, allowing 32-bit arguments to opcodes instead of being forced to stick to the 16-bit limit. This is especially useful for machine-generated code, which can be too long for the SET_LINENO parameter to fit into 16 bits. This closes the implementation portion of SourceForge patch #100893.
Diffstat (limited to 'Lib/dis.py')
-rw-r--r--Lib/dis.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/dis.py b/Lib/dis.py
index 3a80e74..9fc9d30 100644
--- a/Lib/dis.py
+++ b/Lib/dis.py
@@ -56,6 +56,7 @@ def disassemble(co, lasti=-1):
labels = findlabels(code)
n = len(code)
i = 0
+ extended_arg = 0
while i < n:
c = code[i]
op = ord(c)
@@ -68,8 +69,11 @@ def disassemble(co, lasti=-1):
print string.ljust(opname[op], 20),
i = i+1
if op >= HAVE_ARGUMENT:
- oparg = ord(code[i]) + ord(code[i+1])*256
+ oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg
+ extended_arg = 0
i = i+2
+ if op == EXTENDED_ARG:
+ extended_arg = oparg*65536L
print string.rjust(`oparg`, 5),
if op in hasconst:
print '(' + `co.co_consts[oparg]` + ')',
@@ -258,6 +262,8 @@ def_op('CALL_FUNCTION_VAR', 140) # #args + (#kwargs << 8)
def_op('CALL_FUNCTION_KW', 141) # #args + (#kwargs << 8)
def_op('CALL_FUNCTION_VAR_KW', 142) # #args + (#kwargs << 8)
+def_op('EXTENDED_ARG', 143)
+EXTENDED_ARG = 143
def _test():
"""Simple test program to disassemble a file."""