[M0] parameter passing

kjstol parrotcode at gmail.com
Thu Jun 7 22:49:12 UTC 2012


Greetings,

M1's function calls are now properly working, with many thanks to
Nate++ who explained to me what the code should look like.
I'm eagerly working towards getting the Game of Life running. For that
to run, I need parameters.

Parameter and argument handling however has not been specced. I
suspect that parameters (and return values likewise) are passed
through registers in the new callframe that is created for each
function call.

Let' say there's a chunk foo, with the following signature:

foo(int i, num n, string s, string s2, int i2, num n2);

Does it make sense to pass these as follows:

i => I0
n => N0
s => S0
s2 => S1
i2 => I1
n2 => N1

Basically, separate per type, store in the registers of the frame to call.

Likewise, return values can be stored in the *current* frame, just
before returning. (I think). The caller can then access those values.
Alternatively, values can be stored in the parent's call frame (PCF),
but I wonder whether that's reasonable, since the caller's registers
shouldn't just change.

Does this sound reasonable? I'm not asking yet for definite decisions,
but would it look _more or less_ like this?


kjs


More information about the parrot-dev mailing list