summaryrefslogtreecommitdiff
path: root/conf/conf.h
diff options
context:
space:
mode:
authorOndrej Zajicek (work) <santiago@crfreenet.org>2022-03-06 16:37:30 +0100
committerOndrej Zajicek <santiago@crfreenet.org>2022-06-27 21:13:31 +0200
commit946cedfcfe3bdfd850613c4d891f8abfd6b2cafd (patch)
treed95372d01134a350b366892ad7b8737f35d5f161 /conf/conf.h
parent26bc4f9904b014c9949489e8ae28366da473e85d (diff)
Filter: Implement soft scopes
Soft scopes are anonymous scopes that most likely do not contain any symbol, so allocating regular scope is postponed when it is really needed.
Diffstat (limited to 'conf/conf.h')
-rw-r--r--conf/conf.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/conf/conf.h b/conf/conf.h
index 3bc37959..be46f172 100644
--- a/conf/conf.h
+++ b/conf/conf.h
@@ -133,7 +133,8 @@ struct sym_scope {
struct sym_scope *next; /* Next on scope stack */
struct symbol *name; /* Name of this scope */
uint slots; /* Variable slots */
- int active; /* Currently entered */
+ byte active; /* Currently entered */
+ byte soft_scopes; /* Number of soft scopes above */
};
struct bytestring {
@@ -190,6 +191,9 @@ struct symbol *cf_get_symbol(const byte *c);
struct symbol *cf_default_name(char *template, int *counter);
struct symbol *cf_localize_symbol(struct symbol *sym);
+static inline int cf_symbol_is_local(struct symbol *sym)
+{ return (sym->scope == conf_this_scope) && !conf_this_scope->soft_scopes; }
+
/**
* cf_define_symbol - define meaning of a symbol
* @sym: symbol to be defined
@@ -213,6 +217,9 @@ struct symbol *cf_localize_symbol(struct symbol *sym);
void cf_push_scope(struct symbol *);
void cf_pop_scope(void);
+void cf_push_soft_scope(void);
+void cf_pop_soft_scope(void);
+
char *cf_symbol_class_name(struct symbol *sym);
/* Parser */