whiteknight/imcc_tag branch needs review

Andrew Whitworth wknight8111 at gmail.com
Sat Aug 6 12:43:16 UTC 2011

The whiteknight/imcc_tag branch is coming ready for review, and I
would like to get some eyes and some opinions on it. The branch adds a
new :tag syntax for subs, which allows the user to tag any Sub with an
arbitrary string tag or tags. This is intended to be a replacement for
things like :load and :init flags in the long term, and is much more
flexible. Here's a short code example using the new tag syntax:

.sub 'foo' :tag("load", "init")

Then, if we have a PackfileView PMC, we can access these subs like this:

$P0 = pfview.'subs_by_flag'("load")

the 'subs_by_flag' method returns a ResizablePMCArray with all Subs
with the given tag, which you can loop over and execute. Notice that
the new load_bytecode_p_s op doesn't automatically execute :load or
:tag("load") functions the way load_bytecode_s. PackfileView also has
new methods is_initialized and mark_initialized to keep track of
things we've already executed, so we don't accidentally initialize a
library twice. I'll put together some comprehensive docs on all these
details soon.

A few points:

You can get the current PackfileView from interp["packfile"]. You can
get one for a library with "$P0 = load_bytecode 'foo.pbc'", etc

PackfileView.subs_by_flag("load") and "init" will also return Subs
marked with :load and :init respectively. This is for backwards
compatibility while we upgrade a variety of things.

:tag("load") does not automatically execute during load_bytecode_s,
but :load still does (Replace load_bytecode_s with load_bytecode_p_s
and use PackfileView.subs_by_flag instead)

:tag("init") does not automatically execute during program execution,
but :init still does. I'm working to resolve this issue in a separate
branch. For now, you can use PackfileView.subs_by_flag("init") to get
the list of init subs and execute them.

You aren't limited to "load" and "init" tags, you can use any string
you want. So, you can have multi-stage initialization, cleanup, and
other events too.

PackfileView and its methods are already in master. This branch only
adds the new :tag syntax for PIR.

I would really like feedback on the new syntax and all the new
semantics, the implementation if you're brave enough to dig into the
IMCC changesets, etc. Depending on feedback this branch could merge
pretty soon, or wait for a while to iron out details.


--Andrew Whitworth

More information about the parrot-dev mailing list