mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-21 18:52:07 +00:00
Use sym_FindSymbol() where possible
This commit is contained in:
@@ -207,7 +207,7 @@ struct sSymbol *findsymbol(char *s, struct sSymbol *scope)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find a symbol by name and scope
|
* Find a symbol by name, with automatically determined scope
|
||||||
*/
|
*/
|
||||||
struct sSymbol *sym_FindSymbol(char *tzName)
|
struct sSymbol *sym_FindSymbol(char *tzName)
|
||||||
{
|
{
|
||||||
@@ -256,14 +256,7 @@ void sym_Purge(char *tzName)
|
|||||||
*/
|
*/
|
||||||
uint32_t sym_isConstDefined(char *tzName)
|
uint32_t sym_isConstDefined(char *tzName)
|
||||||
{
|
{
|
||||||
struct sSymbol *psym, *pscope;
|
struct sSymbol *psym = sym_FindSymbol(tzName);
|
||||||
|
|
||||||
if (*tzName == '.')
|
|
||||||
pscope = pScope;
|
|
||||||
else
|
|
||||||
pscope = NULL;
|
|
||||||
|
|
||||||
psym = findsymbol(tzName, pscope);
|
|
||||||
|
|
||||||
if (psym && (psym->nType & SYMF_DEFINED)) {
|
if (psym && (psym->nType & SYMF_DEFINED)) {
|
||||||
uint32_t mask = SYMF_EQU | SYMF_SET | SYMF_MACRO | SYMF_STRING;
|
uint32_t mask = SYMF_EQU | SYMF_SET | SYMF_MACRO | SYMF_STRING;
|
||||||
@@ -280,19 +273,9 @@ uint32_t sym_isConstDefined(char *tzName)
|
|||||||
|
|
||||||
uint32_t sym_isDefined(char *tzName)
|
uint32_t sym_isDefined(char *tzName)
|
||||||
{
|
{
|
||||||
struct sSymbol *psym, *pscope;
|
struct sSymbol *psym = sym_FindSymbol(tzName);
|
||||||
|
|
||||||
if (*tzName == '.')
|
return (psym && (psym->nType & SYMF_DEFINED));
|
||||||
pscope = pScope;
|
|
||||||
else
|
|
||||||
pscope = NULL;
|
|
||||||
|
|
||||||
psym = findsymbol(tzName, pscope);
|
|
||||||
|
|
||||||
if (psym && (psym->nType & SYMF_DEFINED))
|
|
||||||
return 1;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -300,21 +283,9 @@ uint32_t sym_isDefined(char *tzName)
|
|||||||
*/
|
*/
|
||||||
uint32_t sym_isConstant(char *s)
|
uint32_t sym_isConstant(char *s)
|
||||||
{
|
{
|
||||||
struct sSymbol *psym, *pscope;
|
struct sSymbol *psym = sym_FindSymbol(s);
|
||||||
|
|
||||||
if (*s == '.')
|
return (psym && (psym->nType & SYMF_CONST));
|
||||||
pscope = pScope;
|
|
||||||
else
|
|
||||||
pscope = NULL;
|
|
||||||
|
|
||||||
psym = findsymbol(s, pscope);
|
|
||||||
|
|
||||||
if (psym != NULL) {
|
|
||||||
if (psym->nType & SYMF_CONST)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -337,14 +308,7 @@ char *sym_GetStringValue(char *tzSym)
|
|||||||
*/
|
*/
|
||||||
uint32_t sym_GetConstantValue(char *s)
|
uint32_t sym_GetConstantValue(char *s)
|
||||||
{
|
{
|
||||||
struct sSymbol *psym, *pscope;
|
struct sSymbol *psym = sym_FindSymbol(s);
|
||||||
|
|
||||||
if (*s == '.')
|
|
||||||
pscope = pScope;
|
|
||||||
else
|
|
||||||
pscope = NULL;
|
|
||||||
|
|
||||||
psym = findsymbol(s, pscope);
|
|
||||||
|
|
||||||
if (psym != NULL) {
|
if (psym != NULL) {
|
||||||
if (psym->nType & SYMF_CONST)
|
if (psym->nType & SYMF_CONST)
|
||||||
@@ -363,14 +327,7 @@ uint32_t sym_GetConstantValue(char *s)
|
|||||||
*/
|
*/
|
||||||
uint32_t sym_GetDefinedValue(char *s)
|
uint32_t sym_GetDefinedValue(char *s)
|
||||||
{
|
{
|
||||||
struct sSymbol *psym, *pscope;
|
struct sSymbol *psym = sym_FindSymbol(s);
|
||||||
|
|
||||||
if (*s == '.')
|
|
||||||
pscope = pScope;
|
|
||||||
else
|
|
||||||
pscope = NULL;
|
|
||||||
|
|
||||||
psym = findsymbol(s, pscope);
|
|
||||||
|
|
||||||
if (psym != NULL) {
|
if (psym != NULL) {
|
||||||
if ((psym->nType & SYMF_DEFINED)) {
|
if ((psym->nType & SYMF_DEFINED)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user