impl: add {pre,post}_assert statements
[m6w6/ext-psi] / src / token.h
index fcf3f4e49f5b3ced600063831438944539db3cb3..75f76fbed19c1b7c7f752093de92ea40102c0051 100644 (file)
@@ -51,6 +51,8 @@ static inline size_t psi_offset_padding(size_t diff, size_t alignment) {
 
 typedef int token_t;
 
+#include "token_oper_cmp.h"
+
 static inline size_t psi_t_alignment(token_t t)
 {
 #define PSI_ALIGNOF(T) case PSI_T_## T: return ALIGNOF_## T ##_T;
@@ -72,6 +74,10 @@ static inline size_t psi_t_alignment(token_t t)
                return ALIGNOF_VOID_P;
        case PSI_T_ENUM:
                return ALIGNOF_INT;
+#ifdef HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               return ALIGNOF_LONG_DOUBLE;
+#endif
        default:
                assert(0);
        }
@@ -94,13 +100,18 @@ static inline size_t psi_t_size(token_t t)
                return SIZEOF_FLOAT;
        case PSI_T_DOUBLE:
                return SIZEOF_DOUBLE;
+       case PSI_T_VOID:
        case PSI_T_POINTER:
        case PSI_T_FUNCTION:
                return SIZEOF_VOID_P;
        case PSI_T_ENUM:
                return SIZEOF_INT;
+#ifdef HAVE_LONG_DOUBLE
+       case PSI_T_LONG_DOUBLE:
+               return SIZEOF_LONG_DOUBLE;
+#endif
        default:
-               assert(0);
+               assert(!t);
        }
        return 0;
 }
@@ -108,12 +119,12 @@ static inline size_t psi_t_size(token_t t)
 static inline const char *psi_t_indent(unsigned level) {
        static const char indent[] =
                        "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
-       return &indent[32 - MAX(0, MIN(32, level))];
+       return &indent[32 - MIN(32, level)];
 }
 
 static inline const char *psi_t_indirection(unsigned pointer_level) {
        static const char indir[] = "********************************";
-       return &indir[32 - MAX(0, MIN(32, pointer_level))];
+       return &indir[32 - MIN(32, pointer_level)];
 }
 
 struct psi_token {