This patch resolves the problem mentioned in Patrick's replies to
#40626 and #41364 that bytecode does not store the :vtable pragma.
This always works:
% cat test.pir
.sub main :main
$P0 = subclass "Hash", "Test"
$P1 = new "Test"
$S0 = $P1
print "done\n"
.end
.namespace [ "Test" ]
.sub get_string :method :vtable
print "get_string\n"
.end
% parrot test.pir
get_string
done
Before the patch:
% parrot -o test.pbc test.pir
% parrot test.pbc
done
After the patch:
% parrot -o test.pbc test.pir
% parrot test.pbc
get_string
done
Subclassing from a core class is just there to show that it doesn't
re-break #40626. The freezing problem is fixed by adding an INTVAL
vtable_index member (index into Parrot_vtable_slot_names[] in
include/parrot/vtable.h) to the Parrot_sub struct in
include/parrot/sub.h, which is then frozen with the Sub PMC. This
hopefully means that we can deprecate the double-underscore method of
overriding vtable methods - if so, I'll happily submit a patch.
In the process, this patch also reworks how Parrot stores :vtable subs
by replacing the storing of duplicate methods in a VTABLE
sub-namespace with a lookup by their vtable_index.
Files changed:
src/objects.c
src/pmc/delegate.pmc
src/pmc/parrotobject.pmc
src/pmc/sub.pmc
lib/Parrot/Pmc2c/delegate.pm
include/parrot/sub.h
include/parrot/objects.h
compilers/imcc/pbc.c
Note: Since this patch affects all .pbc files, you'll have to run
`make clean` to regenerate them during the build process, or you'll
get weird errors. Also, part of this patch updates my last patch,
#41364, so if you get an error patching parrotobject.pmc, it's not
broken - the rest will work fine.
Thanks,
Alek Storm
Thanks!
Jonathan