Merge branch 'slimconfigure'
authorMichael Wallner <mike@php.net>
Mon, 16 Apr 2018 07:16:34 +0000 (09:16 +0200)
committerMichael Wallner <mike@php.net>
Mon, 16 Apr 2018 07:16:34 +0000 (09:16 +0200)
103 files changed:
Makefile.frag
config.m4
m4/psi/psi.m4
php_psi_posix.h.in
psi.d/arpa_inet.psi
psi.d/stat.psi
psi.d/uname.psi
scripts/_include.php
scripts/gen_calc_bin.php
scripts/gen_calc_bool.php
scripts/gen_calc_unary.php [new file with mode: 0644]
src/calc.h
src/calc/basic.h
src/calc/bin.h
src/calc/bool.h
src/calc/cast.h
src/calc/cmp.h
src/calc/unary.h [new file with mode: 0644]
src/context.c
src/context.h
src/cpp.c
src/data.c
src/data.h
src/error.h
src/marshal.c
src/module.c
src/parser.c
src/parser.re
src/parser_proc.c
src/parser_proc.h
src/parser_proc_grammar.y
src/plist.c
src/token.h
src/types.h
src/types/assert_stmt.c
src/types/assert_stmt.h
src/types/const.c
src/types/const.h
src/types/const_type.c [deleted file]
src/types/const_type.h [deleted file]
src/types/cpp_macro_decl.c
src/types/decl.c
src/types/decl.h
src/types/decl_arg.c
src/types/decl_arg.h
src/types/decl_enum_item.c
src/types/decl_extvar.c
src/types/decl_extvar.h
src/types/decl_struct.c
src/types/decl_struct.h
src/types/decl_type.c
src/types/decl_type.h
src/types/decl_union.c
src/types/decl_union.h
src/types/decl_var.c
src/types/decl_var.h
src/types/free_exp.c
src/types/free_exp.h
src/types/free_stmt.c
src/types/free_stmt.h
src/types/impl.c
src/types/impl.h
src/types/impl_arg.c
src/types/impl_def_val.c
src/types/impl_def_val.h
src/types/impl_func.c
src/types/impl_func.h
src/types/impl_type.c
src/types/impl_type.h
src/types/impl_var.c
src/types/impl_var.h
src/types/let_callback.c
src/types/let_callback.h
src/types/let_exp.c
src/types/let_exp.h
src/types/let_func.c
src/types/let_func.h
src/types/let_stmt.c
src/types/let_stmt.h
src/types/num_exp.c
src/types/num_exp.h
src/types/number.c
src/types/number.h
src/types/return_exp.c
src/types/return_exp.h
src/types/return_stmt.c
src/types/return_stmt.h
src/types/set_exp.c
src/types/set_exp.h
src/types/set_func.c
src/types/set_func.h
src/types/set_stmt.c
src/types/set_stmt.h
src/validate.c [new file with mode: 0644]
src/validate.h [new file with mode: 0644]
tests/calc/calc.psi
tests/ndbm/gdbm.psi [new file with mode: 0644]
tests/ndbm/ndbm.psi
tests/ndbm/ndbm001.phpt
tests/pipe/pipe.psi
tests/sqlite/sqlite.psi
tests/uname/uname001.phpt
tests/yaml/yaml.psi

index 5ca422e..91499f6 100644 (file)
@@ -27,10 +27,11 @@ $(PHP_PSI_SRCDIR)/src/parser.c: $(PHP_PSI_SRCDIR)/src/parser.re
 $(PHP_PSI_SRCDIR)/src/calc/%.h: $(PHP_PSI_SRCDIR)/scripts/gen_calc_%.php
        $(PHP_EXECUTABLE) $< >$@
 
-$(PHP_PSI_SRCDIR)/src/calc.h: | $(PHP_PSI_SRCDIR)/src/calc/basic.h $(PHP_PSI_SRCDIR)/src/calc/bin.h $(PHP_PSI_SRCDIR)/src/calc/bool.h $(PHP_PSI_SRCDIR)/src/calc/cast.h $(PHP_PSI_SRCDIR)/src/calc/cmp.h $(PHP_PSI_SRCDIR)/src/calc/oper.h
+$(PHP_PSI_SRCDIR)/src/calc.h: | $(PHP_PSI_SRCDIR)/src/calc/basic.h $(PHP_PSI_SRCDIR)/src/calc/bin.h $(PHP_PSI_SRCDIR)/src/calc/bool.h $(PHP_PSI_SRCDIR)/src/calc/unary.h $(PHP_PSI_SRCDIR)/src/calc/cast.h $(PHP_PSI_SRCDIR)/src/calc/cmp.h $(PHP_PSI_SRCDIR)/src/calc/oper.h
 
 .PHONY: psi-generated
 psi-generated: $(PHP_PSI_GENERATED)
+       
 
 PHP_PSI_DEPEND = $(patsubst $(PHP_PSI_SRCDIR)/%,$(PHP_PSI_BUILDDIR)/%,$(PHP_PSI_SOURCES:.c=.dep))
 
@@ -88,6 +89,10 @@ psi-clean-depend:
 
 psi-clean: psi-clean-depend
 
+.PHONY: psi-watch
+psi-watch:
+       -while inotifywait -q -e modify -r $(PHP_PSI_SRCDIR); do $(MAKE); done
+
 install-headers: psi-build-headers
 clean: psi-clean-headers psi-clean-aux
 ifneq ($(PSI_DEPS),)
index f25cc06..01a82a2 100644 (file)
--- a/config.m4
+++ b/config.m4
@@ -164,7 +164,7 @@ if test "$PHP_PSI" != no; then
 
        PHP_PSI_HEADERS=" \
                src/calc/basic.h src/calc/bin.h src/calc/bool.h src/calc/cast.h \
-               src/calc/cmp.h src/calc/oper.h \
+               src/calc/unary.h src/calc/cmp.h src/calc/oper.h \
                `(cd $PHP_PSI_SRCDIR/src && ls *.h types/*.h)` \
        "
        # parser* should come first
@@ -177,7 +177,7 @@ if test "$PHP_PSI" != no; then
        PHP_PSI_GENERATED=" \
                src/parser_proc.c src/parser.c \
                src/calc/basic.h src/calc/bin.h src/calc/bool.h src/calc/cast.h \
-               src/calc/cmp.h src/calc/oper.h \
+               src/calc/unary.h src/calc/cmp.h src/calc/oper.h \
        "
 
        PHP_NEW_EXTENSION(psi, $PHP_PSI_SOURCES, $ext_shared)
index 470a7a6..ba86907 100644 (file)
@@ -106,7 +106,9 @@ AC_DEFUN(PSI_CONFIG_DONE, [
        
        if $PSI_FAST_CONFIG; then
                for conf_env in $PSI_CONFIG_TMP/*/conf.env; do
-                       source $conf_env
+                       if test "$conf_env" != "$PSI_CONFIG_TMP/*/conf.env"; then
+                               source $conf_env
+                       fi
                done
        fi
        
index 882e30c..6131448 100644 (file)
@@ -110,6 +110,16 @@ static struct psi_func_redir {
        const char *name;
        psi_func_ptr func;
 } psi_func_redirs[] = {
+       {"fstat", (psi_func_ptr) fstat},
+       {"fstatat", (psi_func_ptr) fstatat},
+       {"lstat", (psi_func_ptr) lstat},
+       {"mknod", (psi_func_ptr) mknod},
+       {"mknodat", (psi_func_ptr) mknodat},
+       {"stat", (psi_func_ptr) stat},
+       {"getaddrinfo_a", (psi_func_ptr) getaddrinfo_a},
+       {"gai_suspend", (psi_func_ptr) gai_suspend},
+       {"gai_error", (psi_func_ptr) gai_error},
+       {"gai_cancel", (psi_func_ptr) gai_cancel},
 @PSI_REDIRS@
        {0}
 };
index f9aae9e..6fdf0fb 100644 (file)
@@ -34,7 +34,7 @@ function psi\inet_ntoa(array $in) : string {
 function psi\inet_ntop(int $af, string $src) : string {
        let af = intval($af);
        let src = strval($src);
-       let size = psi\SIZEOF_STRUCT_SOCKADDR_STORAGE;
+       let size = sizeof(struct sockaddr_storage);
        let dst = calloc(1, size);
        return inet_ntop(af, src, dst, size) as to_string(inet_ntop);
 }
@@ -42,7 +42,7 @@ function psi\inet_ntop(int $af, string $src) : string {
 function psi\inet_pton(int $af, string $src, string &$dst) : int {
        let af = intval($af);
        let src = strval($src);
-       let dst = calloc(1, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
+       let dst = calloc(1, sizeof(struct sockaddr_storage));
        return inet_pton(af, src, dst) as to_int(inet_pton);
-       set $dst = to_string(dst, psi\SIZEOF_STRUCT_SOCKADDR_STORAGE);
+       set $dst = to_string(dst, sizeof(struct sockaddr_storage));
 }
\ No newline at end of file
index 3d0e623..68f6781 100644 (file)
@@ -2,7 +2,7 @@
 // extern int stat(char *path, struct stat *buf);
 function psi\stat(string $path, array &$buf = NULL) : int {
        let path = strval($path);
-       let buf = calloc(1, psi\SIZEOF_STRUCT_STAT);
+       let buf = calloc(1, sizeof(struct stat));
        return stat(path, buf) as to_int(stat);
        set $buf = to_array(*buf,
                to_int(st_dev),
index e5144da..404399c 100644 (file)
@@ -1,7 +1,7 @@
 #include <sys/utsname.h>
 
 function psi\uname(array &$u = NULL) : int {
-       let name = calloc(1, psi\SIZEOF_STRUCT_UTSNAME);
+       let name = calloc(1, sizeof(struct utsname));
        return uname(name) as to_int(uname);
        set $u = to_array(*name,
                to_string(sysname),
index acd539b..67a73ca 100644 (file)
@@ -12,6 +12,8 @@ $types = [
                "UINT32" => "u32",
                "INT64" => "i64",
                "UINT64" => "u64",
+               "INT128" => "i128",
+               "UINT128" => "u128",
                "FLOAT" => "fval",
                "DOUBLE" => "dval",
                "LONG_DOUBLE" => "ldval",
@@ -29,6 +31,8 @@ function t_is_int($t) {
 
 function t_is_special($t) {
        switch ($t) {
+               case "INT128_T":
+               case "UINT128_T":
                case "LONG_DOUBLE":
                        return true;
                default:
index c7dbf01..5ee92a8 100644 (file)
@@ -64,35 +64,3 @@ static inline token_t psi_calc_bin_<?=$op_name?>(token_t t1, impl_val *v1, token
        return PSI_T_UINT64;
 }
 <?php endforeach; ?>
-
-static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
-{
-       impl_val i1;
-
-       (void) t2;
-       (void) v2;
-       
-       switch (t1) {<?php /*nobr*/ ?>
-       <?php foreach ($types as $t1 => $v1) : ?>
-       <?php if (t_is_special($t1)) :?>
-       
-#if HAVE_<?=$t1?>
-       <?php endif; ?>
-
-       case PSI_T_<?=$t1?>:
-               i1.u64 = v1-><?=$v1?>;
-               break;
-       <?php if (t_is_special($t1)) : ?>
-
-#endif
-       <?php endif; ?>
-       <?php endforeach; ?>
-
-       default:
-               assert(0);
-               break;
-       }
-
-       res->u64 = ~i1.u64;
-       return PSI_T_UINT64;
-}
\ No newline at end of file
index 1aaad08..1b5b339 100644 (file)
@@ -2,35 +2,6 @@
 include __DIR__."/_include.php";
 ?>
 
-
-static inline token_t psi_calc_bool_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
-{
-       (void) t2;
-       (void) v2;
-       
-       switch (t1) {<?php /*nobr */ ?>
-       <?php foreach ($types as $t1 => $v1) : ?>
-       <?php if (t_is_special($t1)) :?>
-       
-#if HAVE_<?=$t1?>
-       <?php endif; ?>
-
-       case PSI_T_<?=$t1?>:
-               res->u8 = !v1-><?=$v1?>;
-               break;<?php /*nobr */ ?>
-       <?php if (t_is_special($t1)) : ?>
-
-#endif
-       <?php endif; ?>
-       <?php endforeach; ?>
-
-       default:
-               assert(0);
-               break;
-       }
-       return PSI_T_UINT8;
-}
-
 static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
 {
        switch (t1) {<?php /*nobr */ ?>
diff --git a/scripts/gen_calc_unary.php b/scripts/gen_calc_unary.php
new file mode 100644 (file)
index 0000000..ef20720
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+include __DIR__."/_include.php"
+?>
+
+static inline token_t psi_calc_minus(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       (void) t2;
+       (void) v2;
+       
+       switch (t1) {<?php /*nobr */ ?>
+       <?php foreach ($types as $t1 => $v1) : ?>
+       <?php if (t_is_special($t1)) :?>
+       
+#if HAVE_<?=$t1?>
+       <?php endif; ?>
+
+       case PSI_T_<?=$t1?>:
+               res-><?=$v1?> = -v1-><?=$v1?>;
+               break;<?php /*nobr */ ?>
+       <?php if (t_is_special($t1)) : ?>
+
+#endif
+       <?php endif; ?>
+       <?php endforeach; ?>
+
+       default:
+               assert(0);
+               break;
+       }
+       return t1;
+}
+
+
+static inline token_t psi_calc_bool_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       (void) t2;
+       (void) v2;
+       
+       switch (t1) {<?php /*nobr */ ?>
+       <?php foreach ($types as $t1 => $v1) : ?>
+       <?php if (t_is_special($t1)) :?>
+       
+#if HAVE_<?=$t1?>
+       <?php endif; ?>
+
+       case PSI_T_<?=$t1?>:
+               res->u8 = !v1-><?=$v1?>;
+               break;<?php /*nobr */ ?>
+       <?php if (t_is_special($t1)) : ?>
+
+#endif
+       <?php endif; ?>
+       <?php endforeach; ?>
+
+       default:
+               assert(0);
+               break;
+       }
+       return PSI_T_UINT8;
+}
+
+
+static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       impl_val i1;
+
+       (void) t2;
+       (void) v2;
+       
+       switch (t1) {<?php /*nobr*/ ?>
+       <?php foreach ($types as $t1 => $v1) : ?>
+       <?php if (t_is_special($t1)) :?>
+       
+#if HAVE_<?=$t1?>
+       <?php endif; ?>
+
+       case PSI_T_<?=$t1?>:
+               i1.u64 = v1-><?=$v1?>;
+               break;
+       <?php if (t_is_special($t1)) : ?>
+
+#endif
+       <?php endif; ?>
+       <?php endforeach; ?>
+
+       default:
+               assert(0);
+               break;
+       }
+
+       res->u64 = ~i1.u64;
+       return PSI_T_UINT64;
+}
\ No newline at end of file
index 49114ef..21ece7b 100644 (file)
 #include "token.h"
 #include "types/impl_val.h"
 
-#define PRIfval "f"
-#define PRIdval "lf"
-#define PRIldval "Lf"
+#define PRIfval ".13gF"
+#define PRIdval ".53lg"
+#define PRIldval ".64LgL"
 
 typedef token_t (*psi_calc)(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res);
 
 #include "calc/basic.h"
 #include "calc/bin.h"
 #include "calc/bool.h"
+#include "calc/unary.h"
 #include "calc/cast.h"
 #include "calc/cmp.h"
 #include "calc/oper.h"
index ac021e0..ec42112 100644 (file)
@@ -58,6 +58,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i8 + v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i8 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i8 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i8 + v2->fval;
                        return PSI_T_FLOAT;
@@ -101,6 +107,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u8 + v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u8 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u8 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u8 + v2->fval;
                        return PSI_T_FLOAT;
@@ -144,6 +156,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i16 + v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i16 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i16 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i16 + v2->fval;
                        return PSI_T_FLOAT;
@@ -187,6 +205,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u16 + v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u16 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u16 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u16 + v2->fval;
                        return PSI_T_FLOAT;
@@ -230,6 +254,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i32 + v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i32 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i32 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i32 + v2->fval;
                        return PSI_T_FLOAT;
@@ -273,6 +303,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u32 + v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u32 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u32 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u32 + v2->fval;
                        return PSI_T_FLOAT;
@@ -316,6 +352,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i64 + v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i64 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i64 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i64 + v2->fval;
                        return PSI_T_FLOAT;
@@ -359,6 +401,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u64 + v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u64 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u64 + v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u64 + v2->fval;
                        return PSI_T_FLOAT;
@@ -371,6 +419,104 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                        return PSI_T_LONG_DOUBLE;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->i128 = v1->i128 + v2->i8;
+                       return PSI_T_INT128;
+               case PSI_T_UINT8:
+                       res->i128 = v1->i128 + v2->u8;
+                       return PSI_T_INT128;
+               case PSI_T_INT16:
+                       res->i128 = v1->i128 + v2->i16;
+                       return PSI_T_INT128;
+               case PSI_T_UINT16:
+                       res->i128 = v1->i128 + v2->u16;
+                       return PSI_T_INT128;
+               case PSI_T_INT32:
+                       res->i128 = v1->i128 + v2->i32;
+                       return PSI_T_INT128;
+               case PSI_T_UINT32:
+                       res->i128 = v1->i128 + v2->u32;
+                       return PSI_T_INT128;
+               case PSI_T_INT64:
+                       res->i128 = v1->i128 + v2->i64;
+                       return PSI_T_INT128;
+               case PSI_T_UINT64:
+                       res->i128 = v1->i128 + v2->u64;
+                       return PSI_T_INT128;
+               case PSI_T_INT128:
+                       res->i128 = v1->i128 + v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i128 + v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->i128 + v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->i128 + v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->i128 + v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u128 = v1->u128 + v2->i8;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT8:
+                       res->u128 = v1->u128 + v2->u8;
+                       return PSI_T_UINT128;
+               case PSI_T_INT16:
+                       res->u128 = v1->u128 + v2->i16;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT16:
+                       res->u128 = v1->u128 + v2->u16;
+                       return PSI_T_UINT128;
+               case PSI_T_INT32:
+                       res->u128 = v1->u128 + v2->i32;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT32:
+                       res->u128 = v1->u128 + v2->u32;
+                       return PSI_T_UINT128;
+               case PSI_T_INT64:
+                       res->u128 = v1->u128 + v2->i64;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT64:
+                       res->u128 = v1->u128 + v2->u64;
+                       return PSI_T_UINT128;
+               case PSI_T_INT128:
+                       res->u128 = v1->u128 + v2->i128;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u128 + v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->u128 + v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->u128 + v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->u128 + v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -402,6 +548,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->fval = v1->fval + v2->u64;
                        return PSI_T_FLOAT;
+               case PSI_T_INT128:
+                       res->fval = v1->fval + v2->i128;
+                       return PSI_T_FLOAT;
+               case PSI_T_UINT128:
+                       res->fval = v1->fval + v2->u128;
+                       return PSI_T_FLOAT;
                case PSI_T_FLOAT:
                        res->fval = v1->fval + v2->fval;
                        return PSI_T_FLOAT;
@@ -445,6 +597,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->dval = v1->dval + v2->u64;
                        return PSI_T_DOUBLE;
+               case PSI_T_INT128:
+                       res->dval = v1->dval + v2->i128;
+                       return PSI_T_DOUBLE;
+               case PSI_T_UINT128:
+                       res->dval = v1->dval + v2->u128;
+                       return PSI_T_DOUBLE;
                case PSI_T_FLOAT:
                        res->dval = v1->dval + v2->fval;
                        return PSI_T_DOUBLE;
@@ -489,6 +647,12 @@ static inline token_t psi_calc_add(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->ldval = v1->ldval + v2->u64;
                        return PSI_T_LONG_DOUBLE;
+               case PSI_T_INT128:
+                       res->ldval = v1->ldval + v2->i128;
+                       return PSI_T_LONG_DOUBLE;
+               case PSI_T_UINT128:
+                       res->ldval = v1->ldval + v2->u128;
+                       return PSI_T_LONG_DOUBLE;
                case PSI_T_FLOAT:
                        res->ldval = v1->ldval + v2->fval;
                        return PSI_T_LONG_DOUBLE;
@@ -545,6 +709,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i8 - v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i8 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i8 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i8 - v2->fval;
                        return PSI_T_FLOAT;
@@ -588,6 +758,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u8 - v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u8 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u8 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u8 - v2->fval;
                        return PSI_T_FLOAT;
@@ -631,6 +807,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i16 - v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i16 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i16 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i16 - v2->fval;
                        return PSI_T_FLOAT;
@@ -674,6 +856,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u16 - v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u16 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u16 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u16 - v2->fval;
                        return PSI_T_FLOAT;
@@ -717,6 +905,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i32 - v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i32 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i32 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i32 - v2->fval;
                        return PSI_T_FLOAT;
@@ -760,6 +954,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u32 - v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u32 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u32 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u32 - v2->fval;
                        return PSI_T_FLOAT;
@@ -803,6 +1003,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i64 - v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i64 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i64 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i64 - v2->fval;
                        return PSI_T_FLOAT;
@@ -846,6 +1052,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u64 - v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u64 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u64 - v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u64 - v2->fval;
                        return PSI_T_FLOAT;
@@ -858,6 +1070,104 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                        return PSI_T_LONG_DOUBLE;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->i128 = v1->i128 - v2->i8;
+                       return PSI_T_INT128;
+               case PSI_T_UINT8:
+                       res->i128 = v1->i128 - v2->u8;
+                       return PSI_T_INT128;
+               case PSI_T_INT16:
+                       res->i128 = v1->i128 - v2->i16;
+                       return PSI_T_INT128;
+               case PSI_T_UINT16:
+                       res->i128 = v1->i128 - v2->u16;
+                       return PSI_T_INT128;
+               case PSI_T_INT32:
+                       res->i128 = v1->i128 - v2->i32;
+                       return PSI_T_INT128;
+               case PSI_T_UINT32:
+                       res->i128 = v1->i128 - v2->u32;
+                       return PSI_T_INT128;
+               case PSI_T_INT64:
+                       res->i128 = v1->i128 - v2->i64;
+                       return PSI_T_INT128;
+               case PSI_T_UINT64:
+                       res->i128 = v1->i128 - v2->u64;
+                       return PSI_T_INT128;
+               case PSI_T_INT128:
+                       res->i128 = v1->i128 - v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i128 - v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->i128 - v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->i128 - v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->i128 - v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u128 = v1->u128 - v2->i8;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT8:
+                       res->u128 = v1->u128 - v2->u8;
+                       return PSI_T_UINT128;
+               case PSI_T_INT16:
+                       res->u128 = v1->u128 - v2->i16;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT16:
+                       res->u128 = v1->u128 - v2->u16;
+                       return PSI_T_UINT128;
+               case PSI_T_INT32:
+                       res->u128 = v1->u128 - v2->i32;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT32:
+                       res->u128 = v1->u128 - v2->u32;
+                       return PSI_T_UINT128;
+               case PSI_T_INT64:
+                       res->u128 = v1->u128 - v2->i64;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT64:
+                       res->u128 = v1->u128 - v2->u64;
+                       return PSI_T_UINT128;
+               case PSI_T_INT128:
+                       res->u128 = v1->u128 - v2->i128;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u128 - v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->u128 - v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->u128 - v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->u128 - v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -889,6 +1199,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->fval = v1->fval - v2->u64;
                        return PSI_T_FLOAT;
+               case PSI_T_INT128:
+                       res->fval = v1->fval - v2->i128;
+                       return PSI_T_FLOAT;
+               case PSI_T_UINT128:
+                       res->fval = v1->fval - v2->u128;
+                       return PSI_T_FLOAT;
                case PSI_T_FLOAT:
                        res->fval = v1->fval - v2->fval;
                        return PSI_T_FLOAT;
@@ -932,6 +1248,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->dval = v1->dval - v2->u64;
                        return PSI_T_DOUBLE;
+               case PSI_T_INT128:
+                       res->dval = v1->dval - v2->i128;
+                       return PSI_T_DOUBLE;
+               case PSI_T_UINT128:
+                       res->dval = v1->dval - v2->u128;
+                       return PSI_T_DOUBLE;
                case PSI_T_FLOAT:
                        res->dval = v1->dval - v2->fval;
                        return PSI_T_DOUBLE;
@@ -976,6 +1298,12 @@ static inline token_t psi_calc_sub(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->ldval = v1->ldval - v2->u64;
                        return PSI_T_LONG_DOUBLE;
+               case PSI_T_INT128:
+                       res->ldval = v1->ldval - v2->i128;
+                       return PSI_T_LONG_DOUBLE;
+               case PSI_T_UINT128:
+                       res->ldval = v1->ldval - v2->u128;
+                       return PSI_T_LONG_DOUBLE;
                case PSI_T_FLOAT:
                        res->ldval = v1->ldval - v2->fval;
                        return PSI_T_LONG_DOUBLE;
@@ -1032,6 +1360,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i8 * v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i8 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i8 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i8 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1075,6 +1409,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u8 * v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u8 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u8 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u8 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1118,6 +1458,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i16 * v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i16 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i16 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i16 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1161,6 +1507,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u16 * v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u16 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u16 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u16 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1204,6 +1556,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i32 * v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i32 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i32 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i32 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1247,6 +1605,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u32 * v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u32 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u32 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u32 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1290,6 +1654,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i64 * v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i64 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i64 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i64 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1333,6 +1703,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u64 * v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u64 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u64 * v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u64 * v2->fval;
                        return PSI_T_FLOAT;
@@ -1345,6 +1721,104 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                        return PSI_T_LONG_DOUBLE;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->i128 = v1->i128 * v2->i8;
+                       return PSI_T_INT128;
+               case PSI_T_UINT8:
+                       res->i128 = v1->i128 * v2->u8;
+                       return PSI_T_INT128;
+               case PSI_T_INT16:
+                       res->i128 = v1->i128 * v2->i16;
+                       return PSI_T_INT128;
+               case PSI_T_UINT16:
+                       res->i128 = v1->i128 * v2->u16;
+                       return PSI_T_INT128;
+               case PSI_T_INT32:
+                       res->i128 = v1->i128 * v2->i32;
+                       return PSI_T_INT128;
+               case PSI_T_UINT32:
+                       res->i128 = v1->i128 * v2->u32;
+                       return PSI_T_INT128;
+               case PSI_T_INT64:
+                       res->i128 = v1->i128 * v2->i64;
+                       return PSI_T_INT128;
+               case PSI_T_UINT64:
+                       res->i128 = v1->i128 * v2->u64;
+                       return PSI_T_INT128;
+               case PSI_T_INT128:
+                       res->i128 = v1->i128 * v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i128 * v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->i128 * v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->i128 * v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->i128 * v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u128 = v1->u128 * v2->i8;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT8:
+                       res->u128 = v1->u128 * v2->u8;
+                       return PSI_T_UINT128;
+               case PSI_T_INT16:
+                       res->u128 = v1->u128 * v2->i16;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT16:
+                       res->u128 = v1->u128 * v2->u16;
+                       return PSI_T_UINT128;
+               case PSI_T_INT32:
+                       res->u128 = v1->u128 * v2->i32;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT32:
+                       res->u128 = v1->u128 * v2->u32;
+                       return PSI_T_UINT128;
+               case PSI_T_INT64:
+                       res->u128 = v1->u128 * v2->i64;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT64:
+                       res->u128 = v1->u128 * v2->u64;
+                       return PSI_T_UINT128;
+               case PSI_T_INT128:
+                       res->u128 = v1->u128 * v2->i128;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u128 * v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->u128 * v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->u128 * v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->u128 * v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -1376,6 +1850,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->fval = v1->fval * v2->u64;
                        return PSI_T_FLOAT;
+               case PSI_T_INT128:
+                       res->fval = v1->fval * v2->i128;
+                       return PSI_T_FLOAT;
+               case PSI_T_UINT128:
+                       res->fval = v1->fval * v2->u128;
+                       return PSI_T_FLOAT;
                case PSI_T_FLOAT:
                        res->fval = v1->fval * v2->fval;
                        return PSI_T_FLOAT;
@@ -1419,6 +1899,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->dval = v1->dval * v2->u64;
                        return PSI_T_DOUBLE;
+               case PSI_T_INT128:
+                       res->dval = v1->dval * v2->i128;
+                       return PSI_T_DOUBLE;
+               case PSI_T_UINT128:
+                       res->dval = v1->dval * v2->u128;
+                       return PSI_T_DOUBLE;
                case PSI_T_FLOAT:
                        res->dval = v1->dval * v2->fval;
                        return PSI_T_DOUBLE;
@@ -1463,6 +1949,12 @@ static inline token_t psi_calc_mul(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->ldval = v1->ldval * v2->u64;
                        return PSI_T_LONG_DOUBLE;
+               case PSI_T_INT128:
+                       res->ldval = v1->ldval * v2->i128;
+                       return PSI_T_LONG_DOUBLE;
+               case PSI_T_UINT128:
+                       res->ldval = v1->ldval * v2->u128;
+                       return PSI_T_LONG_DOUBLE;
                case PSI_T_FLOAT:
                        res->ldval = v1->ldval * v2->fval;
                        return PSI_T_LONG_DOUBLE;
@@ -1519,6 +2011,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i8 / v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i8 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i8 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i8 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1562,6 +2060,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u8 / v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u8 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u8 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u8 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1605,6 +2109,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i16 / v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i16 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i16 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i16 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1648,6 +2158,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u16 / v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u16 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u16 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u16 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1691,6 +2207,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i32 / v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i32 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i32 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i32 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1734,6 +2256,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u32 / v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u32 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u32 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u32 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1777,6 +2305,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->i64 = v1->i64 / v2->u64;
                        return PSI_T_INT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->i64 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i64 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->i64 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1820,6 +2354,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->u64 = v1->u64 / v2->u64;
                        return PSI_T_UINT64;
+               case PSI_T_INT128:
+                       res->i128 = v1->u64 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u64 / v2->u128;
+                       return PSI_T_UINT128;
                case PSI_T_FLOAT:
                        res->fval = v1->u64 / v2->fval;
                        return PSI_T_FLOAT;
@@ -1832,6 +2372,104 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                        return PSI_T_LONG_DOUBLE;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->i128 = v1->i128 / v2->i8;
+                       return PSI_T_INT128;
+               case PSI_T_UINT8:
+                       res->i128 = v1->i128 / v2->u8;
+                       return PSI_T_INT128;
+               case PSI_T_INT16:
+                       res->i128 = v1->i128 / v2->i16;
+                       return PSI_T_INT128;
+               case PSI_T_UINT16:
+                       res->i128 = v1->i128 / v2->u16;
+                       return PSI_T_INT128;
+               case PSI_T_INT32:
+                       res->i128 = v1->i128 / v2->i32;
+                       return PSI_T_INT128;
+               case PSI_T_UINT32:
+                       res->i128 = v1->i128 / v2->u32;
+                       return PSI_T_INT128;
+               case PSI_T_INT64:
+                       res->i128 = v1->i128 / v2->i64;
+                       return PSI_T_INT128;
+               case PSI_T_UINT64:
+                       res->i128 = v1->i128 / v2->u64;
+                       return PSI_T_INT128;
+               case PSI_T_INT128:
+                       res->i128 = v1->i128 / v2->i128;
+                       return PSI_T_INT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->i128 / v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->i128 / v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->i128 / v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->i128 / v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u128 = v1->u128 / v2->i8;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT8:
+                       res->u128 = v1->u128 / v2->u8;
+                       return PSI_T_UINT128;
+               case PSI_T_INT16:
+                       res->u128 = v1->u128 / v2->i16;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT16:
+                       res->u128 = v1->u128 / v2->u16;
+                       return PSI_T_UINT128;
+               case PSI_T_INT32:
+                       res->u128 = v1->u128 / v2->i32;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT32:
+                       res->u128 = v1->u128 / v2->u32;
+                       return PSI_T_UINT128;
+               case PSI_T_INT64:
+                       res->u128 = v1->u128 / v2->i64;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT64:
+                       res->u128 = v1->u128 / v2->u64;
+                       return PSI_T_UINT128;
+               case PSI_T_INT128:
+                       res->u128 = v1->u128 / v2->i128;
+                       return PSI_T_UINT128;
+               case PSI_T_UINT128:
+                       res->u128 = v1->u128 / v2->u128;
+                       return PSI_T_UINT128;
+               case PSI_T_FLOAT:
+                       res->fval = v1->u128 / v2->fval;
+                       return PSI_T_FLOAT;
+               case PSI_T_DOUBLE:
+                       res->dval = v1->u128 / v2->dval;
+                       return PSI_T_DOUBLE;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->ldval = v1->u128 / v2->ldval;
+                       return PSI_T_LONG_DOUBLE;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -1863,6 +2501,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->fval = v1->fval / v2->u64;
                        return PSI_T_FLOAT;
+               case PSI_T_INT128:
+                       res->fval = v1->fval / v2->i128;
+                       return PSI_T_FLOAT;
+               case PSI_T_UINT128:
+                       res->fval = v1->fval / v2->u128;
+                       return PSI_T_FLOAT;
                case PSI_T_FLOAT:
                        res->fval = v1->fval / v2->fval;
                        return PSI_T_FLOAT;
@@ -1906,6 +2550,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->dval = v1->dval / v2->u64;
                        return PSI_T_DOUBLE;
+               case PSI_T_INT128:
+                       res->dval = v1->dval / v2->i128;
+                       return PSI_T_DOUBLE;
+               case PSI_T_UINT128:
+                       res->dval = v1->dval / v2->u128;
+                       return PSI_T_DOUBLE;
                case PSI_T_FLOAT:
                        res->dval = v1->dval / v2->fval;
                        return PSI_T_DOUBLE;
@@ -1950,6 +2600,12 @@ static inline token_t psi_calc_div(token_t t1, impl_val *v1, token_t t2, impl_va
                case PSI_T_UINT64:
                        res->ldval = v1->ldval / v2->u64;
                        return PSI_T_LONG_DOUBLE;
+               case PSI_T_INT128:
+                       res->ldval = v1->ldval / v2->i128;
+                       return PSI_T_LONG_DOUBLE;
+               case PSI_T_UINT128:
+                       res->ldval = v1->ldval / v2->u128;
+                       return PSI_T_LONG_DOUBLE;
                case PSI_T_FLOAT:
                        res->ldval = v1->ldval / v2->fval;
                        return PSI_T_LONG_DOUBLE;
@@ -2015,6 +2671,14 @@ static inline token_t psi_calc_mod(token_t t1, impl_val *v1, token_t t2, impl_va
                i1.i64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.i64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.i64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.i64 = v1->fval;
                break;
@@ -2060,6 +2724,12 @@ static inline token_t psi_calc_mod(token_t t1, impl_val *v1, token_t t2, impl_va
        case PSI_T_UINT64:
                i2.i64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.i64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.i64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.i64 = v2->fval;
                break;
index 3e9e4a0..772bd98 100644 (file)
@@ -65,6 +65,14 @@ static inline token_t psi_calc_bin_lshift(token_t t1, impl_val *v1, token_t t2,
                i1.u64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -110,6 +118,12 @@ static inline token_t psi_calc_bin_lshift(token_t t1, impl_val *v1, token_t t2,
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -168,6 +182,14 @@ static inline token_t psi_calc_bin_rshift(token_t t1, impl_val *v1, token_t t2,
                i1.u64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -213,6 +235,12 @@ static inline token_t psi_calc_bin_rshift(token_t t1, impl_val *v1, token_t t2,
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -271,6 +299,14 @@ static inline token_t psi_calc_bin_and(token_t t1, impl_val *v1, token_t t2, imp
                i1.u64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -316,6 +352,12 @@ static inline token_t psi_calc_bin_and(token_t t1, impl_val *v1, token_t t2, imp
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -374,6 +416,14 @@ static inline token_t psi_calc_bin_xor(token_t t1, impl_val *v1, token_t t2, imp
                i1.u64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -419,6 +469,12 @@ static inline token_t psi_calc_bin_xor(token_t t1, impl_val *v1, token_t t2, imp
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -477,6 +533,14 @@ static inline token_t psi_calc_bin_or(token_t t1, impl_val *v1, token_t t2, impl
                i1.u64 = v1->u64;
                break;
 
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
        case PSI_T_FLOAT:
                i1.u64 = v1->fval;
                break;
@@ -522,6 +586,12 @@ static inline token_t psi_calc_bin_or(token_t t1, impl_val *v1, token_t t2, impl
        case PSI_T_UINT64:
                i2.u64 = v2->u64;
                break;
+       case PSI_T_INT128:
+               i2.u64 = v2->i128;
+               break;
+       case PSI_T_UINT128:
+               i2.u64 = v2->u128;
+               break;
        case PSI_T_FLOAT:
                i2.u64 = v2->fval;
                break;
@@ -542,67 +612,3 @@ static inline token_t psi_calc_bin_or(token_t t1, impl_val *v1, token_t t2, impl
        res->u64 = i1.u64 | i2.u64;
        return PSI_T_UINT64;
 }
-
-static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
-{
-       impl_val i1;
-
-       (void) t2;
-       (void) v2;
-
-       switch (t1) {
-       case PSI_T_INT8:
-               i1.u64 = v1->i8;
-               break;
-
-       case PSI_T_UINT8:
-               i1.u64 = v1->u8;
-               break;
-
-       case PSI_T_INT16:
-               i1.u64 = v1->i16;
-               break;
-
-       case PSI_T_UINT16:
-               i1.u64 = v1->u16;
-               break;
-
-       case PSI_T_INT32:
-               i1.u64 = v1->i32;
-               break;
-
-       case PSI_T_UINT32:
-               i1.u64 = v1->u32;
-               break;
-
-       case PSI_T_INT64:
-               i1.u64 = v1->i64;
-               break;
-
-       case PSI_T_UINT64:
-               i1.u64 = v1->u64;
-               break;
-
-       case PSI_T_FLOAT:
-               i1.u64 = v1->fval;
-               break;
-
-       case PSI_T_DOUBLE:
-               i1.u64 = v1->dval;
-               break;
-
-#if HAVE_LONG_DOUBLE
-       case PSI_T_LONG_DOUBLE:
-               i1.u64 = v1->ldval;
-               break;
-
-#endif
-
-       default:
-               assert(0);
-               break;
-       }
-
-       res->u64 = ~i1.u64;
-       return PSI_T_UINT64;
-}
\ No newline at end of file
index 99f5f0a..5fe0ce7 100644 (file)
 #include <assert.h>
 
 #include "token.h"
-
-static inline token_t psi_calc_bool_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
-{
-       (void) t2;
-       (void) v2;
-
-       switch (t1) {
-       case PSI_T_INT8:
-               res->u8 = !v1->i8;
-               break;
-       case PSI_T_UINT8:
-               res->u8 = !v1->u8;
-               break;
-       case PSI_T_INT16:
-               res->u8 = !v1->i16;
-               break;
-       case PSI_T_UINT16:
-               res->u8 = !v1->u16;
-               break;
-       case PSI_T_INT32:
-               res->u8 = !v1->i32;
-               break;
-       case PSI_T_UINT32:
-               res->u8 = !v1->u32;
-               break;
-       case PSI_T_INT64:
-               res->u8 = !v1->i64;
-               break;
-       case PSI_T_UINT64:
-               res->u8 = !v1->u64;
-               break;
-       case PSI_T_FLOAT:
-               res->u8 = !v1->fval;
-               break;
-       case PSI_T_DOUBLE:
-               res->u8 = !v1->dval;
-               break;
-#if HAVE_LONG_DOUBLE
-       case PSI_T_LONG_DOUBLE:
-               res->u8 = !v1->ldval;
-               break;
-#endif
-
-       default:
-               assert(0);
-               break;
-       }
-       return PSI_T_UINT8;
-}
-
 static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
 {
        switch (t1) {
@@ -112,6 +62,14 @@ static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, imp
                if (v1->u64)
                        goto return_true;
                break;
+       case PSI_T_INT128:
+               if (v1->i128)
+                       goto return_true;
+               break;
+       case PSI_T_UINT128:
+               if (v1->u128)
+                       goto return_true;
+               break;
        case PSI_T_FLOAT:
                if (v1->fval)
                        goto return_true;
@@ -165,6 +123,14 @@ static inline token_t psi_calc_bool_or(token_t t1, impl_val *v1, token_t t2, imp
                if (v2->u64)
                        goto return_true;
                break;
+       case PSI_T_INT128:
+               if (v2->i128)
+                       goto return_true;
+               break;
+       case PSI_T_UINT128:
+               if (v2->u128)
+                       goto return_true;
+               break;
        case PSI_T_FLOAT:
                if (v2->fval)
                        goto return_true;
@@ -228,6 +194,14 @@ static inline token_t psi_calc_bool_and(token_t t1, impl_val *v1, token_t t2, im
                if (!v1->u64)
                        goto return_false;
                break;
+       case PSI_T_INT128:
+               if (!v1->i128)
+                       goto return_false;
+               break;
+       case PSI_T_UINT128:
+               if (!v1->u128)
+                       goto return_false;
+               break;
        case PSI_T_FLOAT:
                if (!v1->fval)
                        goto return_false;
@@ -281,6 +255,14 @@ static inline token_t psi_calc_bool_and(token_t t1, impl_val *v1, token_t t2, im
                if (!v2->u64)
                        goto return_false;
                break;
+       case PSI_T_INT128:
+               if (!v2->i128)
+                       goto return_false;
+               break;
+       case PSI_T_UINT128:
+               if (!v2->u128)
+                       goto return_false;
+               break;
        case PSI_T_FLOAT:
                if (!v2->fval)
                        goto return_false;
index c6f14aa..eb93b3b 100644 (file)
@@ -57,6 +57,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->i8 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->i8 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->i8 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->i8 = in_val->fval;
                        break;
@@ -100,6 +106,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->u8 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->u8 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->u8 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->u8 = in_val->fval;
                        break;
@@ -143,6 +155,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->i16 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->i16 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->i16 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->i16 = in_val->fval;
                        break;
@@ -186,6 +204,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->u16 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->u16 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->u16 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->u16 = in_val->fval;
                        break;
@@ -229,6 +253,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->i32 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->i32 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->i32 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->i32 = in_val->fval;
                        break;
@@ -272,6 +302,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->u32 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->u32 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->u32 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->u32 = in_val->fval;
                        break;
@@ -315,6 +351,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->i64 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->i64 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->i64 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->i64 = in_val->fval;
                        break;
@@ -358,6 +400,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->u64 = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->u64 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->u64 = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->u64 = in_val->fval;
                        break;
@@ -370,6 +418,104 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (in_type) {
+               case PSI_T_INT8:
+                       out_val->i128 = in_val->i8;
+                       break;
+               case PSI_T_UINT8:
+                       out_val->i128 = in_val->u8;
+                       break;
+               case PSI_T_INT16:
+                       out_val->i128 = in_val->i16;
+                       break;
+               case PSI_T_UINT16:
+                       out_val->i128 = in_val->u16;
+                       break;
+               case PSI_T_INT32:
+                       out_val->i128 = in_val->i32;
+                       break;
+               case PSI_T_UINT32:
+                       out_val->i128 = in_val->u32;
+                       break;
+               case PSI_T_INT64:
+                       out_val->i128 = in_val->i64;
+                       break;
+               case PSI_T_UINT64:
+                       out_val->i128 = in_val->u64;
+                       break;
+               case PSI_T_INT128:
+                       out_val->i128 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->i128 = in_val->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       out_val->i128 = in_val->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       out_val->i128 = in_val->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       out_val->i128 = in_val->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (in_type) {
+               case PSI_T_INT8:
+                       out_val->u128 = in_val->i8;
+                       break;
+               case PSI_T_UINT8:
+                       out_val->u128 = in_val->u8;
+                       break;
+               case PSI_T_INT16:
+                       out_val->u128 = in_val->i16;
+                       break;
+               case PSI_T_UINT16:
+                       out_val->u128 = in_val->u16;
+                       break;
+               case PSI_T_INT32:
+                       out_val->u128 = in_val->i32;
+                       break;
+               case PSI_T_UINT32:
+                       out_val->u128 = in_val->u32;
+                       break;
+               case PSI_T_INT64:
+                       out_val->u128 = in_val->i64;
+                       break;
+               case PSI_T_UINT64:
+                       out_val->u128 = in_val->u64;
+                       break;
+               case PSI_T_INT128:
+                       out_val->u128 = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->u128 = in_val->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       out_val->u128 = in_val->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       out_val->u128 = in_val->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       out_val->u128 = in_val->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -401,6 +547,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->fval = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->fval = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->fval = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->fval = in_val->fval;
                        break;
@@ -444,6 +596,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->dval = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->dval = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->dval = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->dval = in_val->fval;
                        break;
@@ -488,6 +646,12 @@ static inline void psi_calc_cast(token_t in_type, impl_val *in_val, token_t out_
                case PSI_T_UINT64:
                        out_val->ldval = in_val->u64;
                        break;
+               case PSI_T_INT128:
+                       out_val->ldval = in_val->i128;
+                       break;
+               case PSI_T_UINT128:
+                       out_val->ldval = in_val->u128;
+                       break;
                case PSI_T_FLOAT:
                        out_val->ldval = in_val->fval;
                        break;
index 8fac2f3..30bc0c9 100644 (file)
@@ -57,6 +57,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 == v2->fval;
                        break;
@@ -100,6 +106,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 == v2->fval;
                        break;
@@ -143,6 +155,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 == v2->fval;
                        break;
@@ -186,6 +204,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 == v2->fval;
                        break;
@@ -229,6 +253,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 == v2->fval;
                        break;
@@ -272,6 +302,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 == v2->fval;
                        break;
@@ -315,6 +351,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 == v2->fval;
                        break;
@@ -358,6 +400,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 == v2->fval;
                        break;
@@ -370,6 +418,104 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->i128 == v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->i128 == v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->i128 == v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->i128 == v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->i128 == v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->i128 == v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->i128 == v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->i128 == v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 == v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->i128 == v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->i128 == v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->i128 == v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->u128 == v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->u128 == v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->u128 == v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->u128 == v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->u128 == v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->u128 == v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->u128 == v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->u128 == v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 == v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->u128 == v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->u128 == v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->u128 == v2->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -401,6 +547,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->fval == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->fval == v2->fval;
                        break;
@@ -444,6 +596,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->dval == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->dval == v2->fval;
                        break;
@@ -488,6 +646,12 @@ static inline token_t psi_calc_cmp_eq(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->ldval == v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval == v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval == v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->ldval == v2->fval;
                        break;
@@ -543,6 +707,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 != v2->fval;
                        break;
@@ -586,6 +756,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 != v2->fval;
                        break;
@@ -629,6 +805,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 != v2->fval;
                        break;
@@ -672,6 +854,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 != v2->fval;
                        break;
@@ -715,6 +903,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 != v2->fval;
                        break;
@@ -758,6 +952,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 != v2->fval;
                        break;
@@ -801,6 +1001,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 != v2->fval;
                        break;
@@ -844,6 +1050,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 != v2->fval;
                        break;
@@ -856,6 +1068,104 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->i128 != v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->i128 != v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->i128 != v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->i128 != v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->i128 != v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->i128 != v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->i128 != v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->i128 != v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 != v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->i128 != v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->i128 != v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->i128 != v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->u128 != v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->u128 != v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->u128 != v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->u128 != v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->u128 != v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->u128 != v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->u128 != v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->u128 != v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 != v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->u128 != v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->u128 != v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->u128 != v2->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -887,6 +1197,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->fval != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->fval != v2->fval;
                        break;
@@ -930,6 +1246,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->dval != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->dval != v2->fval;
                        break;
@@ -974,6 +1296,12 @@ static inline token_t psi_calc_cmp_ne(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->ldval != v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval != v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval != v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->ldval != v2->fval;
                        break;
@@ -1029,6 +1357,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 < v2->fval;
                        break;
@@ -1072,6 +1406,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 < v2->fval;
                        break;
@@ -1115,6 +1455,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 < v2->fval;
                        break;
@@ -1158,6 +1504,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 < v2->fval;
                        break;
@@ -1201,6 +1553,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 < v2->fval;
                        break;
@@ -1244,6 +1602,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 < v2->fval;
                        break;
@@ -1287,6 +1651,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 < v2->fval;
                        break;
@@ -1330,6 +1700,12 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 < v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 < v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 < v2->fval;
                        break;
@@ -1347,41 +1723,47 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                        break;
                }
                break;
-       case PSI_T_FLOAT:
+       case PSI_T_INT128:
                switch (t2) {
                case PSI_T_INT8:
-                       res->u8 = v1->fval < v2->i8;
+                       res->u8 = v1->i128 < v2->i8;
                        break;
                case PSI_T_UINT8:
-                       res->u8 = v1->fval < v2->u8;
+                       res->u8 = v1->i128 < v2->u8;
                        break;
                case PSI_T_INT16:
-                       res->u8 = v1->fval < v2->i16;
+                       res->u8 = v1->i128 < v2->i16;
                        break;
                case PSI_T_UINT16:
-                       res->u8 = v1->fval < v2->u16;
+                       res->u8 = v1->i128 < v2->u16;
                        break;
                case PSI_T_INT32:
-                       res->u8 = v1->fval < v2->i32;
+                       res->u8 = v1->i128 < v2->i32;
                        break;
                case PSI_T_UINT32:
-                       res->u8 = v1->fval < v2->u32;
+                       res->u8 = v1->i128 < v2->u32;
                        break;
                case PSI_T_INT64:
-                       res->u8 = v1->fval < v2->i64;
+                       res->u8 = v1->i128 < v2->i64;
                        break;
                case PSI_T_UINT64:
-                       res->u8 = v1->fval < v2->u64;
+                       res->u8 = v1->i128 < v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 < v2->u128;
                        break;
                case PSI_T_FLOAT:
-                       res->u8 = v1->fval < v2->fval;
+                       res->u8 = v1->i128 < v2->fval;
                        break;
                case PSI_T_DOUBLE:
-                       res->u8 = v1->fval < v2->dval;
+                       res->u8 = v1->i128 < v2->dval;
                        break;
 #      if HAVE_LONG_DOUBLE
                case PSI_T_LONG_DOUBLE:
-                       res->u8 = v1->fval < v2->ldval;
+                       res->u8 = v1->i128 < v2->ldval;
                        break;
 #      endif
 
@@ -1390,41 +1772,47 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                        break;
                }
                break;
-       case PSI_T_DOUBLE:
+       case PSI_T_UINT128:
                switch (t2) {
                case PSI_T_INT8:
-                       res->u8 = v1->dval < v2->i8;
+                       res->u8 = v1->u128 < v2->i8;
                        break;
                case PSI_T_UINT8:
-                       res->u8 = v1->dval < v2->u8;
+                       res->u8 = v1->u128 < v2->u8;
                        break;
                case PSI_T_INT16:
-                       res->u8 = v1->dval < v2->i16;
+                       res->u8 = v1->u128 < v2->i16;
                        break;
                case PSI_T_UINT16:
-                       res->u8 = v1->dval < v2->u16;
+                       res->u8 = v1->u128 < v2->u16;
                        break;
                case PSI_T_INT32:
-                       res->u8 = v1->dval < v2->i32;
+                       res->u8 = v1->u128 < v2->i32;
                        break;
                case PSI_T_UINT32:
-                       res->u8 = v1->dval < v2->u32;
+                       res->u8 = v1->u128 < v2->u32;
                        break;
                case PSI_T_INT64:
-                       res->u8 = v1->dval < v2->i64;
+                       res->u8 = v1->u128 < v2->i64;
                        break;
                case PSI_T_UINT64:
-                       res->u8 = v1->dval < v2->u64;
+                       res->u8 = v1->u128 < v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 < v2->u128;
                        break;
                case PSI_T_FLOAT:
-                       res->u8 = v1->dval < v2->fval;
+                       res->u8 = v1->u128 < v2->fval;
                        break;
                case PSI_T_DOUBLE:
-                       res->u8 = v1->dval < v2->dval;
+                       res->u8 = v1->u128 < v2->dval;
                        break;
 #      if HAVE_LONG_DOUBLE
                case PSI_T_LONG_DOUBLE:
-                       res->u8 = v1->dval < v2->ldval;
+                       res->u8 = v1->u128 < v2->ldval;
                        break;
 #      endif
 
@@ -1433,42 +1821,47 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                        break;
                }
                break;
-#if HAVE_LONG_DOUBLE
-       case PSI_T_LONG_DOUBLE:
+       case PSI_T_FLOAT:
                switch (t2) {
                case PSI_T_INT8:
-                       res->u8 = v1->ldval < v2->i8;
+                       res->u8 = v1->fval < v2->i8;
                        break;
                case PSI_T_UINT8:
-                       res->u8 = v1->ldval < v2->u8;
+                       res->u8 = v1->fval < v2->u8;
                        break;
                case PSI_T_INT16:
-                       res->u8 = v1->ldval < v2->i16;
+                       res->u8 = v1->fval < v2->i16;
                        break;
                case PSI_T_UINT16:
-                       res->u8 = v1->ldval < v2->u16;
+                       res->u8 = v1->fval < v2->u16;
                        break;
                case PSI_T_INT32:
-                       res->u8 = v1->ldval < v2->i32;
+                       res->u8 = v1->fval < v2->i32;
                        break;
                case PSI_T_UINT32:
-                       res->u8 = v1->ldval < v2->u32;
+                       res->u8 = v1->fval < v2->u32;
                        break;
                case PSI_T_INT64:
-                       res->u8 = v1->ldval < v2->i64;
+                       res->u8 = v1->fval < v2->i64;
                        break;
                case PSI_T_UINT64:
-                       res->u8 = v1->ldval < v2->u64;
+                       res->u8 = v1->fval < v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval < v2->u128;
                        break;
                case PSI_T_FLOAT:
-                       res->u8 = v1->ldval < v2->fval;
+                       res->u8 = v1->fval < v2->fval;
                        break;
                case PSI_T_DOUBLE:
-                       res->u8 = v1->ldval < v2->dval;
+                       res->u8 = v1->fval < v2->dval;
                        break;
 #      if HAVE_LONG_DOUBLE
                case PSI_T_LONG_DOUBLE:
-                       res->u8 = v1->ldval < v2->ldval;
+                       res->u8 = v1->fval < v2->ldval;
                        break;
 #      endif
 
@@ -1477,15 +1870,114 @@ static inline token_t psi_calc_cmp_lt(token_t t1, impl_val *v1, token_t t2, impl
                        break;
                }
                break;
-#endif
-
-       default:
-               assert(0);
-               break;
-       }
-       return PSI_T_UINT8;
-}
-
+       case PSI_T_DOUBLE:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->dval < v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->dval < v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->dval < v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->dval < v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->dval < v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->dval < v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->dval < v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->dval < v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval < v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->dval < v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->dval < v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->dval < v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+#if HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->ldval < v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->ldval < v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->ldval < v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->ldval < v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->ldval < v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->ldval < v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->ldval < v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->ldval < v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval < v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval < v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->ldval < v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->ldval < v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->ldval < v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+#endif
+
+       default:
+               assert(0);
+               break;
+       }
+       return PSI_T_UINT8;
+}
+
 static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
 {
        switch (t1) {
@@ -1515,6 +2007,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 > v2->fval;
                        break;
@@ -1558,6 +2056,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 > v2->fval;
                        break;
@@ -1601,6 +2105,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 > v2->fval;
                        break;
@@ -1644,6 +2154,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 > v2->fval;
                        break;
@@ -1687,6 +2203,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 > v2->fval;
                        break;
@@ -1730,6 +2252,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 > v2->fval;
                        break;
@@ -1773,6 +2301,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 > v2->fval;
                        break;
@@ -1816,6 +2350,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 > v2->fval;
                        break;
@@ -1828,6 +2368,104 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->i128 > v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->i128 > v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->i128 > v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->i128 > v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->i128 > v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->i128 > v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->i128 > v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->i128 > v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 > v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->i128 > v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->i128 > v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->i128 > v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->u128 > v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->u128 > v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->u128 > v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->u128 > v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->u128 > v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->u128 > v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->u128 > v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->u128 > v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 > v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->u128 > v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->u128 > v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->u128 > v2->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -1859,6 +2497,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->fval > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->fval > v2->fval;
                        break;
@@ -1902,6 +2546,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->dval > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->dval > v2->fval;
                        break;
@@ -1946,6 +2596,12 @@ static inline token_t psi_calc_cmp_gt(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->ldval > v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval > v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval > v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->ldval > v2->fval;
                        break;
@@ -2001,6 +2657,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 <= v2->fval;
                        break;
@@ -2044,6 +2706,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 <= v2->fval;
                        break;
@@ -2087,6 +2755,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 <= v2->fval;
                        break;
@@ -2130,6 +2804,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 <= v2->fval;
                        break;
@@ -2173,6 +2853,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 <= v2->fval;
                        break;
@@ -2216,6 +2902,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 <= v2->fval;
                        break;
@@ -2259,6 +2951,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 <= v2->fval;
                        break;
@@ -2302,6 +3000,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 <= v2->fval;
                        break;
@@ -2314,6 +3018,104 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->i128 <= v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->i128 <= v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->i128 <= v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->i128 <= v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->i128 <= v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->i128 <= v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->i128 <= v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->i128 <= v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 <= v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->i128 <= v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->i128 <= v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->i128 <= v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->u128 <= v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->u128 <= v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->u128 <= v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->u128 <= v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->u128 <= v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->u128 <= v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->u128 <= v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->u128 <= v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 <= v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->u128 <= v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->u128 <= v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->u128 <= v2->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -2345,6 +3147,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->fval <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->fval <= v2->fval;
                        break;
@@ -2388,6 +3196,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->dval <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->dval <= v2->fval;
                        break;
@@ -2432,6 +3246,12 @@ static inline token_t psi_calc_cmp_le(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->ldval <= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval <= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval <= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->ldval <= v2->fval;
                        break;
@@ -2487,6 +3307,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i8 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i8 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i8 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i8 >= v2->fval;
                        break;
@@ -2530,6 +3356,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u8 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u8 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u8 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u8 >= v2->fval;
                        break;
@@ -2573,6 +3405,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i16 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i16 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i16 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i16 >= v2->fval;
                        break;
@@ -2616,6 +3454,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u16 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u16 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u16 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u16 >= v2->fval;
                        break;
@@ -2659,6 +3503,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i32 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i32 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i32 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i32 >= v2->fval;
                        break;
@@ -2702,6 +3552,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u32 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u32 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u32 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u32 >= v2->fval;
                        break;
@@ -2745,6 +3601,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->i64 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i64 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i64 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->i64 >= v2->fval;
                        break;
@@ -2788,6 +3650,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->u64 >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u64 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u64 >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->u64 >= v2->fval;
                        break;
@@ -2800,6 +3668,104 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                        break;
 #      endif
 
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_INT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->i128 >= v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->i128 >= v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->i128 >= v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->i128 >= v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->i128 >= v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->i128 >= v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->i128 >= v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->i128 >= v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->i128 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->i128 >= v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->i128 >= v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->i128 >= v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->i128 >= v2->ldval;
+                       break;
+#      endif
+
+               default:
+                       assert(0);
+                       break;
+               }
+               break;
+       case PSI_T_UINT128:
+               switch (t2) {
+               case PSI_T_INT8:
+                       res->u8 = v1->u128 >= v2->i8;
+                       break;
+               case PSI_T_UINT8:
+                       res->u8 = v1->u128 >= v2->u8;
+                       break;
+               case PSI_T_INT16:
+                       res->u8 = v1->u128 >= v2->i16;
+                       break;
+               case PSI_T_UINT16:
+                       res->u8 = v1->u128 >= v2->u16;
+                       break;
+               case PSI_T_INT32:
+                       res->u8 = v1->u128 >= v2->i32;
+                       break;
+               case PSI_T_UINT32:
+                       res->u8 = v1->u128 >= v2->u32;
+                       break;
+               case PSI_T_INT64:
+                       res->u8 = v1->u128 >= v2->i64;
+                       break;
+               case PSI_T_UINT64:
+                       res->u8 = v1->u128 >= v2->u64;
+                       break;
+               case PSI_T_INT128:
+                       res->u8 = v1->u128 >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->u128 >= v2->u128;
+                       break;
+               case PSI_T_FLOAT:
+                       res->u8 = v1->u128 >= v2->fval;
+                       break;
+               case PSI_T_DOUBLE:
+                       res->u8 = v1->u128 >= v2->dval;
+                       break;
+#      if HAVE_LONG_DOUBLE
+               case PSI_T_LONG_DOUBLE:
+                       res->u8 = v1->u128 >= v2->ldval;
+                       break;
+#      endif
+
                default:
                        assert(0);
                        break;
@@ -2831,6 +3797,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->fval >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->fval >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->fval >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->fval >= v2->fval;
                        break;
@@ -2874,6 +3846,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->dval >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->dval >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->dval >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->dval >= v2->fval;
                        break;
@@ -2918,6 +3896,12 @@ static inline token_t psi_calc_cmp_ge(token_t t1, impl_val *v1, token_t t2, impl
                case PSI_T_UINT64:
                        res->u8 = v1->ldval >= v2->u64;
                        break;
+               case PSI_T_INT128:
+                       res->u8 = v1->ldval >= v2->i128;
+                       break;
+               case PSI_T_UINT128:
+                       res->u8 = v1->ldval >= v2->u128;
+                       break;
                case PSI_T_FLOAT:
                        res->u8 = v1->ldval >= v2->fval;
                        break;
diff --git a/src/calc/unary.h b/src/calc/unary.h
new file mode 100644 (file)
index 0000000..72a82e1
--- /dev/null
@@ -0,0 +1,212 @@
+/*******************************************************************************
+ Copyright (c) 2016, Michael Wallner <mike@php.net>.
+ All rights reserved.
+
+ Redistribution and use in source and binary forms, with or without
+ modification, are permitted provided that the following conditions are met:
+
+     * Redistributions of source code must retain the above copyright notice,
+       this list of conditions and the following disclaimer.
+     * Redistributions in binary form must reproduce the above copyright
+       notice, this list of conditions and the following disclaimer in the
+       documentation and/or other materials provided with the distribution.
+
+ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE
+ FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
+ CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
+ OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*******************************************************************************/
+
+#include "php_psi_stdinc.h"
+#include <assert.h>
+
+#include "token.h"
+static inline token_t psi_calc_minus(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       (void) t2;
+       (void) v2;
+
+       switch (t1) {
+       case PSI_T_INT8:
+               res->i8 = -v1->i8;
+               break;
+       case PSI_T_UINT8:
+               res->u8 = -v1->u8;
+               break;
+       case PSI_T_INT16:
+               res->i16 = -v1->i16;
+               break;
+       case PSI_T_UINT16:
+               res->u16 = -v1->u16;
+               break;
+       case PSI_T_INT32:
+               res->i32 = -v1->i32;
+               break;
+       case PSI_T_UINT32:
+               res->u32 = -v1->u32;
+               break;
+       case PSI_T_INT64:
+               res->i64 = -v1->i64;
+               break;
+       case PSI_T_UINT64:
+               res->u64 = -v1->u64;
+               break;
+       case PSI_T_INT128:
+               res->i128 = -v1->i128;
+               break;
+       case PSI_T_UINT128:
+               res->u128 = -v1->u128;
+               break;
+       case PSI_T_FLOAT:
+               res->fval = -v1->fval;
+               break;
+       case PSI_T_DOUBLE:
+               res->dval = -v1->dval;
+               break;
+#if HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               res->ldval = -v1->ldval;
+               break;
+#endif
+
+       default:
+               assert(0);
+               break;
+       }
+       return t1;
+}
+
+
+static inline token_t psi_calc_bool_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       (void) t2;
+       (void) v2;
+
+       switch (t1) {
+       case PSI_T_INT8:
+               res->u8 = !v1->i8;
+               break;
+       case PSI_T_UINT8:
+               res->u8 = !v1->u8;
+               break;
+       case PSI_T_INT16:
+               res->u8 = !v1->i16;
+               break;
+       case PSI_T_UINT16:
+               res->u8 = !v1->u16;
+               break;
+       case PSI_T_INT32:
+               res->u8 = !v1->i32;
+               break;
+       case PSI_T_UINT32:
+               res->u8 = !v1->u32;
+               break;
+       case PSI_T_INT64:
+               res->u8 = !v1->i64;
+               break;
+       case PSI_T_UINT64:
+               res->u8 = !v1->u64;
+               break;
+       case PSI_T_INT128:
+               res->u8 = !v1->i128;
+               break;
+       case PSI_T_UINT128:
+               res->u8 = !v1->u128;
+               break;
+       case PSI_T_FLOAT:
+               res->u8 = !v1->fval;
+               break;
+       case PSI_T_DOUBLE:
+               res->u8 = !v1->dval;
+               break;
+#if HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               res->u8 = !v1->ldval;
+               break;
+#endif
+
+       default:
+               assert(0);
+               break;
+       }
+       return PSI_T_UINT8;
+}
+
+
+static inline token_t psi_calc_bin_not(token_t t1, impl_val *v1, token_t t2, impl_val *v2, impl_val *res)
+{
+       impl_val i1;
+
+       (void) t2;
+       (void) v2;
+
+       switch (t1) {
+       case PSI_T_INT8:
+               i1.u64 = v1->i8;
+               break;
+
+       case PSI_T_UINT8:
+               i1.u64 = v1->u8;
+               break;
+
+       case PSI_T_INT16:
+               i1.u64 = v1->i16;
+               break;
+
+       case PSI_T_UINT16:
+               i1.u64 = v1->u16;
+               break;
+
+       case PSI_T_INT32:
+               i1.u64 = v1->i32;
+               break;
+
+       case PSI_T_UINT32:
+               i1.u64 = v1->u32;
+               break;
+
+       case PSI_T_INT64:
+               i1.u64 = v1->i64;
+               break;
+
+       case PSI_T_UINT64:
+               i1.u64 = v1->u64;
+               break;
+
+       case PSI_T_INT128:
+               i1.u64 = v1->i128;
+               break;
+
+       case PSI_T_UINT128:
+               i1.u64 = v1->u128;
+               break;
+
+       case PSI_T_FLOAT:
+               i1.u64 = v1->fval;
+               break;
+
+       case PSI_T_DOUBLE:
+               i1.u64 = v1->dval;
+               break;
+
+#if HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               i1.u64 = v1->ldval;
+               break;
+
+#endif
+
+       default:
+               assert(0);
+               break;
+       }
+
+       res->u64 = ~i1.u64;
+       return PSI_T_UINT64;
+}
\ No newline at end of file
index 5749a73..d1f808c 100644 (file)
 #include "token.h"
 #include "parser.h"
 
-#define PSI_PREDEF_TYPES
-#define PSI_PREDEF_CONSTS
-#define PSI_PREDEF_COMPOSITES
-#define PSI_PREDEF_DECLS
 #include "php_psi_posix.h"
 
 struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_ops *ops, psi_error_cb error, unsigned flags)
 {
-       struct psi_data T;
-       struct psi_predef_type *predef_type;
-       struct psi_predef_const *predef_const;
-       struct psi_predef_composite *predef_composite;
-       struct psi_predef_decl *predef_decl;
-
        if (!C) {
                C = malloc(sizeof(*C));
        }
@@ -85,139 +75,6 @@ struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_o
        assert(ops->call != NULL);
        assert(ops->compile != NULL);
 
-       /* build up predefs in a temporary psi_data for validation */
-       memset(&T, 0, sizeof(T));
-       psi_data_ctor_with_dtors(&T, error, flags);
-
-#if PHP_DEBUG
-       if (psi_check_env("PSI_SKIP"))
-               goto skip_predefs;
-#endif
-
-       for (predef_type = &psi_predef_types[0]; predef_type->type_tag; ++predef_type) {
-               struct psi_decl_type *type = psi_decl_type_init(predef_type->type_tag, predef_type->type_name);
-               struct psi_decl_var *var = psi_decl_var_init(predef_type->alias, 0, 0); /* FIXME: indirection */
-               struct psi_decl_arg *def = psi_decl_arg_init(type, var);
-
-               T.types = psi_plist_add(T.types, &def);
-       }
-       for (predef_const = &psi_predef_consts[0]; predef_const->type_tag; ++predef_const) {
-               struct psi_const_type *type = psi_const_type_init(predef_const->type_tag, predef_const->type_name);
-               struct psi_impl_def_val *val;
-               struct psi_const *constant;
-
-               switch (type->type) {
-               case PSI_T_INT:
-                       val = psi_impl_def_val_init(PSI_T_INT, NULL);
-                       val->ival.zend.lval = predef_const->value.zend.lval;
-                       break;
-               case PSI_T_STRING:
-                       val = psi_impl_def_val_init(PSI_T_STRING, NULL);
-                       val->ival.zend.str = zend_string_init(predef_const->value.ptr, strlen(predef_const->value.ptr), 1);
-                       break;
-               default:
-                       assert(0);
-                       break;
-               }
-
-               constant = psi_const_init(type, predef_const->var_name, val);
-               T.consts = psi_plist_add(T.consts, &constant);
-       }
-       for (predef_composite = &psi_predef_composites[0]; predef_composite->type_tag; ++predef_composite) {
-               struct psi_predef_composite *member;
-               struct psi_decl_struct *dstruct;
-               struct psi_decl_union *dunion;
-               struct psi_plist *dargs = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
-
-               switch (predef_composite->type_tag) {
-               case PSI_T_STRUCT:
-                       dstruct = psi_decl_struct_init(predef_composite->var_name, dargs);
-                       dstruct->size = predef_composite->size;
-                       dstruct->align = predef_composite->offset;
-                       break;
-               case PSI_T_UNION:
-                       dunion = psi_decl_union_init(predef_composite->var_name, dargs);
-                       dunion->size = predef_composite->size;
-                       dunion->align = predef_composite->offset;
-                       break;
-               default:
-                       assert(0);
-               }
-               for (member = &predef_composite[1]; member->type_tag; ++member) {
-                       struct psi_decl_type *type;
-                       struct psi_decl_var *dvar;
-                       struct psi_decl_arg *darg;
-
-                       type = psi_decl_type_init(member->type_tag, member->type_name);
-                       dvar = psi_decl_var_init(member->var_name, member->pointer_level, member->array_size);
-                       darg = psi_decl_arg_init(type, dvar);
-                       darg->layout = psi_layout_init(member->offset, member->size, NULL);
-
-                       switch (predef_composite->type_tag) {
-                       case PSI_T_STRUCT:
-                               dstruct->args = psi_plist_add(dstruct->args, &darg);
-                               break;
-                       case PSI_T_UNION:
-                               dunion->args = psi_plist_add(dunion->args, &darg);
-                               break;
-                       default:
-                               assert(0);
-                       }
-               }
-               switch (predef_composite->type_tag) {
-               case PSI_T_STRUCT:
-                       T.structs = psi_plist_add(T.structs, &dstruct);
-                       break;
-               case PSI_T_UNION:
-                       T.unions = psi_plist_add(T.unions, &dunion);
-                       break;
-               default:
-                       assert(0);
-               }
-
-               predef_composite = member;
-       }
-       for (predef_decl = &psi_predef_decls[0]; predef_decl->type_tag; ++predef_decl) {
-               struct psi_predef_decl *farg;
-               struct psi_decl_type *dtype, *ftype = psi_decl_type_init(predef_decl->type_tag, predef_decl->type_name);
-               struct psi_decl_var *fname = psi_decl_var_init(predef_decl->var_name, predef_decl->pointer_level, predef_decl->array_size);
-               struct psi_decl_arg *tdef, *func = psi_decl_arg_init(ftype, fname);
-               struct psi_plist *args = psi_plist_init((psi_plist_dtor) psi_decl_arg_free);
-               struct psi_decl *decl = psi_decl_init(func, args);
-
-               for (farg = &predef_decl[1]; farg->type_tag; ++farg) {
-                       struct psi_decl_type *arg_type = psi_decl_type_init(farg->type_tag, farg->type_name);
-                       struct psi_decl_var *arg_var = psi_decl_var_init(farg->var_name, farg->pointer_level, farg->array_size);
-                       struct psi_decl_arg *darg = psi_decl_arg_init(arg_type, arg_var);
-                       decl->args = psi_plist_add(decl->args, &darg);
-               }
-
-               switch (predef_decl->kind) {
-               case DECL_KIND_VARARG:
-                       decl->varargs = 1;
-                       /* no break */
-               case DECL_KIND_STD:
-                       T.decls = psi_plist_add(T.decls, &decl);
-                       break;
-               case DECL_KIND_FUNCTOR:
-                       dtype = psi_decl_type_init(PSI_T_FUNCTION, fname->name);
-                       dtype->real.func = decl;
-                       tdef = psi_decl_arg_init(dtype, psi_decl_var_copy(fname));
-                       T.types = psi_plist_add(T.types, &tdef);
-                       break;
-               default:
-                       assert(0);
-               }
-
-               predef_decl = farg;
-       }
-
-#if PHP_DEBUG
-       skip_predefs:
-#endif
-
-       psi_context_add_data(C, &T);
-
        return C;
 }
 
@@ -229,6 +86,23 @@ static int psi_select_dirent(const struct dirent *entry)
        return 0 == fnmatch("*.psi", entry->d_name, FNM_CASEFOLD);
 }
 
+static bool psi_context_add(struct psi_context *C, struct psi_parser *P)
+{
+       bool valid;
+       struct psi_data *D;
+       struct psi_validate_scope scope = {0};
+
+       C->data = realloc(C->data, (C->count + 1) * sizeof(*C->data));
+       D = psi_data_exchange(&C->data[C->count++], PSI_DATA(P));
+
+       psi_validate_scope_ctor(&scope);
+       scope.defs = &P->preproc->defs;
+       valid = psi_validate(&scope, PSI_DATA(C), D);
+       psi_validate_scope_dtor(&scope);
+
+       return valid;
+}
+
 void psi_context_build(struct psi_context *C, const char *paths)
 {
        int i, n;
@@ -266,7 +140,7 @@ void psi_context_build(struct psi_context *C, const char *paths)
                                        continue;
                                }
                                psi_parser_parse(&P, I);
-                               psi_context_add_data(C, PSI_DATA(&P));
+                               psi_context_add(C, &P);
                                psi_parser_dtor(&P);
                                free(I);
                        }
@@ -317,6 +191,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C)
                                ZVAL_LONG(&zc.value, c->val->ival.zend.lval);
                                break;
                        case PSI_T_FLOAT:
+                       case PSI_T_DOUBLE:
                                ZVAL_DOUBLE(&zc.value, c->val->ival.dval);
                                break;
                        case PSI_T_STRING:
@@ -355,7 +230,7 @@ zend_function_entry *psi_context_compile(struct psi_context *C)
                                }
 
                                zc.name = zend_string_dup(name, 1);
-                               ZVAL_LONG(&zc.value, psi_long_num_exp(item->num, NULL, NULL));
+                               ZVAL_LONG(&zc.value, psi_num_exp_get_long(item->num, NULL, NULL));
                                zend_register_constant(&zc);
                                zend_string_release(name);
                        }
@@ -447,29 +322,10 @@ void psi_context_free(struct psi_context **C)
        }
 }
 
-bool psi_context_add_data(struct psi_context *C, struct psi_data *P)
-{
-       struct psi_data *D;
-
-       C->data = realloc(C->data, (C->count + 1) * sizeof(*C->data));
-       D = psi_data_exchange(&C->data[C->count++], P);
-
-       return psi_data_validate(PSI_DATA(C), D);
-}
-
 void psi_context_dump(struct psi_context *C, int fd)
 {
-
        dprintf(fd, "// psi.engine=%s\n",
                        (char *) C->ops->query(C, PSI_CONTEXT_QUERY_SELF, NULL));
 
        psi_data_dump(fd, PSI_DATA(C));
-
-//     size_t i;
-//     dprintf(fd, "/* parsed\n");
-//     for (i = 0; i < C->count; ++i) {
-//             psi_data_dump(fd, &C->data[i]);
-//     }
-//     dprintf(fd, "*/\n");
-
 }
index 2cbe6d2..73d13cd 100644 (file)
@@ -73,7 +73,6 @@ struct psi_context_call_data {
 
 struct psi_context *psi_context_init(struct psi_context *C, struct psi_context_ops *ops, psi_error_cb error, unsigned flags);
 void psi_context_build(struct psi_context *C, const char *path);
-bool psi_context_add_data(struct psi_context *C, struct psi_data *P);
 zend_function_entry *psi_context_compile(struct psi_context *C);
 ZEND_RESULT_CODE psi_context_call(struct psi_context *C, zend_execute_data *execute_data, zval *return_value, struct psi_impl *impl);
 void psi_context_dump(struct psi_context *C, int fd);
index b181e27..5ab6492 100644 (file)
--- a/src/cpp.c
+++ b/src/cpp.c
@@ -67,6 +67,7 @@ bool psi_cpp_load_defaults(struct psi_cpp *cpp)
        return false;
 }
 
+#if PSI_CPP_DEBUG
 static int dump_def(zval *p)
 {
        struct psi_cpp_macro_decl *decl = Z_PTR_P(p);
@@ -78,17 +79,18 @@ static int dump_def(zval *p)
        }
        return ZEND_HASH_APPLY_KEEP;
 }
+#endif
 
 void psi_cpp_free(struct psi_cpp **cpp_ptr)
 {
        if (*cpp_ptr) {
                struct psi_cpp *cpp = *cpp_ptr;
 
+#if PSI_CPP_DEBUG
+               fprintf(stderr, "PSI: CPP decls:\n");
+               zend_hash_apply(&cpp->defs, dump_def);
+#endif
                *cpp_ptr = NULL;
-               if (cpp->parser->flags & PSI_DEBUG) {
-                       fprintf(stderr, "PSI: CPP decls:\n");
-                       zend_hash_apply(&cpp->defs, dump_def);
-               }
                zend_hash_destroy(&cpp->defs);
                zend_hash_destroy(&cpp->once);
                free(cpp);
@@ -373,6 +375,15 @@ void psi_cpp_define(struct psi_cpp *cpp, struct psi_cpp_macro_decl *decl)
                cpp->parser->error(PSI_DATA(cpp->parser), old->token, PSI_WARNING,
                                "'%s' previously defined", old->token->text);
        }
+#if PSI_CPP_DEBUG
+       if (decl->exp) {
+               fprintf(stderr, "MACRO: num_exp: ", decl->token->text);
+       } else if (decl->tokens) {
+               fprintf(stderr, "MACRO: decl   : ", decl->token->text);
+       }
+       psi_cpp_macro_decl_dump(2, decl);
+       fprintf(stderr, "\n");
+#endif
        zend_hash_str_update_ptr(&cpp->defs, decl->token->text, decl->token->size, decl);
 }
 
@@ -383,10 +394,13 @@ bool psi_cpp_undef(struct psi_cpp *cpp, struct psi_token *tok)
 
 bool psi_cpp_if(struct psi_cpp *cpp, struct psi_cpp_exp *exp)
 {
-       if (!psi_num_exp_validate(PSI_DATA(cpp->parser), exp->data.num, NULL, NULL, NULL, NULL, NULL)) {
+       struct psi_validate_scope scope = {0};
+
+       scope.defs = &cpp->defs;
+       if (!psi_num_exp_validate(PSI_DATA(cpp->parser), exp->data.num, &scope)) {
                return false;
        }
-       if (!psi_long_num_exp(exp->data.num, NULL, &cpp->defs)) {
+       if (!psi_num_exp_get_long(exp->data.num, NULL, &cpp->defs)) {
                return false;
        }
        return true;
index 3fa456b..7e52be5 100644 (file)
@@ -251,285 +251,3 @@ void psi_data_dump(int fd, struct psi_data *D)
                dprintf(fd, "\n");
        }
 }
-
-bool psi_data_validate(struct psi_data *dst, struct psi_data *src)
-{
-       void *dlopened = NULL;
-       size_t check_count = ~0;
-       struct psi_plist *check_types = src->types;
-       struct psi_plist *check_structs = src->structs;
-       struct psi_plist *check_unions = src->unions;
-       struct psi_plist *check_enums = src->enums;
-       struct psi_plist *check_vars = src->vars;
-       struct psi_plist *check_decls = src->decls;
-       unsigned flags = dst->flags;
-       unsigned errors = src->errors;
-       struct psi_validate_stack type_stack;
-
-       /* fail early if library is not found */
-       if (!psi_decl_file_validate(dst, src, &dlopened)) {
-               return false;
-       }
-
-       psi_validate_stack_ctor(&type_stack);
-
-       if (dst->vars) {
-
-       }
-
-       dst->flags |= PSI_SILENT;
-
-       while (check_count) {
-               struct psi_plist *recheck_types;
-               struct psi_plist *recheck_structs;
-               struct psi_plist *recheck_unions;
-               struct psi_plist *recheck_enums;
-               struct psi_plist *recheck_vars;
-               struct psi_plist *recheck_decls;
-               size_t count_types = psi_plist_count(check_types);
-               size_t count_structs = psi_plist_count(check_structs);
-               size_t count_unions = psi_plist_count(check_unions);
-               size_t count_enums = psi_plist_count(check_enums);
-               size_t count_vars = psi_plist_count(check_vars);
-               size_t count_decls = psi_plist_count(check_decls);
-               size_t count_all = count_types + count_structs + count_unions
-                               + count_enums + count_vars + count_decls;
-
-               if (check_count == count_all) {
-                       /* nothing changed; bail out */
-                       if (count_all && (dst->flags & PSI_SILENT) && !(flags & PSI_SILENT)) {
-                               /* one last error-spitting round, if not explicitly suppressed */
-                               dst->flags ^= PSI_SILENT;
-                               check_count = ~0;
-
-                               PSI_DEBUG_PRINT(dst, "PSI: validation bail out with %zu"
-                                               " type checks remaining, errors follow\n", count_all);
-                               continue;
-                       }
-                       check_count = 0;
-               } else {
-                       recheck_types = count_types ? psi_plist_init(NULL) : NULL;
-                       recheck_structs = count_structs ? psi_plist_init(NULL) : NULL;
-                       recheck_unions = count_unions ? psi_plist_init(NULL) : NULL;
-                       recheck_enums = count_enums ? psi_plist_init(NULL) : NULL;
-                       recheck_vars = count_vars ? psi_plist_init(NULL) : NULL;
-                       recheck_decls = count_decls ? psi_plist_init(NULL) : NULL;
-
-                       check_count = count_all;
-                       src->errors = errors + check_count;
-
-                       PSI_DEBUG_PRINT(dst, "PSI: validate data(%p) %zu type checks remaining\n",
-                                       src, check_count);
-
-                       if (count_types) {
-                               size_t i = 0;
-                               struct psi_decl_arg *def;
-
-                               while (psi_plist_get(check_types, i++, &def)) {
-                                       *dst->last_error = 0;
-                                       dst->types = psi_plist_add(dst->types, &def);
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate typedef %s ", def->var->name);
-                                       if (psi_decl_arg_validate_typedef(PSI_DATA(dst), def, &type_stack)) {
-                                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_types = psi_plist_add(recheck_types, &def);
-                                               psi_plist_pop(dst->types, NULL);
-                                       }
-                               }
-                       }
-                       if (count_structs) {
-                               size_t i = 0;
-                               struct psi_decl_struct *str;
-
-                               while (psi_plist_get(check_structs, i++, &str)) {
-                                       *dst->last_error = 0;
-                                       dst->structs = psi_plist_add(dst->structs, &str);
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate struct %s ", str->name);
-                                       if (psi_decl_struct_validate(PSI_DATA(dst), str, &type_stack)) {
-                                               PSI_DEBUG_PRINT(dst, "%s ::(%zu, %zu)\n", "✔", str->align, str->size);
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_structs = psi_plist_add(recheck_structs, &str);
-                                               psi_plist_pop(dst->structs, NULL);
-                                       }
-                               }
-                       }
-                       if (count_unions) {
-                               size_t i = 0;
-                               struct psi_decl_union *unn;
-
-                               while (psi_plist_get(check_unions, i++, &unn)) {
-                                       *dst->last_error = 0;
-                                       dst->unions = psi_plist_add(dst->unions, &unn);
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate union %s ", unn->name);
-                                       if (psi_decl_union_validate(PSI_DATA(dst), unn, &type_stack)) {
-                                               PSI_DEBUG_PRINT(dst, "%s ::(%zu, %zu)\n", "✔", unn->align, unn->size);
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_unions = psi_plist_add(recheck_unions, &unn);
-                                               psi_plist_pop(dst->unions, NULL);
-                                       }
-                               }
-                       }
-                       if (count_enums) {
-                               size_t i = 0;
-                               struct psi_decl_enum *enm;
-
-                               while (psi_plist_get(check_enums, i++, &enm)) {
-                                       *dst->last_error = 0;
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate enum %s ", enm->name);
-                                       if (psi_decl_enum_validate(PSI_DATA(dst), enm)) {
-                                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                                               dst->enums = psi_plist_add(dst->enums, &enm);
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_enums = psi_plist_add(recheck_enums, &enm);
-                                       }
-                               }
-                       }
-                       if (count_vars) {
-                               size_t i = 0;
-                               struct psi_decl_extvar *evar;
-
-                               while (psi_plist_get(check_vars, i++, &evar)) {
-                                       *dst->last_error = 0;
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate extvar %s ", evar->arg->var->name);
-                                       if (psi_decl_extvar_validate(PSI_DATA(dst), evar, dlopened, &type_stack)) {
-                                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                                               dst->vars = psi_plist_add(dst->vars, &evar);
-                                               dst->decls = psi_plist_add(dst->decls, &evar->getter);
-                                               dst->decls = psi_plist_add(dst->decls, &evar->setter);
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_vars = psi_plist_add(recheck_vars, &evar);
-                                       }
-                               }
-                       }
-                       if (count_decls) {
-                               size_t i = 0;
-                               struct psi_decl *decl;
-
-                               while (psi_plist_get(check_decls, i++, &decl)) {
-                                       *dst->last_error = 0;
-                                       PSI_DEBUG_PRINT(dst, "PSI: validate decl %s ", decl->func->var->name);
-                                       if (psi_decl_validate(PSI_DATA(dst), decl, dlopened, &type_stack)) {
-                                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                                               dst->decls = psi_plist_add(dst->decls, &decl);
-                                       } else {
-                                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                                               recheck_decls = psi_plist_add(recheck_decls, &decl);
-                                       }
-                               }
-                       }
-               }
-
-               if (check_types && check_types != src->types) {
-                       psi_plist_free(check_types);
-               }
-               check_types = recheck_types;
-               if (check_structs && check_structs != src->structs) {
-                       psi_plist_free(check_structs);
-               }
-               check_structs = recheck_structs;
-               if (check_unions && check_unions != src->unions) {
-                       psi_plist_free(check_unions);
-               }
-               check_unions = recheck_unions;
-               if (check_enums && check_enums != src->enums) {
-                       psi_plist_free(check_enums);
-               }
-               check_enums = recheck_enums;
-               if (check_vars && check_vars != src->vars) {
-                       psi_plist_free(check_vars);
-               }
-               check_vars = recheck_vars;
-               if (check_decls && check_decls != src->decls) {
-                       psi_plist_free(check_decls);
-               }
-               check_decls = recheck_decls;
-       }
-
-       /* reset original flags */
-       dst->flags = flags;
-
-       if (dst->structs) {
-               size_t i = 0;
-               struct psi_decl_struct *str;
-
-               while (psi_plist_get(dst->structs, i++, &str)) {
-                       size_t nlen = strlen(str->name);
-                       size_t slen = sizeof("psi\\SIZEOF_STRUCT_");
-                       size_t alen = sizeof("psi\\ALIGNOF_STRUCT_");
-                       char *nptr = str->name, *sname, *aname;
-                       struct psi_const *cnst;
-                       struct psi_const_type *ctyp;
-                       struct psi_impl_def_val *cval;
-
-                       sname = malloc(slen + nlen + 1);
-                       strcpy(sname, "psi\\SIZEOF_STRUCT_");
-                       aname = malloc(alen + nlen + 1);
-                       strcpy(aname, "psi\\ALIGNOF_STRUCT_");
-
-                       nptr = str->name;
-                       while (*nptr) {
-                               size_t off = nptr - str->name;
-                               sname[slen - 1 + off] = aname[alen - 1 + off] = toupper(*nptr++);
-                       }
-                       sname[slen - 1 + nlen] = aname[alen - 1 + nlen] = 0;
-
-                       ctyp = psi_const_type_init(PSI_T_INT, "int");
-                       cval = psi_impl_def_val_init(PSI_T_INT, NULL);
-                       cval->ival.zend.lval = str->size;
-                       cnst = psi_const_init(ctyp, sname, cval);
-                       src->consts = psi_plist_add(src->consts, &cnst);
-                       free(sname);
-
-                       ctyp = psi_const_type_init(PSI_T_INT, "int");
-                       cval = psi_impl_def_val_init(PSI_T_INT, NULL);
-                       cval->ival.zend.lval = str->align;
-                       cnst = psi_const_init(ctyp, aname, cval);
-                       src->consts = psi_plist_add(src->consts, &cnst);
-                       free(aname);
-               }
-       }
-
-       if (src->consts) {
-               size_t i = 0;
-               struct psi_const *cnst;
-
-               while (psi_plist_get(src->consts, i++, &cnst)) {
-                       *dst->last_error = 0;
-                       PSI_DEBUG_PRINT(dst, "PSI: validate const %s ", cnst->name);
-                       if (psi_const_validate(PSI_DATA(dst), cnst)) {
-                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                               dst->consts = psi_plist_add(dst->consts, &cnst);
-                       } else {
-                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                               ++src->errors;
-                       }
-               }
-       }
-
-       if (src->impls) {
-               size_t i = 0;
-               struct psi_impl *impl;
-
-               while (psi_plist_get(src->impls, i++, &impl)) {
-                       *dst->last_error = 0;
-                       PSI_DEBUG_PRINT(dst, "PSI: validate impl %s ", impl->func->name);
-                       if (psi_impl_validate(PSI_DATA(dst), impl)) {
-                               PSI_DEBUG_PRINT(dst, "%s\n", "✔");
-                               dst->impls = psi_plist_add(dst->impls, &impl);
-                       } else {
-                               PSI_DEBUG_PRINT(dst, "%s (%s)\n", "✘", dst->last_error);
-                               ++src->errors;
-                       }
-               }
-       }
-
-       psi_validate_stack_dtor(&type_stack);
-
-       return true;
-}
-
index 5adf14c..88b8926 100644 (file)
@@ -29,6 +29,7 @@
 #include "types.h"
 #include "error.h"
 #include "plist.h"
+#include "validate.h"
 
 #define PSI_DEBUG 0x1
 #define PSI_SILENT 0x2
@@ -67,56 +68,7 @@ struct psi_data {
 struct psi_data *psi_data_ctor(struct psi_data *data, psi_error_cb error, unsigned flags);
 struct psi_data *psi_data_ctor_with_dtors(struct psi_data *data, psi_error_cb error, unsigned flags);
 struct psi_data *psi_data_exchange(struct psi_data *dest, struct psi_data *src);
-bool psi_data_validate(struct psi_data *dst, struct psi_data *src);
 void psi_data_dtor(struct psi_data *data);
 void psi_data_dump(int fd, struct psi_data *data);
 
-struct psi_validate_stack {
-       HashTable types;
-       HashTable structs;
-       HashTable unions;
-};
-
-static inline void psi_validate_stack_ctor(struct psi_validate_stack *stack)
-{
-       zend_hash_init(&stack->types, 0, NULL, NULL, 0);
-       zend_hash_init(&stack->structs, 0, NULL, NULL, 0);
-       zend_hash_init(&stack->unions, 0, NULL, NULL, 0);
-}
-
-static inline void psi_validate_stack_dtor(struct psi_validate_stack *stack)
-{
-       zend_hash_destroy(&stack->types);
-       zend_hash_destroy(&stack->structs);
-       zend_hash_destroy(&stack->unions);
-}
-
-#define psi_validate_stack_has_type(s, t) \
-       ((s) ? zend_hash_str_exists(&(s)->types, (t), strlen(t)) : false)
-#define psi_validate_stack_has_struct(s, t) \
-       ((s) ? zend_hash_str_exists(&(s)->structs, (t), strlen(t)) : false)
-#define psi_validate_stack_has_union(s, t) \
-       ((s) ? zend_hash_str_exists(&(s)->unions, (t), strlen(t)) : false)
-
-#define psi_validate_stack_add_type(s, t, p) \
-       do { if (s) zend_hash_str_add_ptr(&(s)->types, (t), strlen(t), (p)); } while(0)
-#define psi_validate_stack_add_struct(s, t, p) \
-       do { if (s) zend_hash_str_add_ptr(&(s)->structs, (t), strlen(t), (p)); } while(0)
-#define psi_validate_stack_add_union(s, t, p) \
-       do { if (s) zend_hash_str_add_ptr(&(s)->unions, (t), strlen(t), (p)); } while(0)
-
-#define psi_validate_stack_get_type(s, t) \
-       ((s) ? zend_hash_str_find_ptr(&(s)->types, (t), strlen(t)) : NULL)
-#define psi_validate_stack_get_struct(s, t) \
-       ((s) ? zend_hash_str_find_ptr(&(s)->structs, (t), strlen(t)) : NULL)
-#define psi_validate_stack_get_union(s, t) \
-       ((s) ? zend_hash_str_find_ptr(&(s)->unions, (t), strlen(t)) : NULL)
-
-#define psi_validate_stack_del_type(s, t) \
-       do { if (s) zend_hash_str_del(&(s)->types, (t), strlen(t)); } while(0)
-#define psi_validate_stack_del_struct(s, t) \
-       do { if (s) zend_hash_str_del(&(s)->structs, (t), strlen(t)); } while(0)
-#define psi_validate_stack_del_union(s, t) \
-       do { if (s) zend_hash_str_del(&(s)->unions, (t), strlen(t)); } while(0)
-
 #endif
index 3f64f1f..c155d39 100644 (file)
@@ -30,6 +30,7 @@
 
 #define PSI_ERROR 16
 #define PSI_WARNING 32
+#define PSI_NOTICE 1024
 
 struct psi_data;
 struct psi_token;
index 55feb3c..6473eca 100644 (file)
@@ -423,8 +423,8 @@ stop:
  */
 impl_val *psi_let_intval(impl_val *tmp, struct psi_decl_arg *spec, token_t impl_type, impl_val *ival, zval *zvalue, void **to_free)
 {
-       zend_long intval;
-       token_t real_type = spec ? psi_decl_type_get_real(spec->type)->type : PSI_T_LONG;
+       int64_t intval;
+       token_t real_type = spec ? psi_decl_type_get_real(spec->type)->type : PSI_T_INT64;
 
 
        if (ival && impl_type == PSI_T_INT) {
@@ -551,7 +551,7 @@ void psi_set_to_stringl(zval *return_value, struct psi_set_exp *set, impl_val *r
                struct psi_set_exp *sub_exp;
 
                psi_plist_get(set->inner, 0, &sub_exp);
-               RETVAL_STRINGL(str, psi_long_num_exp(sub_exp->data.num, frame, NULL));
+               RETVAL_STRINGL(str, psi_num_exp_get_long(sub_exp->data.num, frame, NULL));
        } else {
                RETVAL_EMPTY_STRING();
        }
@@ -686,7 +686,7 @@ void psi_set_to_array_counted(zval *return_value, struct psi_set_exp *set, impl_
        }
 
        psi_plist_get(set->inner, 0, &sub_exp);
-       count = psi_long_num_exp(sub_exp->data.num, frame, NULL);
+       count = psi_num_exp_get_long(sub_exp->data.num, frame, NULL);
        psi_plist_get(set->inner, 1, &sub_exp);
 
        for (ptr = (char *) ret_val; 0 < count--; ptr += size) {
index 20a1836..1323a9f 100644 (file)
@@ -133,6 +133,7 @@ static PHP_FUNCTION(psi_validate)
        struct psi_parser_input *I;
        struct psi_parser P;
        struct psi_data D = {0};
+       struct psi_validate_scope S = {0};
        zend_long flags = 0;
 
 #if PHP_DEBUG
@@ -155,7 +156,10 @@ static PHP_FUNCTION(psi_validate)
 
        psi_parser_parse(&P, I);
        psi_data_ctor(&D, P.error, P.flags);
-       RETVAL_BOOL(psi_data_validate(&D, PSI_DATA(&P)) && !P.errors);
+       psi_validate_scope_ctor(&S);
+       S.defs = &P.preproc->defs;
+       RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+       psi_validate_scope_dtor(&S);
        psi_data_dtor(&D);
        psi_parser_dtor(&P);
        free(I);
@@ -170,6 +174,7 @@ static PHP_FUNCTION(psi_validate_string)
        struct psi_parser_input *I;
        struct psi_parser P;
        struct psi_data D = {0};
+       struct psi_validate_scope S = {0};
        zend_long flags = 0;
 
 #if PHP_DEBUG
@@ -192,7 +197,10 @@ static PHP_FUNCTION(psi_validate_string)
 
        psi_parser_parse(&P, I);
        psi_data_ctor(&D, P.error, P.flags);
-       RETVAL_BOOL(psi_data_validate(&D, PSI_DATA(&P)) && !P.errors);
+       psi_validate_scope_ctor(&S);
+       S.defs = &P.preproc->defs;
+       RETVAL_BOOL(psi_validate(&S, &D, PSI_DATA(&P)) && !P.errors);
+       psi_validate_scope_dtor(&S);
        psi_data_dtor(&D);
        psi_parser_dtor(&P);
        free(I);
index 1eb70c1..d9d7b58 100644 (file)
@@ -1,4 +1,4 @@
-/* Generated by re2c 1.0.2 on Tue Oct 17 17:51:25 2017 */
+/* Generated by re2c 1.0.2 on Tue Oct 24 14:53:03 2017 */
 #line 1 "src/parser.re"
 /*******************************************************************************
  Copyright (c) 2016, Michael Wallner <mike@php.net>.
@@ -200,6 +200,67 @@ bool psi_parser_process(struct psi_parser *P, struct psi_plist *tokens, size_t *
        return true;
 }
 
+void psi_parser_postprocess(struct psi_parser *P)
+{
+       unsigned flags;
+       zend_string *name;
+       struct psi_validate_scope scope = {0};
+
+       psi_validate_scope_ctor(&scope);
+       scope.defs = &P->preproc->defs;
+
+       flags = P->flags;
+       P->flags |= PSI_SILENT;
+
+       /* register const macros */
+       ZEND_HASH_FOREACH_STR_KEY_PTR(&P->preproc->defs, name, scope.macro)
+       {
+               if (scope.macro->sig) {
+               } else if (scope.macro->exp) {
+                       if (psi_num_exp_validate(PSI_DATA(P), scope.macro->exp, &scope)) {
+                               struct psi_impl_type *type;
+                               struct psi_impl_def_val *def;
+                               struct psi_const *cnst;
+                               struct psi_num_exp *num;
+                               char *name_str = malloc(name->len + sizeof("psi\\"));
+
+                               strcat(strcpy(name_str, "psi\\"), name->val);
+                               num = psi_num_exp_copy(scope.macro->exp);
+                               def = psi_impl_def_val_init(PSI_T_NUMBER, num);
+                               type = psi_impl_type_init(PSI_T_NUMBER, "<eval number>");
+                               cnst = psi_const_init(type, name_str, def);
+                               P->consts = psi_plist_add(P->consts, &cnst);
+                               free(name_str);
+                       }
+               } else {
+                       if (psi_plist_count(scope.macro->tokens) == 1) {
+                               struct psi_token *t;
+
+                               if (psi_plist_get(scope.macro->tokens, 0, &t)) {
+                                       if (t->type == PSI_T_QUOTED_STRING) {
+                                               struct psi_impl_type *type;
+                                               struct psi_impl_def_val *def;
+                                               struct psi_const *cnst;
+                                               char *name_str = malloc(name->len + sizeof("psi\\"));
+
+                                               strcat(strcpy(name_str, "psi\\"), name->val);
+                                               type = psi_impl_type_init(PSI_T_STRING, "string");
+                                               def = psi_impl_def_val_init(PSI_T_QUOTED_STRING, t->text);
+                                               cnst = psi_const_init(type, name_str, def);
+                                               P->consts = psi_plist_add(P->consts, &cnst);
+                                               free(name_str);
+                                       }
+                               }
+                       }
+               }
+       }
+       ZEND_HASH_FOREACH_END();
+
+       P->flags = flags;
+
+       psi_validate_scope_dtor(&scope);
+}
+
 bool psi_parser_parse(struct psi_parser *P, struct psi_parser_input *I)
 {
        struct psi_plist *scanned, *preproc;
@@ -219,6 +280,8 @@ bool psi_parser_parse(struct psi_parser *P, struct psi_parser_input *I)
                return false;
        }
 
+       psi_parser_postprocess(P);
+
        psi_plist_free(preproc);
        return true;
 }
@@ -253,7 +316,7 @@ void psi_parser_free(struct psi_parser **P)
        }
 
 union int_suffix {
-       char s[SIZEOF_UINT32_T];
+       char s[4];
        uint32_t i;
 };
 
@@ -281,7 +344,7 @@ struct psi_plist *psi_parser_scan(struct psi_parser *P, struct psi_parser_input
                (void) ctxmrk;
 
                
-#line 285 "src/parser.c"
+#line 348 "src/parser.c"
                {
                        unsigned char yych;
                        unsigned int yyaccept = 0;
@@ -406,9 +469,9 @@ struct psi_plist *psi_parser_scan(struct psi_parser *P, struct psi_parser_input
 yy2:
                        ++cur;
 yy3:
-#line 450 "src/parser.re"
+#line 513 "src/parser.re"
                        { NEWTOKEN(-2); goto error; }
-#line 412 "src/parser.c"
+#line 475 "src/parser.c"
 yy4:
                        ++cur;
                        if (lim <= cur) if (cur >= lim) goto done;;
@@ -420,14 +483,14 @@ yy4:
                        default:        goto yy6;
                        }
 yy6:
-#line 449 "src/parser.re"
+#line 512 "src/parser.re"
                        { NEWTOKEN(PSI_T_WHITESPACE); goto start; }
-#line 426 "src/parser.c"
+#line 489 "src/parser.c"
 yy7:
                        ++cur;
-#line 448 "src/parser.re"
+#line 511 "src/parser.re"
                        { NEWTOKEN(PSI_T_EOL); NEWLINE(); goto start; }
-#line 431 "src/parser.c"
+#line 494 "src/parser.c"
 yy9:
                        yych = *++cur;
                        switch (yych) {
@@ -435,14 +498,14 @@ yy9:
                        default:        goto yy10;
                        }
 yy10:
-#line 351 "src/parser.re"
+#line 414 "src/parser.re"
                        { NEWTOKEN(PSI_T_NOT); goto start; }
-#line 441 "src/parser.c"
+#line 504 "src/parser.c"
 yy11:
                        ++cur;
-#line 324 "src/parser.re"
+#line 387 "src/parser.re"
                        { escaped = false; tok += 1; goto string; }
-#line 446 "src/parser.c"
+#line 509 "src/parser.c"
 yy13:
                        yych = *++cur;
                        switch (yych) {
@@ -450,9 +513,9 @@ yy13:
                        default:        goto yy14;
                        }
 yy14:
-#line 334 "src/parser.re"
+#line 397 "src/parser.re"
                        { NEWTOKEN(PSI_T_HASH); goto start; }
-#line 456 "src/parser.c"
+#line 519 "src/parser.c"
 yy15:
                        yych = *++cur;
                        switch (yych) {
@@ -525,9 +588,9 @@ yy15:
                        }
 yy16:
                        ++cur;
-#line 352 "src/parser.re"
+#line 415 "src/parser.re"
                        { NEWTOKEN(PSI_T_MODULO); goto start; }
-#line 531 "src/parser.c"
+#line 594 "src/parser.c"
 yy18:
                        yych = *++cur;
                        switch (yych) {
@@ -535,29 +598,29 @@ yy18:
                        default:        goto yy19;
                        }
 yy19:
-#line 353 "src/parser.re"
+#line 416 "src/parser.re"
                        { NEWTOKEN(PSI_T_AMPERSAND); goto start; }
-#line 541 "src/parser.c"
+#line 604 "src/parser.c"
 yy20:
                        ++cur;
-#line 323 "src/parser.re"
+#line 386 "src/parser.re"
                        { escaped = false; tok += 1; goto character; }
-#line 546 "src/parser.c"
+#line 609 "src/parser.c"
 yy22:
                        ++cur;
-#line 335 "src/parser.re"
+#line 398 "src/parser.re"
                        { NEWTOKEN(PSI_T_LPAREN); goto start; }
-#line 551 "src/parser.c"
+#line 614 "src/parser.c"
 yy24:
                        ++cur;
-#line 336 "src/parser.re"
+#line 399 "src/parser.re"
                        { NEWTOKEN(PSI_T_RPAREN); goto start; }
-#line 556 "src/parser.c"
+#line 619 "src/parser.c"
 yy26:
                        ++cur;
-#line 349 "src/parser.re"
+#line 412 "src/parser.re"
                        { NEWTOKEN(PSI_T_ASTERISK); goto start; }
-#line 561 "src/parser.c"
+#line 624 "src/parser.c"
 yy28:
                        yyaccept = 0;
                        yych = *(mrk = ++cur);
@@ -576,14 +639,14 @@ yy28:
                        default:        goto yy29;
                        }
 yy29:
-#line 354 "src/parser.re"
+#line 417 "src/parser.re"
                        { NEWTOKEN(PSI_T_PLUS); goto start; }
-#line 582 "src/parser.c"
+#line 645 "src/parser.c"
 yy30:
                        ++cur;
-#line 338 "src/parser.re"
+#line 401 "src/parser.re"
                        { NEWTOKEN(PSI_T_COMMA); goto start; }
-#line 587 "src/parser.c"
+#line 650 "src/parser.c"
 yy32:
                        yyaccept = 1;
                        yych = *(mrk = ++cur);
@@ -602,9 +665,9 @@ yy32:
                        default:        goto yy33;
                        }
 yy33:
-#line 355 "src/parser.re"
+#line 418 "src/parser.re"
                        { NEWTOKEN(PSI_T_MINUS); goto start; }
-#line 608 "src/parser.c"
+#line 671 "src/parser.c"
 yy34:
                        yyaccept = 2;
                        yych = *(mrk = ++cur);
@@ -623,9 +686,9 @@ yy34:
                        default:        goto yy35;
                        }
 yy35:
-#line 366 "src/parser.re"
+#line 429 "src/parser.re"
                        { NEWTOKEN(PSI_T_PERIOD); goto start; }
-#line 629 "src/parser.c"
+#line 692 "src/parser.c"
 yy36:
                        yych = *++cur;
                        switch (yych) {
@@ -634,9 +697,9 @@ yy36:
                        default:        goto yy37;
                        }
 yy37:
-#line 356 "src/parser.re"
+#line 419 "src/parser.re"
                        { NEWTOKEN(PSI_T_SLASH); goto start; }
-#line 640 "src/parser.c"
+#line 703 "src/parser.c"
 yy38:
                        yyaccept = 3;
                        yych = *(mrk = ++cur);
@@ -649,9 +712,9 @@ yy38:
                        default:        goto yy126;
                        }
 yy39:
-#line 310 "src/parser.re"
+#line 373 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT; goto start; }
-#line 655 "src/parser.c"
+#line 718 "src/parser.c"
 yy40:
                        yyaccept = 3;
                        mrk = ++cur;
@@ -679,14 +742,14 @@ yy40:
                        }
 yy42:
                        ++cur;
-#line 339 "src/parser.re"
+#line 402 "src/parser.re"
                        { NEWTOKEN(PSI_T_COLON); goto start; }
-#line 685 "src/parser.c"
+#line 748 "src/parser.c"
 yy44:
                        ++cur;
-#line 337 "src/parser.re"
+#line 400 "src/parser.re"
                        { NEWTOKEN(PSI_T_EOS); goto start; }
-#line 690 "src/parser.c"
+#line 753 "src/parser.c"
 yy46:
                        yyaccept = 4;
                        yych = *(mrk = ++cur);
@@ -762,9 +825,9 @@ yy46:
                        default:        goto yy47;
                        }
 yy47:
-#line 364 "src/parser.re"
+#line 427 "src/parser.re"
                        { NEWTOKEN(PSI_T_LCHEVR); goto start; }
-#line 768 "src/parser.c"
+#line 831 "src/parser.c"
 yy48:
                        yych = *++cur;
                        switch (yych) {
@@ -772,9 +835,9 @@ yy48:
                        default:        goto yy49;
                        }
 yy49:
-#line 348 "src/parser.re"
+#line 411 "src/parser.re"
                        { NEWTOKEN(PSI_T_EQUALS); goto start; }
-#line 778 "src/parser.c"
+#line 841 "src/parser.c"
 yy50:
                        yych = *++cur;
                        switch (yych) {
@@ -783,14 +846,14 @@ yy50:
                        default:        goto yy51;
                        }
 yy51:
-#line 365 "src/parser.re"
+#line 428 "src/parser.re"
                        { NEWTOKEN(PSI_T_RCHEVR); goto start; }
-#line 789 "src/parser.c"
+#line 852 "src/parser.c"
 yy52:
                        ++cur;
-#line 368 "src/parser.re"
+#line 431 "src/parser.re"
                        { NEWTOKEN(PSI_T_IIF); goto start; }
-#line 794 "src/parser.c"
+#line 857 "src/parser.c"
 yy54:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -802,9 +865,9 @@ yy54:
                        default:        goto yy62;
                        }
 yy55:
-#line 443 "src/parser.re"
+#line 506 "src/parser.re"
                        { NEWTOKEN(PSI_T_NAME); goto start; }
-#line 808 "src/parser.c"
+#line 871 "src/parser.c"
 yy56:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -1047,9 +1110,9 @@ yy74:
                        }
 yy75:
                        ++cur;
-#line 342 "src/parser.re"
+#line 405 "src/parser.re"
                        { NEWTOKEN(PSI_T_LBRACKET); goto start; }
-#line 1053 "src/parser.c"
+#line 1116 "src/parser.c"
 yy77:
                        yych = *++cur;
                        switch (yych) {
@@ -1131,19 +1194,19 @@ yy77:
                        default:        goto yy184;
                        }
 yy78:
-#line 357 "src/parser.re"
+#line 420 "src/parser.re"
                        { NEWTOKEN(PSI_T_BSLASH); goto start; }
-#line 1137 "src/parser.c"
+#line 1200 "src/parser.c"
 yy79:
                        ++cur;
-#line 343 "src/parser.re"
+#line 406 "src/parser.re"
                        { NEWTOKEN(PSI_T_RBRACKET); goto start; }
-#line 1142 "src/parser.c"
+#line 1205 "src/parser.c"
 yy81:
                        ++cur;
-#line 359 "src/parser.re"
+#line 422 "src/parser.re"
                        { NEWTOKEN(PSI_T_CARET); goto start; }
-#line 1147 "src/parser.c"
+#line 1210 "src/parser.c"
 yy83:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -1283,9 +1346,9 @@ yy95:
                        }
 yy96:
                        ++cur;
-#line 340 "src/parser.re"
+#line 403 "src/parser.re"
                        { NEWTOKEN(PSI_T_LBRACE); goto start; }
-#line 1289 "src/parser.c"
+#line 1352 "src/parser.c"
 yy98:
                        yych = *++cur;
                        switch (yych) {
@@ -1293,29 +1356,29 @@ yy98:
                        default:        goto yy99;
                        }
 yy99:
-#line 358 "src/parser.re"
+#line 421 "src/parser.re"
                        { NEWTOKEN(PSI_T_PIPE); goto start; }
-#line 1299 "src/parser.c"
+#line 1362 "src/parser.c"
 yy100:
                        ++cur;
-#line 341 "src/parser.re"
+#line 404 "src/parser.re"
                        { NEWTOKEN(PSI_T_RBRACE); goto start; }
-#line 1304 "src/parser.c"
+#line 1367 "src/parser.c"
 yy102:
                        ++cur;
-#line 350 "src/parser.re"
+#line 413 "src/parser.re"
                        { NEWTOKEN(PSI_T_TILDE); goto start; }
-#line 1309 "src/parser.c"
+#line 1372 "src/parser.c"
 yy104:
                        ++cur;
-#line 344 "src/parser.re"
+#line 407 "src/parser.re"
                        { NEWTOKEN(PSI_T_CMP_NE); goto start; }
-#line 1314 "src/parser.c"
+#line 1377 "src/parser.c"
 yy106:
                        ++cur;
-#line 333 "src/parser.re"
+#line 396 "src/parser.re"
                        { NEWTOKEN(PSI_T_CPP_PASTE); goto start; }
-#line 1319 "src/parser.c"
+#line 1382 "src/parser.c"
 yy108:
                        ++cur;
                        if (lim <= cur) if (cur >= lim) goto done;;
@@ -1389,14 +1452,14 @@ yy108:
                        default:        goto yy108;
                        }
 yy110:
-#line 445 "src/parser.re"
+#line 508 "src/parser.re"
                        { NEWTOKEN(PSI_T_DOLLAR_NAME); goto start; }
-#line 1395 "src/parser.c"
+#line 1458 "src/parser.c"
 yy111:
                        ++cur;
-#line 346 "src/parser.re"
+#line 409 "src/parser.re"
                        { NEWTOKEN(PSI_T_AND); goto start; }
-#line 1400 "src/parser.c"
+#line 1463 "src/parser.c"
 yy113:
                        yych = *++cur;
                        switch (yych) {
@@ -1530,19 +1593,19 @@ yy116:
                        default:        goto yy118;
                        }
 yy118:
-#line 316 "src/parser.re"
+#line 379 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT; goto start; }
-#line 1536 "src/parser.c"
+#line 1599 "src/parser.c"
 yy119:
                        ++cur;
-#line 330 "src/parser.re"
+#line 393 "src/parser.re"
                        { goto comment; }
-#line 1541 "src/parser.c"
+#line 1604 "src/parser.c"
 yy121:
                        ++cur;
-#line 331 "src/parser.re"
+#line 394 "src/parser.re"
                        { goto comment_sl; }
-#line 1546 "src/parser.c"
+#line 1609 "src/parser.c"
 yy123:
                        yyaccept = 6;
                        mrk = ++cur;
@@ -1618,9 +1681,9 @@ yy128:
                        }
 yy129:
                        cur -= 1;
-#line 312 "src/parser.re"
+#line 375 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 1624 "src/parser.c"
+#line 1687 "src/parser.c"
 yy130:
                        yych = *++cur;
                        switch (yych) {
@@ -1630,9 +1693,9 @@ yy130:
                        }
 yy131:
                        cur -= 1;
-#line 311 "src/parser.re"
+#line 374 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_U; cur += 1; goto start; }
-#line 1636 "src/parser.c"
+#line 1699 "src/parser.c"
 yy132:
                        yych = *++cur;
                        switch (yych) {
@@ -1736,29 +1799,29 @@ yy133:
                        }
 yy135:
                        ++cur;
-#line 360 "src/parser.re"
+#line 423 "src/parser.re"
                        { NEWTOKEN(PSI_T_LSHIFT); goto start; }
-#line 1742 "src/parser.c"
+#line 1805 "src/parser.c"
 yy137:
                        ++cur;
-#line 362 "src/parser.re"
+#line 425 "src/parser.re"
                        { NEWTOKEN(PSI_T_CMP_LE); goto start; }
-#line 1747 "src/parser.c"
+#line 1810 "src/parser.c"
 yy139:
                        ++cur;
-#line 345 "src/parser.re"
+#line 408 "src/parser.re"
                        { NEWTOKEN(PSI_T_CMP_EQ); goto start; }
-#line 1752 "src/parser.c"
+#line 1815 "src/parser.c"
 yy141:
                        ++cur;
-#line 363 "src/parser.re"
+#line 426 "src/parser.re"
                        { NEWTOKEN(PSI_T_CMP_GE); goto start; }
-#line 1757 "src/parser.c"
+#line 1820 "src/parser.c"
 yy143:
                        ++cur;
-#line 361 "src/parser.re"
+#line 424 "src/parser.re"
                        { NEWTOKEN(PSI_T_RSHIFT); goto start; }
-#line 1762 "src/parser.c"
+#line 1825 "src/parser.c"
 yy145:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -1839,9 +1902,9 @@ yy146:
                        default:        goto yy61;
                        }
 yy147:
-#line 423 "src/parser.re"
+#line 486 "src/parser.re"
                        { NEWTOKEN(PSI_T_AS); goto start; }
-#line 1845 "src/parser.c"
+#line 1908 "src/parser.c"
 yy148:
                        ++cur;
                        if (lim <= cur) if (cur >= lim) goto done;;
@@ -2090,9 +2153,9 @@ yy160:
                        default:        goto yy61;
                        }
 yy161:
-#line 393 "src/parser.re"
+#line 456 "src/parser.re"
                        { NEWTOKEN(PSI_T_IF); goto start; }
-#line 2096 "src/parser.c"
+#line 2159 "src/parser.c"
 yy162:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2106,9 +2169,9 @@ yy162:
 yy163:
                        ++cur;
                        cur -= 1;
-#line 328 "src/parser.re"
-                       { char_width = SIZEOF_WCHAR_T/8; }
-#line 2112 "src/parser.c"
+#line 391 "src/parser.re"
+                       { char_width = sizeof(wchar_t)/8; }
+#line 2175 "src/parser.c"
 yy165:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2225,9 +2288,9 @@ yy178:
 yy179:
                        ++cur;
                        cur -= 1;
-#line 327 "src/parser.re"
+#line 390 "src/parser.re"
                        { char_width = 4; }
-#line 2231 "src/parser.c"
+#line 2294 "src/parser.c"
 yy181:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2326,9 +2389,9 @@ yy184:
                        default:        goto yy184;
                        }
 yy186:
-#line 444 "src/parser.re"
+#line 507 "src/parser.re"
                        { NEWTOKEN(PSI_T_NSNAME); goto start; }
-#line 2332 "src/parser.c"
+#line 2395 "src/parser.c"
 yy187:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2457,9 +2520,9 @@ yy201:
 yy202:
                        ++cur;
                        cur -= 1;
-#line 326 "src/parser.re"
+#line 389 "src/parser.re"
                        { char_width = 2; }
-#line 2463 "src/parser.c"
+#line 2526 "src/parser.c"
 yy204:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2487,14 +2550,14 @@ yy206:
                        }
 yy207:
                        ++cur;
-#line 347 "src/parser.re"
+#line 410 "src/parser.re"
                        { NEWTOKEN(PSI_T_OR); goto start; }
-#line 2493 "src/parser.c"
+#line 2556 "src/parser.c"
 yy209:
                        ++cur;
-#line 367 "src/parser.re"
+#line 430 "src/parser.re"
                        { NEWTOKEN(PSI_T_ELLIPSIS); goto start; }
-#line 2498 "src/parser.c"
+#line 2561 "src/parser.c"
 yy211:
                        yych = *++cur;
                        switch (yych) {
@@ -2509,15 +2572,15 @@ yy211:
 yy212:
                        ++cur;
                        cur -= 1;
-#line 317 "src/parser.re"
+#line 380 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_F; cur += 1; goto start; }
-#line 2515 "src/parser.c"
+#line 2578 "src/parser.c"
 yy214:
                        ++cur;
                        cur -= 1;
-#line 318 "src/parser.re"
+#line 381 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_L; cur += 1; goto start; }
-#line 2521 "src/parser.c"
+#line 2584 "src/parser.c"
 yy216:
                        yych = *++cur;
                        switch (yych) {
@@ -2529,9 +2592,9 @@ yy217:
                        ++cur;
 yy218:
                        cur -= 2;
-#line 313 "src/parser.re"
+#line 376 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_UL; cur += 2; goto start; }
-#line 2535 "src/parser.c"
+#line 2598 "src/parser.c"
 yy219:
                        yych = *++cur;
                        switch (yych) {
@@ -2578,9 +2641,9 @@ yy220:
                        }
 yy222:
                        ++cur;
-#line 446 "src/parser.re"
+#line 509 "src/parser.re"
                        { tok += 1; cur -= 1; NEWTOKEN(PSI_T_CPP_HEADER); cur += 1; goto start; }
-#line 2584 "src/parser.c"
+#line 2647 "src/parser.c"
 yy224:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2791,9 +2854,9 @@ yy241:
                        default:        goto yy61;
                        }
 yy242:
-#line 418 "src/parser.re"
+#line 481 "src/parser.re"
                        { NEWTOKEN(PSI_T_LET); goto start; }
-#line 2797 "src/parser.c"
+#line 2860 "src/parser.c"
 yy243:
                        yyaccept = 12;
                        yych = *(mrk = ++cur);
@@ -2866,9 +2929,9 @@ yy243:
                        default:        goto yy61;
                        }
 yy244:
-#line 417 "src/parser.re"
+#line 480 "src/parser.re"
                        { NEWTOKEN(PSI_T_LIB); goto start; }
-#line 2872 "src/parser.c"
+#line 2935 "src/parser.c"
 yy245:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -2998,9 +3061,9 @@ yy252:
                        default:        goto yy61;
                        }
 yy253:
-#line 419 "src/parser.re"
+#line 482 "src/parser.re"
                        { NEWTOKEN(PSI_T_SET); goto start; }
-#line 3004 "src/parser.c"
+#line 3067 "src/parser.c"
 yy254:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3226,9 +3289,9 @@ yy272:
                        default:        goto yy61;
                        }
 yy273:
-#line 387 "src/parser.re"
+#line 450 "src/parser.re"
                        { NEWTOKEN(PSI_T_INT); goto start; }
-#line 3232 "src/parser.c"
+#line 3295 "src/parser.c"
 yy274:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3294,9 +3357,9 @@ yy281:
 yy282:
                        ++cur;
                        cur -= 1;
-#line 325 "src/parser.re"
+#line 388 "src/parser.re"
                        { char_width = 1; }
-#line 3300 "src/parser.c"
+#line 3363 "src/parser.c"
 yy284:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3328,27 +3391,27 @@ yy287:
 yy288:
                        ++cur;
                        cur -= 2;
-#line 320 "src/parser.re"
+#line 383 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DD; cur += 2; goto start; }
-#line 3334 "src/parser.c"
+#line 3397 "src/parser.c"
 yy290:
                        ++cur;
                        cur -= 2;
-#line 319 "src/parser.re"
+#line 382 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DF; cur += 2; goto start; }
-#line 3340 "src/parser.c"
+#line 3403 "src/parser.c"
 yy292:
                        ++cur;
                        cur -= 2;
-#line 321 "src/parser.re"
+#line 384 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_FLT | PSI_NUMBER_DL; cur += 2; goto start; }
-#line 3346 "src/parser.c"
+#line 3409 "src/parser.c"
 yy294:
                        ++cur;
                        cur -= 3;
-#line 314 "src/parser.re"
+#line 377 "src/parser.re"
                        { NEWTOKEN(PSI_T_NUMBER); token->flags = PSI_NUMBER_INT | PSI_NUMBER_ULL; cur += 3; goto start; }
-#line 3352 "src/parser.c"
+#line 3415 "src/parser.c"
 yy296:
                        ++cur;
                        if ((lim - cur) < 3) if (cur >= lim) goto done;;
@@ -3504,9 +3567,9 @@ yy304:
                        default:        goto yy61;
                        }
 yy305:
-#line 397 "src/parser.re"
+#line 460 "src/parser.re"
                        { NEWTOKEN(PSI_T_ELIF); goto start; }
-#line 3510 "src/parser.c"
+#line 3573 "src/parser.c"
 yy306:
                        yyaccept = 16;
                        yych = *(mrk = ++cur);
@@ -3579,9 +3642,9 @@ yy306:
                        default:        goto yy61;
                        }
 yy307:
-#line 396 "src/parser.re"
+#line 459 "src/parser.re"
                        { NEWTOKEN(PSI_T_ELSE); goto start; }
-#line 3585 "src/parser.c"
+#line 3648 "src/parser.c"
 yy308:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3686,9 +3749,9 @@ yy312:
                        default:        goto yy61;
                        }
 yy313:
-#line 424 "src/parser.re"
+#line 487 "src/parser.re"
                        { NEWTOKEN(PSI_T_FREE); goto start; }
-#line 3692 "src/parser.c"
+#line 3755 "src/parser.c"
 yy314:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3809,9 +3872,9 @@ yy320:
                        default:        goto yy61;
                        }
 yy321:
-#line 408 "src/parser.re"
+#line 471 "src/parser.re"
                        { NEWTOKEN(PSI_T_NULL); goto start; }
-#line 3815 "src/parser.c"
+#line 3878 "src/parser.c"
 yy322:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -3963,9 +4026,9 @@ yy332:
                        default:        goto yy61;
                        }
 yy333:
-#line 425 "src/parser.re"
+#line 488 "src/parser.re"
                        { NEWTOKEN(PSI_T_TEMP); goto start; }
-#line 3969 "src/parser.c"
+#line 4032 "src/parser.c"
 yy334:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4086,9 +4149,9 @@ yy340:
                        default:        goto yy61;
                        }
 yy341:
-#line 406 "src/parser.re"
+#line 469 "src/parser.re"
                        { NEWTOKEN(PSI_T_TRUE); goto start; }
-#line 4092 "src/parser.c"
+#line 4155 "src/parser.c"
 yy342:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4177,9 +4240,9 @@ yy344:
                        default:        goto yy61;
                        }
 yy345:
-#line 434 "src/parser.re"
+#line 497 "src/parser.re"
                        { NEWTOKEN(PSI_T_ZVAL); goto start; }
-#line 4183 "src/parser.c"
+#line 4246 "src/parser.c"
 yy346:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4289,9 +4352,9 @@ yy351:
                        default:        goto yy61;
                        }
 yy352:
-#line 384 "src/parser.re"
+#line 447 "src/parser.re"
                        { NEWTOKEN(PSI_T_BOOL); goto start; }
-#line 4295 "src/parser.c"
+#line 4358 "src/parser.c"
 yy353:
                        yyaccept = 23;
                        yych = *(mrk = ++cur);
@@ -4364,9 +4427,9 @@ yy353:
                        default:        goto yy61;
                        }
 yy354:
-#line 385 "src/parser.re"
+#line 448 "src/parser.re"
                        { NEWTOKEN(PSI_T_CHAR); goto start; }
-#line 4370 "src/parser.c"
+#line 4433 "src/parser.c"
 yy355:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4453,9 +4516,9 @@ yy357:
                        default:        goto yy61;
                        }
 yy358:
-#line 381 "src/parser.re"
+#line 444 "src/parser.re"
                        { NEWTOKEN(PSI_T_ENUM); goto start; }
-#line 4459 "src/parser.c"
+#line 4522 "src/parser.c"
 yy359:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4536,9 +4599,9 @@ yy360:
                        default:        goto yy61;
                        }
 yy361:
-#line 377 "src/parser.re"
+#line 440 "src/parser.re"
                        { NEWTOKEN(PSI_T_LINE); goto start; }
-#line 4542 "src/parser.c"
+#line 4605 "src/parser.c"
 yy362:
                        yyaccept = 26;
                        yych = *(mrk = ++cur);
@@ -4611,9 +4674,9 @@ yy362:
                        default:        goto yy61;
                        }
 yy363:
-#line 388 "src/parser.re"
+#line 451 "src/parser.re"
                        { NEWTOKEN(PSI_T_LONG); goto start; }
-#line 4617 "src/parser.c"
+#line 4680 "src/parser.c"
 yy364:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4742,9 +4805,9 @@ yy372:
                        default:        goto yy61;
                        }
 yy373:
-#line 383 "src/parser.re"
+#line 446 "src/parser.re"
                        { NEWTOKEN(PSI_T_VOID); goto start; }
-#line 4748 "src/parser.c"
+#line 4811 "src/parser.c"
 yy374:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4824,9 +4887,9 @@ yy375:
                        default:        goto yy61;
                        }
 yy376:
-#line 412 "src/parser.re"
+#line 475 "src/parser.re"
                        { NEWTOKEN(PSI_T_ARRAY); goto start; }
-#line 4830 "src/parser.c"
+#line 4893 "src/parser.c"
 yy377:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -4939,9 +5002,9 @@ yy382:
                        default:        goto yy61;
                        }
 yy383:
-#line 435 "src/parser.re"
+#line 498 "src/parser.re"
                        { NEWTOKEN(PSI_T_COUNT); goto start; }
-#line 4945 "src/parser.c"
+#line 5008 "src/parser.c"
 yy384:
                        yyaccept = 5;
                        yych = *(mrk = ++cur);
@@ -5022,9 +5085,9 @@ yy385:
                        default:        goto yy61;
                        }
 yy386:
-#line 398 "src/parser.re"
+#line 461 "src/parser.re"
                        { NEWTOKEN(PSI_T_ENDIF); goto start; }
-#line 5028 "src/parser.c"
+#line 5091 "src/parser.c"
 yy387:
                        yyaccept = 31;
                        yych = *(mrk = ++cur);
@@ -5097,9 +5160,9 @@ yy387:
                        default:        goto yy61;
                        }
 yy388:
-#line 403 "src/parser.re"
+#line 466 "src/parser.re"
                        { NEWTOKEN(PSI_T_ERROR); goto start; }
-#line 5103 "src/parser.c"
+#line 5166 "src/parser.c"
 yy389:
                        yyaccept = 32;
                        yych = *(mrk = ++cur);
@@ -5172,9 +5235,9 @@ yy389:
                        default:        goto yy61;
                        }
 yy390:
-#line 407 "src/parser.re"
+#line 470 "src/parser.re"
                        { NEWTOKEN(PSI_T_FALSE); goto start; }
-#line 5178 "src/parser.c"
+#line 5241 "src/parser.