Bytecode annotations - annotations op and custom backtraces

Jonathan Worthington jonathan at jnthn.net
Tue Jan 6 16:07:56 UTC 2009


Hi,

I've got PDD13 bytecode annotations implemented, plus the things 
mentioned in PDD19 (so they're now parsed and stored in the bytecode) 
and PDD23 (the .annotations method on exceptions, to get the annotations 
that applied when the exception was thrown).

Now this stuff is done, I'm ready to merge the branch in, after some 
feedback from folks++ on IRC. However, I have a couple more thoughts on 
things we might do to make this more useful (post-merge, since I doubt 
they'll be so disruptive).

1) In Perl 6, you can do things like $?FILE and $?LINE to get the 
current file and line number. I think the easiest way to make this work 
will be an annotations op.

  $P0 = annotations # gets a hash of all annotations in force
  $P0 = annotations 'line' # value of the 'line' annotation only

2) I think we're going to want some better control over generating 
backtraces. I suggest a backtrace method on an Exception object. It will 
return an array of hashes, which represent the backtrace and contain the 
keys:

    sub - the Sub PMC of the sub that had been called (or sub subclass 
of it)
    annotations - a hash of the annotations in force at the point the 
exception was thrown in the top entry, and those in force at the point 
of call down the rest of the chain

This should give HLL developers the ability to emit backtraces as they 
wish (since the language they are implementing may want a trace emitted 
in a given form).

Want? Not want?

Thanks,

Jonathan



More information about the parrot-dev mailing list