How rewrite without '::' ?
Allison Randal
allison at parrot.org
Wed Nov 19 22:16:57 UTC 2008
François Perrad wrote:
> the PMC equivalent of the following PIR :
> $P0 = new 'Foo::Bar'
> is like :
> INTVAL type = pmc_type(INTERP, const_string(INTERP, "Foo::Bar"));
> PMC *pmc = pmc_new(INTERP, type);
>
> Now, how rewrite
> $P0 = new ['Foo'; 'Bar']
>
> INTVAL type = pmc_type_p(INTERP, ??? any idea ???);
> PMC *pmc = pmc_new(INTERP, type);
PMC *foo_part = key_new_cstring(INTERP, "Foo");
PMC *bar_part = key_new_cstring(INTERP, "Bar");
PMC *key = key_append(INTERP, foo_part, bar_part);
PMC *class_object = Parrot_oo_get_class(INTERP, key);
PMC *object = VTABLE_instantiate(INTERP, class_object, PMCNULL);
'Parrot_oo_get_class' will also take an array, so you can do that
instead of a key, but this is the most direct translation of the PIR code.
We should probably add a function that takes a C varargs list and does
all this for you.
Allison
More information about the parrot-dev
mailing list