summaryrefslogtreecommitdiff
path: root/src/driver
diff options
context:
space:
mode:
Diffstat (limited to 'src/driver')
-rw-r--r--src/driver/amgc_driver_ctx.c37
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)