summaryrefslogtreecommitdiff
path: root/filter/f-inst.c
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2022-03-06 02:18:01 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2022-06-27 21:13:31 +0200
commit26bc4f9904b014c9949489e8ae28366da473e85d (patch)
tree71b89917bb301831e8c77d4a1a8496a9ce84de9c /filter/f-inst.c
parentfb1d8f65136aa6190b527b691f24abe16a461471 (diff)
Filter: Implement direct recursion
Direct recursion almost worked, just crashed on function signature check. Split function parsing such that function signature is saved before function body is processed. Recursive calls are marked so they can be avoided during f_same() and similar code walking. Also, include tower of hanoi solver as a test case.
Diffstat (limited to 'filter/f-inst.c')
-rw-r--r--filter/f-inst.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/filter/f-inst.c b/filter/f-inst.c
index 500732c6..e75b5e01 100644
--- a/filter/f-inst.c
+++ b/filter/f-inst.c
@@ -1165,11 +1165,16 @@
whati->fvar = tmp;
what->size += tmp->size;
+ /* Mark recursive calls, they have dummy f_line */
+ if (!sym->function->len)
+ what->flags |= FIF_RECURSIVE;
+
FID_SAME_BODY()
- if (!(f1->sym->flags & SYM_FLAG_SAME))
- return 0;
+ if (!(f1->sym->flags & SYM_FLAG_SAME) && !(f1_->flags & FIF_RECURSIVE))
+ return 0;
FID_ITERATE_BODY()
+ if (!(what->flags & FIF_RECURSIVE))
BUFFER_PUSH(fit->lines) = whati->sym->function;
FID_INTERPRET_BODY()