mirror of
https://github.com/fish-shell/fish-shell.git
synced 2025-01-23 09:15:32 +08:00
tinyexpr: Move enums together and stop explicit numbering
We should _not_ be doing bit-fiddling with these, so there's no reason to care about the number. This also removes the unused "TE_VARIABLE" symbol.
This commit is contained in:
parent
3bbec871e4
commit
b193df8b42
|
@ -38,8 +38,10 @@ typedef double (*te_fun1)(double);
|
|||
typedef double (*te_fun0)();
|
||||
|
||||
enum {
|
||||
TE_VARIABLE = 0, TE_CONSTANT,
|
||||
TE_FUNCTION0 = 8, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3
|
||||
TE_CONSTANT = 0,
|
||||
TE_FUNCTION0, TE_FUNCTION1, TE_FUNCTION2, TE_FUNCTION3,
|
||||
TOK_NULL, TOK_ERROR, TOK_END, TOK_SEP,
|
||||
TOK_OPEN, TOK_CLOSE, TOK_NUMBER, TOK_INFIX
|
||||
};
|
||||
|
||||
int get_arity(const int type) {
|
||||
|
@ -49,12 +51,6 @@ int get_arity(const int type) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
// TODO: Is it actually used that these share a space?
|
||||
enum {
|
||||
TOK_NULL = TE_FUNCTION0+16, TOK_ERROR, TOK_END, TOK_SEP,
|
||||
TOK_OPEN, TOK_CLOSE, TOK_NUMBER, TOK_INFIX
|
||||
};
|
||||
|
||||
typedef struct te_expr {
|
||||
int type;
|
||||
union {double value; const void *function;};
|
||||
|
@ -465,7 +461,6 @@ double te_eval(const te_expr *n) {
|
|||
static void optimize(te_expr *n) {
|
||||
/* Evaluates as much as possible. */
|
||||
if (n->type == TE_CONSTANT) return;
|
||||
if (n->type == TE_VARIABLE) return;
|
||||
|
||||
const int arity = get_arity(n->type);
|
||||
bool known = true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user