Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r58220:ad5cf022a7b3
Date: 2012-10-17 22:19 +0100
http://bitbucket.org/pypy/pypy/changeset/ad5cf022a7b3/

Log:    Copy cpython_code_signature()

diff --git a/pypy/objspace/flow/bytecode.py b/pypy/objspace/flow/bytecode.py
--- a/pypy/objspace/flow/bytecode.py
+++ b/pypy/objspace/flow/bytecode.py
@@ -1,11 +1,28 @@
 """
 Bytecode handling classes and functions for use by the flow space.
 """
-from pypy.interpreter.pycode import (BytecodeCorruption,
-        cpython_code_signature)
+from pypy.interpreter.pycode import BytecodeCorruption
 from pypy.tool.stdlib_opcode import (host_bytecode_spec, EXTENDED_ARG,
         HAVE_ARGUMENT)
-from pypy.interpreter.astcompiler.consts import CO_GENERATOR
+from pypy.interpreter.astcompiler.consts import (CO_GENERATOR, CO_VARARGS,
+        CO_VARKEYWORDS)
+from pypy.interpreter.argument import Signature
+
+def cpython_code_signature(code):
+    "([list-of-arg-names], vararg-name-or-None, kwarg-name-or-None)."
+    argcount = code.co_argcount
+    argnames = list(code.co_varnames[:argcount])
+    if code.co_flags & CO_VARARGS:
+        varargname = code.co_varnames[argcount]
+        argcount += 1
+    else:
+        varargname = None
+    if code.co_flags & CO_VARKEYWORDS:
+        kwargname = code.co_varnames[argcount]
+        argcount += 1
+    else:
+        kwargname = None
+    return Signature(argnames, varargname, kwargname)
 
 class HostCode(object):
     """
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to