Grupuri Google nu mai acceptă postările sau abonamentele noi Usenet. Conținutul anterior este în continuare vizibil.

[HOWTO] call a method on a PMC in PIR

6 afișări
Accesați primul mesaj necitit

Karl Forner

necitită,
28 sept. 2006, 06:47:4128.09.2006
– Internals List
I suppose that again it is a trivial question, but I did not manage to find
the answer by myself in the documentation.
So I want for example to call diretly the "elements" method on a
FixedBooleanArray

I tried

pmc.elements()
pmc."elements"()
pmc._elements()
pmc.__elements()

But it did not work...

In fact, what I really want to do, for debugging purposes, is to add a
custom method in the FixedBooleanArray.pmc (e.g get_allocated_size() ) and
be able to call it
from PIR test code.

Thanks
Karl Forner

Leopold Toetsch

necitită,
28 sept. 2006, 07:11:5328.09.2006
– perl6-i...@perl.org
Am Donnerstag, 28. September 2006 12:47 schrieb Karl Forner:
> I suppose that again it is a trivial question, but I did not manage to find
> the answer by myself in the documentation.
> So I want for example to call diretly the "elements" method on a
> FixedBooleanArray
>
> I tried
>
> pmc.elements()
> pmc."elements"()
> pmc._elements()
> pmc.__elements()
>
> But it did not work...

Exactly. Due to asymmetry of methods and vtables, the latter are not
accessible as methods. You have to use the equivalent opcode:

$I0 = elements ar_pmc

But you can code a PIR wrapper for it:

.namespace ['FixedBooleanArray']
.sub 'elements' :method
$I0 = elements self
.return ($I0)
.end

usable as:

$I0 = ar_pmc.'elements'()

> In fact, what I really want to do, for debugging purposes, is to add a
> custom method in the FixedBooleanArray.pmc (e.g get_allocated_size() ) and
> be able to call it
> from PIR test code.

As you need PMC internals for this, you'd have to add it to the .pmc itself
(temporarely):

METHOD INTVAL get_allocated_size() {
return PMC_int_val2(SELF); /* or whatever */
}

> Thanks
> Karl Forner

HTH,
leo

Karl Forner

necitită,
28 sept. 2006, 18:22:2828.09.2006
– Leopold Toetsch, perl6-i...@perl.org
>
> METHOD INTVAL get_allocated_size() {
> return PMC_int_val2(SELF); /* or whatever */
> }


great, exactly what I needed
thanks
karl

0 mesaje noi