PUSHS and POPS also affect the symbol scope

Now, when POPS is executed, it restores the symbol scope of the
corresponding PUSHS. That way, the local symbols previously available
can be used again after the POPS.

This is useful in cases like this one:

```
    SECTION "Section 1", ROMX

BigFunction:

    ...

.loop:

    ...

    PUSHS

    SECTION "Section 2", ROMX

DataForBigFunction:
    DB 1, 2, 3, 4, 5

    POPS

    ld  a,BANK(DataForBigFunction)
    ld  hl,DataForBigFunction

    ...

    jr  .loop
```

Signed-off-by: Antonio Niño Díaz <antonio_nd@outlook.com>
This commit is contained in:
Antonio Niño Díaz
2018-01-07 23:05:04 +00:00
parent f5164325d2
commit de32e245c9
3 changed files with 18 additions and 1 deletions

View File

@@ -19,7 +19,7 @@
#include "extern/version.h"
struct sSymbol *tHashedSymbols[HASHSIZE];
static struct sSymbol *pScope;
static struct sSymbol *pScope; /* Current section symbol scope */
struct sSymbol *pPCSymbol;
static struct sSymbol *p_NARGSymbol;
static struct sSymbol *p__LINE__Symbol;
@@ -406,6 +406,16 @@ uint32_t sym_GetDefinedValue(char *s)
return 0;
}
struct sSymbol *sym_GetCurrentSymbolScope(void)
{
return pScope;
}
void sym_SetCurrentSymbolScope(struct sSymbol *pNewScope)
{
pScope = pNewScope;
}
/*
* Macro argument stuff
*/