summaryrefslogtreecommitdiff
path: root/conf
diff options
context:
space:
mode:
authorOndrej Zajicek <santiago@crfreenet.org>2022-10-18 03:58:19 +0200
committerOndrej Zajicek <santiago@crfreenet.org>2022-10-18 03:58:19 +0200
commite471f9e0fb7ade475dd3eb8b230bcb440877ee7e (patch)
tree5d9c5a23474b9a9464e75cadf3e872042fa9097e /conf
parent324252975004154cc70623c94f05083bff100209 (diff)
Filter: Fix handling of variables in anonymous filters
Define scope for anonymous filters, and also explicitly distinguish block scopes and function/filter scopes instead of using anonymous / named distinction. Anonymous filters forgot to push scope, so variables for them were in fact defined in the top scope and therefore they shared a frame. This got broken after rework of variables, which assumed that there is a named scope for every function/filter.
Diffstat (limited to 'conf')
-rw-r--r--conf/cf-lex.l6
-rw-r--r--conf/conf.h7
2 files changed, 10 insertions, 3 deletions
diff --git a/conf/cf-lex.l b/conf/cf-lex.l
index d6f46223..28d9ba50 100644
--- a/conf/cf-lex.l
+++ b/conf/cf-lex.l
@@ -812,7 +812,7 @@ cf_push_soft_scope(void)
if (conf_this_scope->soft_scopes < 0xfe)
conf_this_scope->soft_scopes++;
else
- cf_push_scope(NULL);
+ cf_push_block_scope();
}
/**
@@ -826,7 +826,7 @@ cf_pop_soft_scope(void)
if (conf_this_scope->soft_scopes)
conf_this_scope->soft_scopes--;
else
- cf_pop_scope();
+ cf_pop_block_scope();
}
/**
@@ -841,7 +841,7 @@ cf_swap_soft_scope(void)
if (conf_this_scope->soft_scopes)
{
conf_this_scope->soft_scopes--;
- cf_push_scope(NULL);
+ cf_push_block_scope();
}
}
diff --git a/conf/conf.h b/conf/conf.h
index be46f172..96c873df 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -134,6 +134,7 @@ struct sym_scope {
struct symbol *name; /* Name of this scope */
uint slots; /* Variable slots */
byte active; /* Currently entered */
+ byte block; /* No independent stack frame */
byte soft_scopes; /* Number of soft scopes above */
};
@@ -220,6 +221,12 @@ void cf_pop_scope(void);
void cf_push_soft_scope(void);
void cf_pop_soft_scope(void);
+static inline void cf_push_block_scope(void)
+{ cf_push_scope(NULL); conf_this_scope->block = 1; }
+
+static inline void cf_pop_block_scope(void)
+{ ASSERT(conf_this_scope->block); cf_pop_scope(); }
+
char *cf_symbol_class_name(struct symbol *sym);
/* Parser */