Ada, treelang needs to be converted to --enable-mapped-location
Per Bothner
per@bothner.com
Wed Oct 6 23:25:00 GMT 2004
Richard Kenner wrote:
> The point is that sinfo.ads and sinfo.adb is a huge and complex piece of
> code, far larger than linemap.c.
Are you thinking of some other file? sinfo.ad[sb] barely mentions
Source_Ptr at all: Only in two functions to get/set the End_Span,
neither of looks like they would need to be changed when converting
to source_location!
> It's going to be a tremendous amout
> of work to do the type of surgery you suggest
I'm not convinced. And I'm willing to bet on it: I'll do it
for USD 5k. If I reluctantly come to the conclusion you're right,
then no charge.
But see below.
> and I don't see *any* gain in doing do.
The gain is that alternative solutions require mapping between two
encodings for source locations. Plus better integration between
Ada and the rest of the compilers, which *we* think is desirable.
Plus using source_location is probably faster, considering what
you have to go through in Sloc_to_locus (even *before* switching
to source_location.
> In another thread I proposed a very simple solution. Can you please
> comment on whether it's workable or not?
IRC you proposed making a localized change in Sloc_to_locus. That is
certainly possible. There are two basic approaches:
(1) simple-minded - just create source_location values as requested,
without any "planning". If the requested location does not map
acceptably into the current line_map, just allocate a new one with
linemap_add. This to some extent happens automatically anyway. The
risk/downside is you may get too many line_map entries if the Source_Ptr
jumps around too much, but in practice it may not matter too much.
(1a) like (1) but with some caching. Keep a cache of say the 5 most
recently used line_map entries. If the requested Source_Ptr matches
one of them, use it. If not, create a new line_map entry using
linemap_add. The downside is that this ties you to the line-map
internals. The way around that is to define an API and place it
in a new file in libcpp. E.g. in libcpp/line-map-cache.[ch]:
static (struct line_map*) cache[5];
source_location
linemap_get_location (struct line_table*,
const char *filename, int line, int column);
(2) Build dome data structure to map Source_Ptr to source_location
efficiently and "compactly". E.g. such that the mapping is monotonic.
This is probably not worth it. at least not to begin with.
I suggest starting with (1), but defining the interfaces so you can
switch easily to (1a). Or just go for (1a) immediately.
--
--Per Bothner
per@bothner.com http://per.bothner.com/
More information about the Gcc
mailing list