Browse Source

rename remaining _DUK_xxx macros

pull/1/head
Sami Vaarala 11 years ago
parent
commit
04f377b94c
  1. 16
      src/duk_debug.h
  2. 24
      src/duk_heap.h
  3. 32
      src/duk_heaphdr.h
  4. 124
      src/duk_tval.h

16
src/duk_debug.h

@ -26,25 +26,25 @@
/* Note: combining __FILE__, __LINE__, and __func__ into fmt would be
* possible compile time, but waste some space with shared function names.
*/
#define _DUK_DEBUG_LOG(lev,...) duk_debug_log((lev), DUK_FILE_MACRO, (int) DUK_LINE_MACRO, DUK_FUNC_MACRO, __VA_ARGS__);
#define DUK__DEBUG_LOG(lev,...) duk_debug_log((lev), DUK_FILE_MACRO, (int) DUK_LINE_MACRO, DUK_FUNC_MACRO, __VA_ARGS__);
#define DUK_DPRINT(...) _DUK_DEBUG_LOG(DUK_LEVEL_DEBUG, __VA_ARGS__)
#define DUK_DPRINT(...) DUK__DEBUG_LOG(DUK_LEVEL_DEBUG, __VA_ARGS__)
#ifdef DUK_USE_DDEBUG
#define DUK_DDPRINT(...) _DUK_DEBUG_LOG(DUK_LEVEL_DDEBUG, __VA_ARGS__)
#define DUK_DDPRINT(...) DUK__DEBUG_LOG(DUK_LEVEL_DDEBUG, __VA_ARGS__)
#else
#define DUK_DDPRINT(...)
#endif
#ifdef DUK_USE_DDDEBUG
#define DUK_DDDPRINT(...) _DUK_DEBUG_LOG(DUK_LEVEL_DDDEBUG, __VA_ARGS__)
#define DUK_DDDPRINT(...) DUK__DEBUG_LOG(DUK_LEVEL_DDDEBUG, __VA_ARGS__)
#else
#define DUK_DDDPRINT(...)
#endif
#else /* DUK_USE_VARIADIC_MACROS */
#define _DUK_DEBUG_STASH(lev) \
#define DUK__DEBUG_STASH(lev) \
(void) DUK_MEMSET((void *) duk_debug_file_stash, 0, (size_t) DUK_DEBUG_STASH_SIZE), \
(void) DUK_MEMSET((void *) duk_debug_line_stash, 0, (size_t) DUK_DEBUG_STASH_SIZE), \
(void) DUK_MEMSET((void *) duk_debug_func_stash, 0, (size_t) DUK_DEBUG_STASH_SIZE), \
@ -54,19 +54,19 @@
(void) (duk_debug_level_stash = (lev))
#ifdef DUK_USE_DEBUG
#define DUK_DPRINT _DUK_DEBUG_STASH(DUK_LEVEL_DEBUG), (void) duk_debug_log /* args go here in parens */
#define DUK_DPRINT DUK__DEBUG_STASH(DUK_LEVEL_DEBUG), (void) duk_debug_log /* args go here in parens */
#else
#define DUK_DPRINT 0 &&
#endif
#ifdef DUK_USE_DDEBUG
#define DUK_DDPRINT _DUK_DEBUG_STASH(DUK_LEVEL_DDEBUG), (void) duk_debug_log /* args go here in parens */
#define DUK_DDPRINT DUK__DEBUG_STASH(DUK_LEVEL_DDEBUG), (void) duk_debug_log /* args go here in parens */
#else
#define DUK_DDPRINT 0 &&
#endif
#ifdef DUK_USE_DDDEBUG
#define DUK_DDDPRINT _DUK_DEBUG_STASH(DUK_LEVEL_DDDEBUG), (void) duk_debug_log /* args go here in parens */
#define DUK_DDDPRINT DUK__DEBUG_STASH(DUK_LEVEL_DDDEBUG), (void) duk_debug_log /* args go here in parens */
#else
#define DUK_DDDPRINT 0 &&
#endif

24
src/duk_heap.h

@ -21,25 +21,25 @@
#define DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED (1 << 1) /* mark-and-sweep marking reached a recursion limit and must use multi-pass marking */
#define DUK_HEAP_FLAG_REFZERO_FREE_RUNNING (1 << 2) /* refcount code is processing refzero list */
#define _DUK_HEAP_HAS_FLAGS(heap,bits) ((heap)->flags & (bits))
#define _DUK_HEAP_SET_FLAGS(heap,bits) do { \
#define DUK__HEAP_HAS_FLAGS(heap,bits) ((heap)->flags & (bits))
#define DUK__HEAP_SET_FLAGS(heap,bits) do { \
(heap)->flags |= (bits); \
} while (0)
#define _DUK_HEAP_CLEAR_FLAGS(heap,bits) do { \
#define DUK__HEAP_CLEAR_FLAGS(heap,bits) do { \
(heap)->flags &= ~(bits); \
} while (0)
#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap) _DUK_HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap) _DUK_HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap) _DUK_HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
#define DUK_HEAP_HAS_MARKANDSWEEP_RUNNING(heap) DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_HAS_MARKANDSWEEP_RECLIMIT_REACHED(heap) DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_HAS_REFZERO_FREE_RUNNING(heap) DUK__HEAP_HAS_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
#define DUK_HEAP_SET_MARKANDSWEEP_RUNNING(heap) _DUK_HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap) _DUK_HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_SET_REFZERO_FREE_RUNNING(heap) _DUK_HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
#define DUK_HEAP_SET_MARKANDSWEEP_RUNNING(heap) DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_SET_MARKANDSWEEP_RECLIMIT_REACHED(heap) DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_SET_REFZERO_FREE_RUNNING(heap) DUK__HEAP_SET_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING(heap) _DUK_HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap) _DUK_HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING(heap) _DUK_HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RUNNING(heap) DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RUNNING)
#define DUK_HEAP_CLEAR_MARKANDSWEEP_RECLIMIT_REACHED(heap) DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_MARKANDSWEEP_RECLIMIT_REACHED)
#define DUK_HEAP_CLEAR_REFZERO_FREE_RUNNING(heap) DUK__HEAP_CLEAR_FLAGS((heap), DUK_HEAP_FLAG_REFZERO_FREE_RUNNING)
/*
* Longjmp types, also double as identifying continuation type for a rethrow (in 'finally')

32
src/duk_heaphdr.h

@ -182,22 +182,22 @@ struct duk_heaphdr_string {
#define DUK_TVAL_INCREF(thr,tv) duk_heap_tval_incref((tv))
#define DUK_TVAL_DECREF(thr,tv) duk_heap_tval_decref((thr),(tv))
#define _DUK_HEAPHDR_INCREF(thr,h) duk_heap_heaphdr_incref((h))
#define _DUK_HEAPHDR_DECREF(thr,h) duk_heap_heaphdr_decref((thr),(h))
#define DUK_HEAPHDR_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HEAPHDR_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HSTRING_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HSTRING_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HOBJECT_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HOBJECT_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HBUFFER_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HBUFFER_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HCOMPILEDFUNCTION_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HCOMPILEDFUNCTION_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HNATIVEFUNCTION_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HNATIVEFUNCTION_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HTHREAD_INCREF(thr,h) _DUK_HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HTHREAD_DECREF(thr,h) _DUK_HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK__HEAPHDR_INCREF(thr,h) duk_heap_heaphdr_incref((h))
#define DUK__HEAPHDR_DECREF(thr,h) duk_heap_heaphdr_decref((thr),(h))
#define DUK_HEAPHDR_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HEAPHDR_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HSTRING_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HSTRING_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HOBJECT_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HOBJECT_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HBUFFER_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) (h))
#define DUK_HBUFFER_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) (h))
#define DUK_HCOMPILEDFUNCTION_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HCOMPILEDFUNCTION_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HNATIVEFUNCTION_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HNATIVEFUNCTION_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HTHREAD_INCREF(thr,h) DUK__HEAPHDR_INCREF((thr),(duk_heaphdr *) &(h)->obj)
#define DUK_HTHREAD_DECREF(thr,h) DUK__HEAPHDR_DECREF((thr),(duk_heaphdr *) &(h)->obj)
#else /* DUK_USE_REFERENCE_COUNTING */

124
src/duk_tval.h

@ -128,124 +128,124 @@ typedef union duk_tval duk_tval;
/* raw setters */
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_UNDEFINED_ACTUAL_FULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_ACTUAL_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (unsigned long long) DUK_XTAG_UNDEFINED_ACTUAL; \
} while (0)
#else
#define _DUK_TVAL_SET_UNDEFINED_ACTUAL_FULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_ACTUAL_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = ((unsigned long long) DUK_XTAG_UNDEFINED_ACTUAL) << 32; \
} while (0)
#endif
#define _DUK_TVAL_SET_UNDEFINED_ACTUAL_NOTFULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_ACTUAL_NOTFULL(v) do { \
(v)->ui[DUK_DBL_IDX_UI0] = (unsigned int) DUK_XTAG_UNDEFINED_ACTUAL; \
} while (0)
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_UNDEFINED_UNUSED_FULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_UNUSED_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (unsigned long long) DUK_XTAG_UNDEFINED_UNUSED; \
} while (0)
#else
#define _DUK_TVAL_SET_UNDEFINED_UNUSED_FULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_UNUSED_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = ((unsigned long long) DUK_XTAG_UNDEFINED_UNUSED) << 32; \
} while (0)
#endif
#define _DUK_TVAL_SET_UNDEFINED_UNUSED_NOTFULL(v) do { \
#define DUK__TVAL_SET_UNDEFINED_UNUSED_NOTFULL(v) do { \
(v)->ui[DUK_DBL_IDX_UI0] = (unsigned int) DUK_XTAG_UNDEFINED_UNUSED; \
} while (0)
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_NULL_FULL(v) do { \
#define DUK__TVAL_SET_NULL_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) DUK_TAG_NULL) << 16); \
} while (0)
#else
#define _DUK_TVAL_SET_NULL_FULL(v) do { \
#define DUK__TVAL_SET_NULL_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) DUK_TAG_NULL) << 48); \
} while (0)
#endif
/* Note: 16-bit initializer suffices (unlike for undefined/boolean) */
#define _DUK_TVAL_SET_NULL_NOTFULL(v) do { \
#define DUK__TVAL_SET_NULL_NOTFULL(v) do { \
(v)->us[DUK_DBL_IDX_US0] = (unsigned short) DUK_TAG_NULL; \
} while (0)
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_BOOLEAN_FULL(v,val) do { \
#define DUK__TVAL_SET_BOOLEAN_FULL(v,val) do { \
DUK_ASSERT((val) == 0 || (val) == 1); \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) DUK_TAG_BOOLEAN) << 16) | ((unsigned long long) (val)); \
} while (0)
#else
#define _DUK_TVAL_SET_BOOLEAN_FULL(v,val) do { \
#define DUK__TVAL_SET_BOOLEAN_FULL(v,val) do { \
DUK_ASSERT((val) == 0 || (val) == 1); \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) DUK_TAG_BOOLEAN) << 48) | (((unsigned long long) (val)) << 32); \
} while (0)
#endif
#define _DUK_TVAL_SET_BOOLEAN_NOTFULL(v,val) do { \
#define DUK__TVAL_SET_BOOLEAN_NOTFULL(v,val) do { \
DUK_ASSERT((val) == 0 || (val) == 1); \
(v)->ui[DUK_DBL_IDX_UI0] = (((unsigned int) DUK_TAG_BOOLEAN) << 16) | ((unsigned int) (val)); \
} while (0)
/* assumes that caller has normalized a possible NaN value of 'val', otherwise trouble ahead */
#define _DUK_TVAL_SET_NUMBER_FULL(v,val) do { \
#define DUK__TVAL_SET_NUMBER_FULL(v,val) do { \
(v)->d = (double) (val); \
} while (0)
/* no notfull variant */
#define _DUK_TVAL_SET_NUMBER_NOTFULL(v,d) _DUK_TVAL_SET_NUMBER_FULL(v,d)
#define DUK__TVAL_SET_NUMBER_NOTFULL(v,d) DUK__TVAL_SET_NUMBER_FULL(v,d)
/* two casts to avoid gcc warning: "warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]" */
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_TAGGEDPOINTER(v,h,tag) do { \
#define DUK__TVAL_SET_TAGGEDPOINTER(v,h,tag) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) (tag)) << 16) | (((unsigned long long) (unsigned int) (h)) << 32); \
} while (0)
#else
#define _DUK_TVAL_SET_TAGGEDPOINTER(v,h,tag) do { \
#define DUK__TVAL_SET_TAGGEDPOINTER(v,h,tag) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = (((unsigned long long) (tag)) << 48) | ((unsigned long long) (unsigned int) (h)); \
} while (0)
#endif
#ifdef _USE_ME_VARIANT
#define _DUK_TVAL_SET_NAN_FULL(v) do { \
#define DUK__TVAL_SET_NAN_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = 0x000000007ff80000ULL; \
} while (0)
#else
#define _DUK_TVAL_SET_NAN_FULL(v) do { \
#define DUK__TVAL_SET_NAN_FULL(v) do { \
(v)->ull[DUK_DBL_IDX_ULL0] = 0x7ff8000000000000ULL; \
} while (0)
#endif
#define _DUK_TVAL_SET_NAN_NOTFULL(v) do { \
#define DUK__TVAL_SET_NAN_NOTFULL(v) do { \
(v)->us[DUK_DBL_IDX_US0] = 0x7ff8; \
} while (0)
#define _DUK_DOUBLE_SET_NAN_FULL(d) _DUK_TVAL_SET_NAN_FULL((duk_tval *)(d))
#define _DUK_DOUBLE_SET_NAN_NOTFULL(d) _DUK_TVAL_SET_NAN_NOTFULL((duk_tval *)(d))
#define DUK__DOUBLE_SET_NAN_FULL(d) DUK__TVAL_SET_NAN_FULL((duk_tval *)(d))
#define DUK__DOUBLE_SET_NAN_NOTFULL(d) DUK__TVAL_SET_NAN_NOTFULL((duk_tval *)(d))
/* select actual setters */
#ifdef DUK_USE_FULL_TVAL
#define DUK_TVAL_SET_UNDEFINED_ACTUAL(v) _DUK_TVAL_SET_UNDEFINED_ACTUAL_FULL((v))
#define DUK_TVAL_SET_UNDEFINED_UNUSED(v) _DUK_TVAL_SET_UNDEFINED_UNUSED_FULL((v))
#define DUK_TVAL_SET_NULL(v) _DUK_TVAL_SET_NULL_FULL((v))
#define DUK_TVAL_SET_BOOLEAN(v,i) _DUK_TVAL_SET_BOOLEAN_FULL((v),(i))
#define DUK_TVAL_SET_NUMBER(v,d) _DUK_TVAL_SET_NUMBER_FULL((v),(d))
#define DUK_TVAL_SET_NAN(v) _DUK_TVAL_SET_NAN_FULL((v))
#define DUK_DOUBLE_SET_NAN(d) _DUK_DOUBLE_SET_NAN_FULL((d))
#define DUK_TVAL_SET_UNDEFINED_ACTUAL(v) DUK__TVAL_SET_UNDEFINED_ACTUAL_FULL((v))
#define DUK_TVAL_SET_UNDEFINED_UNUSED(v) DUK__TVAL_SET_UNDEFINED_UNUSED_FULL((v))
#define DUK_TVAL_SET_NULL(v) DUK__TVAL_SET_NULL_FULL((v))
#define DUK_TVAL_SET_BOOLEAN(v,i) DUK__TVAL_SET_BOOLEAN_FULL((v),(i))
#define DUK_TVAL_SET_NUMBER(v,d) DUK__TVAL_SET_NUMBER_FULL((v),(d))
#define DUK_TVAL_SET_NAN(v) DUK__TVAL_SET_NAN_FULL((v))
#define DUK_DOUBLE_SET_NAN(d) DUK__DOUBLE_SET_NAN_FULL((d))
#else
#define DUK_TVAL_SET_UNDEFINED_ACTUAL(v) _DUK_TVAL_SET_UNDEFINED_ACTUAL_NOTFULL((v))
#define DUK_TVAL_SET_UNDEFINED_UNUSED(v) _DUK_TVAL_SET_UNDEFINED_UNUSED_NOTFULL((v))
#define DUK_TVAL_SET_NULL(v) _DUK_TVAL_SET_NULL_NOTFULL((v))
#define DUK_TVAL_SET_BOOLEAN(v,i) _DUK_TVAL_SET_BOOLEAN_NOTFULL((v),(i))
#define DUK_TVAL_SET_NUMBER(v,d) _DUK_TVAL_SET_NUMBER_NOTFULL((v),(d))
#define DUK_TVAL_SET_NAN(v) _DUK_TVAL_SET_NAN_NOTFULL((v))
#define DUK_DOUBLE_SET_NAN(d) _DUK_DOUBLE_SET_NAN_NOTFULL((d))
#define DUK_TVAL_SET_UNDEFINED_ACTUAL(v) DUK__TVAL_SET_UNDEFINED_ACTUAL_NOTFULL((v))
#define DUK_TVAL_SET_UNDEFINED_UNUSED(v) DUK__TVAL_SET_UNDEFINED_UNUSED_NOTFULL((v))
#define DUK_TVAL_SET_NULL(v) DUK__TVAL_SET_NULL_NOTFULL((v))
#define DUK_TVAL_SET_BOOLEAN(v,i) DUK__TVAL_SET_BOOLEAN_NOTFULL((v),(i))
#define DUK_TVAL_SET_NUMBER(v,d) DUK__TVAL_SET_NUMBER_NOTFULL((v),(d))
#define DUK_TVAL_SET_NAN(v) DUK__TVAL_SET_NAN_NOTFULL((v))
#define DUK_DOUBLE_SET_NAN(d) DUK__DOUBLE_SET_NAN_NOTFULL((d))
#endif
#define DUK_TVAL_SET_STRING(v,h) _DUK_TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_STRING)
#define DUK_TVAL_SET_OBJECT(v,h) _DUK_TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_OBJECT)
#define DUK_TVAL_SET_BUFFER(v,h) _DUK_TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_BUFFER)
#define DUK_TVAL_SET_POINTER(v,p) _DUK_TVAL_SET_TAGGEDPOINTER((v),(p),DUK_TAG_POINTER)
#define DUK_TVAL_SET_STRING(v,h) DUK__TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_STRING)
#define DUK_TVAL_SET_OBJECT(v,h) DUK__TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_OBJECT)
#define DUK_TVAL_SET_BUFFER(v,h) DUK__TVAL_SET_TAGGEDPOINTER((v),(h),DUK_TAG_BUFFER)
#define DUK_TVAL_SET_POINTER(v,p) DUK__TVAL_SET_TAGGEDPOINTER((v),(p),DUK_TAG_POINTER)
#define DUK_TVAL_SET_TVAL(v,x) do { *(v) = *(x); } while (0)
@ -289,55 +289,55 @@ typedef union duk_tval duk_tval;
/* XXX: reading unsigned int instead of unsigned short is one byte shorter on x86 :) */
#ifdef _USE_ME_VARIANT
#define _DUK_DOUBLE_IS_NAN_FULL(d) \
#define DUK__DOUBLE_IS_NAN_FULL(d) \
/* E == 0x7ff, F != 0 => NaN */ \
(((((duk_tval *)(d))->us[DUK_DBL_IDX_US0] & 0x7ff0) == 0x7ff0) && \
(((((duk_tval *)(d))->ull[DUK_DBL_IDX_ULL0]) & 0x000fffffffffffffULL) != 0))
#else
#define _DUK_DOUBLE_IS_NAN_FULL(d) \
#define DUK__DOUBLE_IS_NAN_FULL(d) \
/* E == 0x7ff, F != 0 => NaN */ \
(((((duk_tval *)(d))->us[DUK_DBL_IDX_US0] & 0x7ff0) == 0x7ff0) && \
(((((duk_tval *)(d))->ull[DUK_DBL_IDX_ULL0]) & 0xffffffff000fffffULL) != 0))
#endif
/* XXX: avoid possible double read? */
#define _DUK_DOUBLE_IS_NAN_NOTFULL(d) \
#define DUK__DOUBLE_IS_NAN_NOTFULL(d) \
/* E == 0x7ff, topmost four bits of F != 0 => assume NaN */ \
(((((duk_tval *)(d))->us[DUK_DBL_IDX_US0] & 0x7ff0) == 0x7ff0) && \
((((duk_tval *)(d))->us[DUK_DBL_IDX_US0] & 0x000f) != 0x0000))
#define _DUK_DOUBLE_NORMALIZE_NAN_CHECK_FULL(d) do { \
if (_DUK_DOUBLE_IS_NAN_FULL((d))) { \
_DUK_DOUBLE_SET_NAN_FULL((d)); \
#define DUK__DOUBLE_NORMALIZE_NAN_CHECK_FULL(d) do { \
if (DUK__DOUBLE_IS_NAN_FULL((d))) { \
DUK__DOUBLE_SET_NAN_FULL((d)); \
} \
} while (0)
#define _DUK_DOUBLE_NORMALIZE_NAN_CHECK_NOTFULL(d) do { \
if (_DUK_DOUBLE_IS_NAN_NOTFULL((d))) { \
_DUK_DOUBLE_SET_NAN_NOTFULL((d)); \
#define DUK__DOUBLE_NORMALIZE_NAN_CHECK_NOTFULL(d) do { \
if (DUK__DOUBLE_IS_NAN_NOTFULL((d))) { \
DUK__DOUBLE_SET_NAN_NOTFULL((d)); \
} \
} while (0)
#ifdef _USE_ME_VARIANT
#define _DUK_DOUBLE_IS_NORMALIZED_NAN_FULL(d) \
#define DUK__DOUBLE_IS_NORMALIZED_NAN_FULL(d) \
(((duk_tval *)(d))->ull[DUK_DBL_IDX_ULL0] == 0x000000007ff80000ULL)
#else
#define _DUK_DOUBLE_IS_NORMALIZED_NAN_FULL(d) \
#define DUK__DOUBLE_IS_NORMALIZED_NAN_FULL(d) \
(((duk_tval *)(d))->ull[DUK_DBL_IDX_ULL0] == 0x7ff8000000000000ULL)
#endif
#define _DUK_DOUBLE_IS_NORMALIZED_NAN_NOTFULL(d) \
#define DUK__DOUBLE_IS_NORMALIZED_NAN_NOTFULL(d) \
/* E == 0x7ff, F == 8 => normalized NaN */ \
(((duk_tval *)(d))->us[DUK_DBL_IDX_US0] == 0x7ff8)
#ifdef DUK_USE_FULL_TVAL
#define DUK_DOUBLE_NORMALIZE_NAN_CHECK(d) _DUK_DOUBLE_NORMALIZE_NAN_CHECK_FULL((d))
#define DUK_DOUBLE_IS_NAN(d) _DUK_DOUBLE_IS_NAN_FULL((d))
#define DUK_DOUBLE_IS_NORMALIZED_NAN(d) _DUK_DOUBLE_IS_NORMALIZED_NAN_FULL((d))
#define DUK_DOUBLE_NORMALIZE_NAN_CHECK(d) DUK__DOUBLE_NORMALIZE_NAN_CHECK_FULL((d))
#define DUK_DOUBLE_IS_NAN(d) DUK__DOUBLE_IS_NAN_FULL((d))
#define DUK_DOUBLE_IS_NORMALIZED_NAN(d) DUK__DOUBLE_IS_NORMALIZED_NAN_FULL((d))
#else
#define DUK_DOUBLE_NORMALIZE_NAN_CHECK(d) _DUK_DOUBLE_NORMALIZE_NAN_CHECK_NOTFULL((d))
#define DUK_DOUBLE_IS_NAN(d) _DUK_DOUBLE_IS_NAN_NOTFULL((d))
#define DUK_DOUBLE_IS_NORMALIZED_NAN(d) _DUK_DOUBLE_IS_NORMALIZED_NAN_NOTFULL((d))
#define DUK_DOUBLE_NORMALIZE_NAN_CHECK(d) DUK__DOUBLE_NORMALIZE_NAN_CHECK_NOTFULL((d))
#define DUK_DOUBLE_IS_NAN(d) DUK__DOUBLE_IS_NAN_NOTFULL((d))
#define DUK_DOUBLE_IS_NORMALIZED_NAN(d) DUK__DOUBLE_IS_NORMALIZED_NAN_NOTFULL((d))
#endif
/* this is used for assertions - it checks that the NaN is properly normalized */
@ -374,7 +374,7 @@ struct duk_tval_struct {
} v;
};
#define _DUK_TAG_NUMBER 0 /* not exposed */
#define DUK__TAG_NUMBER 0 /* not exposed */
#define DUK_TAG_UNDEFINED 1
#define DUK_TAG_NULL 2
#define DUK_TAG_BOOLEAN 3
@ -383,7 +383,7 @@ struct duk_tval_struct {
#define DUK_TAG_OBJECT 6
#define DUK_TAG_BUFFER 7
/* _DUK_TAG_NUMBER is intentionally first, as it is the default clause in code
/* DUK__TAG_NUMBER is intentionally first, as it is the default clause in code
* to support the 8-byte representation. Further, it is a non-heap-allocated
* type so it should come before DUK_TAG_STRING. Finally, it should not break
* the tag value ranges covered by case-clauses in a switch-case.
@ -410,7 +410,7 @@ struct duk_tval_struct {
} while (0)
#define DUK_TVAL_SET_NUMBER(tv,val) do { \
(tv)->t = _DUK_TAG_NUMBER; \
(tv)->t = DUK__TAG_NUMBER; \
(tv)->v.d = (val); \
} while (0)
@ -436,7 +436,7 @@ struct duk_tval_struct {
#define DUK_TVAL_SET_NAN(tv) do { \
/* in non-packed representation we don't care about which NaN is used */ \
(tv)->t = _DUK_TAG_NUMBER; \
(tv)->t = DUK__TAG_NUMBER; \
(tv)->v.d = DUK_DOUBLE_NAN; \
} while (0)
@ -459,7 +459,7 @@ struct duk_tval_struct {
/* decoding */
#define DUK_TVAL_GET_TAG(tv) ((tv)->t)
#define DUK_TVAL_IS_NUMBER(tv) ((tv)->t == _DUK_TAG_NUMBER)
#define DUK_TVAL_IS_NUMBER(tv) ((tv)->t == DUK__TAG_NUMBER)
#define DUK_TVAL_IS_UNDEFINED(tv) ((tv)->t == DUK_TAG_UNDEFINED)
#define DUK_TVAL_IS_UNDEFINED_ACTUAL(tv) (((tv)->t == DUK_TAG_UNDEFINED) && ((tv)->v.i == 0))
#define DUK_TVAL_IS_UNDEFINED_UNUSED(tv) (((tv)->t == DUK_TAG_UNDEFINED) && ((tv)->v.i != 0))

Loading…
Cancel
Save