[m-dev.] Generating methods for foreign classes
Peter Ross
peter.ross at miscrit.be
Fri May 25 20:34:40 AEST 2001
On Thu, May 24, 2001 at 04:28:43PM +1000, Fergus Henderson wrote:
> On 24-May-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > In MLDS the body of Salary would look something like:
> >
> > call(Signature, FunctionRval, yes(ThisRval),
> > [
> > lval(var("s")),
> > lval(field(no, ThisRval, named_field("state")...)),
> > mem_ref(lval(field(no, ThisRval, named_field("state")...))
> > ],
> > [], yes)
> >
> > But the big problem is that I don't know what ThisRval should be.
> > There doesn't appear to be an rval for "this". I think it might be
> > missing from the MLDS actually.
>
> Right. I think we should add a new lval constructor, called "this" or
> "self", for "this" in Java/C#, argument 0 in MSIL, and either "this" or
> "*this" in C++. I'm not quite sure which is the best thing to use in
> the C++ case; the MLDS is a bit inconsistent about it and the relevant
> parts of the code are currently not used, so it's hard to know what
> will keep things simplest. Probably we should name the MLDS lval
> constructor "self" to avoid tying it too strongly to the C++ "this"
> keyword.
>
I will work on adding a new lval called 'self' on the dotnet-foreign
branch. Then use it to generate my code, fix all the bugs then merge
the 'self' change back onto the main branch.
> > > > I now want to generate a .NET method body along the lines of
> > > >
> > > > .method void Salary(int s)
> > > > {
> > > > ldarg s
> > > > ldarg this_pointer
> > > > ldfld store
> > > > ldarg this_pointer
> > > > ldflda store
> > > > call mercury_salary_3(int, object[], object[]&)
>
> I think the `ldarg this_pointer' instructions need to be `ldarg 0'.
>
Correct, I just wanted to make clear what that ldarg instruction was for.
Pete
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list