summaryrefslogtreecommitdiff
path: root/filter/f-inst.c
diff options
context:
space:
mode:
authorMaria Matejka <mq@ucw.cz>2023-01-23 19:46:26 +0100
committerMaria Matejka <mq@ucw.cz>2023-01-23 19:46:26 +0100
commit758aabd96c0f09709183dff4261ffbfdd72ae870 (patch)
tree75d17bb906331213d5107a6be6446f58f0251541 /filter/f-inst.c
parent4821612c94f9e935a6e841f6bcace9465dd2ad78 (diff)
parent7fb23041a52d01754c53ba963e2282e524813364 (diff)
Merge commit '7fb23041a52d01754c53ba963e2282e524813364' into thread-next
Diffstat (limited to 'filter/f-inst.c')
-rw-r--r--filter/f-inst.c25
1 files changed, 22 insertions, 3 deletions
diff --git a/filter/f-inst.c b/filter/f-inst.c
index 801eceec..caffc2b8 100644
--- a/filter/f-inst.c
+++ b/filter/f-inst.c
@@ -1265,14 +1265,33 @@
FID_MEMBER(struct f_tree *, tree, [[!same_tree(f1->tree, f2->tree)]], "tree %p", item->tree);
+ FID_LINEARIZE_BODY()
+ /* Linearize all branches in switch */
+ struct f_inst *last_inst = NULL;
+ struct f_line *last_line = NULL;
+ for (struct f_tree *t = whati->tree; t; t = t->left)
+ {
+ if (t->data != last_inst)
+ {
+ last_inst = t->data;
+ last_line = f_linearize(t->data, 0);
+ }
+
+ t->data = last_line;
+ }
+
+ /* Balance the tree */
+ item->tree = build_tree(whati->tree);
+
FID_ITERATE_BODY()
- tree_walk(whati->tree, f_add_tree_lines, fit);
+ tree_walk(whati->tree, f_add_tree_lines, fit);
FID_INTERPRET_BODY()
- const struct f_tree *t = find_tree(tree, &v1);
+ /* In parse-time use find_tree_linear(), in runtime use find_tree() */
+ const struct f_tree *t = FID_HIC(,find_tree,find_tree_linear)(tree, &v1);
if (!t) {
v1.type = T_VOID;
- t = find_tree(tree, &v1);
+ t = FID_HIC(,find_tree,find_tree_linear)(tree, &v1);
if (!t) {
debug( "No else statement?\n");
FID_HIC(,break,return NULL);