diff options
author | Maria Matejka <mq@ucw.cz> | 2019-07-01 11:57:35 +0200 |
---|---|---|
committer | Maria Matejka <mq@ucw.cz> | 2019-07-01 11:57:35 +0200 |
commit | 236828d06f512b44457970795e44068d9d38ad3e (patch) | |
tree | 08b36a392ffb805ccdc3b3c68d184a10ece4908c | |
parent | 63f49457dcc4216002742166dfecce751efa78d5 (diff) |
Filter: The interpreter code now shares its diversion with constructor
This is a preparation for filter pre-evaluation.
-rw-r--r-- | filter/decl.m4 | 34 |
1 files changed, 17 insertions, 17 deletions
diff --git a/filter/decl.m4 b/filter/decl.m4 index 925a7d9b..50224abd 100644 --- a/filter/decl.m4 +++ b/filter/decl.m4 @@ -15,8 +15,7 @@ m4_divert(-1)m4_dnl # 8 linearize # 9 same (filter comparator) # 1 union in struct f_inst -# 3 constructors -# 10 interpreter +# 3 constructors + interpreter # # Per-inst Diversions: # 101 content of per-inst struct @@ -43,7 +42,6 @@ m4_define(FID_DUMP, `FID_ZONE(6, Dump line)') m4_define(FID_DUMP_CALLER, `FID_ZONE(7, Dump line caller)') m4_define(FID_LINEARIZE, `FID_ZONE(8, Linearize)') m4_define(FID_SAME, `FID_ZONE(9, Comparison)') -m4_define(FID_INTERPRET, `FID_ZONE(10, Interpret)') m4_define(FID_STRUCT_IN, `m4_divert(101)') m4_define(FID_NEW_ARGS, `m4_divert(102)') @@ -71,13 +69,23 @@ struct { m4_undivert(107) } i_[[]]INST_NAME(); FID_NEW -struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code -m4_undivert(102) -) FID_HIC( -[[;]], -[[]], [[ +struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code +[[m4_undivert(102)]] +);]], +[[ + case INST_NAME(): + #define whati (&(what->i_]]INST_NAME()[[)) + m4_ifelse(m4_eval(INST_INVAL() > 0), 1, [[if (fstk->vcnt < INST_INVAL()) runtime("Stack underflow"); fstk->vcnt -= INST_INVAL(); ]]) + [[m4_undivert(108)]] + #undef whati + break; +]], +[[ +struct f_inst *f_new_inst_]]INST_NAME()[[(enum f_instruction_code fi_code +[[m4_undivert(102)]] +) { struct f_inst *what = cfg_allocz(sizeof(struct f_inst)); what->fi_code = fi_code; @@ -126,14 +134,6 @@ m4_undivert(106) #undef f2 break; -FID_INTERPRET -case INST_NAME(): -#define whati (&(what->i_]]INST_NAME()[[)) -m4_ifelse(m4_eval(INST_INVAL() > 0), 1, [[if (fstk->vcnt < INST_INVAL()) runtime("Stack underflow"); fstk->vcnt -= INST_INVAL(); ]]) -m4_undivert(108) -#undef whati -break; - ]])') m4_define(INST, `m4_dnl @@ -252,7 +252,7 @@ m4_define(FID_WR_STOP, `m4_define([[FID_WR_PUT]])m4_divert(-1)') m4_changequote([[,]]) FID_WR_DIRECT(I) -FID_WR_PUT(10) +FID_WR_PUT(3) FID_WR_DIRECT(C) #include "nest/bird.h" #include "filter/filter.h" |