summaryrefslogtreecommitdiffstats
path: root/src/state.c
blob: 33025b6000afc857f4fbf87043b305d76b9f43dc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif

#include "state.h"


void ccmmc_state_init (CcmmcState *state)
{
    state->ast = NULL;
    state->table = NULL;
    state->line_number = 1;
    state->asm_output = NULL;
    state->reg_pool = NULL;
    // XXX: TA's broken toolchain prevent this number from starting from zero
    state->label_number = 3;
}

void ccmmc_state_fini (CcmmcState *state)
{
    if (state->ast != NULL) {
        // TODO: Free the AST
    }
    if (state->table != NULL) {
        // TODO: Free the symbol table
    }
    if (state->asm_output != NULL) {
        fclose(state->asm_output);
    }
    if (state->reg_pool != NULL) {
        ccmmc_register_fini(state->reg_pool);
    }
}

// vim: set sw=4 ts=4 sts=4 et: