[pypy-svn] r15817 - in pypy/dist/pypy: annotation translator translator/goal
arigo at codespeak.net
arigo at codespeak.net
Tue Aug 9 16:19:16 CEST 2005
Author: arigo
Date: Tue Aug 9 16:19:12 2005
New Revision: 15817
Modified:
pypy/dist/pypy/annotation/policy.py
pypy/dist/pypy/translator/annrpython.py
pypy/dist/pypy/translator/goal/translate_pypy.py
Log:
Complain the first time a SomeObject is seen for stand-alone translation
targets. Useful for targetpypystandalone.
To do later: allow a target to return a custom policy.
Modified: pypy/dist/pypy/annotation/policy.py
==============================================================================
--- pypy/dist/pypy/annotation/policy.py (original)
+++ pypy/dist/pypy/annotation/policy.py Tue Aug 9 16:19:12 2005
@@ -8,6 +8,7 @@
class BasicAnnotatorPolicy:
+ allow_someobjects = True
def specialize(pol, bookkeeper, spaceop, func, args, mono):
return None, None
Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py (original)
+++ pypy/dist/pypy/translator/annrpython.py Tue Aug 9 16:19:12 2005
@@ -227,6 +227,25 @@
history.append(self.bindings[arg])
cause_history = self.binding_cause_history.setdefault(arg, [])
cause_history.append(self.binding_caused_by[arg])
+ degenerated = (s_value.__class__ is annmodel.SomeObject and
+ s_value.knowntype is not type)
+ if degenerated and not self.policy.allow_someobjects:
+ msglines = ["annotation of %r degenerated to SomeObject()" % (arg,)]
+ try:
+ position_key = self.bookkeeper.position_key
+ except AttributeError:
+ pass
+ else:
+ msglines.append(".. %r position: %s" % (
+ arg, self.whereami(position_key),))
+ if called_from is not None:
+ msglines.append(".. called from %r" % (called_from,))
+ if hasattr(called_from, '__module__'):
+ msglines[-1] += " from module %r"% (called_from.__module__,)
+ if s_value.origin is not None:
+ msglines.append(".. SomeObject() origin: %s" % (
+ self.whereami(s_value.origin),))
+ raise AnnotatorError('\n'.join(msglines))
self.bindings[arg] = s_value
if annmodel.DEBUG:
if arg in self.return_bindings:
@@ -234,7 +253,7 @@
(self.whereami((self.return_bindings[arg], None, None)),
s_value))
- if arg in self.return_bindings and s_value == annmodel.SomeObject():
+ if arg in self.return_bindings and degenerated:
log.red("*** WARNING: %s result degenerated to SomeObject" %
self.whereami((self.return_bindings[arg],None, None)))
Modified: pypy/dist/pypy/translator/goal/translate_pypy.py
==============================================================================
--- pypy/dist/pypy/translator/goal/translate_pypy.py (original)
+++ pypy/dist/pypy/translator/goal/translate_pypy.py Tue Aug 9 16:19:12 2005
@@ -106,15 +106,17 @@
a = t.annotator
t.frozen = False
standalone = inputtypes is None
+ policy = PyPyAnnotatorPolicy()
if standalone:
ldef = listdef.ListDef(None, annmodel.SomeString())
inputtypes = [annmodel.SomeList(ldef)]
+ policy.allow_someobjects = False
if listen_port:
run_async_server()
if not options['-no-a']:
print 'Annotating...'
- a = t.annotate(inputtypes, policy=PyPyAnnotatorPolicy())
+ a = t.annotate(inputtypes, policy=policy)
sanity_check_exceptblocks(t)
lost = query.sanity_check_methods(t)
assert not lost, "lost methods, something gone wrong with the annotation of method defs"
More information about the Pypy-commit
mailing list