Author: Ronan Lamy <[email protected]>
Branch: translation-cleanup
Changeset: r57785:375bfab2defa
Date: 2012-10-04 20:03 +0100
http://bitbucket.org/pypy/pypy/changeset/375bfab2defa/
Log: Don't derive HostCode from PyCode.
* Make HostCode.signature an ordinary attribute instead of a method.
* Add HostCode.formalargcount property, replacing
.getformalargcount().
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
@@ -2,7 +2,7 @@
Bytecode handling classes and functions for use by the flow space.
"""
from types import CodeType
-from pypy.interpreter.pycode import (PyCode, BytecodeCorruption, cpython_magic,
+from pypy.interpreter.pycode import (BytecodeCorruption, cpython_magic,
cpython_code_signature)
from pypy.tool.stdlib_opcode import (host_bytecode_spec, EXTENDED_ARG,
HAVE_ARGUMENT)
@@ -11,7 +11,7 @@
from pypy.interpreter.nestedscope import Cell
from pypy.objspace.flow.model import Constant
-class HostCode(PyCode):
+class HostCode(object):
"""
A wrapper around a native code object of the host interpreter
"""
@@ -41,7 +41,7 @@
self.co_lnotab = lnotab
self.hidden_applevel = hidden_applevel
self.magic = magic
- self._signature = cpython_code_signature(self)
+ self.signature = cpython_code_signature(self)
self._initialize()
def _initialize(self):
@@ -95,6 +95,12 @@
list(code.co_cellvars),
hidden_applevel, cpython_magic)
+ @property
+ def formalargcount(self):
+ """Total number of arguments passed into the frame, including *vararg
+ and **varkwarg, if they exist."""
+ return self.signature.scope_length()
+
def make_cells(self, closure):
"""Convert a Python closure object into a list of Cells"""
if closure is not None:
diff --git a/pypy/objspace/flow/flowcontext.py
b/pypy/objspace/flow/flowcontext.py
--- a/pypy/objspace/flow/flowcontext.py
+++ b/pypy/objspace/flow/flowcontext.py
@@ -240,7 +240,7 @@
"""
Initialize the locals and the stack.
- The locals are ordered according to self.pycode.signature().
+ The locals are ordered according to self.pycode.signature.
"""
self.valuestackdepth = code.co_nlocals
self.locals_stack_w = [None] * (code.co_stacksize + code.co_nlocals)
diff --git a/pypy/objspace/flow/pygraph.py b/pypy/objspace/flow/pygraph.py
--- a/pypy/objspace/flow/pygraph.py
+++ b/pypy/objspace/flow/pygraph.py
@@ -13,7 +13,7 @@
def __init__(self, func, code):
from pypy.objspace.flow.flowcontext import SpamBlock
data = [None] * code.co_nlocals
- for i in range(code.getformalargcount()):
+ for i in range(code.formalargcount):
data[i] = Variable()
state = FrameState(data + [Constant(None), Constant(None)], [], 0)
initialblock = SpamBlock(state)
@@ -23,7 +23,7 @@
super(PyGraph, self).__init__(self._sanitize_funcname(func),
initialblock)
self.func = func
- self.signature = code.signature()
+ self.signature = code.signature
self.defaults = func.func_defaults or ()
@staticmethod
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit