First I'd like to thank all contributors for the steady stream of patches that made this round revision number possible.

Rev 9000 happened to hit leo-ctx5. It is a test and looks like this:

$ cat cobj.pir
.sub make_obj @IMMEDIATE, @ANON
    .local pmc cl, o
    cl = newclass "Foo"
    addattribute cl, 'x'
    o = new 'Foo'
    $P0 = new String
    $P0 = "ok 1\n"
    setattribute o, 'x', $P0
    .return (o)
.end

.sub main @MAIN
    .const .Sub o = "make_obj"
    $P0 = getattribute o, 'x'
    print $P0
.end

$ parrot -o cobj.pbc cobj.pir

During compilation the code of the subroutine 'make_obj' is run due to it's @IMMEDIATE flag and an instance of Foo is returned. This PMC replaces now the entry of the Sub PMC in the constant table. PMCs in the constant table are serialized as frozen images in the PBC.

At runtime ...

$ parrot cobj.pir
ok 1

... first the PBC is unpacked, which thaws the object (and it's class). Only 'main' is executed. The constant definition line, which is actually

  set_p_pc Px, PMC_CONST(n)

fetches an already created object from the constant table.

Have fun,
leo

Reply via email to