Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Subroutine calls

10 views
Skip to first unread message

Leopold Toetsch

unread,
Apr 2, 2004, 10:25:14 AM4/2/04
to P6I
The PIR subroutine call syntax

_f()

expands (besides other instructions) to something like:

newsub P0, .Sub, _f
invokecc

I've now hacked together this sequence:
1) a new opcode (in dynoplibs/myops.ops for quick testing)

op pmc_const(out PMC, inlabelconst INT) {
$1 = PCONST($2)->u.key;
goto NEXT();
}

2) The call:
loadlib P10, "myops_ops"
pmc_const P0, 3
...
invokecc

(The constant number #3 is known to imcc when generating the const table
entry - actuall it would ne more like pmc_const P0, _f)

So *if* all is as static as in this code, and the Sub PMC isn't abused
by different callers (e.g. by attaching properties or such), then this
scheme would safe the C<newsub> operation, i.e. the construction of a
new PMC.

Comments welcome,
leo

0 new messages