[pypy-svn] r37388 - in pypy/dist/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Fri Jan 26 15:25:54 CET 2007
Author: antocuni
Date: Fri Jan 26 15:25:53 2007
New Revision: 37388
Modified:
pypy/dist/pypy/translator/cli/dotnet.py
pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
Add support for SomeCliInstance constants equal to None in the rtyper.
Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/dotnet.py Fri Jan 26 15:25:53 2007
@@ -56,6 +56,9 @@
def __repr__(self):
return '%s(%s, can_be_None=%s)' % (self.__class__.__name__, self.ootype, self.can_be_None)
+ def rtyper_makerepr(self, rtyper):
+ return CliInstanceRepr(self.ootype)
+
_make_none_union('SomeCliInstance', 'ootype=obj.ootype, can_be_None=True', globals())
class __extend__(pairtype(SomeCliInstance, SomeInteger)):
@@ -112,7 +115,14 @@
cDesc = hop.inputconst(ootype.Void, desc)
return hop.genop("direct_call", [cDesc] + vlist, resulttype=resulttype)
-class __extend__(pairtype(OOInstanceRepr, IntegerRepr)):
+class CliInstanceRepr(OOInstanceRepr):
+ def convert_const(self, value):
+ if value is None:
+ return ootype.null(self.lowleveltype)
+ else:
+ return OOInstanceRepr.convert_const(self, value)
+
+class __extend__(pairtype(CliInstanceRepr, IntegerRepr)):
def rtype_getitem((r_inst, r_int), hop):
if not r_inst.lowleveltype._isArray:
Modified: pypy/dist/pypy/translator/cli/test/test_dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/test/test_dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/test/test_dotnet.py Fri Jan 26 15:25:53 2007
@@ -296,6 +296,15 @@
res = self.interpret(fn, [])
assert res is True
+ def test_mix_None_and_instance(self):
+ def fn(x):
+ if x:
+ return None
+ else:
+ return box(42)
+ res = self.interpret(fn, [1])
+ assert res is None
+
class TestPythonnet(TestDotnetRtyping):
# don't interpreter functions but execute them directly through pythonnet
def interpret(self, f, args):
More information about the Pypy-commit
mailing list