Add pushc and popc directives

This commit is contained in:
dbrotz
2019-08-30 19:36:23 -07:00
parent 461ef6cea5
commit d3db5f0d76
8 changed files with 149 additions and 61 deletions

View File

@@ -20,11 +20,18 @@
#define CHARMAP_HASH_SIZE (1 << 9)
struct CharmapStackEntry {
struct Charmap *charmap;
struct CharmapStackEntry *next;
};
static struct Charmap *tHashedCharmaps[CHARMAP_HASH_SIZE];
static struct Charmap *mainCharmap;
static struct Charmap *currentCharmap;
struct CharmapStackEntry *charmapStack;
static void warnSectionCharmap(void)
{
static bool warned = false;
@@ -119,6 +126,32 @@ void charmap_Set(const char *name)
currentCharmap = *ppCharmap;
}
void charmap_Push(void)
{
struct CharmapStackEntry *stackEntry;
stackEntry = malloc(sizeof(struct CharmapStackEntry));
if (stackEntry == NULL)
fatalerror("No memory for charmap stack");
stackEntry->charmap = currentCharmap;
stackEntry->next = charmapStack;
charmapStack = stackEntry;
}
void charmap_Pop(void)
{
if (charmapStack == NULL)
fatalerror("No entries in the charmap stack");
struct CharmapStackEntry *top = charmapStack;
currentCharmap = top->charmap;
charmapStack = top->next;
free(top);
}
void charmap_InitMain(void)
{
mainCharmap = charmap_New("main", NULL);