6502bench icon indicating copy to clipboard operation
6502bench copied to clipboard

Hyperlinks in generated HTML for local vars and non-unique local labels

Open micahcowan opened this issue 1 month ago • 3 comments

If local vars extends some ways, it can be very cumbersom to have to search around for where that name was defined and commented, it would be nice for SourceGen to hyperlink to the containing var table in which it was defined.

Similarly for non-unique local labels (and, if it applies, unique ones; I don't use those as I'm not sure what the advantage is over global). While a human reader might be confused as to which non-unique label of the same name might be the target, SourceGen certainly knows. Moreover, if there are several non-locals nearby, even of differing names, it's more of a hassle to examine the names of each than to click a hyperlink as per usual.

micahcowan avatar Nov 24 '25 20:11 micahcowan

There's a "TODO" for this in the code. I don't remember the details, but I suspect the reason I didn't do it initially is because the exporter is actually working off of the screen-formatted text. This ensures that the export matches the on-screen version, and was a whole lot easier to implement, but it makes it awkward to get at things like the uniquified form of local labels.

I should be able to make this work by tucking extra data into the list of on-screen lines.

fadden avatar Nov 24 '25 23:11 fadden

Yeah, I was thinking you could perhaps include the original-file offset as part of the anchor, similar to the way you auto-generate LADDR labels (you could use the .org address, as you do there... but eventually I think it'd be really cool for SourceGen to support e.g. NES mapper chips (the main reason I don't use SourceGen for most NES disassemblies... fortunately the current one is for a cartridge that doesn't remap ROM regions), so file offset would be more robust toward that sort of eventuality).

It won't be nearly as pretty as the anchor system you have in place for unique names... but it'll get the job done.

micahcowan avatar Nov 25 '25 00:11 micahcowan

Remapping ROM regions should work. See e.g. this monster. There are some tricks for managing wayward references.

Internally, non-unique locals are stored with the file offset. If you use File > Generate Label File you'll see them.

fadden avatar Nov 25 '25 00:11 fadden