[pypy-svn] rev 2613 - in pypy/trunk/src/pypy/translator: . test tool
arigo at codespeak.net
arigo at codespeak.net
Sat Dec 20 10:02:48 CET 2003
Author: arigo
Date: Sat Dec 20 10:02:48 2003
New Revision: 2613
Added:
pypy/trunk/src/pypy/translator/tool/temptest.py (contents, props changed)
pypy/trunk/src/pypy/translator/tool/tracer.py (contents, props changed)
Modified:
pypy/trunk/src/pypy/translator/annrpython.py
pypy/trunk/src/pypy/translator/test/snippet.py
Log:
Added a new example which shows a problem.
Modified: pypy/trunk/src/pypy/translator/annrpython.py
==============================================================================
--- pypy/trunk/src/pypy/translator/annrpython.py (original)
+++ pypy/trunk/src/pypy/translator/annrpython.py Sat Dec 20 10:02:48 2003
@@ -149,12 +149,13 @@
elif cells is not None:
self.mergeinputargs(block, cells)
if not self.annotated[block]:
+ self.annotated[block] = True
try:
self.flowin(block)
except DelayAnnotation:
- self.delayedblocks.append(block) # failed, hopefully temporarily
+ self.annotated[block] = False # failed, hopefully temporarily
+ self.delayedblocks.append(block)
else:
- self.annotated[block] = True
# When flowin succeeds, i.e. when the analysis progress,
# we can tentatively re-schedlue the delayed blocks.
for block in self.delayedblocks:
Modified: pypy/trunk/src/pypy/translator/test/snippet.py
==============================================================================
--- pypy/trunk/src/pypy/translator/test/snippet.py (original)
+++ pypy/trunk/src/pypy/translator/test/snippet.py Sat Dec 20 10:02:48 2003
@@ -266,3 +266,11 @@
return 1
else:
return n * factorial(n-1)
+
+def append_five(lst):
+ lst += [5]
+
+def call_five():
+ a = []
+ h(a)
+ return a
Added: pypy/trunk/src/pypy/translator/tool/temptest.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/translator/tool/temptest.py Sat Dec 20 10:02:48 2003
@@ -0,0 +1,34 @@
+import sys
+from pypy.translator.translator import *
+from pypy.translator.test import snippet as test
+
+from pypy.translator.tool import tracer
+tracer.trace(AnnotationSet)
+tracer.trace(RPythonAnnotator)
+
+def h(lst):
+ lst += [5]
+
+def calling_h():
+ a = []
+ h(a)
+ return a
+
+
+t = Translator(calling_h) # test.poor_man_rev_range)
+t.simplify()
+a = t.annotate([])
+lines = []
+for key, value in a.bindings.items():
+ lines.append('%r: %r' % (key, value))
+lines.sort()
+for line in lines:
+ print line
+print '-'*50
+print a.heap
+sys.stdout.flush()
+
+print '-'*50
+print t.pyrex()
+
+t.gv()
Added: pypy/trunk/src/pypy/translator/tool/tracer.py
==============================================================================
--- (empty file)
+++ pypy/trunk/src/pypy/translator/tool/tracer.py Sat Dec 20 10:02:48 2003
@@ -0,0 +1,42 @@
+import types, sys
+from pypy.annotation.model import SomeValue, debugname
+from pypy.annotation.annset import AnnotationSet
+from pypy.translator.annrpython import RPythonAnnotator
+
+indent1 = ['']
+
+def show(n):
+ if isinstance(n, AnnotationSet):
+ return 'heap'
+ elif isinstance(n, RPythonAnnotator):
+ return 'rpyann'
+ else:
+ return repr(n)
+
+def trace(o):
+ if isinstance(o, types.ClassType):
+ for key, value in o.__dict__.items():
+ o.__dict__[key] = trace(value)
+ elif isinstance(o, types.FunctionType):
+ d = {'o': o, 'show': show, 'indent1': indent1, 'stderr': sys.stderr}
+ exec """
+def %s(*args, **kwds):
+ indent, = indent1
+ rargs = [show(a) for a in args]
+ for kw, value in kwds.items():
+ rargs.append('%%s=%%r' %% (kw, value))
+ print >> stderr, indent + %r + '(%%s)' %% ', '.join(rargs)
+ indent1[0] += '| '
+ try:
+ result = o(*args, **kwds)
+ except Exception, e:
+ indent1[0] = indent
+ print >> stderr, indent + '+--> %%s: %%s' %% (e.__class__.__name__, e)
+ raise
+ indent1[0] = indent
+ if result is not None:
+ print >> stderr, indent + '+-->', show(result)
+ return result
+result = %s
+""" % (o.__name__, o.__name__, o.__name__) in d
+ return d['result']
More information about the Pypy-commit
mailing list