[rdnzl-devel] Rdnzl Problem

Edi Weitz edi at agharta.de
Tue Feb 5 03:01:14 UTC 2008


On Mon, 4 Feb 2008 11:22:10 +0100, "Iver Odin Kvello" <iverodin at gmail.com> wrote:

> I don't understand why I haven't seen it before, but it seems
> something happens with values returned from lisp to .Net.

Iver, thanks for the analysis.  With that as a starting point, I've
managed to find the actual problem.  (And this seems to show that
Michael was the first one for a long time who actually used callbacks
into Lisp which are supposed to return something... :)

The code in DelegateAdapterBuilder.cpp creates the wrong IL code.  I
don't have the time right now to prepare a new release (maybe in the
next days), but if you want to fix this yourself, here's what to do:

1. The error is in "generateInvokeMethod" /after/ "invoke" has been
   called, i.e. when the return value is handled.

2. In case of a void return value, the code is correct.

3. In case of a value type, the correct loading form (depending on the
   type) must be emitted after the "Unbox" operation - for
   System.Int32 this would be "Ldind_I4" for example - to bring the
   actual value on the stack.

   Which loading form has to be emitted must be decided from a small
   table lookup or so - "Ldind_I1" for booleans, "Ldind_R8" for double
   floats, and so on.

4. And in the third case the code which is there (which emits
   "Ldind_I4") is bogus.  In this case nothing has to be done and the
   return value is already correct.

I've confirmed that with these changes I can use Lisp callbacks which
return System.Int32 as well as ones which return System.String.

Thanks to you and Michael for catching this one,
Edi.



More information about the rdnzl-devel mailing list