diff options
author | kugwa <kugwa2000@gmail.com> | 2015-12-30 15:45:47 +0800 |
---|---|---|
committer | kugwa <kugwa2000@gmail.com> | 2015-12-30 15:45:47 +0800 |
commit | fb439f1b706f21e94bdfe2195af9d0f3c9bc4246 (patch) | |
tree | 267984264a2aae04775d3b058387a96e1d4c50ea | |
parent | 463be4aa241f9c9b8453ba46a89ce5d67995c55b (diff) | |
download | compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar.gz compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar.bz2 compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar.lz compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar.xz compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.tar.zst compiler2015-fb439f1b706f21e94bdfe2195af9d0f3c9bc4246.zip |
Add 3 static code-generation functions
-rw-r--r-- | src/code-generation.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/code-generation.c b/src/code-generation.c index 294389f..445d03b 100644 --- a/src/code-generation.c +++ b/src/code-generation.c @@ -8,6 +8,34 @@ #include <stdio.h> #include <stdlib.h> +static void generate_global_variable(CcmmcAst *global, CcmmcState *state) +{ +} + +static void generate_function(CcmmcAst *funcion, CcmmcState *state) +{ +} + +static void generate_program(CcmmcState *state) +{ + for (CcmmcAst *global_decl = state->ast->child; global_decl != NULL; + global_decl = global_decl->right_sibling) { + switch (global_decl->value_decl.kind) { + case CCMMC_KIND_DECL_VARIABLE: + generate_global_variable(global_decl, state); + break; + case CCMMC_KIND_DECL_FUNCTION: + generate_function(global_decl, state); + break; + case CCMMC_KIND_DECL_FUNCTION_PARAMETER: + case CCMMC_KIND_DECL_TYPE: + default: + assert(false); + } + } +} + void ccmmc_code_generation(CcmmcState *state) { + generate_program(state); } |