diff options
author | Jo-Philipp Wich <jo@mein.io> | 2021-06-08 13:00:37 +0200 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2021-06-08 13:54:50 +0200 |
commit | 4e410c3411f73da6d27b28ce057159cda7b50b66 (patch) | |
tree | 6fd8ee299fb46c678acce2ce36f7d76fb91a4dbc /value.c | |
parent | ce6081dbbd588fb111754f3c2c1c93d2421c6ee6 (diff) |
treewide: let uc_cmp() use instruction instead of token numbers
This allows us to drop some token->instruction mapping case switches
in the VM.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'value.c')
-rw-r--r-- | value.c | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -23,7 +23,6 @@ #include "util.h" #include "chunk.h" #include "value.h" -#include "lexer.h" /* TK_* */ #include "vm.h" #define TAG_TYPE uint64_t @@ -288,7 +287,7 @@ uc_cmp(int how, uc_value_t *v1, uc_value_t *v2) /* all comparison results except `!=` involving NaN are false */ if (isnan(d1) || isnan(d2)) - return (how == TK_NE); + return (how == I_NE); if (d1 == d2) delta = 0; @@ -304,22 +303,22 @@ uc_cmp(int how, uc_value_t *v1, uc_value_t *v2) } switch (how) { - case TK_LT: + case I_LT: return (delta < 0); - case TK_LE: + case I_LE: return (delta <= 0); - case TK_GT: + case I_GT: return (delta > 0); - case TK_GE: + case I_GE: return (delta >= 0); - case TK_EQ: + case I_EQ: return (delta == 0); - case TK_NE: + case I_NE: return (delta != 0); default: |