[RFC] Constant PMCs in PBC

Patrick R. Michaud pmichaud at pobox.com
Mon Dec 7 15:28:47 UTC 2009


On Mon, Dec 07, 2009 at 09:04:41AM -0500, Will Coleda wrote:
> > The other limitation is that :immediate only helps when creating
> > constants of core PMC types.  If you have a dynpmc or some other
> > structure (e.g., for HLL constants), or if the act of creating the
> > constant has other side-effects, then :immediate doesn't help.
> 
> I believe this issue of creating non-core types can be addressed by
> creating and hll_mapping your types in a preceding :immediate, but am
> not in a position to verify it now.

I think this works when running .pir files, but fails when trying
to do the same from a precompiled .pbc:

    $ cat x.pir

    .sub 'main'
        .const 'Sub' $P0 = 'myconst'
        $S0 = typeof $P0
        say $S0
    .end
    
    .sub '' :anon :immediate
        $P0 = get_class ['Integer']
        $P1 = subclass $P0, ['MyInt']
    .end
    
    .sub 'myconst' :immediate
        $P0 = new ['MyInt']
        .return ($P0)
    .end

    $ ./parrot x.pir
    MyInt
    $ ./parrot -o x.pbc x.pir
    $ ./parrot x.pbc
    Invalid charset number '1850308941' specified
    $ 

In general I've found that the side-effects of :immediate subs 
don't carry through to precompiled .pbc files.

I speculate that the bytecode that gets frozen into the .pbc 
(e.g., for 'myconst' above) ends up being of a type that 
isn't frozen/thawed/properly created when the .pbc is
then loaded.

Pm


More information about the parrot-dev mailing list