Re: [cc65] Understanding inner workings of ca65

From: Ullrich von Bassewitz <uz1musoftware.de>
Date: 2013-07-03 23:43:57
Hi!

On Wed, Jul 03, 2013 at 09:18:54PM +0200, Spiro Trikaliotis wrote:
> If I understand it correctly, for macros, ca65 does *not* remember the
> actual lines, but only the already tokenized input.
> a. Is this correct?

Yes.

> b. If yes, I cannot recreate the exact source input line, or is this
>    data hidden somewhere?

There are facilities to keep track of lines, otherwise the listing wouldn't be
possible. But since ca65 hasn't been designed for listing of macro expansions,
the necessary changes will probably require more than just calling a function
to retrieve the info.

> I am currently thinking about different approaches to get a "full"
> listing:
>
> a. add "somehow" dummy-fragments for lines in macros which do not emit
>    data bytes; this way, the struct Fragment would contain line info for
>    these lines, too.
> b1. from the file name/line number info, recreate the input line by
>     rereading the input file (this also applies for macro lines that
>     actually emit data)
> b2. alternative to b1: add code so that the full input line data is
>     actually added, so that I do not need to reread the input line.
>     (where, how is totally unclear to me ATM)
>
> Alternative to this:
> Try to use b2 all over, that is, for each macro, remember the actual
> lines that lead to the token (by copying them) and actually generating
> full listing info.
>
> Is this clear? Is this feasable? What would make the most sense?

Probably none of all this is really good. The input lines are already there,
because they're used for the listing. What you need is to add data structures
that track references between tokens and the actual lines. You might have
noticed that tokens do contain a file position, so the data is there. But as
said above a proper solution will take more than just add a few function
calls.

Regards


        Uz


-- 
Ullrich von Bassewitz                                  uz@musoftware.de
----------------------------------------------------------------------
To unsubscribe from the list send mail to majordomo@musoftware.de with
the string "unsubscribe cc65" in the body(!) of the mail.
Received on Wed Jul 3 23:44:05 2013

This archive was generated by hypermail 2.1.8 : 2013-07-03 23:44:08 CEST