shithub: rgbds

Download patch

ref: 8da4feb83c5bc9bb3879ea590ab2f7104733196f
parent: 23f5e9dacc4a4730d26cb93f8b031f6c5a085f5a
author: dbrotz <43593771+dbrotz@users.noreply.github.com>
date: Sun May 5 14:10:05 EDT 2019

Use sym_FindSymbol() where possible

--- a/src/asm/symbol.c
+++ b/src/asm/symbol.c
@@ -207,7 +207,7 @@
 }
 
 /*
- * Find a symbol by name and scope
+ * Find a symbol by name, with automatically determined scope
  */
 struct sSymbol *sym_FindSymbol(char *tzName)
 {
@@ -256,15 +256,8 @@
  */
 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)) {
 		uint32_t mask = SYMF_EQU | SYMF_SET | SYMF_MACRO | SYMF_STRING;
 
@@ -280,19 +273,9 @@
 
 uint32_t sym_isDefined(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))
-		return 1;
-	else
-		return 0;
+	return (psym && (psym->nType & SYMF_DEFINED));
 }
 
 /*
@@ -300,21 +283,9 @@
  */
 uint32_t sym_isConstant(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->nType & SYMF_CONST)
-			return 1;
-	}
-
-	return 0;
+	return (psym && (psym->nType & SYMF_CONST));
 }
 
 /*
@@ -337,15 +308,8 @@
  */
 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->nType & SYMF_CONST)
 			return getvaluefield(psym);
@@ -363,14 +327,7 @@
  */
 uint32_t sym_GetDefinedValue(char *s)
 {
-	struct sSymbol *psym, *pscope;
-
-	if (*s == '.')
-		pscope = pScope;
-	else
-		pscope = NULL;
-
-	psym = findsymbol(s, pscope);
+	struct sSymbol *psym = sym_FindSymbol(s);
 
 	if (psym != NULL) {
 		if ((psym->nType & SYMF_DEFINED)) {