Ada, treelang needs to be converted to --enable-mapped-location

Robert Dewar dewar@gnat.com
Thu Oct 7 09:52:00 GMT 2004


I did a bit more rummaging in the GNAT front end to see
how source locations are used, and as I rummage, more comes
to light (and to memory).

Basically an Sloc value in GNAT encodes a triple
(file-with-instantiation-history, line, column)

where line is unlimited and column is 0-32767, though
that limit on columns could trivially be increased if
necessary.

There is a strong assumption (really subsuming my
assumptions 1 and 2 in the previous note), that a
source location can be used as a direct index into
the source buffer for a given file, e.g.

    Source_Buffer (Sloc)

where Source_Buffer is a pointer to a source buffer
appropriately biased, allows direct access to the
character in the source buffer corresponding to Sloc,

This assumption is made throughout the front end, but only
in a relatively few places outside the lexical scanner. The
lexical scanner however is fundamentally dependent on this
assumption, since for example Token_Ptr, a pointer to the
current token *is* a Sloc value and that identity is assumed
througout the scanner.

Trying to abstract this out would require a lot of
source changes, and run the risk of introducing substantial
overhead into the lexical scanner, where speed is really
important.

My basic conclusion here is that trying to make any significant
change to the Sloc data structure in GNAT would be really major
work, and require substantial rewriting of the scanner.

Of course, it is still possible to do a conversion from one
form to the other in gigi, not trivial, but certainly possible.
None of my observations here speak to that possibility.



More information about the Gcc mailing list