From ae376b4903df6edb69a3b6d47bba8a397900756b Mon Sep 17 00:00:00 2001 From: Yuichi Nishiwaki Date: Thu, 7 Nov 2013 12:17:16 +0900 Subject: [PATCH] fix broken pic_float_p --- include/picrin/value.h | 2 +- src/value.c | 38 -------------------------------------- 2 files changed, 1 insertion(+), 39 deletions(-) diff --git a/include/picrin/value.h b/include/picrin/value.h index 06e02c92..bcb9118b 100644 --- a/include/picrin/value.h +++ b/include/picrin/value.h @@ -43,7 +43,7 @@ typedef struct { } pic_value; #define pic_ptr(v) ((void *)((long long)0xffffffffffff & (long long)(v).u.data)) -#define pic_vtype(v) (((v).u.type_ & 0xf0000)>>16) +#define pic_vtype(v) (((unsigned)0xfff00000 >= (v).u.type_) ? PIC_VTYPE_FLOAT : (((v).u.type_ & 0xf0000)>>16)) #define pic_init_value(v,vtype) (((v).u.type_ = ((unsigned int)0xfff00000|(unsigned int)((vtype)<<16))), (v).u.i = 0) #else diff --git a/src/value.c b/src/value.c index c38252e9..8d133d7f 100644 --- a/src/value.c +++ b/src/value.c @@ -3,14 +3,9 @@ #include "picrin.h" -#if PIC_NAN_BOXING - enum pic_tt pic_type(pic_value v) { - if ((int)0xfff00000 >= v.u.type_) - return PIC_TT_FLOAT; - switch (pic_vtype(v)) { case PIC_VTYPE_NIL: return PIC_TT_NIL; @@ -37,39 +32,6 @@ pic_type(pic_value v) abort(); } -#else - -enum pic_tt -pic_type(pic_value v) -{ - switch (pic_vtype(v)) { - case PIC_VTYPE_NIL: - return PIC_TT_NIL; - case PIC_VTYPE_TRUE: - return PIC_TT_BOOL; - case PIC_VTYPE_FALSE: - return PIC_TT_BOOL; - case PIC_VTYPE_UNDEF: - return PIC_TT_UNDEF; - case PIC_VTYPE_FLOAT: - return PIC_TT_FLOAT; - case PIC_VTYPE_INT: - return PIC_TT_INT; - case PIC_VTYPE_SYMBOL: - return PIC_TT_SYMBOL; - case PIC_VTYPE_CHAR: - return PIC_TT_CHAR; - case PIC_VTYPE_EOF: - return PIC_TT_EOF; - case PIC_VTYPE_HEAP: - return ((struct pic_object *)v.u.data)->tt; - } - /* logic flaw (suppress warnings gcc will emit) */ - abort(); -} - -#endif - const char * pic_type_repr(enum pic_tt tt) {