On Tuesday 23 October 2007 09:40:29 François PERRAD wrote:

> I've the following problem in languages/lua/pmc/luathread.pmc :
>
> when the creation of Parrot::Coroutine
> (runtime/parrot/library/Parrot/Coroutine.pir) was :
>
>      .local pmc coro
>      .const .Sub coro_sub = "enumerate_tree"
>      coro = new 'Parrot::Coroutine', coro_sub
>
> in luathread.pmc, I wrote (translation PIR to C):
>
>      void init_pmc(PMC* sub) {
>          INTVAL type = pmc_type(INTERP,
>                            const_string(INTERP, "Parrot::Coroutine"));
>          if (type)
>              PMC_pmc_val(SELF) = pmc_new_init(INTERP, type, sub);
>          else
>              real_exception(INTERP, NULL, E_Exception,
>                             "Parrot::Coroutine not found");
>      }
>
> now, the creation of Parrot::Coroutine becomes (r21929) :
>
>      .local pmc coro
>      .const .Sub coro_sub = "enumerate_tree"
>      coro_class = get_class 'Parrot::Coroutine'
>      coro = coro_class.'new'('initial_sub' => coro_sub)
>
> So, how translate it in PMC ?

I think it's something like:

        STRING *name   = CONST_STRING(INTERP, "Parrot::Coroutine");
        PMC    *sub    = ... ;
        PMC    *_class = Parrot_oo_get_class_str(INTERP, name);
        PMC    *coro;

        if (PMC_IS_NULL(_class))
                real_exception(INTERP, ... );

        coro = VTABLE_instantiate(INTERP, _class, sub);

-- c

Reply via email to