0
0
mirror of https://github.com/netwide-assembler/nasm.git synced 2025-10-10 00:25:06 -04:00

labels: make the prefix/suffix options and pragmas consistent

Make the spellings for the label-mangling options and pragmas
consistent, and implement the directive forms which were documented
but never implemented.

Signed-off-by: H. Peter Anvin (Intel) <hpa@zytor.com>
This commit is contained in:
H. Peter Anvin (Intel)
2025-10-07 18:46:39 -07:00
parent c08b4edca1
commit ae9335a0b9
11 changed files with 116 additions and 50 deletions

View File

@@ -262,14 +262,45 @@ static inline bool is_global(enum label_type type)
return type == LBL_GLOBAL || type == LBL_COMMON;
}
enum mangle_index {
LM_LPREFIX, /* Local variable prefix */
LM_LSUFFIX, /* Local variable suffix */
LM_GPREFIX, /* Global variable prefix */
LM_GSUFFIX /* GLobal variable suffix */
};
static const char *mangle_strings[] = {"", "", "", ""};
static bool mangle_string_set[ARRAY_SIZE(mangle_strings)];
/*
* Set a prefix or suffix
*/
void set_label_mangle(enum mangle_index which, const char *what)
void set_label_mangle(enum directive how, const char *what)
{
enum mangle_index which;
switch (how) {
case D_PREFIX:
case D_GPREFIX:
which = LM_GPREFIX;
break;
case D_SUFFIX:
case D_GSUFFIX:
case D_POSTFIX:
case D_GPOSTFIX:
which = LM_GSUFFIX;
break;
case D_LPREFIX:
which = LM_LPREFIX;
break;
case D_LSUFFIX:
case D_LPOSTFIX:
which = LM_LSUFFIX;
break;
default:
return;
}
if (mangle_string_set[which])
return; /* Once set, do not change */