Author: Ronan Lamy <[email protected]>
Branch: Opcode-class
Changeset: r63836:83dc2f3f8201
Date: 2013-05-02 19:09 +0100
http://bitbucket.org/pypy/pypy/changeset/83dc2f3f8201/

Log:    Create @register_opcode

diff --git a/rpython/flowspace/bytecode.py b/rpython/flowspace/bytecode.py
--- a/rpython/flowspace/bytecode.py
+++ b/rpython/flowspace/bytecode.py
@@ -132,3 +132,21 @@
 
     def eval(self, frame):
         return getattr(frame, self.name)(self.arg)
+
+    @classmethod
+    def register_name(cls, name, op_class):
+        try:
+            num = OPNAMES.index(name)
+            cls.num2op[num] = op_class
+            return num
+        except ValueError:
+            return -1
+
+    def __repr__(self):
+        return "%s(%d)" % (self.name, self.arg)
+
+def register_opcode(cls):
+    """Class decorator: register opcode class as real Python opcode"""
+    name = cls.__name__
+    cls.num = Opcode.register_name(name, cls)
+    return cls
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to