summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--filter/decl.m452
-rw-r--r--filter/f-inst.c21
-rw-r--r--filter/f-inst.h2
-rw-r--r--filter/f-util.c2
4 files changed, 35 insertions, 42 deletions
diff --git a/filter/decl.m4 b/filter/decl.m4
index 88808973..925a7d9b 100644
--- a/filter/decl.m4
+++ b/filter/decl.m4
@@ -31,9 +31,6 @@ m4_divert(-1)m4_dnl
# Final diversions
# 200+ completed text before it is flushed to output
-# Flush the completed instruction
-m4_define(FID_END, `m4_divert(-1)')
-
m4_dnl m4_debugmode(aceflqtx)
m4_define(FID_ZONE, `m4_divert($1) /* $2 for INST_NAME() */')
@@ -58,8 +55,6 @@ m4_define(FID_LINE_IN, `m4_divert(107)')
m4_define(FID_INTERPRET_BODY, `m4_divert(108)')
m4_define(FID_ALL, `FID_INTERPRET_BODY');
-
-m4_define(FID_ALL_TARGETS, `m4_ifdef([[FID_CURDIV]], [[m4_divert(FID_CURDIV)m4_undefine([[FID_CURDIV]])]])')
m4_define(FID_HIC, `m4_ifelse(TARGET, [[H]], $1, TARGET, [[I]], $2, TARGET, [[C]], $3)')
m4_define(INST_FLUSH, `m4_ifdef([[INST_NAME]], [[
@@ -84,14 +79,14 @@ FID_HIC(
[[]],
[[
{
- struct f_inst *what_ = cfg_allocz(sizeof(struct f_inst));
- what_->fi_code = fi_code;
- what_->lineno = ifs->lino;
- what_->size = 1;
- #define what (&(what_->i_]]INST_NAME()[[))
+ struct f_inst *what = cfg_allocz(sizeof(struct f_inst));
+ what->fi_code = fi_code;
+ what->lineno = ifs->lino;
+ what->size = 1;
+ #define whati (&(what->i_]]INST_NAME()[[))
[[m4_undivert(103)]]
- #undef what
- return what_;
+ #undef whati
+ return what;
}
]])
@@ -111,13 +106,13 @@ m4_undivert(104)
FID_LINEARIZE
case INST_NAME(): {
-#define what (&(what_->i_]]INST_NAME()[[))
+#define whati (&(what->i_]]INST_NAME()[[))
#define item (&(dest->items[pos].i_]]INST_NAME()[[))
m4_undivert(105)
-#undef what
+#undef whati
#undef item
- dest->items[pos].fi_code = what_->fi_code;
- dest->items[pos].lineno = what_->lineno;
+ dest->items[pos].fi_code = what->fi_code;
+ dest->items[pos].lineno = what->lineno;
break;
}
m4_undefine([[FID_LINEARIZE_BODY_EXISTS]])
@@ -139,7 +134,6 @@ m4_undivert(108)
#undef whati
break;
-FID_END
]])')
m4_define(INST, `m4_dnl
@@ -165,10 +159,10 @@ $1 $2;
FID_NEW_ARGS
, $1 $2
FID_NEW_BODY
-what->$2 = $2;
+whati->$2 = $2;
m4_ifelse($3,,,[[
FID_LINEARIZE_BODY
-item->$3 = what->$2;
+item->$3 = whati->$2;
]])
m4_ifelse($4,,,[[
FID_SAME_BODY
@@ -186,14 +180,14 @@ FID_ALL')
m4_define(ARG_ANY, `
FID_STRUCT_IN
-const struct f_inst * f$1;
+struct f_inst * f$1;
FID_NEW_ARGS
-, const struct f_inst * f$1
+, struct f_inst * f$1
FID_NEW_BODY
-what->f$1 = f$1;
-for (const struct f_inst *child = f$1; child; child = child->next) what_->size += child->size;
+whati->f$1 = f$1;
+for (const struct f_inst *child = f$1; child; child = child->next) what->size += child->size;
FID_LINEARIZE_BODY
-pos = linearize(dest, what->f$1, pos);m4_dnl
+pos = linearize(dest, whati->f$1, pos);m4_dnl
FID_ALL()')
m4_define(ARG, `ARG_ANY($1)
@@ -220,11 +214,11 @@ const struct f_inst * f$1;
FID_NEW_ARGS
, const struct f_inst * f$1
FID_NEW_BODY
-what->f$1 = f$1;
+whati->f$1 = f$1;
FID_DUMP_BODY
f_dump_line(item->fl$1, indent + 1);
FID_LINEARIZE_BODY
-item->fl$1 = f_linearize(what->f$1);
+item->fl$1 = f_linearize(whati->f$1);
FID_SAME_BODY
if (!f_same(f1->fl$1, f2->fl$1)) return 0;
FID_INTERPRET_BODY
@@ -307,10 +301,10 @@ FID_WR_PUT(7)
/* Linearize */
static uint
-linearize(struct f_line *dest, const struct f_inst *what_, uint pos)
+linearize(struct f_line *dest, const struct f_inst *what, uint pos)
{
- for ( ; what_; what_ = what_->next) {
- switch (what_->fi_code) {
+ for ( ; what; what = what->next) {
+ switch (what->fi_code) {
FID_WR_PUT(8)
}
pos++;
diff --git a/filter/f-inst.c b/filter/f-inst.c
index 7349bf72..f033bea1 100644
--- a/filter/f-inst.c
+++ b/filter/f-inst.c
@@ -27,8 +27,8 @@
* m4_dnl LINE(num, unused); this argument has to be converted to its own f_line
* m4_dnl ECS; extended community subtype
* m4_dnl COUNT(unused); simply a uint
- * m4_dnl SYMBOL(unused); symbol handed from config
- * m4_dnl FRET(unused); filter return value
+ * m4_dnl SYMBOL; symbol handed from config
+ * m4_dnl FRET; filter return value
* m4_dnl STATIC_ATTR; static attribute definition
* m4_dnl DYNAMIC_ATTR; dynamic attribute definition
* m4_dnl RTC; route table config
@@ -153,7 +153,7 @@
if (tt->fi_code != FI_CONSTANT)
dyn++;
- what->count = len;
+ whati->count = len;
FID_ALL
if (fstk->vcnt < whati->count) /* TODO: make this check systematic */
@@ -262,8 +262,8 @@
/* Set to indirect value prepared in v1 */
INST(FI_VAR_SET, 1, 0) {
- ARG_ANY(2);
- SYMBOL(1);
+ ARG_ANY(1);
+ SYMBOL;
if ((sym->class != (SYM_VARIABLE | v1.type)) && (v1.type != T_VOID))
{
/* IP->Quad implicit conversion */
@@ -294,17 +294,16 @@
FID_NEW_ARGS
, const struct f_val val
FID_NEW_BODY
- what->val = val;
+ whati->val = val;
FID_LINEARIZE_BODY
- item->val = what->val;
+ item->val = whati->val;
FID_SAME_BODY
if (!val_same(&(f1->val), &(f2->val))) return 0;
FID_DUMP_BODY
debug("%svalue %s\n", INDENT, val_dump(&item->val));
FID_ALL
- res = whati->val;
- RESULT_OK;
+ RESULT_VAL(whati->val);
}
INST(FI_CONSTANT_DEFINED, 0, 1) {
FID_STRUCT_IN
@@ -315,9 +314,9 @@
FID_NEW_ARGS
, const struct symbol *sym
FID_NEW_BODY
- what->sym = sym;
+ whati->sym = sym;
FID_LINEARIZE_BODY
- item->valp = (item->sym = what->sym)->val;
+ item->valp = (item->sym = whati->sym)->val;
FID_SAME_BODY
if (strcmp(f1->sym->name, f2->sym->name) || !val_same(f1->sym->val, f2->sym->val)) return 0;
FID_DUMP_BODY
diff --git a/filter/f-inst.h b/filter/f-inst.h
index f0dcec64..2a2d050e 100644
--- a/filter/f-inst.h
+++ b/filter/f-inst.h
@@ -79,7 +79,7 @@ static inline struct f_line *f_linearize(const struct f_inst *root)
void f_dump_line(const struct f_line *, uint indent);
-struct filter *f_new_where(const struct f_inst *);
+struct filter *f_new_where(struct f_inst *);
static inline struct f_dynamic_attr f_new_dynamic_attr(u8 type, u8 bit, enum f_type f_type, uint code) /* Type as core knows it, type as filters know it, and code of dynamic attribute */
{ return (struct f_dynamic_attr) { .type = type, .bit = bit, .f_type = f_type, .ea_code = code }; } /* f_type currently unused; will be handy for static type checking */
static inline struct f_static_attr f_new_static_attr(int f_type, int code, int readonly)
diff --git a/filter/f-util.c b/filter/f-util.c
index 5500f282..4b580fb9 100644
--- a/filter/f-util.c
+++ b/filter/f-util.c
@@ -30,7 +30,7 @@ filter_name(const struct filter *filter)
return filter->sym->name;
}
-struct filter *f_new_where(const struct f_inst *where)
+struct filter *f_new_where(struct f_inst *where)
{
struct f_inst acc = {
.fi_code = FI_PRINT_AND_DIE,