"Leopold Toetsch (via RT)" <[EMAIL PROTECTED]> wrote:
SYNOPSIS
pbc_merge -o all.pbc a.pbc, b.pbc [, ...]
ABSTRACT
Read all given pbc files and repack the bytecode into one result pbc.
DESCRIPTION
Since r8676 parrot can (again) create a string representation of evaled
code.
compiled = compiler(code)
print io, compiled
is all to create a packfile, suitable for later loading with
C<load_bytecode>.
But as some language compilers like forth create a lot of evaled code,
there should be a way to combine these packfiles into one.
The utility should roughly work like this:
- create all default segments
- for all pbcs
append each segment to the combined one and
- fold constants
- relocate subroutine offsets to the new offset
Done, checked in as revision r9207. Example of it at work is at the end of
the email, which tests both sub offset relocation and constant table pointer
corrections.
To build it, after an svn up and re-configuring, do:-
make pbc_merge # pbc_merge.exe on Win32
Or it is also built when you do:-
make parrot_utils
Feedback (bugs, issues with the code, feature requests) welcome.
Folding constants is a bit tricky, as it needs also to walk trough the
code and replace changed constant table entries.
This sounded harder than it actually turned out to be - the ops side of
Parrot is well put together.
Have fun,
Jonathan
$ cat in1.imc
.sub _main @MAIN
.local string ft
ft = _FortyTwo()
print "Got "
print ft
print "\n"
.end
$ cat in2.imc
.sub _FortyTwo
.return("42")
.end
$ parrot -o in1.pbc in1.imc
$ parrot -o in2.pbc in2.imc
$ pbc_merge -o out.pbc in1.pbc in2.pbc
$ parrot out.pbc
Got 42
$ pbc_merge -o out.pbc in2.pbc in1.pbc
$ parrot out.pbc
Got 42