aboutsummaryrefslogtreecommitdiff
path: root/interpreter/eval.c
diff options
context:
space:
mode:
authorCamil Staps2016-10-12 09:26:57 +0200
committerCamil Staps2016-10-12 09:26:57 +0200
commitf3f81123c2082672dd5bbd47520bd5fdce9a066a (patch)
tree1907f61551badef1f1ae2bb61b7acbe90f930816 /interpreter/eval.c
parentFix initialisation warning (diff)
Make debug graphs a command line option (-g)
Diffstat (limited to 'interpreter/eval.c')
-rw-r--r--interpreter/eval.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/interpreter/eval.c b/interpreter/eval.c
index 097dd21..1997d4e 100644
--- a/interpreter/eval.c
+++ b/interpreter/eval.c
@@ -210,6 +210,7 @@ void eval_code_app(struct fuspel *rules, struct node **node) {
#ifdef _FUSPEL_DEBUG
struct node **root_node;
+bool debug_graphs;
#endif
void eval(struct fuspel *rules, struct node **node, bool to_rnf) {
@@ -226,7 +227,7 @@ void eval(struct fuspel *rules, struct node **node, bool to_rnf) {
repls = my_calloc(1, sizeof(struct replacements));
#ifdef _FUSPEL_DEBUG
- if (!root_node) {
+ if (!root_node && debug_graphs) {
root_node = node;
print_node_to_file(*root_node, NULL, NULL);
}
@@ -235,7 +236,7 @@ void eval(struct fuspel *rules, struct node **node, bool to_rnf) {
do {
rerun = 0;
#ifdef _FUSPEL_DEBUG
- print_graph = true;
+ print_graph = debug_graphs;
#endif
switch ((*node)->kind) {
@@ -346,10 +347,18 @@ void eval(struct fuspel *rules, struct node **node, bool to_rnf) {
my_free(repls);
}
-struct expression *eval_main(struct fuspel *rules) {
+struct expression *eval_main(struct fuspel *rules
+#ifdef _FUSPEL_DEBUG
+ , bool debug_graphs_enabled
+#endif
+ ) {
struct node *main_node = my_calloc(1, sizeof(struct node));
struct expression *expr = my_calloc(1, sizeof(struct expression));
+#ifdef _FUSPEL_DEBUG
+ debug_graphs = debug_graphs_enabled;
+#endif
+
main_node->kind = EXPR_NAME;
main_node->used_count = 1;
main_node->var1 = my_calloc(1, 5);