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)
This commit is contained in:
Emanuele Torre authored and Nico Williams committed 2023-08-04 11:47:34 -05:00
1 parent 5fc5453409
commit 3b6e7ddd72
5 files changed
+841 -894

No files matched your search

Generated
+2 -2
View File
@@ -45,7 +45,7 @@
extern int yydebug;
#endif
/* "%code requires" blocks. */
#line 11 "src/parser.y"
#line 12 "src/parser.y"
#include "locfile.h"
struct lexer_param;
@@ -178,7 +178,7 @@ struct lexer_param;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
union YYSTYPE
{
#line 31 "src/parser.y"
#line 32 "src/parser.y"
jv literal;
block blk;