Author: Ronan Lamy <[email protected]>
Branch: Opcode-class
Changeset: r63834:612e87240217
Date: 2013-05-02 05:43 +0100
http://bitbucket.org/pypy/pypy/changeset/612e87240217/
Log: Implement registration of opcode classes
diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -106,7 +106,11 @@
if opnum in opcode.hasjrel:
oparg += next_instr
- return next_instr, Opcode(opnum, oparg, pos)
+ try:
+ op = Opcode.num2op[opnum](oparg, pos)
+ except KeyError:
+ op = Opcode(opnum, oparg, pos)
+ return next_instr, op
@property
def is_generator(self):
@@ -115,8 +119,10 @@
OPNAMES = host_bytecode_spec.method_names
class Opcode(object):
+ num2op = {}
def __init__(self, opcode, arg, offset=-1):
self.name = OPNAMES[opcode]
+ self.num = opcode
self.arg = arg
self.offset = offset
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit