[pypy-svn] r26327 - in pypy/dist/pypy: annotation objspace/cpy
arigo at codespeak.net
arigo at codespeak.net
Tue Apr 25 13:51:29 CEST 2006
Author: arigo
Date: Tue Apr 25 13:51:27 2006
New Revision: 26327
Modified:
pypy/dist/pypy/annotation/annrpython.py
pypy/dist/pypy/objspace/cpy/ann_policy.py
pypy/dist/pypy/objspace/cpy/wrappable.py
Log:
Disallow SomeObjects again, with an exception: they are allowed inside
functions with an attribute 'allow_someobjects=True'.
Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py (original)
+++ pypy/dist/pypy/annotation/annrpython.py Tue Apr 25 13:51:27 2006
@@ -243,12 +243,19 @@
def ondegenerated(self, what, s_value, where=None, called_from_graph=None):
if self.policy.allow_someobjects:
return
+
+ # is the function itself tagged with allow_someobjects?
+ position_key = where or getattr(self.bookkeeper, 'position_key', None)
+ if position_key is not None:
+ graph, block, i = position_key
+ try:
+ if graph.func.allow_someobjects:
+ return
+ except AttributeError:
+ pass
+
msglines = ["annotation of %r degenerated to SomeObject()" % (what,)]
- try:
- position_key = where or self.bookkeeper.position_key
- except AttributeError:
- pass
- else:
+ if position_key is not None:
msglines.append(".. position: %s" % (self.whereami(position_key),))
if called_from_graph is not None:
msglines.append(".. called from %r" % (called_from_graph,))
@@ -427,10 +434,10 @@
assert block in self.annotated
self.annotated[block] = False # must re-flow
- def bindinputargs(self, graph, block, inputcells,
- called_from_graph=None, where=None):
+ def bindinputargs(self, graph, block, inputcells, called_from_graph=None):
# Create the initial bindings for the input args of a block.
assert len(block.inputargs) == len(inputcells)
+ where = (graph, block, None)
for a, cell in zip(block.inputargs, inputcells):
self.setbinding(a, cell, called_from_graph, where=where)
self.annotated[block] = False # must flowin.
@@ -442,8 +449,7 @@
unions = [annmodel.unionof(c1,c2) for c1, c2 in zip(oldcells,inputcells)]
# if the merged cells changed, we must redo the analysis
if unions != oldcells:
- self.bindinputargs(graph, block, unions,
- called_from_graph, where=(graph, block, None))
+ self.bindinputargs(graph, block, unions, called_from_graph)
def whereami(self, position_key):
graph, block, i = position_key
Modified: pypy/dist/pypy/objspace/cpy/ann_policy.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/ann_policy.py (original)
+++ pypy/dist/pypy/objspace/cpy/ann_policy.py Tue Apr 25 13:51:27 2006
@@ -1,8 +1,6 @@
from pypy.translator.goal.ann_override import PyPyAnnotatorPolicy
class CPyAnnotatorPolicy(PyPyAnnotatorPolicy):
- allow_someobjects = True
-
- # XXX make it more subtle: only allow SomeObjects in
- # some specific functions, not all of them.
- # Currently only trampoline() in wrapper.py should need them.
+ """Annotation policy to compile CPython extension modules with
+ the CPyObjSpace.
+ """
Modified: pypy/dist/pypy/objspace/cpy/wrappable.py
==============================================================================
--- pypy/dist/pypy/objspace/cpy/wrappable.py (original)
+++ pypy/dist/pypy/objspace/cpy/wrappable.py Tue Apr 25 13:51:27 2006
@@ -27,6 +27,7 @@
w_arg = space.W_Object(a)
w_result = bltin(space, w_arg)
return w_result.value
+ trampoline.allow_someobjects = True # annotator hint
w_result = W_Object(trampoline)
More information about the Pypy-commit
mailing list