[pypy-svn] r10250 - in pypy/dist/pypy/translator: . test
arigo at codespeak.net
arigo at codespeak.net
Sat Apr 2 17:07:59 CEST 2005
Author: arigo
Date: Sat Apr 2 17:07:59 2005
New Revision: 10250
Modified:
pypy/dist/pypy/translator/genc_funcdef.py
pypy/dist/pypy/translator/genc_type.h
pypy/dist/pypy/translator/test/test_ctrans.py
pypy/dist/pypy/translator/typer.py
Log:
Minor fixes, and an extension to test_ctrans that compiles and runs the
functions using the typer (disabled for now, as some of these still segfault).
Modified: pypy/dist/pypy/translator/genc_funcdef.py
==============================================================================
--- pypy/dist/pypy/translator/genc_funcdef.py (original)
+++ pypy/dist/pypy/translator/genc_funcdef.py Sat Apr 2 17:07:59 2005
@@ -226,7 +226,7 @@
print >> f, '\t' + footer
print >> f, '\treturn oret;'
- if conversions:
+ if conversions or footer:
print >> f, ' type_error:'
print >> f, ' return NULL;'
Modified: pypy/dist/pypy/translator/genc_type.h
==============================================================================
--- pypy/dist/pypy/translator/genc_type.h (original)
+++ pypy/dist/pypy/translator/genc_type.h Sat Apr 2 17:07:59 2005
@@ -10,3 +10,6 @@
FAIL(err)
#define OP_INT_IS_TRUE(x,r,err) r = (x != 0);
+
+#define OP_INT_ADD(x,y,r,err) r = x + y;
+#define OP_INT_SUB(x,y,r,err) r = x - y;
Modified: pypy/dist/pypy/translator/test/test_ctrans.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_ctrans.py (original)
+++ pypy/dist/pypy/translator/test/test_ctrans.py Sat Apr 2 17:07:59 2005
@@ -2,6 +2,7 @@
import py
from pypy.tool.udir import udir
from pypy.translator.genc import GenC
+from pypy.translator.typer import GenCSpecializer
from pypy.objspace.flow.model import *
from pypy.translator.tool.buildpyxmodule import make_module_from_c
from pypy.translator.tool.buildpyxmodule import skip_missing_compiler
@@ -214,7 +215,7 @@
assert fn(117, 124) == -3
-class TestTypedTestCase:
+class TestAnnotatedTestCase:
def getcompiled(self, func):
t = Translator(func, simplifying=True)
@@ -313,4 +314,21 @@
assert result == list('abc')
result = fn(l, 2**64)
assert result == list('abc')
-
+
+
+class IN_PROGRESS_TestTypedTestCase(TestAnnotatedTestCase):
+
+ def getcompiled(self, func):
+ t = Translator(func, simplifying=True)
+ # builds starting-types from func_defs
+ argstypelist = []
+ if func.func_defaults:
+ for spec in func.func_defaults:
+ if isinstance(spec, tuple):
+ spec = spec[0] # use the first type only for the tests
+ argstypelist.append(spec)
+ a = t.annotate(argstypelist)
+ a.simplify()
+ GenCSpecializer(a).specialize()
+ t.checkgraphs()
+ return skip_missing_compiler(t.ccompile)
Modified: pypy/dist/pypy/translator/typer.py
==============================================================================
--- pypy/dist/pypy/translator/typer.py (original)
+++ pypy/dist/pypy/translator/typer.py Sat Apr 2 17:07:59 2005
@@ -8,7 +8,7 @@
self.s_type = s_type
self.type_cls = type_cls
-class TyperError:
+class TyperError(Exception):
pass
More information about the Pypy-commit
mailing list