Commit 9aec608c authored by Jan Maria Matejka's avatar Jan Maria Matejka
Browse files

TMP

parent 60da7d89
Loading
Loading
Loading
Loading
+2 −10
Original line number Diff line number Diff line
@@ -589,7 +589,7 @@ static struct tbf rl_runtime_err = TBF_DEFAULT_LOG_LIMITS;

#define runtime(x) do { \
    log_rl(&rl_runtime_err, L_ERR "filters, line %d: %s", what->lineno, x); \
    return (struct f_val) { .type = T_RETURN; .val.i = F_ERROR; }; \
    return (struct f_val) { .type = T_RETURN, .val.i = F_ERROR, }; \
  } while(0)

struct filter_instruction {
@@ -597,15 +597,7 @@ struct filter_instruction {
  int (*same)(struct f_inst *f1, struct f_inst *f2);
};

#define FI__DEF(code,interpret,same) \
  static struct f_val * _filter_interpret_##code(struct f_inst *what) interpret \
  static struct f_val * _filter_same_##code(struct f_inst *what) same

static struct filter_instruction filter_instruction[] = {
#define FI__DO(code) \
  [FI_NUMERIC_CODE(code)] = { _filter_interpret_##code, _filter_same_##code },
FI__LIST
};
static struct f_val interpret(struct f_inst *what);

#include "filter/interpret.h"

+4 −4
Original line number Diff line number Diff line
@@ -9,8 +9,8 @@
#define BITFIELD_MASK(what) \
  (1u << (what->a2.i >> 24))

#define ARG(n) \
  struct f_val v##n = interpret((n == 3) ? (INST3(what).p) : what->a##n.p); \
#define ARG(n,call) \
  struct f_val v##n = call((n == 3) ? (INST3(what).p) : what->a##n.p); \
  if (v##n.type & T_RETURN) \
    return v##n;

@@ -28,7 +28,7 @@
  { \
    AI(1); AI(2); \
    if ((v1.type != T_INT) || (v2.type != T_INT)) \
      runtime( "Incompatible types for operation " #op ); \
      runtime( "Incompatible types for arithmetic operation" ); \
    RET(T_INT, i, (v1.val.i op v2.val.i)); \
  }

@@ -40,7 +40,7 @@ FI_INST_INTERPRET(divide)
{
  AI(1); AI(2);
  if ((v1.type != T_INT) || (v2.type != T_INT))
    runtime( "Incompatible types for operation " #op );
    runtime( "Incompatible types for arithmetic operation" );
  if (v2.val.i == 0)
    runtime( "I don't believe in division by zero" );
  RET(T_INT, i, (v1.val.i / v2.val.i));