summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorSøren Sandmann Pedersen <ssp@redhat.com>2012-06-15 10:33:58 -0400
committerSøren Sandmann Pedersen <ssp@redhat.com>2012-06-15 10:33:58 -0400
commit162ffd529a3316416b91f8c1db92fbea93b027fe (patch)
treeabaa08aa5865901f5b2b05f393e03b40df8d0738 /main.c
parenta109f716fd8c002a3b5f1d4dd04050faed91d218 (diff)
Do debug spew from within compile().
Dump the goto graph after optimization if debug_spew is turned on.
Diffstat (limited to 'main.c')
-rw-r--r--main.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/main.c b/main.c
index 8ab9f25..61bf10a 100644
--- a/main.c
+++ b/main.c
@@ -23,7 +23,7 @@
#include "ast.h"
ast_t *
-compile (const char *input, gboolean do_optimize)
+compile (const char *input, gboolean do_optimize, gboolean debug_spew)
{
token_t *tokens;
ast_t *ast;
@@ -34,6 +34,9 @@ compile (const char *input, gboolean do_optimize)
if (!(ast = parse (tokens)))
return NULL;
+ if (debug_spew)
+ dump_program (&ast->program);
+
if (!prepare (ast))
return NULL;
@@ -51,6 +54,9 @@ compile (const char *input, gboolean do_optimize)
if (!graph (ast))
return NULL;
+
+ if (debug_spew)
+ dump_graph (&ast->program);
if (!init_check (ast))
return NULL;
@@ -61,8 +67,17 @@ compile (const char *input, gboolean do_optimize)
if (!levels (ast))
return NULL;
- if (do_optimize && !optimize (ast))
- return NULL;
+ if (do_optimize)
+ {
+ if (!optimize (ast))
+ return NULL;
+
+ if (debug_spew)
+ {
+ g_print ("-=-=-=-=- Graph after optimization -=-=-=-=-=- \n");
+ dump_graph (&ast->program);
+ }
+ }
if (!offsets (ast))
return NULL;
@@ -131,13 +146,8 @@ main (int argc, char **argv)
{
ast_t *ast;
- if ((ast = compile (contents, optimize)))
+ if ((ast = compile (contents, optimize, debug_spew)))
{
- if (debug_spew)
- {
- dump_program (&ast->program);
- dump_graph (&ast->program);
- }
interpret (ast);
}
}