Dan --

We were talking earlier about Jako supporting native calls. I have looked
at PDD 6 and PDD 3, and here's what I think so far...

I don't think I can get the native call stuff working until I have IMCC 
support
for PDD 3. IMCC is totally in charge of what goes into each register, and 
I
like it that way. I think I'd need something like this:

    .pcall
    .parg ...
    .parg ...
    call _whatever
    .pend

(prefix "P" for Parrot standard convention).

The .pcall directive resets any IMCC bookkeeping about any previous calls
and what registers were in use.

The .parg directives plop things where they go and increment the counters.

The .pend directive means done with this call. Free up registers for other
stuff, since I've got what I need.

This would be enough, I think, for me to create Jako calls out to native 
stuff.
Assuming the native stuff plops its return value according to PDD 6, then
we'll need the IMCC support for that, too. It might be handy for the 
entire
(1) set up args (2) call out (3) deal with returned values sequence to be
wrapped between .pcall and .pend:

    loadlib $P38, "libsdl"
    dlfunc $P39, $P38, "SDL_BlitSurface", "ipppp"
    .pcall
    .parg $P33
    .parg $P34
    .parg $P35
    .parg $P36
    invoke $P39
    .pres $I100
    .pend


jakoc would have to know what virtual register types to use for this to 
work out.
It would probably look something like this in Jako:

    sub int SDL_BlitSurface : "libsdl:SDL_BlitSurface:ipppp" (obj src, 
obj, srcrect, obj dst, obj dstrect);

Where the third colon-separated field is redundant in this case and can 
become the empty string.

Or possibly (a call without a previous declaration):

    var int foo = SDL_BlitSurface : "libsdl:SDL_BlitSurface:ipppp" (a, b, 
c, d);

(although please don't hold me to these syntax ideas -- they are only my 
first ones).


Things that would make this nice:

  * Multiple loadlibs for the same lib don't cause trouble and are fast.

  * Same for multiple dlfunc calls for the same thing.

Anyway, more thinking and talking is probably in order. I'd love to see an 
imcc
implementation of PDD 3 like or better than the above sketch, so I can 
rely on
IMCC to keep all the register stuff straight. After that, I don't think 
the incremental
effort in jakoc creates a high barrier.


Regards,

-- Gregor

Reply via email to