Make istruc "at" support struc local labels

istruc currently does not work very well with passing local labels to
"at" macro, as the labels are inserted literally. E.g. considering the
example from test/struc.asm:

	struc teststruc1
	  .long: resd 1
	  .word: resw 1
	  .byte: resb 1
	  .str:  resb 32
	endstruc
	; ...
	istruc teststruc1
	 at .word, db 5
	iend

if one were to put a global label before istruc to refer to its
instance, the code would fail to compile, due to ".word" being unknown
in that scope. Of course one could then use full form after "at", i.e.
"teststruc1.word", but this seems rather tedious.

This also makes istruc use with local labels fail for anything but the
last declared struc.

The change automatically prepends struc name to the label if the label
given to "at" starts with a dot.

Signed-off-by: Sławomir Bocheński <lkslawek@gmail.com>
This commit is contained in:
Sławomir Bocheński 2022-09-08 20:37:53 +02:00
parent a8ff6bf771
commit 5b9bcacebb

View file

@ -99,7 +99,13 @@ STD: nasm
%endmacro
%imacro at 1-2+.nolist
times (%1-%$strucname)-($-%$strucstart) db 0
%defstr %$member %1
%substr %$member1 %$member 1
%ifidn %$member1, '.'
times (%$strucname%1-%$strucname)-($-%$strucstart) db 0
%else
times (%1-%$strucname)-($-%$strucstart) db 0
%endif
%2
%endmacro