From 1fd161942ef2abaaccbda1188a765baf38b7cb82 Mon Sep 17 00:00:00 2001 From: midipix Date: Tue, 29 Dec 2015 04:54:34 -0500 Subject: driver: add cparser init/exit routines. --- src/driver/amgc_driver_ctx.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) (limited to 'src') 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 #include +#include +#include +#include +#include +#include +#include +#include + #define ARGV_DRIVER #include @@ -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) -- cgit v1.2.3