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

Per Bothner per@bothner.com
Fri Oct 1 02:58:00 GMT 2004


Richard Kenner wrote:

> Remember that Ada is not using the lexer, so these (and subsequent) calls
> make no sense to me.  Can you look at the existing code and tell me what
> has to be changed?

You basically need to map Ada's Source_Ptr to source_location.  It is
reasonable for the mapping to be monotonic, i.e. one increases with the
order.  I see 3 basic strategies:
(1) Incrementally, as each source file is added.
(2) After all lexing, using a separate pass after the Ada front-end
is done, to build tables to map Source_Ptr to source_location.
(3) Replace the Source_Ptr reprepresentation by source_location.

Long-term (3) may or may not be the best option, but it is probably
to extensive a change for now.  (2) has the advantage that the changes
may be more centralized and require fewer "call-backs" from Ada code
into the line-map code, but it is probably less efficient, and
complicates interleaving front-end and back-end code.

So that suggests (1).  That means that we call linemap_add
when a new source file is read - i.e. when a new Source_Buffer
in the Source_File.Table.  The mapping from Source_Ptr to
source_location can be constructed:
(a) when first processing a Source_Buffer;
(b) some time later but before the next Source_Buffer;
(c) as each token is lexed.

To summarize:  you can create the Source_Ptr -> source_location
mapping in two basic ways:  interleaved with lexing, or as a
mapping when the Source_Buffer is read in.  Whichever you prefer.
-- 
	--Per Bothner
per@bothner.com   http://per.bothner.com/



More information about the Gcc mailing list