Files
jq/src/builtin.h
T
Emanuele Torre 3b6e7ddd72 Constant fold all kinds of constants
This patch exports all the binary operator builtins functions from
builtin.c and uses them for constant folding in the parser, allowing
constant folding to work will all kinds and combinations of constants.

Now string*number,  $ARGS+$ARGS,  string/string,  etc will also be
constant folded and the implementation of constant folded operators and
runtime operators will be the same.

And thanks to the new ERRORK bytecode operation, errors are constant
folded too! (e.g. 1 / 0   [] * {}   etc)
2023-08-04 11:47:34 -05:00

29 lines
428 B
C

#ifndef BUILTIN_H
#define BUILTIN_H
#include "jq.h"
#include "bytecode.h"
#include "compile.h"
int builtins_bind(jq_state *, block*);
#define BINOPS \
BINOP(plus) \
BINOP(minus) \
BINOP(multiply) \
BINOP(divide) \
BINOP(mod) \
BINOP(equal) \
BINOP(notequal) \
BINOP(less) \
BINOP(lesseq) \
BINOP(greater) \
BINOP(greatereq) \
#define BINOP(name) jv binop_ ## name(jv, jv);
BINOPS
#undef BINOP
#endif