[pypy-svn] r51942 - in pypy/dist/pypy/translator/cli: . test
antocuni at codespeak.net
antocuni at codespeak.net
Fri Feb 29 11:42:42 CET 2008
Author: antocuni
Date: Fri Feb 29 11:42:40 2008
New Revision: 51942
Modified:
pypy/dist/pypy/translator/cli/constant.py
pypy/dist/pypy/translator/cli/database.py
pypy/dist/pypy/translator/cli/dotnet.py
pypy/dist/pypy/translator/cli/test/test_dotnet.py
Log:
make sure we can mix the result of classof(cliClass) and
classof(FUNCTYPE)
Modified: pypy/dist/pypy/translator/cli/constant.py
==============================================================================
--- pypy/dist/pypy/translator/cli/constant.py (original)
+++ pypy/dist/pypy/translator/cli/constant.py Fri Feb 29 11:42:40 2008
@@ -340,8 +340,13 @@
def push_inline(self, gen, EXPECTED_TYPE):
if not self.is_null():
- INSTANCE = self.value._INSTANCE
- gen.ilasm.opcode('ldtoken', self.db.class_or_delegate_name(INSTANCE))
+ if hasattr(self.value, '_FUNC'):
+ FUNC = self.value._FUNC
+ classname = self.db.record_delegate(FUNC)
+ else:
+ INSTANCE = self.value._INSTANCE
+ classname = self.db.class_name(INSTANCE)
+ gen.ilasm.opcode('ldtoken', classname)
gen.ilasm.call('class [mscorlib]System.Type class [mscorlib]System.Type::GetTypeFromHandle(valuetype [mscorlib]System.RuntimeTypeHandle)')
return
super(CLIClassConst, self).push_inline(gen, EXPECTED_TYPE)
Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py (original)
+++ pypy/dist/pypy/translator/cli/database.py Fri Feb 29 11:42:40 2008
@@ -150,9 +150,3 @@
self.delegates[TYPE] = name
self.pending_node(Delegate(self, TYPE, name))
return name
-
- def class_or_delegate_name(self, TYPE):
- if isinstance(TYPE, ootype.StaticMethod):
- return self.record_delegate(TYPE)
- else:
- return self.class_name(TYPE)
Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py (original)
+++ pypy/dist/pypy/translator/cli/dotnet.py Fri Feb 29 11:42:40 2008
@@ -569,7 +569,8 @@
FUNC = cliClass_or_type
return known_delegates_class[FUNC]
except KeyError:
- cls = ootype._class(FUNC)
+ cls = ootype._class(ootype.ROOT)
+ cls._FUNC = FUNC
known_delegates_class[FUNC] = cls
return cls
else:
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 Feb 29 11:42:40 2008
@@ -629,6 +629,18 @@
res = self.interpret(fn, [])
assert res.startswith('StaticMethod__')
+ def test_mix_classof(self):
+ a = classof(System.Int32)
+ b = classof(FUNCTYPE)
+ def fn(flag):
+ if flag:
+ x = a
+ else:
+ x = b
+ return clidowncast(box(x), System.Type).get_Name()
+ res = self.interpret(fn, [True])
+ assert res == 'Int32'
+
class TestPythonnet(TestDotnetRtyping):
# don't interpreter functions but execute them directly through pythonnet
More information about the Pypy-commit
mailing list