mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-23 03:22:08 +00:00
Actually rely on createsymbol never returning NULL
This reduces complexity, basically
This commit is contained in:
@@ -493,12 +493,10 @@ void sym_AddEqu(char *tzSym, int32_t value)
|
|||||||
{
|
{
|
||||||
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
||||||
|
|
||||||
if (nsym) {
|
nsym->nValue = value;
|
||||||
nsym->nValue = value;
|
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->nType |= SYMF_EQU | SYMF_DEFINED | SYMF_CONST;
|
nsym->pScope = NULL;
|
||||||
nsym->pScope = NULL;
|
updateSymbolFilename(nsym);
|
||||||
updateSymbolFilename(nsym);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -517,18 +515,16 @@ void sym_AddString(char *tzSym, char *tzValue)
|
|||||||
{
|
{
|
||||||
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
||||||
|
|
||||||
if (nsym) {
|
nsym->pMacro = malloc(strlen(tzValue) + 1);
|
||||||
nsym->pMacro = malloc(strlen(tzValue) + 1);
|
|
||||||
|
|
||||||
if (nsym->pMacro != NULL)
|
if (nsym->pMacro != NULL)
|
||||||
strcpy(nsym->pMacro, tzValue);
|
strcpy(nsym->pMacro, tzValue);
|
||||||
else
|
else
|
||||||
fatalerror("No memory for string equate");
|
fatalerror("No memory for string equate");
|
||||||
|
|
||||||
nsym->nType |= SYMF_STRING | SYMF_DEFINED;
|
nsym->nType |= SYMF_STRING | SYMF_DEFINED;
|
||||||
nsym->ulMacroSize = strlen(tzValue);
|
nsym->ulMacroSize = strlen(tzValue);
|
||||||
nsym->pScope = NULL;
|
nsym->pScope = NULL;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -570,12 +566,10 @@ void sym_AddSet(char *tzSym, int32_t value)
|
|||||||
nsym = createsymbol(tzSym);
|
nsym = createsymbol(tzSym);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsym) {
|
nsym->nValue = value;
|
||||||
nsym->nValue = value;
|
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
||||||
nsym->nType |= SYMF_SET | SYMF_DEFINED | SYMF_CONST;
|
nsym->pScope = NULL;
|
||||||
nsym->pScope = NULL;
|
updateSymbolFilename(nsym);
|
||||||
updateSymbolFilename(nsym);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -634,24 +628,22 @@ void sym_AddReloc(char *tzSym)
|
|||||||
nsym = createsymbol(tzSym);
|
nsym = createsymbol(tzSym);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsym) {
|
nsym->nValue = nPC;
|
||||||
nsym->nValue = nPC;
|
nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
|
||||||
nsym->nType |= SYMF_RELOC | SYMF_DEFINED;
|
if (localPtr)
|
||||||
if (localPtr)
|
nsym->nType |= SYMF_LOCAL;
|
||||||
nsym->nType |= SYMF_LOCAL;
|
|
||||||
|
|
||||||
if (exportall)
|
if (exportall)
|
||||||
nsym->nType |= SYMF_EXPORT;
|
nsym->nType |= SYMF_EXPORT;
|
||||||
|
|
||||||
nsym->pScope = scope;
|
nsym->pScope = scope;
|
||||||
nsym->pSection = pCurrentSection;
|
nsym->pSection = pCurrentSection;
|
||||||
/* Labels need to be assigned a section, except PC */
|
/* Labels need to be assigned a section, except PC */
|
||||||
if (!pCurrentSection && strcmp(tzSym, "@"))
|
if (!pCurrentSection && strcmp(tzSym, "@"))
|
||||||
yyerror("Label \"%s\" created outside of a SECTION",
|
yyerror("Label \"%s\" created outside of a SECTION",
|
||||||
tzSym);
|
tzSym);
|
||||||
|
|
||||||
updateSymbolFilename(nsym);
|
updateSymbolFilename(nsym);
|
||||||
}
|
|
||||||
|
|
||||||
pScope = findsymbol(tzSym, scope);
|
pScope = findsymbol(tzSym, scope);
|
||||||
}
|
}
|
||||||
@@ -713,8 +705,7 @@ void sym_Export(char *tzSym)
|
|||||||
if (nsym == NULL)
|
if (nsym == NULL)
|
||||||
nsym = createsymbol(tzSym);
|
nsym = createsymbol(tzSym);
|
||||||
|
|
||||||
if (nsym)
|
nsym->nType |= SYMF_EXPORT;
|
||||||
nsym->nType |= SYMF_EXPORT;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -724,18 +715,16 @@ void sym_AddMacro(char *tzSym, int32_t nDefLineNo)
|
|||||||
{
|
{
|
||||||
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
struct sSymbol *nsym = createNonrelocSymbol(tzSym);
|
||||||
|
|
||||||
if (nsym) {
|
nsym->nType |= SYMF_MACRO | SYMF_DEFINED;
|
||||||
nsym->nType |= SYMF_MACRO | SYMF_DEFINED;
|
nsym->pScope = NULL;
|
||||||
nsym->pScope = NULL;
|
nsym->ulMacroSize = ulNewMacroSize;
|
||||||
nsym->ulMacroSize = ulNewMacroSize;
|
nsym->pMacro = tzNewMacro;
|
||||||
nsym->pMacro = tzNewMacro;
|
updateSymbolFilename(nsym);
|
||||||
updateSymbolFilename(nsym);
|
/*
|
||||||
/*
|
* The symbol is created at the line after the `endm`,
|
||||||
* The symbol is created at the line after the `endm`,
|
* override this with the actual definition line
|
||||||
* override this with the actual definition line
|
*/
|
||||||
*/
|
nsym->nFileLine = nDefLineNo;
|
||||||
nsym->nFileLine = nDefLineNo;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -762,12 +751,11 @@ void sym_Ref(char *tzSym)
|
|||||||
|
|
||||||
nsym = createsymbol(tzSym);
|
nsym = createsymbol(tzSym);
|
||||||
|
|
||||||
if (nsym && isLocal)
|
if (isLocal)
|
||||||
nsym->nType |= SYMF_LOCAL;
|
nsym->nType |= SYMF_LOCAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nsym)
|
nsym->nType |= SYMF_REF;
|
||||||
nsym->nType |= SYMF_REF;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
Reference in New Issue
Block a user