Hi,
Writing a compiler for Parrot? I need your input! :-) I'm looking to work
on enabling Parrot to store away HLL debug info - that is, the file name,
line number, columns etc in the high level language source code. This data
can then be used to emit useful error messages that relate to the HLL source
code rather than the generated PIR/PASM/whatever. We'll provide some
mechanism to allow a language to emit a custom error message using that data
later on.
This kinda breaks down into:-
1) Some PIR syntax for attaching the info to pieces of PIR/PASM/whatever.
2) A format for storing this info in a packfile.
Here are my current thoughts.
* We shouldn't restrict this info to a fixed set of fields. If we have file
name and line, someone will want column. If we have all three, I expect
someone will then want something else. Let's future-proof this somewhat.
* Much data that will be stored has one to many relationships. For example,
a file has many lines, and a line has many columns. Having to specify the
file and line every time you want to specify a column will bloat generated
code massively and mean that an efficient storage scheme would have to do
more work.
* I'm thinking of a PIR syntax along the lines of this:-
.hll_debug file "something.pl"
.hll_debug line 1
# code from something.pl line 1 goes here
.hll_debug line 2
# code from something.pl line 2 goes here - note file is "inherited"
How does it feel? I doubt it'll be something that is written by hand,
mind - still might as well have something that's OK to read and generate
though.
* Storage wise, there will be a "table" mapping each field name to a number
and also specify a type for it (integer or string). This will be in the HLL
debug segment header. The data part of the segment will contain entries
consisting of 3 integers:
Instruction Number
Field number (is it a line, or a file name, or whatever)
Either an integer or a string constant from the constants table
Note that one instruction may have more than one entry. Instructions with
no entreis inherit the entries made for each field in a prior instruction.
A special entry, maybe with instruction number having value 0xFFFFFFFF, will
be reserved to indicate that all currently inherited data should be
dispensed with, so it is possible to merge bytecode sanely.
* Maybe there is a need for some PIR syntax for the special entry described
above?
.hll_debug
Or maybe:-
.hll_debug -
Like it? Hate it? Got ideas? Please let me know, so I can spec and
implement something that's actually useful and usable.
Thanks,
Jonathan