Add more test coverage for RGBASM (#1256)

This also fixes two bugs: `-1 >>> 32` was -1 not 0, and `macro_FreeArgs` should have been called but wasn't.
This commit is contained in:
Rangi
2023-11-29 15:16:05 -05:00
committed by GitHub
parent b46aa0f55b
commit cee3d1c859
51 changed files with 238 additions and 80 deletions

View File

@@ -104,12 +104,6 @@ struct Charmap *charmap_New(char const *name, char const *baseName)
return charmap;
}
void charmap_Delete(struct Charmap *charmap)
{
free(charmap->name);
free(charmap);
}
void charmap_Set(char const *name)
{
struct Charmap **charmap = (struct Charmap **)hash_GetNode(charmaps, name);

View File

@@ -272,8 +272,10 @@ bool yywrap(void)
lexer_DeleteState(context->lexerState);
// Restore args if a macro (not REPT) saved them
if (context->fileInfo->type == NODE_MACRO)
if (context->fileInfo->type == NODE_MACRO) {
macro_FreeArgs(macro_GetCurrentArgs());
macro_UseNewArgs(contextStack->macroArgs);
}
// Free the file stack node
if (!context->fileInfo->referenced)
free(context->fileInfo);

View File

@@ -677,18 +677,6 @@ void sect_Skip(uint32_t skip, bool ds)
}
}
// Output a NULL terminated string (excluding the NULL-character)
void sect_String(char const *s)
{
if (!checkcodesection())
return;
if (!reserveSpace(strlen(s)))
return;
while (*s)
writebyte(*s++);
}
// Output a relocatable byte. Checking will be done to see if it
// is an absolute value in disguise.
void sect_RelByte(struct Expression *expr, uint32_t pcShift)

View File

@@ -173,15 +173,6 @@ struct Symbol *sym_FindExactSymbol(char const *symName)
return (struct Symbol *)hash_GetElement(symbols, symName);
}
struct Symbol *sym_FindUnscopedSymbol(char const *symName)
{
if (strchr(symName, '.')) {
error("Expected non-scoped symbol name, not \"%s\"\n", symName);
return NULL;
}
return sym_FindExactSymbol(symName);
}
struct Symbol *sym_FindScopedSymbol(char const *symName)
{
char const *localName = strchr(symName, '.');

View File

@@ -60,7 +60,7 @@ int32_t op_shift_right(int32_t value, int32_t amount)
// Repeat the easy cases here to avoid INT_MIN funny business
if (amount == 0)
return value;
if (value == 0 || amount <= -32)
if (value == 0 || amount < -31)
return 0;
if (amount > 31)
return (value < 0) ? -1 : 0;
@@ -84,10 +84,8 @@ int32_t op_shift_right_unsigned(int32_t value, int32_t amount)
// Repeat the easy cases here to avoid INT_MIN funny business
if (amount == 0)
return value;
if (value == 0 || amount <= -32)
if (value == 0 || amount < -31 || amount > 31)
return 0;
if (amount > 31)
return (value < 0) ? -1 : 0;
if (amount < 0)
return op_shift_left(value, -amount);