This commit is contained in:
parent
d83c3635ec
commit
0b9d05e5c3
@ -2138,8 +2138,8 @@ val_arr:
|
||||
|
||||
ssz = HAWK_ARR_SIZE(arr);
|
||||
HAWK_ASSERT (msz <= ssz);
|
||||
HAWK_ASSERT (msz <= HAWK_QINT_MAX);
|
||||
HAWK_ASSERT (ssz <= HAWK_QINT_MAX);
|
||||
HAWK_ASSERT (msz <= HAWK_INT_MAX);
|
||||
HAWK_ASSERT (ssz <= HAWK_INT_MAX);
|
||||
|
||||
va = (hawk_val_t**)hawk_rtx_allocmem(rtx, msz * HAWK_SIZEOF(*va));
|
||||
if (HAWK_UNLIKELY(!va)) return -1;
|
||||
|
@ -266,7 +266,7 @@ static int fnc_gc (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
gen = hawk_rtx_gc(rtx, gen);
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(gen));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(gen));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, gen));
|
||||
return 0;
|
||||
}
|
||||
@ -282,7 +282,7 @@ static int fnc_gc_get_threshold (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
threshold = rtx->gc.threshold[gen];
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(threshold));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(threshold));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, threshold));
|
||||
return 0;
|
||||
}
|
||||
@ -300,7 +300,7 @@ static int fnc_gc_set_threshold (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
|
||||
if (threshold >= 0)
|
||||
{
|
||||
if (threshold >= HAWK_QINT_MAX) threshold = HAWK_QINT_MAX;
|
||||
if (threshold >= HAWK_INT_MAX) threshold = HAWK_INT_MAX;
|
||||
rtx->gc.threshold[gen] = threshold; /* update */
|
||||
}
|
||||
else
|
||||
@ -308,7 +308,7 @@ static int fnc_gc_set_threshold (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
threshold = rtx->gc.threshold[gen]; /* no update. but retrieve the existing value */
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(threshold));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(threshold));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, threshold));
|
||||
return 0;
|
||||
}
|
||||
|
@ -650,7 +650,7 @@ static int fnc_open (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -693,7 +693,7 @@ static int fnc_openfd (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_EINVAL, HAWK_T("invalid file descriptor %jd"), (hawk_intmax_t)fd);
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -718,7 +718,7 @@ static int fnc_read (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
if (sys_node)
|
||||
{
|
||||
if (hawk_rtx_getnargs(rtx) >= 3 && (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 2), &reqsize) <= -1 || reqsize <= 0)) reqsize = 8192;
|
||||
if (reqsize > HAWK_QINT_MAX) reqsize = HAWK_QINT_MAX;
|
||||
if (reqsize > HAWK_INT_MAX) reqsize = HAWK_INT_MAX;
|
||||
|
||||
if (reqsize > sys_list->ctx.readbuf_capa)
|
||||
{
|
||||
@ -828,7 +828,7 @@ static int fnc_read (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
|
||||
done:
|
||||
/* the value in 'rx' never exceeds HAWK_QINT_MAX as 'reqsize' has been limited to
|
||||
/* the value in 'rx' never exceeds HAWK_INT_MAX as 'reqsize' has been limited to
|
||||
* it before the call to 'read'. so it's safe not to check the result of hawk_rtx_makeintval() */
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
@ -997,7 +997,7 @@ static int fnc_dup (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
|
||||
done:
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx)); /* assume a file descriptor never gets larger than HAWK_QINT_MAX */
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx)); /* assume a file descriptor never gets larger than HAWK_INT_MAX */
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -1774,7 +1774,7 @@ static int fnc_opendir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
}
|
||||
|
||||
/*HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));*/
|
||||
/*HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));*/
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -2804,7 +2804,7 @@ done:
|
||||
if (val) hawk_rtx_freevalbcstr (rtx, a1, val);
|
||||
if (var) hawk_rtx_freevalbcstr (rtx, a0, var);
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -2846,7 +2846,7 @@ static int fnc_unsetenv (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
done:
|
||||
if (str) hawk_rtx_freevalbcstr (rtx, a0, str);
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3011,7 +3011,7 @@ static int fnc_system (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
done:
|
||||
if (str) hawk_rtx_freevaloocstr (rtx, a0, str);
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3060,7 +3060,7 @@ static int fnc_chroot (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3112,7 +3112,7 @@ static int fnc_chmod (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3192,7 +3192,7 @@ static int fnc_mkdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3268,7 +3268,7 @@ static int fnc_rmdir (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3346,7 +3346,7 @@ static int fnc_unlink (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3394,7 +3394,7 @@ static int fnc_symlink (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3563,7 +3563,7 @@ static int fnc_stat (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
done:
|
||||
#endif
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3628,7 +3628,7 @@ static int fnc_utime (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
#endif
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3684,7 +3684,7 @@ static int fnc_openmux (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = set_error_on_sys_list(rtx, sys_list, HAWK_ENOIMPL, HAWK_NULL);
|
||||
#endif
|
||||
|
||||
/*HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));*/
|
||||
/*HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));*/
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -3945,11 +3945,11 @@ static int fnc_getmuxevt (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
goto done;
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(file_node->id));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(file_node->id));
|
||||
x = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 2), hawk_rtx_makeintval(rtx, file_node->id));
|
||||
if (x <= -1) goto fail;
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(mux_data->x_evt[index].events));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(mux_data->x_evt[index].events));
|
||||
x = hawk_rtx_setrefval(rtx, (hawk_val_ref_t*)hawk_rtx_getarg(rtx, 3), hawk_rtx_makeintval(rtx, mux_data->x_evt[index].events));
|
||||
if (x <= -1) goto fail;
|
||||
}
|
||||
@ -3996,7 +3996,7 @@ static int fnc_sockaddrdom (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = copy_error_to_sys_list(rtx, sys_list);
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -4037,7 +4037,7 @@ static int fnc_socket (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
rx = set_error_on_sys_list_with_errno(rtx, sys_list, HAWK_NULL);
|
||||
}
|
||||
|
||||
HAWK_ASSERT (HAWK_IN_QINT_RANGE(rx));
|
||||
HAWK_ASSERT (HAWK_IN_INT_RANGE(rx));
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
}
|
||||
@ -4105,7 +4105,7 @@ static int fnc_recvfrom (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
socklen_t addrlen;
|
||||
|
||||
if (hawk_rtx_getnargs(rtx) >= 3 && (hawk_rtx_valtoint(rtx, hawk_rtx_getarg(rtx, 2), &reqsize) <= -1 || reqsize <= 0)) reqsize = 8192;
|
||||
if (reqsize > HAWK_QINT_MAX) reqsize = HAWK_QINT_MAX;
|
||||
if (reqsize > HAWK_INT_MAX) reqsize = HAWK_INT_MAX;
|
||||
|
||||
if (reqsize > sys_list->ctx.readbuf_capa)
|
||||
{
|
||||
@ -4175,7 +4175,7 @@ static int fnc_recvfrom (hawk_rtx_t* rtx, const hawk_fnc_info_t* fi)
|
||||
}
|
||||
|
||||
done:
|
||||
/* the value in 'rx' never exceeds HAWK_QINT_MAX as 'reqsize' has been limited to
|
||||
/* the value in 'rx' never exceeds HAWK_INT_MAX as 'reqsize' has been limited to
|
||||
* it before the call to 'read'. so it's safe not to check the result of hawk_rtx_makeintval() */
|
||||
hawk_rtx_setretval (rtx, hawk_rtx_makeintval(rtx, rx));
|
||||
return 0;
|
||||
|
@ -8140,7 +8140,7 @@ static hawk_ooi_t idxnde_to_int (hawk_rtx_t* rtx, hawk_nde_t* nde, hawk_nde_t**
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (v < 0 || v > HAWK_QINT_MAX)
|
||||
if (v < 0 || v > HAWK_INT_MAX)
|
||||
{
|
||||
/* array index out of permitted range */
|
||||
hawk_rtx_seterrnum (rtx, &nde->loc, HAWK_EARRIDXRANGE);
|
||||
|
@ -82,10 +82,10 @@ struct hawk_val_rchunk_t
|
||||
|
||||
|
||||
#define HAWK_VTR_TYPE_BITS_POINTER 0 /* 00 */
|
||||
#define HAWK_VTR_TYPE_BITS_QINT 1 /* 01 */
|
||||
#define HAWK_VTR_TYPE_BITS_QCHAR 2 /* 10 */
|
||||
#define HAWK_VTR_TYPE_BITS_INT 1 /* 01 */
|
||||
#define HAWK_VTR_TYPE_BITS_CHAR 2 /* 10 */
|
||||
#define HAWK_VTR_TYPE_BITS_QEXT 3 /* 11 extended */
|
||||
#define HAWK_VTR_TYPE_BITS_QBCHR 3 /* 0011 */
|
||||
#define HAWK_VTR_TYPE_BITS_BCHR 3 /* 0011 */
|
||||
#define HAWK_VTR_TYPE_BITS_RESERVED0 7 /* 0111 */
|
||||
#define HAWK_VTR_TYPE_BITS_RESERVED1 11 /* 1011 */
|
||||
#define HAWK_VTR_TYPE_BITS_RESERVED2 15 /* 1111 */
|
||||
@ -95,9 +95,9 @@ struct hawk_val_rchunk_t
|
||||
* i want abs(max) == abs(min).
|
||||
* i don't want abs(max) + 1 == abs(min). e.g min: -32768, max: 32767
|
||||
*/
|
||||
#define HAWK_QINT_MAX ((hawk_int_t)((~(hawk_uintptr_t)0) >> (HAWK_VTR_NUM_TYPE_BITS_LO + 1)))
|
||||
#define HAWK_QINT_MIN (-HAWK_QINT_MAX)
|
||||
#define HAWK_IN_QINT_RANGE(i) ((i) >= HAWK_QINT_MIN && (i) <= HAWK_QINT_MAX)
|
||||
#define HAWK_INT_MAX ((hawk_int_t)((~(hawk_uintptr_t)0) >> (HAWK_VTR_NUM_TYPE_BITS_LO + 1)))
|
||||
#define HAWK_INT_MIN (-HAWK_INT_MAX)
|
||||
#define HAWK_IN_INT_RANGE(i) ((i) >= HAWK_INT_MIN && (i) <= HAWK_INT_MAX)
|
||||
|
||||
#define HAWK_VTR_TYPE_BITS_LO(p) (((hawk_uintptr_t)(p)) & HAWK_VTR_MASK_TYPE_BITS_LO)
|
||||
#define HAWK_VTR_TYPE_BITS_LOHI(p) (((hawk_uintptr_t)(p)) & HAWK_VTR_MASK_TYPE_BITS_LOHI)
|
||||
@ -107,47 +107,47 @@ struct hawk_val_rchunk_t
|
||||
|
||||
|
||||
#define HAWK_VTR_IS_POINTER(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_POINTER)
|
||||
#define HAWK_VTR_IS_QINT(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_QINT)
|
||||
#define HAWK_VTR_IS_QCHAR(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_QCHAR)
|
||||
#define HAWK_VTR_IS_QBCHR(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_QBCHR)
|
||||
#define HAWK_VTR_IS_INT(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_INT)
|
||||
#define HAWK_VTR_IS_CHAR(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_CHAR)
|
||||
#define HAWK_VTR_IS_BCHR(p) (HAWK_VTR_TYPE_BITS(p) == HAWK_VTR_TYPE_BITS_BCHR)
|
||||
|
||||
#define HAWK_QINT_TO_VTR_POSITIVE(i) \
|
||||
(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_QINT)
|
||||
#define HAWK_INT_TO_VTR_POSITIVE(i) \
|
||||
(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_INT)
|
||||
|
||||
#define HAWK_QINT_TO_VTR_NEGATIVE(i) \
|
||||
((((hawk_uintptr_t)-(i)) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_QINT | HAWK_VTR_SIGN_BIT)
|
||||
#define HAWK_INT_TO_VTR_NEGATIVE(i) \
|
||||
((((hawk_uintptr_t)-(i)) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_INT | HAWK_VTR_SIGN_BIT)
|
||||
|
||||
#define HAWK_QINT_TO_VTR(i) \
|
||||
((hawk_val_t*)(((i) < 0)? HAWK_QINT_TO_VTR_NEGATIVE(i): HAWK_QINT_TO_VTR_POSITIVE(i)))
|
||||
#define HAWK_INT_TO_VTR(i) \
|
||||
((hawk_val_t*)(((i) < 0)? HAWK_INT_TO_VTR_NEGATIVE(i): HAWK_INT_TO_VTR_POSITIVE(i)))
|
||||
|
||||
#define HAWK_QCHAR_TO_VTR(i) ((hawk_val_t*)(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_QCHAR))
|
||||
#define HAWK_QBCHR_TO_VTR(i) ((hawk_val_t*)(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LOHI) | HAWK_VTR_TYPE_BITS_QBCHR))
|
||||
#define HAWK_CHAR_TO_VTR(i) ((hawk_val_t*)(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LO) | HAWK_VTR_TYPE_BITS_CHAR))
|
||||
#define HAWK_BCHR_TO_VTR(i) ((hawk_val_t*)(((hawk_uintptr_t)(i) << HAWK_VTR_NUM_TYPE_BITS_LOHI) | HAWK_VTR_TYPE_BITS_BCHR))
|
||||
|
||||
#define HAWK_VTR_ZERO ((hawk_val_t*)HAWK_QINT_TO_VTR_POSITIVE(0))
|
||||
#define HAWK_VTR_ONE ((hawk_val_t*)HAWK_QINT_TO_VTR_POSITIVE(1))
|
||||
#define HAWK_VTR_NEGONE ((hawk_val_t*)HAWK_QINT_TO_VTR_NEGATIVE(-1))
|
||||
#define HAWK_VTR_ZERO ((hawk_val_t*)HAWK_INT_TO_VTR_POSITIVE(0))
|
||||
#define HAWK_VTR_ONE ((hawk_val_t*)HAWK_INT_TO_VTR_POSITIVE(1))
|
||||
#define HAWK_VTR_NEGONE ((hawk_val_t*)HAWK_INT_TO_VTR_NEGATIVE(-1))
|
||||
|
||||
/* sizeof(hawk_intptr_t) may not be the same as sizeof(hawk_int_t).
|
||||
* so step-by-step type conversions are needed.
|
||||
* e.g) pointer to uintptr_t, uintptr_t to intptr_t, intptr_t to hawk_int_t */
|
||||
#define HAWK_VTR_TO_QINT_POSITIVE(p) \
|
||||
#define HAWK_VTR_TO_INT_POSITIVE(p) \
|
||||
((hawk_intptr_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS_LO))
|
||||
#define HAWK_VTR_TO_QINT_NEGATIVE(p) \
|
||||
#define HAWK_VTR_TO_INT_NEGATIVE(p) \
|
||||
(-(hawk_intptr_t)(((hawk_uintptr_t)(p) & ~HAWK_VTR_SIGN_BIT) >> HAWK_VTR_NUM_TYPE_BITS_LO))
|
||||
#define HAWK_VTR_TO_QINT(p) \
|
||||
(((hawk_uintptr_t)(p) & HAWK_VTR_SIGN_BIT)? HAWK_VTR_TO_QINT_NEGATIVE(p): HAWK_VTR_TO_QINT_POSITIVE(p))
|
||||
#define HAWK_VTR_TO_INT(p) \
|
||||
(((hawk_uintptr_t)(p) & HAWK_VTR_SIGN_BIT)? HAWK_VTR_TO_INT_NEGATIVE(p): HAWK_VTR_TO_INT_POSITIVE(p))
|
||||
|
||||
#define HAWK_VTR_TO_QCHAR(p) ((hawk_ooch_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS_LO))
|
||||
#define HAWK_VTR_TO_QBCHR(p) ((hawk_ooch_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS_LOHI))
|
||||
#define HAWK_VTR_TO_CHAR(p) ((hawk_ooch_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS_LO))
|
||||
#define HAWK_VTR_TO_BCHR(p) ((hawk_ooch_t)((hawk_uintptr_t)(p) >> HAWK_VTR_NUM_TYPE_BITS_LOHI))
|
||||
|
||||
#define HAWK_GET_VAL_TYPE(p) (HAWK_VTR_IS_QINT(p)? HAWK_VAL_INT: \
|
||||
HAWK_VTR_IS_QCHAR(p)? HAWK_VAL_CHAR: \
|
||||
HAWK_VTR_IS_QBCHR(p)? HAWK_VAL_BCHR: (p)->v_type)
|
||||
#define HAWK_GET_VAL_TYPE(p) (HAWK_VTR_IS_INT(p)? HAWK_VAL_INT: \
|
||||
HAWK_VTR_IS_CHAR(p)? HAWK_VAL_CHAR: \
|
||||
HAWK_VTR_IS_BCHR(p)? HAWK_VAL_BCHR: (p)->v_type)
|
||||
|
||||
#define HAWK_RTX_GETVALTYPE(rtx, p) HAWK_GET_VAL_TYPE(p)
|
||||
#define HAWK_RTX_GETINTFROMVAL(rtx, p) ((HAWK_VTR_IS_QINT(p)? (hawk_int_t)HAWK_VTR_TO_QINT(p): ((hawk_val_int_t*)(p))->i_val))
|
||||
#define HAWK_RTX_GETCHARFROMVAL(rtx, p) (HAWK_VTR_TO_QCHAR(p))
|
||||
#define HAWK_RTX_GETBCHRFROMVAL(rtx, p) (HAWK_VTR_TO_QBCHR(p))
|
||||
#define HAWK_RTX_GETINTFROMVAL(rtx, p) ((HAWK_VTR_IS_INT(p)? (hawk_int_t)HAWK_VTR_TO_INT(p): ((hawk_val_int_t*)(p))->i_val))
|
||||
#define HAWK_RTX_GETCHARFROMVAL(rtx, p) (HAWK_VTR_TO_CHAR(p))
|
||||
#define HAWK_RTX_GETBCHRFROMVAL(rtx, p) (HAWK_VTR_TO_BCHR(p))
|
||||
|
||||
|
||||
#define HAWK_VAL_ZERO HAWK_VTR_ZERO
|
||||
|
@ -489,19 +489,19 @@ hawk_val_t* hawk_rtx_makenilval (hawk_rtx_t* rtx)
|
||||
|
||||
hawk_val_t* hawk_rtx_makecharval (hawk_rtx_t* rtx, hawk_ooch_t v)
|
||||
{
|
||||
return HAWK_QCHAR_TO_VTR((hawk_oochu_t)v);
|
||||
return HAWK_CHAR_TO_VTR((hawk_oochu_t)v);
|
||||
}
|
||||
|
||||
hawk_val_t* hawk_rtx_makebchrval (hawk_rtx_t* rtx, hawk_bch_t v)
|
||||
{
|
||||
return HAWK_QBCHR_TO_VTR((hawk_bchu_t)v);
|
||||
return HAWK_BCHR_TO_VTR((hawk_bchu_t)v);
|
||||
}
|
||||
|
||||
hawk_val_t* hawk_rtx_makeintval (hawk_rtx_t* rtx, hawk_int_t v)
|
||||
{
|
||||
hawk_val_int_t* val;
|
||||
|
||||
if (HAWK_IN_QINT_RANGE(v)) return HAWK_QINT_TO_VTR(v);
|
||||
if (HAWK_IN_INT_RANGE(v)) return HAWK_INT_TO_VTR(v);
|
||||
|
||||
if (!rtx->vmgr.ifree)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user