From: Wolfgang (Blub) Bumiller Date: Thu, 3 May 2012 11:26:49 +0000 (+0200) Subject: ast_test to build an IR X-Git-Tag: 0.1-rc1~505 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=627ef279fd74e201753ad77a77f0ba7a59bf9acb;p=xonotic%2Fgmqcc.git ast_test to build an IR --- diff --git a/test/ast-test.c b/test/ast-test.c index afe9007..00e8c05 100644 --- a/test/ast-test.c +++ b/test/ast-test.c @@ -14,6 +14,7 @@ VECTOR_MAKE(ast_function*, functions); int main() { + /* AST */ ast_expression *exp; ast_value *gfoo = NULL; ast_value *gbar = NULL; @@ -24,6 +25,11 @@ int main() ast_block *ba = NULL; ast_value *li = NULL; + /* IR */ + ir_builder *ir = NULL; + + /* common stuff */ + size_t i; lex_ctx ctx; ctx.file = NULL; @@ -99,6 +105,29 @@ int main() /* Next up: Having the AST generate IR */ + ir = ir_builder_new("ast_test"); + assert(ir); + + /* gen globals */ + for (i = 0; i < globals_elements; ++i) { + if (!ast_global_codegen(globals_data[i], ir)) { + assert(!"failed to generate global"); + } + } + + /* gen functions */ + for (i = 0; i < functions_elements; ++i) { + if (!ast_function_codegen(functions_data[i], ir)) { + assert(!"failed to generate function"); + } + } + + /* dump */ + ir_builder_dump(ir, printf); + + /* ir cleanup */ + ir_builder_delete(ir); + /* cleanup */ /* Functions must be deleted FIRST since their expressions * reference global variables.