diff options
author | midipix <writeonce@midipix.org> | 2015-12-29 04:54:34 -0500 |
---|---|---|
committer | midipix <writeonce@midipix.org> | 2016-01-01 22:50:23 -0500 |
commit | 1fd161942ef2abaaccbda1188a765baf38b7cb82 (patch) | |
tree | b43ca038158acc715593b82ba175faececaa6359 /src/driver | |
parent | 8b8a8d15174ec92d653cea97ea64dd559a7285e4 (diff) | |
download | apimagic-1fd161942ef2abaaccbda1188a765baf38b7cb82.tar.bz2 apimagic-1fd161942ef2abaaccbda1188a765baf38b7cb82.tar.xz |
driver: add cparser init/exit routines.
Diffstat (limited to 'src/driver')
-rw-r--r-- | src/driver/amgc_driver_ctx.c | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/driver/amgc_driver_ctx.c b/src/driver/amgc_driver_ctx.c index 65f5b30..bef0c44 100644 --- a/src/driver/amgc_driver_ctx.c +++ b/src/driver/amgc_driver_ctx.c @@ -8,6 +8,14 @@ #include <unistd.h> #include <fcntl.h> +#include <cparser/driver/driver.h> +#include <cparser/driver/driver_t.h> +#include <cparser/driver/tempfile.h> +#include <cparser/firm/ast2firm.h> +#include <cparser/firm/firm_opt.h> +#include <cparser/parser/parser.h> +#include <cparser/parser/preprocessor.h> + #define ARGV_DRIVER #include <apimagic/apimagic.h> @@ -91,6 +99,19 @@ static int amgc_get_driver_ctx_fail(struct argv_meta * meta) return -1; } +static int amgc_init_cparser(void) +{ + init_temp_files(); + init_default_driver(); + init_driver(); + init_preprocessor(); + init_parser(); + init_ast(); + init_gen_firm(); + + return 0; +} + int amgc_get_driver_ctx( const char ** argv, const char ** envp, @@ -133,6 +154,9 @@ int amgc_get_driver_ctx( nunits++; } + if (amgc_init_cparser()) + return amgc_get_driver_ctx_fail(meta); + if (!(ctx = amgc_driver_ctx_alloc(meta,&cctx,nunits))) return amgc_get_driver_ctx_fail(meta); @@ -163,10 +187,23 @@ int amgc_create_driver_ctx( return AMGC_OK; } +static void amgc_exit_cparser(void) +{ + exit_gen_firm(); + exit_ast2firm(); + exit_ast(); + exit_parser(); + exit_preprocessor(); + exit_driver(); + exit_default_driver(); + exit_temp_files(); +} + static void amgc_free_driver_ctx_impl(struct amgc_driver_ctx_alloc * ictx) { argv_free(ictx->meta); free(ictx); + amgc_exit_cparser(); } void amgc_free_driver_ctx(struct amgc_driver_ctx * ctx) |