That is:
load_bytecode 'foo.pir'
load_bytecode 'foo.pasm' # silently ignored
load_bytecode 'foo.pbc' # silently ignored
load_bytecode 'bar/foo.pir' # ok [2]
There is also an interface to query load_bytecode-ed code:
.include 'iglobals.pasm'
interp = getinterp
hsh = interp[.IGLOBALS_PBC_LIBS'] # well PASM/PIR too
is_loaded = exists hsh['foo']
# or iterate over the hash or whatever
fullnane = hsh['foo']
HTH
leo
[1] the hash key is the given filename w/o extension. So it's not really
testing if it is the same file, but should be good enough for now.
[2] untested - more tests welcome
Neat - this is a fine approximate solution until we have real pbc
hashing, and *may* continue to be necessary even with hashing,
depending on whether we can count on reproducible hashes from
successive compilations of the same source file.
--
Chip Salzenberg <ch...@pobox.com>
Surely in that case we instead choose to hash based on the source file?
(Or the Parrot equivalent of hashing C code by hashing the C pre-processor
output. Something akin to how ccache works.)
Nicholas Clark
That's a good fallback, but a perfect hash scheme would figure out
that e.g. /tmp/bar.pbc is identical to the compilation output of
/usr/share/bar.pir, and thus refuse to load one if the other has
already been loaded.
There are lots of ways to get good enough here; I'm not worried.
--
Chip Salzenberg <ch...@pobox.com>