[pypy-svn] r21725 - in pypy/dist/pypy/translator: . test
pedronis at codespeak.net
pedronis at codespeak.net
Thu Jan 5 22:00:45 CET 2006
Author: pedronis
Date: Thu Jan 5 22:00:44 2006
New Revision: 21725
Modified:
pypy/dist/pypy/translator/interactive.py
pypy/dist/pypy/translator/test/test_interactive.py
Log:
some progress on interactive.py
Modified: pypy/dist/pypy/translator/interactive.py
==============================================================================
--- pypy/dist/pypy/translator/interactive.py (original)
+++ pypy/dist/pypy/translator/interactive.py Thu Jan 5 22:00:44 2006
@@ -41,13 +41,17 @@
self.update_options(argtypes, kwds)
+ FREEZE = {
+ 'annotate': ['debug'],
+ 'rtype': ['insist'],
+ }
+
def driver_event(self, kind, goal, func):
if kind == 'pre':
print goal
self.ensure_setup()
elif kind == 'post':
- if 'goal' == 'annotate': # xxx use a table instead
- self.frozen_options['debug'] = True
+ self.frozen_options.update(dict.fromkeys(self.FREEZE[goal], True))
def ensure_setup(self, argtypes=None, policy=None):
if not self.driver_setup:
@@ -60,9 +64,9 @@
else:
# check consistency
if argtypes is not None and argtypes != self.ann_argtypes:
- raise Exception("xxx")
+ raise Exception("incosistent argtype supplied")
if policy is not None and policy != self.ann_policy:
- raise Exception("xxx")
+ raise Exception("incosistent annotation polish supplied")
def update_options(self, argtypes, kwds):
if argtypes or kwds.get('policy'):
@@ -70,15 +74,23 @@
for optname, value in kwds:
if optname in self.frozen_options:
if getattr(self.driver.options, optname) != value:
- raise Exception("xxx")
+ raise Exception("incosistent option supplied: %s" % optname)
else:
setattr(self.driver.options, optname, value)
self.frozen_options[optname] = True
+ # backend independent
+
def annotate(self, argtypes=None, **kwds):
self.update_options(argtypes, kwds)
return self.driver.annotate()
+ def rtype(self, argtypes=None, **kwds):
+ self.update_options(argtypes, kwds)
+ return self.driver.rtype()
+
+ # backend depedent xxx
+
def source(self, argtypes, **kwds):
backend = self.ensure_backend()
self.update_options(argtypes, kwds)
Modified: pypy/dist/pypy/translator/test/test_interactive.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_interactive.py (original)
+++ pypy/dist/pypy/translator/test/test_interactive.py Thu Jan 5 22:00:44 2006
@@ -10,6 +10,10 @@
s = t.annotate([int, int])
assert s.knowntype == int
+ t = Translation(f, [int, int])
+ s = t.annotate()
+ assert s.knowntype == int
+
t = Translation(f)
s = t.annotate([int, int])
assert s.knowntype == int
@@ -18,3 +22,19 @@
py.test.raises(Exception, "t.annotate([int, float])")
+def test_simple_rtype():
+
+ def f(x,y):
+ return x+y
+
+ t = Translation(f, [int, int])
+ s = t.annotate()
+ t.rtype()
+
+ t = Translation(f)
+ s = t.annotate([int, int])
+ t.rtype()
+
+ t = Translation(f, [int, int])
+ t.annotate()
+ py.test.raises(Exception, "t.rtype([int, int],debug=False)")
More information about the Pypy-commit
mailing list