mirror of
https://github.com/gbdev/rgbds.git
synced 2025-11-20 18:22:07 +00:00
Create specialized symbol finder functions
The old "find symbol with auto scope" function is now three: - One finds the exact name passed to it, skipping any checks This is useful e.g. if such checks were already performed. - One checks that the name is not scoped, and calls the first. This is useful for names that cannot be scoped, such as checking for EQUS. Doing this instead of the third should improve performance somehwat, since this specific case is hit by the lexer each time an identifier is read. - The last one checks if the name should be expanded (`.loc` → `Glob.loc`), and that the local part is not scoped. This is essentially the old function.
This commit is contained in:
@@ -1311,7 +1311,7 @@ static char const *readInterpolation(void)
|
||||
}
|
||||
symName[i] = '\0';
|
||||
|
||||
struct Symbol const *sym = sym_FindSymbol(symName);
|
||||
struct Symbol const *sym = sym_FindScopedSymbol(symName);
|
||||
|
||||
if (!sym) {
|
||||
error("Interpolated symbol \"%s\" does not exist\n", symName);
|
||||
@@ -1691,9 +1691,10 @@ static int yylex_NORMAL(void)
|
||||
if (tokenType != T_ID && tokenType != T_LOCAL_ID)
|
||||
return tokenType;
|
||||
|
||||
if (lexerState->expandStrings) {
|
||||
/* Local symbols cannot be string expansions */
|
||||
if (tokenType == T_ID && lexerState->expandStrings) {
|
||||
/* Attempt string expansion */
|
||||
struct Symbol const *sym = sym_FindSymbol(yylval.tzSym);
|
||||
struct Symbol const *sym = sym_FindExactSymbol(yylval.tzSym);
|
||||
|
||||
if (sym && sym->type == SYM_EQUS) {
|
||||
char const *s = sym_GetStringValue(sym);
|
||||
|
||||
Reference in New Issue
Block a user