I'm adding this code in now (sorry I've been behind on p6i mail--hopefully I'll catch up in a big dump today). Here's the sketch.

One new op:

bnc Pw, Px, Sy, Sz

which builds up a native call pmc that can be invoked. W is the new PMC for the function (we create it), X is a handle to a dlopened library, Y is the function name, and Z is the signature.

In this case, the signature is zero or more characters. The first character is the return type, the remaining ones are the parameters. The following letters apply:

v - void. Nothing. Only good for return types
c - char
C - char *
s - short
S - short *
i - int
I - int *
l - long
L - long *
f - float
F - float *
d - double
D - double *
x - long double
X - long double *
p - pointer from pmc
P - pointer to PMC
b - pointer from buffer
B - pointer to buffer

In the case of no signature characters, the signature is assumed to be "void foo()".

The data's stored in a PMC of type NCI. The data pointer holds a pointer to the main routine to call, while the struct value holds a pointer to an ancillary routine. In the starting case the ancillary routine will be the actual C function, while the main routine is one that knows how to extract the parameters out of the various registers, pass them in, and store the result somewhere. Later the ancillary routine may be nonexistant if we build up the function headers on the fly and embed the destination function into them. (We'll see)

Parameters of type short, int, and long come from I registers.
Parameters of type char, char *, and the buffer pointers come from S registers
Parameters of type float and double come from N registers
Parameters of type P and p come from P registers.

Currently open is the situation of flags and such from more complex calls. (Like what we do if we get back a pointer that's getting stuffed into a PMC--do we set the type, if so what type, and what do we set the flags to?)

I'm thinking, as part of this, that more introspection on buffers and PMCs is in order, so we can have bytecode manipulate their flags and types properly.
--
Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski even samurai
[EMAIL PROTECTED] have teddy bears and even
teddy bears get drunk

Reply via email to