changed functions and macros related to quick integer handling
This commit is contained in:
parent
aed205c298
commit
84798f4fd0
@ -2525,6 +2525,16 @@ QSE_EXPORT int qse_awk_rtx_isstaticval (
|
||||
qse_awk_val_t* val /**< value to check */
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_awk_rtx_getvaltype (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_awk_val_t* val
|
||||
);
|
||||
|
||||
QSE_EXPORT int qse_awk_rtx_getintfromval (
|
||||
qse_awk_rtx_t* rtx,
|
||||
qse_awk_val_t* val
|
||||
);
|
||||
|
||||
/**
|
||||
* The qse_awk_rtx_refupval() function increments a reference count of a
|
||||
* value \a val.
|
||||
|
@ -457,7 +457,7 @@ int Awk::Value::getStr (const char_t** str, size_t* len) const
|
||||
|
||||
if (this->run)
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype (this->run->rtx, this->val) == QSE_AWK_VAL_STR)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (this->run->rtx, this->val) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
p = ((qse_awk_val_str_t*)this->val)->val.ptr;
|
||||
l = ((qse_awk_val_str_t*)this->val)->val.len;
|
||||
@ -643,7 +643,7 @@ int Awk::Value::setIndexedVal (Run* r, const Index& idx, val_t* v)
|
||||
{
|
||||
QSE_ASSERT (r != QSE_NULL);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (r->rtx, val) != QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (r->rtx, val) != QSE_AWK_VAL_MAP)
|
||||
{
|
||||
// the previous value is not a map.
|
||||
// a new map value needs to be created first.
|
||||
@ -803,7 +803,7 @@ int Awk::Value::setIndexedStr (Run* r, const Index& idx, const char_t* str, bool
|
||||
bool Awk::Value::isIndexed () const
|
||||
{
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
return qse_awk_rtx_getvaltype (this->run->rtx, val) == QSE_AWK_VAL_MAP;
|
||||
return QSE_AWK_RTX_GETVALTYPE (this->run->rtx, val) == QSE_AWK_VAL_MAP;
|
||||
}
|
||||
|
||||
int Awk::Value::getIndexed (const Index& idx, Value* v) const
|
||||
@ -811,7 +811,7 @@ int Awk::Value::getIndexed (const Index& idx, Value* v) const
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
// not a map. v is just nil. not an error
|
||||
if (qse_awk_rtx_getvaltype (this->run->rtx, val) != QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (this->run->rtx, val) != QSE_AWK_VAL_MAP)
|
||||
{
|
||||
v->clear ();
|
||||
return 0;
|
||||
@ -836,7 +836,7 @@ Awk::Value::IndexIterator Awk::Value::getFirstIndex (Index* idx) const
|
||||
{
|
||||
QSE_ASSERT (this->val != QSE_NULL);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (this->run->rtx, this->val) != QSE_AWK_VAL_MAP) return IndexIterator::END;
|
||||
if (QSE_AWK_RTX_GETVALTYPE (this->run->rtx, this->val) != QSE_AWK_VAL_MAP) return IndexIterator::END;
|
||||
|
||||
QSE_ASSERT (this->run != QSE_NULL);
|
||||
|
||||
@ -856,7 +856,7 @@ Awk::Value::IndexIterator Awk::Value::getNextIndex (
|
||||
{
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (this->run->rtx, val) != QSE_AWK_VAL_MAP) return IndexIterator::END;
|
||||
if (QSE_AWK_RTX_GETVALTYPE (this->run->rtx, val) != QSE_AWK_VAL_MAP) return IndexIterator::END;
|
||||
|
||||
QSE_ASSERT (this->run != QSE_NULL);
|
||||
|
||||
@ -1399,7 +1399,7 @@ int Awk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
int xx;
|
||||
val_t* v = qse_awk_rtx_getarg (run->rtx, i);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (run->rtx, v) == QSE_AWK_VAL_REF)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (run->rtx, v) == QSE_AWK_VAL_REF)
|
||||
{
|
||||
qse_awk_val_ref_t* ref = (qse_awk_val_ref_t*)v;
|
||||
|
||||
@ -1470,7 +1470,7 @@ int Awk::dispatch_function (Run* run, const fnc_info_t* fi)
|
||||
"Do NOT change the run field from function handler");
|
||||
|
||||
val_t* v = qse_awk_rtx_getarg (run->rtx, i);
|
||||
if (qse_awk_rtx_getvaltype (run->rtx, v) == QSE_AWK_VAL_REF)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (run->rtx, v) == QSE_AWK_VAL_REF)
|
||||
{
|
||||
if (qse_awk_rtx_setrefval (run->rtx, (qse_awk_val_ref_t*)v, args[i].toVal()) <= -1)
|
||||
{
|
||||
|
@ -843,7 +843,7 @@ int StdAwk::open_console_in (Console& io)
|
||||
*/
|
||||
argv = qse_awk_rtx_getgbl (rtx, this->gbl_argv);
|
||||
QSE_ASSERT (argv != QSE_NULL);
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, argv) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, argv) == QSE_AWK_VAL_MAP);
|
||||
|
||||
map = ((qse_awk_val_map_t*)argv)->map;
|
||||
QSE_ASSERT (map != QSE_NULL);
|
||||
|
@ -508,7 +508,7 @@ int qse_awk_fnc_length (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
else
|
||||
{
|
||||
v = qse_awk_rtx_getarg (rtx, 0);
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
|
||||
if (vtype == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
@ -622,7 +622,7 @@ int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
a1 = qse_awk_rtx_getarg (rtx, 1);
|
||||
a2 = (nargs >= 3)? qse_awk_rtx_getarg (rtx, 2): QSE_NULL;
|
||||
|
||||
a1_vtype = qse_awk_rtx_getvaltype (rtx, a1);
|
||||
a1_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, a1);
|
||||
|
||||
QSE_ASSERT (a1_vtype == QSE_AWK_VAL_REF);
|
||||
|
||||
@ -646,7 +646,7 @@ int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
{
|
||||
/* get the value from FS */
|
||||
t1 = qse_awk_rtx_getgbl (rtx, QSE_AWK_GBL_FS);
|
||||
t1_vtype = qse_awk_rtx_getvaltype (rtx, t1);
|
||||
t1_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, t1);
|
||||
if (t1_vtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
fs.ptr = QSE_T(" ");
|
||||
@ -668,7 +668,7 @@ int qse_awk_fnc_split (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
}
|
||||
else
|
||||
{
|
||||
a2_vtype = qse_awk_rtx_getvaltype (rtx, a2);
|
||||
a2_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, a2);
|
||||
|
||||
if (a2_vtype == QSE_AWK_VAL_REX)
|
||||
{
|
||||
@ -904,8 +904,8 @@ static int __substitute (qse_awk_rtx_t* rtx, qse_awk_int_t max_count)
|
||||
a1 = qse_awk_rtx_getarg (rtx, 1);
|
||||
a2 = (nargs >= 3)? qse_awk_rtx_getarg (rtx, 2): QSE_NULL;
|
||||
|
||||
a0_vtype = qse_awk_rtx_getvaltype (rtx, a0);
|
||||
QSE_ASSERT (a2 == QSE_NULL || qse_awk_rtx_getvaltype(rtx, a2) == QSE_AWK_VAL_REF);
|
||||
a0_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, a0);
|
||||
QSE_ASSERT (a2 == QSE_NULL || QSE_AWK_RTX_GETVALTYPE(rtx, a2) == QSE_AWK_VAL_REF);
|
||||
|
||||
if (a0_vtype == QSE_AWK_VAL_REX)
|
||||
{
|
||||
|
@ -1298,7 +1298,7 @@ int qse_awk_rtx_matchrex (
|
||||
|
||||
icase = rtx->gbl.ignorecase;
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, val) == QSE_AWK_VAL_REX)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, val) == QSE_AWK_VAL_REX)
|
||||
{
|
||||
code = ((qse_awk_val_rex_t*)val)->code[icase];
|
||||
}
|
||||
@ -1335,7 +1335,7 @@ int qse_awk_rtx_matchrex (
|
||||
if (x <= -1) qse_awk_rtx_seterrnum (rtx, awkerr, QSE_NULL);
|
||||
#endif
|
||||
|
||||
if (qse_awk_rtx_getvaltype(rtx, val) == QSE_AWK_VAL_REX)
|
||||
if (QSE_AWK_RTX_GETVALTYPE(rtx, val) == QSE_AWK_VAL_REX)
|
||||
{
|
||||
/* nothing to free */
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ int qse_awk_rtx_setrec (
|
||||
return -1;
|
||||
}
|
||||
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (run, run->inrec.d0) == QSE_AWK_VAL_NIL);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (run, run->inrec.d0) == QSE_AWK_VAL_NIL);
|
||||
/* d0 should be cleared before the next line is reached
|
||||
* as it doesn't call qse_awk_rtx_refdownval on run->inrec.d0 */
|
||||
run->inrec.d0 = v;
|
||||
@ -110,7 +110,7 @@ static int split_record (qse_awk_rtx_t* rtx)
|
||||
|
||||
/* get FS */
|
||||
fs = qse_awk_rtx_getgbl (rtx, QSE_AWK_GBL_FS);
|
||||
fsvtype = qse_awk_rtx_getvaltype (rtx, fs);
|
||||
fsvtype = QSE_AWK_RTX_GETVALTYPE (rtx, fs);
|
||||
if (fsvtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
fs_ptr = QSE_T(" ");
|
||||
@ -509,9 +509,9 @@ static int recomp_record_fields (
|
||||
}
|
||||
|
||||
v = qse_awk_rtx_getgbl (run, QSE_AWK_GBL_NF);
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, v) == QSE_AWK_VAL_INT);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, v) == QSE_AWK_VAL_INT);
|
||||
|
||||
if (qse_awk_rtx_getintfromval (rtx, v)!= max)
|
||||
if (QSE_AWK_RTX_GETINTFROMVAL (rtx, v)!= max)
|
||||
{
|
||||
v = qse_awk_rtx_makeintval (run, (qse_awk_int_t)max);
|
||||
if (v == QSE_NULL) return -1;
|
||||
|
@ -197,7 +197,7 @@ static QSE_INLINE int resolve_rs (
|
||||
qse_awk_val_type_t rs_vtype;
|
||||
|
||||
|
||||
rs_vtype = qse_awk_rtx_getvaltype (rtx, rs);
|
||||
rs_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, rs);
|
||||
|
||||
switch (rs_vtype)
|
||||
{
|
||||
@ -627,7 +627,7 @@ int qse_awk_rtx_readio (
|
||||
}
|
||||
}
|
||||
|
||||
if (rrs.ptr && qse_awk_rtx_getvaltype (rtx, rs) != QSE_AWK_VAL_STR)
|
||||
if (rrs.ptr && QSE_AWK_RTX_GETVALTYPE (rtx, rs) != QSE_AWK_VAL_STR)
|
||||
QSE_AWK_FREE (run->awk, rrs.ptr);
|
||||
qse_awk_rtx_refdownval (run, rs);
|
||||
|
||||
@ -644,7 +644,7 @@ int qse_awk_rtx_writeio_val (
|
||||
qse_awk_val_type_t vtype;
|
||||
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (run, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (run, v);
|
||||
|
||||
if (vtype == QSE_AWK_VAL_STR)
|
||||
{
|
||||
|
@ -296,8 +296,8 @@ static int set_global (
|
||||
|
||||
old = RTX_STACK_GBL (rtx, idx);
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
old_vtype = qse_awk_rtx_getvaltype (rtx, old);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
old_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, old);
|
||||
|
||||
if (!(rtx->awk->opt.trait & QSE_AWK_FLEXMAP))
|
||||
{
|
||||
@ -480,9 +480,9 @@ static int set_global (
|
||||
|
||||
case QSE_AWK_GBL_IGNORECASE:
|
||||
{
|
||||
qse_awk_val_type_t vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
qse_awk_val_type_t vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
rtx->gbl.ignorecase =
|
||||
((vtype == QSE_AWK_VAL_INT && qse_awk_rtx_getintfromval (rtx,val) != 0) ||
|
||||
((vtype == QSE_AWK_VAL_INT && QSE_AWK_RTX_GETINTFROMVAL (rtx,val) != 0) ||
|
||||
(vtype == QSE_AWK_VAL_FLT && ((qse_awk_val_flt_t*)val)->val != 0.0) ||
|
||||
(vtype == QSE_AWK_VAL_STR && ((qse_awk_val_str_t*)val)->val.len != 0))? 1: 0;
|
||||
break;
|
||||
@ -2303,7 +2303,7 @@ static int run_foreach (qse_awk_rtx_t* rtx, qse_awk_nde_foreach_t* nde)
|
||||
if (rv == QSE_NULL) return -1;
|
||||
|
||||
qse_awk_rtx_refupval (rtx, rv);
|
||||
rvtype = qse_awk_rtx_getvaltype (rtx, rv);
|
||||
rvtype = QSE_AWK_RTX_GETVALTYPE (rtx, rv);
|
||||
if (rvtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
/* just return without excuting the loop body */
|
||||
@ -2355,7 +2355,7 @@ static int run_return (qse_awk_rtx_t* rtx, qse_awk_nde_return_t* nde)
|
||||
|
||||
if (!(rtx->awk->opt.trait & QSE_AWK_FLEXMAP))
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype (rtx, val) == QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, val) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* cannot return a map */
|
||||
qse_awk_rtx_refupval (rtx, val);
|
||||
@ -2506,7 +2506,7 @@ static int delete_indexed (
|
||||
|
||||
qse_awk_rtx_refupval (rtx, idx);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, idx) == QSE_AWK_VAL_STR)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, idx) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
/* delete x["abc"] */
|
||||
|
||||
@ -2605,7 +2605,7 @@ static int run_delete_named (qse_awk_rtx_t* rtx, qse_awk_nde_var_t* var)
|
||||
val = (qse_awk_val_t*)QSE_HTB_VPTR(pair);
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, val) != QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, val) != QSE_AWK_VAL_MAP)
|
||||
{
|
||||
SETERR_ARGX_LOC (
|
||||
rtx, QSE_AWK_ENOTDEL,
|
||||
@ -2654,7 +2654,7 @@ static int run_delete_unnamed (qse_awk_rtx_t* rtx, qse_awk_nde_var_t* var)
|
||||
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
if (vtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
qse_awk_val_t* tmp;
|
||||
@ -2801,7 +2801,7 @@ static int reset_variable (qse_awk_rtx_t* rtx, qse_awk_nde_var_t* var)
|
||||
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, val) != QSE_AWK_VAL_NIL)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, val) != QSE_AWK_VAL_NIL)
|
||||
{
|
||||
qse_awk_rtx_refdownval (rtx, val);
|
||||
switch (var->type)
|
||||
@ -3109,7 +3109,7 @@ static int run_printf (qse_awk_rtx_t* rtx, qse_awk_nde_print_t* nde)
|
||||
}
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
if (qse_awk_rtx_getvaltype (rtx, v) != QSE_AWK_VAL_STR)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, v) != QSE_AWK_VAL_STR)
|
||||
{
|
||||
/* the remaining arguments are ignored as the format cannot
|
||||
* contain any % characters */
|
||||
@ -3218,7 +3218,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
v = eval_expression0 (rtx, nde);
|
||||
if (v == QSE_NULL) return QSE_NULL;
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, v) == QSE_AWK_VAL_REX)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, v) == QSE_AWK_VAL_REX)
|
||||
{
|
||||
qse_cstr_t vs;
|
||||
|
||||
@ -3229,7 +3229,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
*/
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
|
||||
if (qse_awk_rtx_getvaltype (rtx, rtx->inrec.d0) == QSE_AWK_VAL_NIL)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, rtx->inrec.d0) == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
/* the record has never been read.
|
||||
* probably, this function has been triggered
|
||||
@ -3240,7 +3240,7 @@ static qse_awk_val_t* eval_expression (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
else
|
||||
{
|
||||
QSE_ASSERTX (
|
||||
qse_awk_rtx_getvaltype(rtx, rtx->inrec.d0) == QSE_AWK_VAL_STR,
|
||||
QSE_AWK_RTX_GETVALTYPE(rtx, rtx->inrec.d0) == QSE_AWK_VAL_STR,
|
||||
"the internal value representing $0 should always be of the string type once it has been set/updated. it is nil initially.");
|
||||
|
||||
vs.ptr = ((qse_awk_val_str_t*)rtx->inrec.d0)->val.ptr;
|
||||
@ -3456,7 +3456,7 @@ static qse_awk_val_t* do_assignment (
|
||||
case QSE_AWK_NDE_GBLIDX:
|
||||
case QSE_AWK_NDE_LCLIDX:
|
||||
case QSE_AWK_NDE_ARGIDX:
|
||||
if (qse_awk_rtx_getvaltype(rtx, val) == QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE(rtx, val) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* a map cannot become a member of a map */
|
||||
errnum = QSE_AWK_EMAPTOIDX;
|
||||
@ -3467,7 +3467,7 @@ static qse_awk_val_t* do_assignment (
|
||||
break;
|
||||
|
||||
case QSE_AWK_NDE_POS:
|
||||
if (qse_awk_rtx_getvaltype(rtx, val) == QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE(rtx, val) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* a map cannot be assigned to a positional */
|
||||
errnum = QSE_AWK_EMAPTOPOS;
|
||||
@ -3503,7 +3503,7 @@ static qse_awk_val_t* do_assignment_nonidx (
|
||||
);
|
||||
|
||||
QSE_ASSERT (var->idx == QSE_NULL);
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
|
||||
switch (var->type)
|
||||
{
|
||||
@ -3515,7 +3515,7 @@ static qse_awk_val_t* do_assignment_nonidx (
|
||||
|
||||
if (!(run->awk->opt.trait & QSE_AWK_FLEXMAP))
|
||||
{
|
||||
if (pair && qse_awk_rtx_getvaltype (rtx, (qse_awk_val_t*)QSE_HTB_VPTR(pair)) == QSE_AWK_VAL_MAP)
|
||||
if (pair && QSE_AWK_RTX_GETVALTYPE (rtx, (qse_awk_val_t*)QSE_HTB_VPTR(pair)) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* old value is a map - it can only be accessed through indexing. */
|
||||
qse_awk_errnum_t errnum;
|
||||
@ -3560,7 +3560,7 @@ static qse_awk_val_t* do_assignment_nonidx (
|
||||
|
||||
if (!(run->awk->opt.trait & QSE_AWK_FLEXMAP))
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype (rtx, old) == QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, old) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* old value is a map - it can only be accessed through indexing. */
|
||||
qse_awk_errnum_t errnum;
|
||||
@ -3589,7 +3589,7 @@ static qse_awk_val_t* do_assignment_nonidx (
|
||||
|
||||
if (!(run->awk->opt.trait & QSE_AWK_FLEXMAP))
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype (rtx, old) == QSE_AWK_VAL_MAP)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, old) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* old value is a map - it can only be accessed through indexing. */
|
||||
qse_awk_errnum_t errnum;
|
||||
@ -3631,7 +3631,7 @@ static qse_awk_val_t* do_assignment_idx (
|
||||
var->type == QSE_AWK_NDE_GBLIDX ||
|
||||
var->type == QSE_AWK_NDE_LCLIDX ||
|
||||
var->type == QSE_AWK_NDE_ARGIDX) && var->idx != QSE_NULL);
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, val) != QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, val) != QSE_AWK_VAL_MAP);
|
||||
|
||||
retry:
|
||||
switch (var->type)
|
||||
@ -3660,7 +3660,7 @@ retry:
|
||||
break;
|
||||
}
|
||||
|
||||
mvtype = qse_awk_rtx_getvaltype (rtx, map);
|
||||
mvtype = QSE_AWK_RTX_GETVALTYPE (rtx, map);
|
||||
if (mvtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
qse_awk_val_t* tmp;
|
||||
@ -3797,7 +3797,7 @@ static qse_awk_val_t* do_assignment_pos (
|
||||
return QSE_NULL;
|
||||
}
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
if (vtype == QSE_AWK_VAL_STR)
|
||||
{
|
||||
str = ((qse_awk_val_str_t*)val)->val;
|
||||
@ -4072,7 +4072,7 @@ static qse_awk_val_t* eval_binop_in (
|
||||
|
||||
qse_awk_rtx_refupval (run, rv);
|
||||
|
||||
rvtype = qse_awk_rtx_getvaltype (run, rv);
|
||||
rvtype = QSE_AWK_RTX_GETVALTYPE (run, rv);
|
||||
if (rvtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
if (str != idxbuf) QSE_AWK_FREE (run->awk, str);
|
||||
@ -4155,7 +4155,7 @@ static int __cmp_nil_nil (
|
||||
static int __cmp_nil_int (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_awk_int_t v = qse_awk_rtx_getintfromval (rtx, right);
|
||||
qse_awk_int_t v = QSE_AWK_RTX_GETINTFROMVAL (rtx, right);
|
||||
return (v < 0)? 1: ((v > 0)? -1: 0);
|
||||
}
|
||||
|
||||
@ -4176,7 +4176,7 @@ static int __cmp_nil_str (
|
||||
static int __cmp_int_nil (
|
||||
qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_awk_int_t v = qse_awk_rtx_getintfromval (rtx, left);
|
||||
qse_awk_int_t v = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
return (v > 0)? 1: ((v < 0)? -1: 0);
|
||||
}
|
||||
|
||||
@ -4184,15 +4184,15 @@ static int __cmp_int_int (
|
||||
qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
|
||||
qse_awk_int_t v1 = qse_awk_rtx_getintfromval (rtx, left);
|
||||
qse_awk_int_t v2 = qse_awk_rtx_getintfromval (rtx, right);
|
||||
qse_awk_int_t v1 = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
qse_awk_int_t v2 = QSE_AWK_RTX_GETINTFROMVAL (rtx, right);
|
||||
return (v1 > v2)? 1: ((v1 < v2)? -1: 0);
|
||||
}
|
||||
|
||||
static int __cmp_int_real (
|
||||
qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_awk_int_t v1 = qse_awk_rtx_getintfromval (rtx, left);
|
||||
qse_awk_int_t v1 = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
if (v1 > ((qse_awk_val_flt_t*)right)->val) return 1;
|
||||
if (v1 < ((qse_awk_val_flt_t*)right)->val) return -1;
|
||||
return 0;
|
||||
@ -4217,7 +4217,7 @@ static int __cmp_int_str (
|
||||
&ll, &rr
|
||||
);
|
||||
|
||||
v1 = qse_awk_rtx_getintfromval (rtx, left);
|
||||
v1 = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
if (n == 0)
|
||||
{
|
||||
/* a numeric integral string */
|
||||
@ -4267,7 +4267,7 @@ static int __cmp_flt_nil (
|
||||
static int __cmp_flt_int (
|
||||
qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right)
|
||||
{
|
||||
qse_awk_int_t v2 = qse_awk_rtx_getintfromval (rtx, right);
|
||||
qse_awk_int_t v2 = QSE_AWK_RTX_GETINTFROMVAL (rtx, right);
|
||||
if (((qse_awk_val_flt_t*)left)->val > v2) return 1;
|
||||
if (((qse_awk_val_flt_t*)left)->val < v2) return -1;
|
||||
return 0;
|
||||
@ -4449,8 +4449,8 @@ static int __cmp_val (
|
||||
__cmp_str_nil, __cmp_str_int, __cmp_str_real, __cmp_str_str,
|
||||
};
|
||||
|
||||
lvtype = qse_awk_rtx_getvaltype(rtx, left);
|
||||
rvtype = qse_awk_rtx_getvaltype(rtx, right);
|
||||
lvtype = QSE_AWK_RTX_GETVALTYPE(rtx, left);
|
||||
rvtype = QSE_AWK_RTX_GETVALTYPE(rtx, right);
|
||||
if (lvtype == QSE_AWK_VAL_MAP || rvtype == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* TODO: get the map size and use it for comparison */
|
||||
@ -4473,8 +4473,8 @@ static int teq_val (qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* righ
|
||||
if (left == right) n = 1;
|
||||
else
|
||||
{
|
||||
lt = qse_awk_rtx_getvaltype (rtx, left);
|
||||
rt = qse_awk_rtx_getvaltype (rtx, right);
|
||||
lt = QSE_AWK_RTX_GETVALTYPE (rtx, left);
|
||||
rt = QSE_AWK_RTX_GETVALTYPE (rtx, right);
|
||||
|
||||
if (lt != rt) n = 0;
|
||||
else
|
||||
@ -4486,8 +4486,8 @@ static int teq_val (qse_awk_rtx_t* rtx, qse_awk_val_t* left, qse_awk_val_t* righ
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
n = (qse_awk_rtx_getintfromval (rtx, left) ==
|
||||
qse_awk_rtx_getintfromval (rtx, right));
|
||||
n = (QSE_AWK_RTX_GETINTFROMVAL (rtx, left) ==
|
||||
QSE_AWK_RTX_GETINTFROMVAL (rtx, right));
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_FLT:
|
||||
@ -5094,7 +5094,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
break;
|
||||
|
||||
case QSE_AWK_UNROP_LNOT:
|
||||
if (qse_awk_rtx_getvaltype (rtx, left) == QSE_AWK_VAL_STR)
|
||||
if (QSE_AWK_RTX_GETVALTYPE (rtx, left) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
/* 0 if the string length is greater than 0.
|
||||
* 1 if it's empty */
|
||||
@ -5129,7 +5129,7 @@ static qse_awk_val_t* eval_unary (qse_awk_rtx_t* run, qse_awk_nde_t* nde)
|
||||
case QSE_AWK_UNROP_DEF:
|
||||
/* is defined? */
|
||||
res = qse_awk_rtx_makeintval (
|
||||
run, ((qse_awk_rtx_getvaltype (rtx, left) == QSE_AWK_VAL_NIL)? 0: 1));
|
||||
run, ((QSE_AWK_RTX_GETVALTYPE (rtx, left) == QSE_AWK_VAL_NIL)? 0: 1));
|
||||
break;
|
||||
}
|
||||
|
||||
@ -5183,13 +5183,13 @@ static qse_awk_val_t* eval_incpre (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
if (left == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_awk_rtx_refupval (rtx, left);
|
||||
left_vtype = qse_awk_rtx_getvaltype (rtx, left);
|
||||
left_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, left);
|
||||
|
||||
switch (left_vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_INT:
|
||||
{
|
||||
qse_awk_int_t r = qse_awk_rtx_getintfromval (rtx, left);
|
||||
qse_awk_int_t r = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
res = qse_awk_rtx_makeintval (rtx, r + inc_val_int);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -5303,13 +5303,13 @@ static qse_awk_val_t* eval_incpst (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
|
||||
qse_awk_rtx_refupval (rtx, left);
|
||||
|
||||
left_vtype = qse_awk_rtx_getvaltype (rtx, left);
|
||||
left_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, left);
|
||||
|
||||
switch (left_vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_INT:
|
||||
{
|
||||
qse_awk_int_t r = qse_awk_rtx_getintfromval (rtx, left);
|
||||
qse_awk_int_t r = QSE_AWK_RTX_GETINTFROMVAL (rtx, left);
|
||||
res = qse_awk_rtx_makeintval (rtx, r);
|
||||
if (res == QSE_NULL)
|
||||
{
|
||||
@ -6025,7 +6025,7 @@ static qse_awk_val_t** get_reference_indexed (
|
||||
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, *val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, *val);
|
||||
if (vtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
qse_awk_val_t* tmp;
|
||||
@ -6159,7 +6159,7 @@ static qse_awk_val_t* eval_indexed (
|
||||
|
||||
QSE_ASSERT (val != QSE_NULL);
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (run, *val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (run, *val);
|
||||
if (vtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
qse_awk_val_t* tmp;
|
||||
@ -6292,7 +6292,7 @@ static qse_awk_val_t* eval_getline (qse_awk_rtx_t* rtx, qse_awk_nde_t* nde)
|
||||
if (v == QSE_NULL) return QSE_NULL;
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
if (vtype == QSE_AWK_VAL_STR)
|
||||
{
|
||||
dst = ((qse_awk_val_str_t*)v)->val.ptr;
|
||||
@ -6504,7 +6504,7 @@ static int shorten_record (qse_awk_rtx_t* run, qse_size_t nflds)
|
||||
{
|
||||
v = RTX_STACK_GBL(run, QSE_AWK_GBL_OFS);
|
||||
qse_awk_rtx_refupval (run, v);
|
||||
vtype = qse_awk_rtx_getvaltype (run, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (run, v);
|
||||
|
||||
if (vtype == QSE_AWK_VAL_NIL)
|
||||
{
|
||||
@ -7255,7 +7255,7 @@ wp_mod_main:
|
||||
}
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
switch (vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_NIL:
|
||||
@ -7264,7 +7264,7 @@ wp_mod_main:
|
||||
break;
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
ch = (qse_char_t)qse_awk_rtx_getintfromval (rtx, v);
|
||||
ch = (qse_char_t)QSE_AWK_RTX_GETINTFROMVAL (rtx, v);
|
||||
ch_len = 1;
|
||||
break;
|
||||
|
||||
@ -7375,7 +7375,7 @@ wp_mod_main:
|
||||
|
||||
qse_awk_rtx_refupval (rtx, v);
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
switch (vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_NIL:
|
||||
|
@ -1392,7 +1392,7 @@ static int open_rio_console (qse_awk_rtx_t* rtx, qse_awk_rio_arg_t* riod)
|
||||
*/
|
||||
argv = qse_awk_rtx_getgbl (rtx, xtn->gbl_argv);
|
||||
QSE_ASSERT (argv != QSE_NULL);
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, argv) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, argv) == QSE_AWK_VAL_MAP);
|
||||
|
||||
map = ((qse_awk_val_map_t*)argv)->map;
|
||||
QSE_ASSERT (map != QSE_NULL);
|
||||
|
@ -658,7 +658,7 @@ qse_awk_val_t* qse_awk_rtx_setmapvalfld (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* map,
|
||||
const qse_char_t* kptr, qse_size_t klen, qse_awk_val_t* v)
|
||||
{
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
|
||||
if (qse_htb_upsert (
|
||||
((qse_awk_val_map_t*)map)->map,
|
||||
@ -683,7 +683,7 @@ qse_awk_val_t* qse_awk_rtx_getmapvalfld (
|
||||
{
|
||||
qse_htb_pair_t* pair;
|
||||
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
|
||||
pair = qse_htb_search (((qse_awk_val_map_t*)map)->map, kptr, klen);
|
||||
if (pair == QSE_NULL)
|
||||
@ -704,7 +704,7 @@ qse_awk_val_t* qse_awk_rtx_getmapvalfld (
|
||||
qse_awk_val_map_itr_t* qse_awk_rtx_getfirstmapvalitr (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* map, qse_awk_val_map_itr_t* itr)
|
||||
{
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
|
||||
itr->pair = qse_htb_getfirstpair (((qse_awk_val_map_t*)map)->map, &itr->buckno);
|
||||
return itr->pair? itr: QSE_NULL;
|
||||
@ -713,7 +713,7 @@ qse_awk_val_map_itr_t* qse_awk_rtx_getfirstmapvalitr (
|
||||
qse_awk_val_map_itr_t* qse_awk_rtx_getnextmapvalitr (
|
||||
qse_awk_rtx_t* rtx, qse_awk_val_t* map, qse_awk_val_map_itr_t* itr)
|
||||
{
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, map) == QSE_AWK_VAL_MAP);
|
||||
|
||||
itr->pair = qse_htb_getnextpair (((qse_awk_val_map_t*)map)->map, itr->pair, &itr->buckno);
|
||||
return itr->pair? itr: QSE_NULL;
|
||||
@ -772,6 +772,17 @@ int QSE_INLINE qse_awk_rtx_isstaticval (qse_awk_rtx_t* rtx, qse_awk_val_t* val)
|
||||
return IS_REAL_POINTER(val) && IS_STATICVAL(val);
|
||||
}
|
||||
|
||||
int qse_awk_rtx_getvaltype (qse_awk_rtx_t* rtx, qse_awk_val_t* val)
|
||||
{
|
||||
return QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
}
|
||||
|
||||
|
||||
int qse_awk_rtx_getintfromval (qse_awk_rtx_t* rtx, qse_awk_val_t* val)
|
||||
{
|
||||
return QSE_AWK_RTX_GETINTFROMVAL (rtx, val);
|
||||
}
|
||||
|
||||
void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
|
||||
{
|
||||
qse_awk_val_type_t vtype;
|
||||
@ -786,7 +797,7 @@ void qse_awk_rtx_freeval (qse_awk_rtx_t* rtx, qse_awk_val_t* val, int cache)
|
||||
qse_errputstrf (QSE_T("\n"));
|
||||
#endif
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
switch (vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_NIL:
|
||||
@ -968,7 +979,7 @@ static int val_ref_to_bool (qse_awk_rtx_t* rtx, const qse_awk_val_ref_t* ref)
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in QSEAWK */
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, *xref)!= QSE_AWK_VAL_REF);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, *xref)!= QSE_AWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return qse_awk_rtx_valtobool (rtx, *xref);
|
||||
@ -982,13 +993,13 @@ int qse_awk_rtx_valtobool (qse_awk_rtx_t* rtx, const qse_awk_val_t* val)
|
||||
|
||||
if (val == QSE_NULL) return 0;
|
||||
|
||||
vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
switch (vtype)
|
||||
{
|
||||
case QSE_AWK_VAL_NIL:
|
||||
return 0;
|
||||
case QSE_AWK_VAL_INT:
|
||||
return qse_awk_rtx_getintfromval (rtx, val) != 0;
|
||||
return QSE_AWK_RTX_GETINTFROMVAL (rtx, val) != 0;
|
||||
case QSE_AWK_VAL_FLT:
|
||||
return ((qse_awk_val_flt_t*)val)->val != 0.0;
|
||||
case QSE_AWK_VAL_STR:
|
||||
@ -1092,7 +1103,7 @@ static int val_int_to_str (
|
||||
qse_char_t* tmp;
|
||||
qse_size_t rlen = 0;
|
||||
int type = out->type & ~QSE_AWK_RTX_VALTOSTR_PRINT;
|
||||
qse_awk_int_t orgval = qse_awk_rtx_getintfromval (rtx, v);
|
||||
qse_awk_int_t orgval = QSE_AWK_RTX_GETINTFROMVAL (rtx, v);
|
||||
qse_awk_uint_t t;
|
||||
|
||||
if (orgval == 0) rlen++;
|
||||
@ -1375,7 +1386,7 @@ static int val_ref_to_str (
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in QSEAWK */
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, *xref) != QSE_AWK_VAL_REF);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, *xref) != QSE_AWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return qse_awk_rtx_valtostr (rtx, *xref, out);
|
||||
@ -1387,7 +1398,7 @@ int qse_awk_rtx_valtostr (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v,
|
||||
qse_awk_rtx_valtostr_out_t* out)
|
||||
{
|
||||
qse_awk_val_type_t vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
qse_awk_val_type_t vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
|
||||
switch (vtype)
|
||||
{
|
||||
@ -1504,7 +1515,7 @@ qse_wchar_t* qse_awk_rtx_valtowcsdup (
|
||||
qse_char_t* qse_awk_rtx_getvalstr (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_size_t* len)
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype(rtx, v) == QSE_AWK_VAL_STR)
|
||||
if (QSE_AWK_RTX_GETVALTYPE(rtx, v) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
if (len) *len = ((qse_awk_val_str_t*)v)->val.len;
|
||||
return ((qse_awk_val_str_t*)v)->val.ptr;
|
||||
@ -1518,7 +1529,7 @@ qse_char_t* qse_awk_rtx_getvalstr (
|
||||
void qse_awk_rtx_freevalstr (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_char_t* str)
|
||||
{
|
||||
if (qse_awk_rtx_getvaltype(rtx, v) != QSE_AWK_VAL_STR ||
|
||||
if (QSE_AWK_RTX_GETVALTYPE(rtx, v) != QSE_AWK_VAL_STR ||
|
||||
str != ((qse_awk_val_str_t*)v)->val.ptr)
|
||||
{
|
||||
qse_awk_rtx_freemem (rtx, str);
|
||||
@ -1574,7 +1585,7 @@ static int val_ref_to_num (
|
||||
/* A reference value is not able to point to another
|
||||
* refernce value for the way values are represented
|
||||
* in QSEAWK */
|
||||
QSE_ASSERT (qse_awk_rtx_getvaltype (rtx, *xref) != QSE_AWK_VAL_REF);
|
||||
QSE_ASSERT (QSE_AWK_RTX_GETVALTYPE (rtx, *xref) != QSE_AWK_VAL_REF);
|
||||
|
||||
/* make a recursive call back to the caller */
|
||||
return qse_awk_rtx_valtonum (rtx, *xref, l, r);
|
||||
@ -1586,7 +1597,7 @@ static int val_ref_to_num (
|
||||
int qse_awk_rtx_valtonum (
|
||||
qse_awk_rtx_t* rtx, const qse_awk_val_t* v, qse_awk_int_t* l, qse_awk_flt_t* r)
|
||||
{
|
||||
qse_awk_val_type_t vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
qse_awk_val_type_t vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
|
||||
switch (vtype)
|
||||
{
|
||||
@ -1598,7 +1609,7 @@ int qse_awk_rtx_valtonum (
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
{
|
||||
*l = qse_awk_rtx_getintfromval (rtx, v);
|
||||
*l = QSE_AWK_RTX_GETINTFROMVAL (rtx, v);
|
||||
return 0; /* long */
|
||||
}
|
||||
|
||||
@ -1704,7 +1715,7 @@ static qse_awk_uint_t hash (qse_uint8_t* ptr, qse_size_t len)
|
||||
|
||||
qse_awk_int_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
{
|
||||
qse_awk_val_type_t vtype = qse_awk_rtx_getvaltype (rtx, v);
|
||||
qse_awk_val_type_t vtype = QSE_AWK_RTX_GETVALTYPE (rtx, v);
|
||||
qse_awk_int_t hv;
|
||||
|
||||
switch (vtype)
|
||||
@ -1715,7 +1726,7 @@ qse_awk_int_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
|
||||
case QSE_AWK_VAL_INT:
|
||||
{
|
||||
qse_awk_int_t tmp = qse_awk_rtx_getintfromval (rtx, v);
|
||||
qse_awk_int_t tmp = QSE_AWK_RTX_GETINTFROMVAL (rtx, v);
|
||||
/*hv = ((qse_awk_val_int_t*)v)->val;*/
|
||||
hv = (qse_awk_int_t)hash ((qse_uint8_t*)&tmp, QSE_SIZEOF(tmp));
|
||||
break;
|
||||
@ -1751,7 +1762,7 @@ qse_awk_int_t qse_awk_rtx_hashval (qse_awk_rtx_t* rtx, qse_awk_val_t* v)
|
||||
|
||||
int qse_awk_rtx_setrefval (qse_awk_rtx_t* rtx, qse_awk_val_ref_t* ref, qse_awk_val_t* val)
|
||||
{
|
||||
qse_awk_val_type_t vtype = qse_awk_rtx_getvaltype (rtx, val);
|
||||
qse_awk_val_type_t vtype = QSE_AWK_RTX_GETVALTYPE (rtx, val);
|
||||
|
||||
if (vtype == QSE_AWK_VAL_REX || vtype == QSE_AWK_VAL_REF)
|
||||
{
|
||||
@ -1830,7 +1841,7 @@ int qse_awk_rtx_setrefval (qse_awk_rtx_t* rtx, qse_awk_val_ref_t* ref, qse_awk_v
|
||||
qse_awk_val_type_t rref_vtype;
|
||||
|
||||
rref = (qse_awk_val_t**)ref->adr; /* old value pointer */
|
||||
rref_vtype = qse_awk_rtx_getvaltype (rtx, *rref); /* old value type */
|
||||
rref_vtype = QSE_AWK_RTX_GETVALTYPE (rtx, *rref); /* old value type */
|
||||
if (vtype == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* new value: map, old value: nil or map => ok */
|
||||
|
@ -102,8 +102,8 @@ struct qse_awk_val_rchunk_t
|
||||
* e.g) pointer to uintptr_t, uintptr_t to intptr_t, intptr_t to awk_int_t */
|
||||
#define GET_QUICKINT_FROM_POINTER(p) (((qse_uintptr_t)(p) & VAL_SIGN_BIT)? -(qse_intptr_t)(((qse_uintptr_t)(p) & ~VAL_SIGN_BIT) >> 2): (qse_intptr_t)((qse_uintptr_t)(p) >> 2))
|
||||
|
||||
#define qse_awk_rtx_getvaltype(rtx,p) (IS_QUICKINT_POINTER(p)? QSE_AWK_VAL_INT: (p)->v_type)
|
||||
#define qse_awk_rtx_getintfromval(rtx,p) ((IS_QUICKINT_POINTER(p)? (qse_awk_int_t)GET_QUICKINT_FROM_POINTER(p): ((qse_awk_val_int_t*)(p))->i_val))
|
||||
#define QSE_AWK_RTX_GETVALTYPE(rtx,p) (IS_QUICKINT_POINTER(p)? QSE_AWK_VAL_INT: (p)->v_type)
|
||||
#define QSE_AWK_RTX_GETINTFROMVAL(rtx,p) ((IS_QUICKINT_POINTER(p)? (qse_awk_int_t)GET_QUICKINT_FROM_POINTER(p): ((qse_awk_val_int_t*)(p))->i_val))
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
|
@ -86,7 +86,7 @@ static int awk_main (int argc, qse_char_t* argv[])
|
||||
goto oops;
|
||||
}
|
||||
|
||||
if (rtv->type == QSE_AWK_VAL_MAP)
|
||||
if (qse_awk_rtx_getvaltype (rtx, rtv) == QSE_AWK_VAL_MAP)
|
||||
{
|
||||
/* if a returned value is a map,
|
||||
* traverse the map and print the key/value pairs. */
|
||||
|
@ -20,7 +20,7 @@ static int fnc_basename (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
/* get the value of the first parameter */
|
||||
a0 = qse_awk_rtx_getarg (rtx, 0);
|
||||
if (a0->type == QSE_AWK_VAL_STR)
|
||||
if (qse_awk_rtx_getvaltype (rtx, a0) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
/* if it is a string value, don't duplicate the value */
|
||||
ptr = ((qse_awk_val_str_t*)a0)->val.ptr;
|
||||
|
@ -20,7 +20,7 @@ static int fnc_basename (qse_awk_rtx_t* rtx, const qse_awk_fnc_info_t* fi)
|
||||
|
||||
/* get the value of the first parameter */
|
||||
a0 = qse_awk_rtx_getarg (rtx, 0);
|
||||
if (a0->type == QSE_AWK_VAL_STR)
|
||||
if (qse_awk_rtx_getvaltype (rtx, a0) == QSE_AWK_VAL_STR)
|
||||
{
|
||||
/* if it is a string value, don't duplicate the value */
|
||||
ptr = ((qse_awk_val_str_t*)a0)->val.ptr;
|
||||
|
Loading…
Reference in New Issue
Block a user