partially renamed functions related to a runtime context

This commit is contained in:
hyung-hwan 2009-01-31 22:03:05 +00:00
parent 987e709021
commit b9c02b48bc
13 changed files with 333 additions and 248 deletions

View File

@ -296,6 +296,7 @@ protected:
Source::Mode mode = io.getMode(); Source::Mode mode = io.getMode();
FILE* fp = QSE_NULL; FILE* fp = QSE_NULL;
// TODO: use sio instead of stdio
if (mode == Source::READ) if (mode == Source::READ)
{ {
if (srcInName == QSE_NULL) if (srcInName == QSE_NULL)
@ -708,7 +709,7 @@ static struct
{ QSE_T("bxor"), TestAwk::OPT_BXOR }, { QSE_T("bxor"), TestAwk::OPT_BXOR },
{ QSE_T("shift"), TestAwk::OPT_SHIFT }, { QSE_T("shift"), TestAwk::OPT_SHIFT },
{ QSE_T("idiv"), TestAwk::OPT_IDIV }, { QSE_T("idiv"), TestAwk::OPT_IDIV },
{ QSE_T("extio"), TestAwk::OPT_EXTIO }, { QSE_T("eio"), TestAwk::OPT_EIO },
{ QSE_T("rwpipe"), TestAwk::OPT_RWPIPE }, { QSE_T("rwpipe"), TestAwk::OPT_RWPIPE },
{ QSE_T("newline"), TestAwk::OPT_NEWLINE }, { QSE_T("newline"), TestAwk::OPT_NEWLINE },
{ QSE_T("baseone"), TestAwk::OPT_BASEONE }, { QSE_T("baseone"), TestAwk::OPT_BASEONE },
@ -746,7 +747,7 @@ static void print_usage (const qse_char_t* argv0)
qse_printf (QSE_T("\nYou may specify the following options to change the behavior of the interpreter.\n")); qse_printf (QSE_T("\nYou may specify the following options to change the behavior of the interpreter.\n"));
for (j = 0; j < QSE_COUNTOF(otab); j++) for (j = 0; j < (int)QSE_COUNTOF(otab); j++)
{ {
qse_printf (QSE_T(" -%-20s -no%-20s\n"), otab[j].name, otab[j].name); qse_printf (QSE_T(" -%-20s -no%-20s\n"), otab[j].name, otab[j].name);
} }
@ -794,7 +795,7 @@ static int awk_main (int argc, qse_char_t* argv[])
if (argv[i][1] == QSE_T('n') && argv[i][2] == QSE_T('o')) if (argv[i][1] == QSE_T('n') && argv[i][2] == QSE_T('o'))
{ {
for (j = 0; j < QSE_COUNTOF(otab); j++) for (j = 0; j < (int)QSE_COUNTOF(otab); j++)
{ {
if (qse_strcmp(&argv[i][3], otab[j].name) == 0) if (qse_strcmp(&argv[i][3], otab[j].name) == 0)
{ {
@ -805,7 +806,7 @@ static int awk_main (int argc, qse_char_t* argv[])
} }
else else
{ {
for (j = 0; j < QSE_COUNTOF(otab); j++) for (j = 0; j < (int)QSE_COUNTOF(otab); j++)
{ {
if (qse_strcmp(&argv[i][1], otab[j].name) == 0) if (qse_strcmp(&argv[i][1], otab[j].name) == 0)
{ {

View File

@ -32,7 +32,7 @@
# include <errno.h> # include <errno.h>
#endif #endif
static qse_awk_run_t* app_run = NULL; static qse_awk_rtx_t* app_run = NULL;
static int app_debug = 0; static int app_debug = 0;
struct argout_t struct argout_t
@ -65,7 +65,7 @@ static BOOL WINAPI stop_run (DWORD ctrl_type)
if (ctrl_type == CTRL_C_EVENT || if (ctrl_type == CTRL_C_EVENT ||
ctrl_type == CTRL_CLOSE_EVENT) ctrl_type == CTRL_CLOSE_EVENT)
{ {
qse_awk_stop (app_run); qse_awk_rtx_stop (app_run);
return TRUE; return TRUE;
} }
@ -100,7 +100,7 @@ static int setsignal (int sig, void(*handler)(int), int restart)
static void stop_run (int sig) static void stop_run (int sig)
{ {
int e = errno; int e = errno;
qse_awk_stop (app_run); qse_awk_rtx_stop (app_run);
errno = e; errno = e;
} }
@ -124,7 +124,7 @@ static void unset_intr_run (void)
#endif #endif
} }
static int on_run_start (qse_awk_run_t* run, void* data) static int on_run_start (qse_awk_rtx_t* run, void* data)
{ {
app_run = run; app_run = run;
set_intr_run (); set_intr_run ();
@ -136,7 +136,7 @@ static int on_run_start (qse_awk_run_t* run, void* data)
static qse_map_walk_t print_awk_value ( static qse_map_walk_t print_awk_value (
qse_map_t* map, qse_map_pair_t* pair, void* arg) qse_map_t* map, qse_map_pair_t* pair, void* arg)
{ {
qse_awk_run_t* run = (qse_awk_run_t*)arg; qse_awk_rtx_t* run = (qse_awk_rtx_t*)arg;
qse_char_t* str; qse_char_t* str;
qse_size_t len; qse_size_t len;
@ -150,19 +150,19 @@ static qse_map_walk_t print_awk_value (
dprint (QSE_T("%.*s = %.*s\n"), dprint (QSE_T("%.*s = %.*s\n"),
(int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair), (int)QSE_MAP_KLEN(pair), QSE_MAP_KPTR(pair),
(int)len, str); (int)len, str);
qse_awk_free (qse_awk_getrunawk(run), str); qse_awk_free (qse_awk_rtx_getawk(run), str);
} }
return QSE_MAP_WALK_FORWARD; return QSE_MAP_WALK_FORWARD;
} }
static void on_run_statement ( static void on_run_statement (
qse_awk_run_t* run, qse_size_t line, void* data) qse_awk_rtx_t* run, qse_size_t line, void* data)
{ {
/*dprint (L"running %d\n", (int)line);*/ /*dprint (L"running %d\n", (int)line);*/
} }
static int on_run_enter (qse_awk_run_t* run, void* data) static int on_run_enter (qse_awk_rtx_t* run, void* data)
{ {
struct argout_t* ao = (struct argout_t*)data; struct argout_t* ao = (struct argout_t*)data;
@ -174,7 +174,7 @@ static int on_run_enter (qse_awk_run_t* run, void* data)
if (fs == QSE_NULL) return -1; if (fs == QSE_NULL) return -1;
qse_awk_refupval (run, fs); qse_awk_refupval (run, fs);
qse_awk_setglobal (run, QSE_AWK_GLOBAL_FS, fs); qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_FS, fs);
qse_awk_refdownval (run, fs); qse_awk_refdownval (run, fs);
} }
@ -183,7 +183,7 @@ static int on_run_enter (qse_awk_run_t* run, void* data)
} }
static void on_run_exit ( static void on_run_exit (
qse_awk_run_t* run, qse_awk_val_t* ret, void* data) qse_awk_rtx_t* run, qse_awk_val_t* ret, void* data)
{ {
qse_size_t len; qse_size_t len;
qse_char_t* str; qse_char_t* str;
@ -202,16 +202,16 @@ static void on_run_exit (
else else
{ {
dprint (QSE_T("[RETURN] - [%.*s]\n"), (int)len, str); dprint (QSE_T("[RETURN] - [%.*s]\n"), (int)len, str);
qse_awk_free (qse_awk_getrunawk(run), str); qse_awk_free (qse_awk_rtx_getawk(run), str);
} }
} }
dprint (QSE_T("[NAMED VARIABLES]\n")); dprint (QSE_T("[NAMED VARIABLES]\n"));
qse_map_walk (qse_awk_getrunnvmap(run), print_awk_value, run); qse_map_walk (qse_awk_rtx_getnvmap(run), print_awk_value, run);
dprint (QSE_T("[END NAMED VARIABLES]\n")); dprint (QSE_T("[END NAMED VARIABLES]\n"));
} }
static void on_run_end (qse_awk_run_t* run, int errnum, void* data) static void on_run_end (qse_awk_rtx_t* run, int errnum, void* data)
{ {
if (errnum != QSE_AWK_ENOERR) if (errnum != QSE_AWK_ENOERR)
{ {
@ -239,7 +239,7 @@ static struct
{ QSE_T("bxor"), QSE_AWK_BXOR }, { QSE_T("bxor"), QSE_AWK_BXOR },
{ QSE_T("shift"), QSE_AWK_SHIFT }, { QSE_T("shift"), QSE_AWK_SHIFT },
{ QSE_T("idiv"), QSE_AWK_IDIV }, { QSE_T("idiv"), QSE_AWK_IDIV },
{ QSE_T("extio"), QSE_AWK_EXTIO }, { QSE_T("eio"), QSE_AWK_EIO },
{ QSE_T("rwpipe"), QSE_AWK_RWPIPE }, { QSE_T("rwpipe"), QSE_AWK_RWPIPE },
{ QSE_T("newline"), QSE_AWK_NEWLINE }, { QSE_T("newline"), QSE_AWK_NEWLINE },
{ QSE_T("baseone"), QSE_AWK_BASEONE }, { QSE_T("baseone"), QSE_AWK_BASEONE },
@ -273,7 +273,7 @@ static void print_usage (const qse_char_t* argv0)
} }
static int bfn_sleep ( static int bfn_sleep (
qse_awk_run_t* run, const qse_char_t* fnm, qse_size_t fnl) qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
{ {
qse_size_t nargs; qse_size_t nargs;
qse_awk_val_t* a0; qse_awk_val_t* a0;
@ -282,10 +282,10 @@ static int bfn_sleep (
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
n = qse_awk_valtonum (run, a0, &lv, &rv); n = qse_awk_valtonum (run, a0, &lv, &rv);
if (n == -1) return -1; if (n == -1) return -1;
@ -305,7 +305,7 @@ static int bfn_sleep (
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }

View File

@ -410,7 +410,7 @@ enum qse_awk_eio_mode_t
enum qse_awk_global_id_t enum qse_awk_global_id_t
{ {
/* this table should match gtab in parse.c. /* this table should match gtab in parse.c.
* in addition, qse_awk_setglobal also counts * in addition, qse_awk_rtx_setglobal also counts
* on the order of these values */ * on the order of these values */
QSE_AWK_GLOBAL_ARGC, QSE_AWK_GLOBAL_ARGC,
@ -865,46 +865,94 @@ int qse_awk_runsimple (
); );
/******/ /******/
/** /****f* qse.awk/qse_awk_run
* Executes a parsed program. * NAME
* * qse_awk_run - execute a parsed program
* qse_awk_run returns 0 on success and -1 on failure, generally speaking. * DESCRIPTION
* The qse_awk_run() function returns 0 on success and -1 on failure.
* A runtime context is required for it to start running the program. * A runtime context is required for it to start running the program.
* Once the runtime context is created, the program starts to run. * Once a runtime context is created, the program starts to run.
* The context creation failure is reported by the return value -1 of * The failure of context creation is reported by the return value of -1.
* this function. however, the runtime error after the context creation * However, the runtime error after context creation is reported differently
* is reported differently depending on the use of the callback. * depending on the callbacks specified. When no callback is specified
* When no callback is specified (i.e. runcbs is QSE_NULL), qse_awk_run * (i.e. runcbs is QSE_NULL), the qse_awk_run() function returns -1 on an
* returns -1 on an error and awk->errnum is set accordingly. * error and awk->errnum is set accordingly. If a callback is specified
* However, if a callback is specified (i.e. runcbs is not QSE_NULL), * (i.e. runcbs is not QSE_NULL), the qse_awk_run() returns 0 on both success
* qse_awk_run returns 0 on both success and failure. Instead, the * and failure. Instead, the on_end handler of the callback is triggered with
* on_end handler of the callback is triggered with the relevant * the relevant error number. The third parameter to on_end is the error
* error number. The third parameter to on_end denotes this error number. * number.
* SYNOPSIS
*/ */
int qse_awk_run ( int qse_awk_run (
qse_awk_t* awk, const qse_char_t* main, qse_awk_t* awk,
qse_awk_runios_t* runios, qse_awk_runcbs_t* runcbs, const qse_char_t* main,
const qse_cstr_t* runarg, void* data); qse_awk_runios_t* runios,
qse_awk_runcbs_t* runcbs,
const qse_cstr_t* runarg,
void* data
);
/******/
void qse_awk_stop (qse_awk_rtx_t* run); /****f* qse.awk/qse_awk_shouldstop
void qse_awk_stopall (qse_awk_t* awk);
qse_bool_t qse_awk_isstop (qse_awk_rtx_t* run);
/**
* Gets the number of arguments passed to qse_awk_run
*/
qse_size_t qse_awk_getnargs (qse_awk_rtx_t* run);
/**
* Gets an argument passed to qse_awk_run
*/
qse_awk_val_t* qse_awk_getarg (qse_awk_rtx_t* run, qse_size_t idx);
/****f* qse.awk/qse_awk_getglobal
* NAME * NAME
* qse_awk_getglobal - gets the value of a global variable * qse_awk_rtx_stop - test if qse_awk_rtx_stop() is called
* SYNOPSIS
*/
qse_bool_t qse_awk_rtx_shouldstop (
qse_awk_rtx_t* rtx
);
/******/
/****f* qse.awk/qse_awk_rtx_stop
* NAME
* qse_awk_rtx_stop - stop a runtime context
* DESCRIPTION
* The qse_awk_rtx_stop() function causes the active qse_awk_run() function to
* be aborted.
* SYNOPSIS
*/
void qse_awk_rtx_stop (
qse_awk_rtx_t* rtx
);
/******/
/****f* qse.awk/qse_awk_rtx_stopall
* NAME
* qse_awk_rtx_stop - stop all runtime contexts
* DESCRIPTION
* The qse_awk_rtx_stopall() function aborts all active qse_awk_run() functions
* invoked with the awk parameter.
* SYNOPSIS
*/
void qse_awk_rtx_stopall (
qse_awk_t* awk
);
/******/
/****f* qse.awk/qse_awk_rtx_getnargs
* NAME
* qse_awk_rtx_getnargs - get the number of arguments passed to qse_awk_run()
* SYNOPSIS
*/
qse_size_t qse_awk_rtx_getnargs (
qse_awk_rtx_t* rtx
);
/******/
/****f* qse.awk/qse_awk_rtx_getarg
* NAME
* qse_awk_rtx_getarg - get an argument passed to qse_awk_run
* SYNOPSIS
*/
qse_awk_val_t* qse_awk_rtx_getarg (
qse_awk_rtx_t* rtx,
qse_size_t idx
);
/******/
/****f* qse.awk/qse_awk_rtx_getglobal
* NAME
* qse_awk_rtx_getglobal - gets the value of a global variable
* *
* PARAMETERS * PARAMETERS
* id - A global variable id. An ID is one of the predefined global * id - A global variable id. An ID is one of the predefined global
@ -916,104 +964,125 @@ qse_awk_val_t* qse_awk_getarg (qse_awk_rtx_t* run, qse_size_t idx);
* *
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_val_t* qse_awk_getglobal ( qse_awk_val_t* qse_awk_rtx_getglobal (
qse_awk_rtx_t* run, qse_awk_rtx_t* rtx,
int id int id
); );
/******/ /******/
/****f* qse.awk/qse_awk_setglobal /****f* qse.awk/qse_awk_rtx_setglobal
* NAME * NAME
* qse_awk_setglobal - set the value of a global variable * qse_awk_rtx_setglobal - set the value of a global variable
* *
* SYNOPSIS * SYNOPSIS
*/ */
int qse_awk_setglobal ( int qse_awk_rtx_setglobal (
qse_awk_rtx_t* run, qse_awk_rtx_t* rtx,
int id, int id,
qse_awk_val_t* val qse_awk_val_t* val
); );
/******/ /******/
/****f* qse.awk/qse_awk_setretval /****f* qse.awk/qse_awk_rtx_setretval
* NAME * NAME
* qse_awk_setretval - set the return value * qse_awk_rtx_setretval - set the return value
*
* DESCRIPTION * DESCRIPTION
* The qse_awk_setretval() sets the return value of a function * The qse_awk_rtx_setretval() sets the return value of a function
* when called from within a function handlers. The caller doesn't * when called from within a function handlers. The caller doesn't
* have to invoke qse_awk_refupval() and qse_awk_refdownval() * have to invoke qse_awk_refupval() and qse_awk_refdownval()
* with the value to be passed to qse_awk_setretval(). * with the value to be passed to qse_awk_rtx_setretval().
* The qse_awk_setretval() will update its reference count properly * The qse_awk_rtx_setretval() will update its reference count properly
* once the return value is set. * once the return value is set.
* SYNOPSIS
*/ */
void qse_awk_setretval ( void qse_awk_rtx_setretval (
qse_awk_rtx_t* run, qse_awk_rtx_t* rtx,
qse_awk_val_t* val qse_awk_val_t* val
); );
/******/
int qse_awk_setfilename ( /****f* qse.awk/qse_awk_rtx_setfilename
qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len);
int qse_awk_setofilename (
qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len);
/****f* qse.awk/qse_awk_getrunawk
* NAME * NAME
* qse_awk_getrunawk - get the owning awk object * qse_awk_rtx_setfilename - set FILENAME
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_awk_t* qse_awk_getrunawk ( int qse_awk_rtx_setfilename (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx,
const qse_char_t* name,
qse_size_t len
); );
/******/ /******/
/****f* qse.awk/qse_awk_getrunmmgr /****f* qse.awk/qse_awk_rtx_setofilename
* NAME * NAME
* qse_awk_getrunmmgr - get the memory manager of a run object * qse_awk_rtx_setofilename - set OFILENAME
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_mmgr_t* qse_awk_getrunmmgr ( int qse_awk_rtx_setofilename (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx,
const qse_char_t* name,
qse_size_t len
); );
/******/ /******/
/****f* qse.awk/qse_awk_getrundata /****f* qse.awk/qse_awk_rtx_getawk
* NAME * NAME
* qse_awk_getrundata - get the user-specified data for a run object * qse_awk_rtx_getawk - get the owning awk object
*
* SYNOPSIS * SYNOPSIS
*/ */
void* qse_awk_getrundata ( qse_awk_t* qse_awk_rtx_getawk (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx
); );
/******/ /******/
/****f* qse.awk/qse_awk_getrunnvmap /****f* qse.awk/qse_awk_rtx_getmmgr
* NAME * NAME
* qse_awk_getrunnvmap - get the map of named variables * qse_awk_rtx_getmmgr - get the memory manager of a runtime context
*
* SYNOPSIS * SYNOPSIS
*/ */
qse_map_t* qse_awk_getrunnvmap ( qse_mmgr_t* qse_awk_rtx_getmmgr (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx
); );
/******/ /******/
/* functions to manipulate the run-time error */ /****f* qse.awk/qse_awk_rtx_getdata
int qse_awk_getrunerrnum ( * NAME
qse_awk_rtx_t* run * qse_awk_rtx_getdata - get the user-specified data for a runtime context
* SYNOPSIS
*/
void* qse_awk_rtx_getdata (
qse_awk_rtx_t* rtx
); );
/******/
/****f* qse.awk/qse_awk_rtx_getnvmap
* NAME
* qse_awk_rtx_getnvmap - get the map of named variables
* SYNOPSIS
*/
qse_map_t* qse_awk_rtx_getnvmap (
qse_awk_rtx_t* rtx
);
/******/
/****f* qse.awk/qse_awk_rtx_geterrnum
* NAME
* qse_awk_rtx_geterrnum - get the error number of a runtime context
* SYNOPSIS
*/
int qse_awk_rtx_geterrnum (
qse_awk_rtx_t* rtx
);
/******/
qse_size_t qse_awk_getrunerrlin ( qse_size_t qse_awk_getrunerrlin (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx
); );
const qse_char_t* qse_awk_getrunerrmsg ( const qse_char_t* qse_awk_getrunerrmsg (
qse_awk_rtx_t* run qse_awk_rtx_t* rtx
); );
void qse_awk_setrunerrnum ( void qse_awk_setrunerrnum (
qse_awk_rtx_t* run, qse_awk_rtx_t* rtx,
int errnum int errnum
); );
void qse_awk_setrunerrmsg ( void qse_awk_setrunerrmsg (
@ -1024,22 +1093,37 @@ void qse_awk_setrunerrmsg (
); );
void qse_awk_getrunerror ( void qse_awk_getrunerror (
qse_awk_rtx_t* run, int* errnum, qse_awk_rtx_t* run,
qse_size_t* errlin, const qse_char_t** errmsg); int* errnum,
qse_size_t* errlin,
const qse_char_t** errmsg
);
void qse_awk_setrunerror ( void qse_awk_setrunerror (
qse_awk_rtx_t* run, int errnum, qse_size_t errlin, qse_awk_rtx_t* run,
const qse_cstr_t* errarg, qse_size_t argcnt); int errnum,
qse_size_t errlin,
const qse_cstr_t* errarg,
qse_size_t argcnt
);
/* functions to manipulate intrinsic functions */ /* functions to manipulate intrinsic functions */
void* qse_awk_addfunc ( void* qse_awk_addfunc (
qse_awk_t* awk, const qse_char_t* name, qse_size_t name_len, qse_awk_t* awk,
int when_valid, qse_size_t min_args, qse_size_t max_args, const qse_char_t* name,
qse_size_t name_len,
int when_valid,
qse_size_t min_args,
qse_size_t max_args,
const qse_char_t* arg_spec, const qse_char_t* arg_spec,
int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)); int (*handler)(qse_awk_rtx_t*,const qse_char_t*,qse_size_t)
);
int qse_awk_delfunc ( int qse_awk_delfunc (
qse_awk_t* awk, const qse_char_t* name, qse_size_t name_len); qse_awk_t* awk,
const qse_char_t* name,
qse_size_t len
);
void qse_awk_clrbfn (qse_awk_t* awk); void qse_awk_clrbfn (qse_awk_t* awk);

View File

@ -141,12 +141,12 @@ int Awk::Console::setFileName (const char_t* name)
{ {
if (eio->mode == READ) if (eio->mode == READ)
{ {
return qse_awk_setfilename ( return qse_awk_rtx_setfilename (
eio->run, name, qse_strlen(name)); eio->run, name, qse_strlen(name));
} }
else else
{ {
return qse_awk_setofilename ( return qse_awk_rtx_setofilename (
eio->run, name, qse_strlen(name)); eio->run, name, qse_strlen(name));
} }
} }
@ -160,7 +160,7 @@ int Awk::Console::setFNR (long_t fnr)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_refupval (eio->run, tmp); qse_awk_refupval (eio->run, tmp);
n = qse_awk_setglobal (eio->run, QSE_AWK_GLOBAL_FNR, tmp); n = qse_awk_rtx_setglobal (eio->run, QSE_AWK_GLOBAL_FNR, tmp);
qse_awk_refdownval (eio->run, tmp); qse_awk_refdownval (eio->run, tmp);
return n; return n;
@ -929,19 +929,19 @@ Awk::Run::operator Awk::run_t* () const
void Awk::Run::stop () const void Awk::Run::stop () const
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
qse_awk_stop (this->run); qse_awk_rtx_stop (this->run);
} }
bool Awk::Run::isStop () const bool Awk::Run::isStop () const
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
return qse_awk_isstop (this->run)? true: false; return qse_awk_rtx_shouldstop (this->run)? true: false;
} }
Awk::ErrorCode Awk::Run::getErrorCode () const Awk::ErrorCode Awk::Run::getErrorCode () const
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
return (ErrorCode)qse_awk_getrunerrnum (this->run); return (ErrorCode)qse_awk_rtx_geterrnum (this->run);
} }
Awk::size_t Awk::Run::getErrorLine () const Awk::size_t Awk::Run::getErrorLine () const
@ -998,7 +998,7 @@ int Awk::Run::setGlobal (int id, long_t v)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
int n = qse_awk_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setglobal (this->run, id, tmp);
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
return n; return n;
} }
@ -1011,7 +1011,7 @@ int Awk::Run::setGlobal (int id, real_t v)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
int n = qse_awk_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setglobal (this->run, id, tmp);
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
return n; return n;
} }
@ -1024,7 +1024,7 @@ int Awk::Run::setGlobal (int id, const char_t* ptr, size_t len)
if (tmp == QSE_NULL) return -1; if (tmp == QSE_NULL) return -1;
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
int n = qse_awk_setglobal (this->run, id, tmp); int n = qse_awk_rtx_setglobal (this->run, id, tmp);
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
return n; return n;
} }
@ -1033,7 +1033,7 @@ int Awk::Run::setGlobal (int id, const Return& global)
{ {
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
return qse_awk_setglobal (this->run, id, global.toVal()); return qse_awk_rtx_setglobal (this->run, id, global.toVal());
} }
int Awk::Run::getGlobal (int id, Argument& global) const int Awk::Run::getGlobal (int id, Argument& global) const
@ -1041,7 +1041,7 @@ int Awk::Run::getGlobal (int id, Argument& global) const
QSE_ASSERT (this->run != QSE_NULL); QSE_ASSERT (this->run != QSE_NULL);
global.clear (); global.clear ();
return global.init (qse_awk_getglobal(this->run,id)); return global.init (qse_awk_rtx_getglobal(this->run,id));
} }
void Awk::Run::setData (void* data) void Awk::Run::setData (void* data)
@ -1402,7 +1402,7 @@ int Awk::run (const char_t* main, const char_t** args, size_t nargs)
void Awk::stop () void Awk::stop ()
{ {
QSE_ASSERT (awk != QSE_NULL); QSE_ASSERT (awk != QSE_NULL);
qse_awk_stopall (awk); qse_awk_rtx_stopall (awk);
} }
int Awk::dispatchFunction (Run* run, const char_t* name, size_t len) int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
@ -1410,7 +1410,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
pair_t* pair; pair_t* pair;
awk_t* awk = run->awk->awk; awk_t* awk = run->awk->awk;
//awk = qse_awk_getrunawk (run); //awk = qse_awk_rtx_getawk (run);
pair = qse_map_search (functionMap, name, len); pair = qse_map_search (functionMap, name, len);
if (pair == QSE_NULL) if (pair == QSE_NULL)
@ -1422,7 +1422,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
FunctionHandler handler; FunctionHandler handler;
handler = *(FunctionHandler*)QSE_MAP_VPTR(pair); handler = *(FunctionHandler*)QSE_MAP_VPTR(pair);
size_t i, nargs = qse_awk_getnargs(run->run); size_t i, nargs = qse_awk_rtx_getnargs(run->run);
//Argument* args = QSE_NULL; //Argument* args = QSE_NULL;
//try { args = new Argument [nargs]; } catch (...) {} //try { args = new Argument [nargs]; } catch (...) {}
@ -1438,7 +1438,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
args[i].run = run; // dirty late initialization args[i].run = run; // dirty late initialization
// due to c++ array creation limitation. // due to c++ array creation limitation.
val_t* v = qse_awk_getarg (run->run, i); val_t* v = qse_awk_rtx_getarg (run->run, i);
if (args[i].init (v) == -1) if (args[i].init (v) == -1)
{ {
run->setError (ERR_NOMEM, 0, QSE_NULL, 0); run->setError (ERR_NOMEM, 0, QSE_NULL, 0);
@ -1460,7 +1460,7 @@ int Awk::dispatchFunction (Run* run, const char_t* name, size_t len)
return -1; return -1;
} }
qse_awk_setretval (run->run, ret); qse_awk_rtx_setretval (run->run, ret);
return 0; return 0;
} }
@ -1709,7 +1709,7 @@ Awk::ssize_t Awk::consoleHandler (
int Awk::functionHandler ( int Awk::functionHandler (
run_t* run, const char_t* name, size_t len) run_t* run, const char_t* name, size_t len)
{ {
Run* ctx = (Run*) qse_awk_getrundata (run); Run* ctx = (Run*) qse_awk_rtx_getdata (run);
Awk* awk = ctx->awk; Awk* awk = ctx->awk;
return awk->dispatchFunction (ctx, name, len); return awk->dispatchFunction (ctx, name, len);
} }

View File

@ -366,7 +366,7 @@ void qse_awk_setoption (qse_awk_t* awk, int opt)
} }
void qse_awk_stopall (qse_awk_t* awk) void qse_awk_rtx_stopall (qse_awk_t* awk)
{ {
awk->stopall = QSE_TRUE; awk->stopall = QSE_TRUE;
} }

View File

@ -204,7 +204,7 @@ int qse_awk_readeio (
qse_str_clear (buf); qse_str_clear (buf);
/* get the record separator */ /* get the record separator */
rs = qse_awk_getglobal (run, QSE_AWK_GLOBAL_RS); rs = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_RS);
qse_awk_refupval (run, rs); qse_awk_refupval (run, rs);
if (rs->type == QSE_AWK_VAL_NIL) if (rs->type == QSE_AWK_VAL_NIL)

View File

@ -345,7 +345,7 @@ void qse_awk_seterror (
} }
} }
int qse_awk_getrunerrnum (qse_awk_rtx_t* run) int qse_awk_rtx_geterrnum (qse_awk_rtx_t* run)
{ {
return run->errnum; return run->errnum;
} }

View File

@ -235,11 +235,11 @@ static int bfn_close (
qse_char_t* name; qse_char_t* name;
qse_size_t len; qse_size_t len;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
/* TODO: support close (xxx, "to"/"from"/"rw"/"r"/"w"/????) */ /* TODO: support close (xxx, "to"/"from"/"rw"/"r"/"w"/????) */
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
QSE_ASSERT (a0 != QSE_NULL); QSE_ASSERT (a0 != QSE_NULL);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
@ -299,7 +299,7 @@ skip_close:
return -1; return -1;
} }
qse_awk_setretval (run, v); qse_awk_rtx_setretval (run, v);
return 0; return 0;
} }
@ -342,7 +342,7 @@ static int bfn_fflush (
qse_size_t len0; qse_size_t len0;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 0 || nargs == 1); QSE_ASSERT (nargs == 0 || nargs == 1);
if (nargs == 0) if (nargs == 0)
@ -355,7 +355,7 @@ static int bfn_fflush (
{ {
qse_char_t* ptr, * end; qse_char_t* ptr, * end;
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
str0 = ((qse_awk_val_str_t*)a0)->ptr; str0 = ((qse_awk_val_str_t*)a0)->ptr;
@ -410,7 +410,7 @@ static int bfn_fflush (
return -1; return -1;
} }
qse_awk_setretval (run, a0); qse_awk_rtx_setretval (run, a0);
return 0; return 0;
} }
@ -423,11 +423,11 @@ static int bfn_index (
qse_size_t len0, len1; qse_size_t len0, len1;
qse_long_t idx; qse_long_t idx;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 2); QSE_ASSERT (nargs == 2);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
@ -473,7 +473,7 @@ static int bfn_index (
return -1; return -1;
} }
qse_awk_setretval (run, a0); qse_awk_rtx_setretval (run, a0);
return 0; return 0;
} }
@ -485,10 +485,10 @@ static int bfn_length (
qse_char_t* str; qse_char_t* str;
qse_size_t len; qse_size_t len;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
v = qse_awk_getarg (run, 0); v = qse_awk_rtx_getarg (run, 0);
if (v->type == QSE_AWK_VAL_STR) if (v->type == QSE_AWK_VAL_STR)
{ {
len = ((qse_awk_val_str_t*)v)->len; len = ((qse_awk_val_str_t*)v)->len;
@ -508,7 +508,7 @@ static int bfn_length (
return -1; return -1;
} }
qse_awk_setretval (run, v); qse_awk_rtx_setretval (run, v);
return 0; return 0;
} }
@ -523,12 +523,12 @@ static int bfn_substr (
qse_real_t rindex, rcount; qse_real_t rindex, rcount;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs >= 2 && nargs <= 3); QSE_ASSERT (nargs >= 2 && nargs <= 3);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
a2 = (nargs >= 3)? qse_awk_getarg (run, 2): QSE_NULL; a2 = (nargs >= 3)? qse_awk_rtx_getarg (run, 2): QSE_NULL;
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
@ -582,7 +582,7 @@ static int bfn_substr (
} }
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str); if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -602,12 +602,12 @@ static int bfn_split (
void* fs_rex_free = QSE_NULL; void* fs_rex_free = QSE_NULL;
int errnum; int errnum;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs >= 2 && nargs <= 3); QSE_ASSERT (nargs >= 2 && nargs <= 3);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
a2 = (nargs >= 3)? qse_awk_getarg (run, 2): QSE_NULL; a2 = (nargs >= 3)? qse_awk_rtx_getarg (run, 2): QSE_NULL;
QSE_ASSERT (a1->type == QSE_AWK_VAL_REF); QSE_ASSERT (a1->type == QSE_AWK_VAL_REF);
@ -652,7 +652,7 @@ static int bfn_split (
if (a2 == QSE_NULL) if (a2 == QSE_NULL)
{ {
/* get the value from FS */ /* get the value from FS */
t1 = qse_awk_getglobal (run, QSE_AWK_GLOBAL_FS); t1 = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_FS);
if (t1->type == QSE_AWK_VAL_NIL) if (t1->type == QSE_AWK_VAL_NIL)
{ {
fs_ptr = QSE_T(" "); fs_ptr = QSE_T(" ");
@ -839,7 +839,7 @@ static int bfn_split (
return -1; return -1;
} }
qse_awk_setretval (run, t1); qse_awk_rtx_setretval (run, t1);
return 0; return 0;
} }
@ -851,10 +851,10 @@ static int bfn_tolower (
qse_size_t len, i; qse_size_t len, i;
qse_awk_val_t* a0, * r; qse_awk_val_t* a0, * r;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
@ -879,7 +879,7 @@ static int bfn_tolower (
} }
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str); if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -891,10 +891,10 @@ static int bfn_toupper (
qse_size_t len, i; qse_size_t len, i;
qse_awk_val_t* a0, * r; qse_awk_val_t* a0, * r;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
@ -919,7 +919,7 @@ static int bfn_toupper (
} }
if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str); if (a0->type != QSE_AWK_VAL_STR) QSE_AWK_FREE (run->awk, str);
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -939,12 +939,12 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
qse_str_t new; qse_str_t new;
qse_long_t sub_count; qse_long_t sub_count;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs >= 2 && nargs <= 3); QSE_ASSERT (nargs >= 2 && nargs <= 3);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
a2 = (nargs >= 3)? qse_awk_getarg (run, 2): QSE_NULL; a2 = (nargs >= 3)? qse_awk_rtx_getarg (run, 2): QSE_NULL;
QSE_ASSERT (a2 == QSE_NULL || a2->type == QSE_AWK_VAL_REF); QSE_ASSERT (a2 == QSE_NULL || a2->type == QSE_AWK_VAL_REF);
@ -1210,7 +1210,7 @@ static int __substitute (qse_awk_rtx_t* run, qse_long_t max_count)
return -1; return -1;
} }
qse_awk_setretval (run, v); qse_awk_rtx_setretval (run, v);
return 0; return 0;
} }
@ -1239,11 +1239,11 @@ static int bfn_match (
const qse_char_t* mat_ptr; const qse_char_t* mat_ptr;
qse_size_t mat_len; qse_size_t mat_len;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 2); QSE_ASSERT (nargs == 2);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
@ -1324,21 +1324,21 @@ static int bfn_match (
qse_awk_refupval (run, a1); qse_awk_refupval (run, a1);
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_RSTART, a0) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_RSTART, a0) == -1)
{ {
qse_awk_refdownval (run, a1); qse_awk_refdownval (run, a1);
qse_awk_refdownval (run, a0); qse_awk_refdownval (run, a0);
return -1; return -1;
} }
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_RLENGTH, a1) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_RLENGTH, a1) == -1)
{ {
qse_awk_refdownval (run, a1); qse_awk_refdownval (run, a1);
qse_awk_refdownval (run, a0); qse_awk_refdownval (run, a0);
return -1; return -1;
} }
qse_awk_setretval (run, a0); qse_awk_rtx_setretval (run, a0);
qse_awk_refdownval (run, a1); qse_awk_refdownval (run, a1);
qse_awk_refdownval (run, a0); qse_awk_refdownval (run, a0);
@ -1354,7 +1354,7 @@ static int bfn_sprintf (
qse_xstr_t cs0; qse_xstr_t cs0;
qse_xstr_t x; qse_xstr_t x;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs > 0); QSE_ASSERT (nargs > 0);
if (qse_str_init (&out, run->awk->mmgr, 256) == QSE_NULL) if (qse_str_init (&out, run->awk->mmgr, 256) == QSE_NULL)
@ -1369,7 +1369,7 @@ static int bfn_sprintf (
return -1; return -1;
} }
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
if (a0->type == QSE_AWK_VAL_STR) if (a0->type == QSE_AWK_VAL_STR)
{ {
cs0.ptr = ((qse_awk_val_str_t*)a0)->ptr; cs0.ptr = ((qse_awk_val_str_t*)a0)->ptr;
@ -1410,6 +1410,6 @@ static int bfn_sprintf (
qse_str_fini (&fbu); qse_str_fini (&fbu);
/*qse_str_yield (&out, QSE_NULL, 0);*/ /*qse_str_yield (&out, QSE_NULL, 0);*/
qse_str_fini (&out); qse_str_fini (&out);
qse_awk_setretval (run, a0); qse_awk_rtx_setretval (run, a0);
return 0; return 0;
} }

View File

@ -455,7 +455,7 @@ void qse_awk_setmaxdepth (qse_awk_t* awk, int types, qse_size_t depth)
} }
} }
const qse_char_t* qse_awk_getglobalname ( const qse_char_t* qse_awk_rtx_getglobalname (
qse_awk_t* awk, qse_size_t idx, qse_size_t* len) qse_awk_t* awk, qse_size_t idx, qse_size_t* len)
{ {
/* /*

View File

@ -55,7 +55,7 @@ int qse_awk_putsrcstr (qse_awk_t* awk, const qse_char_t* str);
int qse_awk_putsrcstrx ( int qse_awk_putsrcstrx (
qse_awk_t* awk, const qse_char_t* str, qse_size_t len); qse_awk_t* awk, const qse_char_t* str, qse_size_t len);
const qse_char_t* qse_awk_getglobalname ( const qse_char_t* qse_awk_rtx_getglobalname (
qse_awk_t* awk, qse_size_t idx, qse_size_t* len); qse_awk_t* awk, qse_size_t idx, qse_size_t* len);
qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s); qse_cstr_t* qse_awk_getkw (qse_awk_t* awk, int id, qse_cstr_t* s);

View File

@ -107,7 +107,7 @@ static int split_record (qse_awk_rtx_t* run)
QSE_ASSERT (run->inrec.nflds == 0); QSE_ASSERT (run->inrec.nflds == 0);
/* get FS */ /* get FS */
fs = qse_awk_getglobal (run, QSE_AWK_GLOBAL_FS); fs = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_FS);
if (fs->type == QSE_AWK_VAL_NIL) if (fs->type == QSE_AWK_VAL_NIL)
{ {
fs_ptr = QSE_T(" "); fs_ptr = QSE_T(" ");
@ -237,7 +237,7 @@ static int split_record (qse_awk_rtx_t* run)
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
qse_awk_refupval (run, v); qse_awk_refupval (run, v);
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1)
{ {
qse_awk_refdownval (run, v); qse_awk_refdownval (run, v);
return -1; return -1;
@ -270,7 +270,7 @@ int qse_awk_clrrec (qse_awk_rtx_t* run, qse_bool_t skip_inrec_line)
} }
run->inrec.nflds = 0; run->inrec.nflds = 0;
if (qse_awk_setglobal ( if (qse_awk_rtx_setglobal (
run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1) run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1)
{ {
/* first of all, this should never happen. /* first of all, this should never happen.
@ -432,7 +432,7 @@ static int recomp_record_fields (
} }
} }
v = qse_awk_getglobal (run, QSE_AWK_GLOBAL_NF); v = qse_awk_rtx_getglobal (run, QSE_AWK_GLOBAL_NF);
QSE_ASSERT (v->type == QSE_AWK_VAL_INT); QSE_ASSERT (v->type == QSE_AWK_VAL_INT);
if (((qse_awk_val_int_t*)v)->val != max) if (((qse_awk_val_int_t*)v)->val != max)
@ -441,7 +441,7 @@ static int recomp_record_fields (
if (v == QSE_NULL) return -1; if (v == QSE_NULL) return -1;
qse_awk_refupval (run, v); qse_awk_refupval (run, v);
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NF, v) == -1)
{ {
qse_awk_refdownval (run, v); qse_awk_refdownval (run, v);
return -1; return -1;

View File

@ -231,23 +231,23 @@ typedef qse_awk_val_t* (*binop_func_t) (
qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right); qse_awk_rtx_t* run, qse_awk_val_t* left, qse_awk_val_t* right);
typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_rtx_t* run, qse_awk_nde_t* nde); typedef qse_awk_val_t* (*eval_expr_t) (qse_awk_rtx_t* run, qse_awk_nde_t* nde);
qse_size_t qse_awk_getnargs (qse_awk_rtx_t* run) qse_size_t qse_awk_rtx_getnargs (qse_awk_rtx_t* run)
{ {
return (qse_size_t) STACK_NARGS (run); return (qse_size_t) STACK_NARGS (run);
} }
qse_awk_val_t* qse_awk_getarg (qse_awk_rtx_t* run, qse_size_t idx) qse_awk_val_t* qse_awk_rtx_getarg (qse_awk_rtx_t* run, qse_size_t idx)
{ {
return STACK_ARG (run, idx); return STACK_ARG (run, idx);
} }
qse_awk_val_t* qse_awk_getglobal (qse_awk_rtx_t* run, int id) qse_awk_val_t* qse_awk_rtx_getglobal (qse_awk_rtx_t* run, int id)
{ {
QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals)); QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals));
return STACK_GLOBAL (run, id); return STACK_GLOBAL (run, id);
} }
int qse_awk_setglobal (qse_awk_rtx_t* run, int id, qse_awk_val_t* val) int qse_awk_rtx_setglobal (qse_awk_rtx_t* run, int id, qse_awk_val_t* val)
{ {
QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals)); QSE_ASSERT (id >= 0 && id < (int)QSE_LDA_SIZE(run->awk->parse.globals));
return set_global (run, (qse_size_t)id, QSE_NULL, val); return set_global (run, (qse_size_t)id, QSE_NULL, val);
@ -278,10 +278,10 @@ static int set_global (
} }
else else
{ {
/* qse_awk_setglobal has been called */ /* qse_awk_rtx_setglobal has been called */
qse_cstr_t errarg; qse_cstr_t errarg;
errarg.ptr = qse_awk_getglobalname ( errarg.ptr = qse_awk_rtx_getglobalname (
run->awk, idx, &errarg.len); run->awk, idx, &errarg.len);
qse_awk_setrunerror (run, qse_awk_setrunerror (run,
QSE_AWK_EMAPTOSCALAR, 0, &errarg, 1); QSE_AWK_EMAPTOSCALAR, 0, &errarg, 1);
@ -547,7 +547,7 @@ static int set_global (
return 0; return 0;
} }
void qse_awk_setretval (qse_awk_rtx_t* run, qse_awk_val_t* val) void qse_awk_rtx_setretval (qse_awk_rtx_t* run, qse_awk_val_t* val)
{ {
qse_awk_refdownval (run, STACK_RETVAL(run)); qse_awk_refdownval (run, STACK_RETVAL(run));
STACK_RETVAL(run) = val; STACK_RETVAL(run) = val;
@ -555,7 +555,7 @@ void qse_awk_setretval (qse_awk_rtx_t* run, qse_awk_val_t* val)
qse_awk_refupval (run, val); qse_awk_refupval (run, val);
} }
int qse_awk_setfilename ( int qse_awk_rtx_setfilename (
qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len) qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len)
{ {
qse_awk_val_t* tmp; qse_awk_val_t* tmp;
@ -569,13 +569,13 @@ int qse_awk_setfilename (
} }
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
n = qse_awk_setglobal (run, QSE_AWK_GLOBAL_FILENAME, tmp); n = qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_FILENAME, tmp);
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
return n; return n;
} }
int qse_awk_setofilename ( int qse_awk_rtx_setofilename (
qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len) qse_awk_rtx_t* run, const qse_char_t* name, qse_size_t len)
{ {
qse_awk_val_t* tmp; qse_awk_val_t* tmp;
@ -591,7 +591,7 @@ int qse_awk_setofilename (
} }
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
n = qse_awk_setglobal (run, QSE_AWK_GLOBAL_OFILENAME, tmp); n = qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_OFILENAME, tmp);
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
} }
else n = 0; else n = 0;
@ -599,22 +599,22 @@ int qse_awk_setofilename (
return n; return n;
} }
qse_awk_t* qse_awk_getrunawk (qse_awk_rtx_t* run) qse_awk_t* qse_awk_rtx_getawk (qse_awk_rtx_t* run)
{ {
return run->awk; return run->awk;
} }
qse_mmgr_t* qse_awk_getrunmmgr (qse_awk_rtx_t* run) qse_mmgr_t* qse_awk_rtx_getmmgr (qse_awk_rtx_t* run)
{ {
return run->awk->mmgr; return run->awk->mmgr;
} }
void* qse_awk_getrundata (qse_awk_rtx_t* run) void* qse_awk_rtx_getdata (qse_awk_rtx_t* run)
{ {
return run->data; return run->data;
} }
qse_map_t* qse_awk_getrunnvmap (qse_awk_rtx_t* run) qse_map_t* qse_awk_rtx_getnvmap (qse_awk_rtx_t* run)
{ {
return run->named; return run->named;
} }
@ -727,12 +727,12 @@ int qse_awk_run (qse_awk_t* awk,
return n; return n;
} }
void qse_awk_stop (qse_awk_rtx_t* run) void qse_awk_rtx_stop (qse_awk_rtx_t* run)
{ {
run->exit_level = EXIT_ABORT; run->exit_level = EXIT_ABORT;
} }
qse_bool_t qse_awk_isstop (qse_awk_rtx_t* run) qse_bool_t qse_awk_rtx_shouldstop (qse_awk_rtx_t* run)
{ {
return (run->exit_level == EXIT_ABORT || run->awk->stopall); return (run->exit_level == EXIT_ABORT || run->awk->stopall);
} }
@ -1069,14 +1069,14 @@ static int build_runarg (
QSE_ASSERT ( QSE_ASSERT (
STACK_GLOBAL(run,QSE_AWK_GLOBAL_ARGC) == qse_awk_val_nil); STACK_GLOBAL(run,QSE_AWK_GLOBAL_ARGC) == qse_awk_val_nil);
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_ARGC, v_argc) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_ARGC, v_argc) == -1)
{ {
qse_awk_refdownval (run, v_argc); qse_awk_refdownval (run, v_argc);
qse_awk_refdownval (run, v_argv); qse_awk_refdownval (run, v_argv);
return -1; return -1;
} }
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_ARGV, v_argv) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_ARGV, v_argv) == -1)
{ {
/* ARGC is assigned nil when ARGV assignment has failed. /* ARGC is assigned nil when ARGV assignment has failed.
* However, this requires preconditions, as follows: * However, this requires preconditions, as follows:
@ -1084,7 +1084,7 @@ static int build_runarg (
* as it is not a generic-purpose routine. * as it is not a generic-purpose routine.
* 2. ARGC should be nil before build_runarg is called * 2. ARGC should be nil before build_runarg is called
* If the restoration fails, nothing can salvage it. */ * If the restoration fails, nothing can salvage it. */
qse_awk_setglobal (run, QSE_AWK_GLOBAL_ARGC, qse_awk_val_nil); qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_ARGC, qse_awk_val_nil);
qse_awk_refdownval (run, v_argc); qse_awk_refdownval (run, v_argc);
qse_awk_refdownval (run, v_argv); qse_awk_refdownval (run, v_argv);
return -1; return -1;
@ -1121,14 +1121,14 @@ static int update_fnr (qse_awk_rtx_t* run, qse_long_t fnr, qse_long_t nr)
} }
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_FNR, tmp1) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_FNR, tmp1) == -1)
{ {
if (nr != fnr) qse_awk_refdownval (run, tmp2); if (nr != fnr) qse_awk_refdownval (run, tmp2);
qse_awk_refdownval (run, tmp1); qse_awk_refdownval (run, tmp1);
return -1; return -1;
} }
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_NR, tmp2) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NR, tmp2) == -1)
{ {
if (nr != fnr) qse_awk_refdownval (run, tmp2); if (nr != fnr) qse_awk_refdownval (run, tmp2);
qse_awk_refdownval (run, tmp1); qse_awk_refdownval (run, tmp1);
@ -1183,11 +1183,11 @@ static int set_globals_to_default (qse_awk_rtx_t* run)
QSE_ASSERT ( QSE_ASSERT (
STACK_GLOBAL(run,gtab[i].idx) == qse_awk_val_nil); STACK_GLOBAL(run,gtab[i].idx) == qse_awk_val_nil);
if (qse_awk_setglobal (run, gtab[i].idx, tmp) == -1) if (qse_awk_rtx_setglobal (run, gtab[i].idx, tmp) == -1)
{ {
for (j = 0; j < i; j++) for (j = 0; j < i; j++)
{ {
qse_awk_setglobal ( qse_awk_rtx_setglobal (
run, gtab[i].idx, qse_awk_val_nil); run, gtab[i].idx, qse_awk_val_nil);
} }
@ -1237,7 +1237,7 @@ static int prepare_globals (qse_awk_rtx_t* run, const qse_cstr_t* runarg)
} }
/* override NF to zero */ /* override NF to zero */
if (qse_awk_setglobal ( if (qse_awk_rtx_setglobal (
run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1) goto oops; run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1) goto oops;
/* override ARGC and ARGV */ /* override ARGC and ARGV */
@ -1376,7 +1376,7 @@ static int run_bpae_loop (qse_awk_rtx_t* run)
} }
/* execute END blocks. the first END block is executed if the /* execute END blocks. the first END block is executed if the
* program is not explicitly aborted with qse_awk_stop().*/ * program is not explicitly aborted with qse_awk_rtx_stop().*/
for (nde = run->awk->tree.end; for (nde = run->awk->tree.end;
ret == 0 && nde != QSE_NULL && run->exit_level < EXIT_ABORT; ret == 0 && nde != QSE_NULL && run->exit_level < EXIT_ABORT;
nde = nde->next) nde = nde->next)
@ -1663,7 +1663,7 @@ static int ____run_main_to_be_removed____ (
} }
} }
if (qse_awk_setglobal (run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1) if (qse_awk_rtx_setglobal (run, QSE_AWK_GLOBAL_NF, qse_awk_val_zero) == -1)
{ {
/* it can simply restore the top of the stack this way /* it can simply restore the top of the stack this way
* because the values pused onto the stack so far are * because the values pused onto the stack so far are
@ -1915,7 +1915,7 @@ static int ____run_main_to_be_removed____ (
} }
/* the first END block is executed if the program is not /* the first END block is executed if the program is not
* explicitly aborted with qse_awk_stop */ * explicitly aborted with qse_awk_rtx_stop */
for (nde = run->awk->tree.end; for (nde = run->awk->tree.end;
n == 0 && nde != QSE_NULL && run->exit_level < EXIT_ABORT; n == 0 && nde != QSE_NULL && run->exit_level < EXIT_ABORT;
nde = nde->next) nde = nde->next)
@ -3020,7 +3020,7 @@ static int run_delete (qse_awk_rtx_t* run, qse_awk_nde_delete_t* nde)
if (var->type == QSE_AWK_NDE_GLOBAL || if (var->type == QSE_AWK_NDE_GLOBAL ||
var->type == QSE_AWK_NDE_GLOBALIDX) var->type == QSE_AWK_NDE_GLOBALIDX)
{ {
if (qse_awk_setglobal ( if (qse_awk_rtx_setglobal (
run, (int)var->id.idxa, tmp) == -1) run, (int)var->id.idxa, tmp) == -1)
{ {
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
@ -3911,7 +3911,7 @@ static qse_awk_val_t* do_assignment_map (
else if (var->type == QSE_AWK_NDE_GLOBALIDX) else if (var->type == QSE_AWK_NDE_GLOBALIDX)
{ {
qse_awk_refupval (run, tmp); qse_awk_refupval (run, tmp);
if (qse_awk_setglobal (run, (int)var->id.idxa, tmp) == -1) if (qse_awk_rtx_setglobal (run, (int)var->id.idxa, tmp) == -1)
{ {
qse_awk_refdownval (run, tmp); qse_awk_refdownval (run, tmp);
@ -6140,7 +6140,7 @@ static qse_awk_val_t* eval_call (
* adjust the reference count of the return value. * adjust the reference count of the return value.
* the value must not be freed even if the reference count * the value must not be freed even if the reference count
* reached zero because its reference has been incremented * reached zero because its reference has been incremented
* in run_return or directly by qse_awk_setretval * in run_return or directly by qse_awk_rtx_setretval
* regardless of its reference count. */ * regardless of its reference count. */
qse_awk_refdownval_nofree (run, v); qse_awk_refdownval_nofree (run, v);
} }
@ -7061,7 +7061,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {
@ -7167,7 +7167,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {
@ -7288,7 +7288,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {
@ -7376,7 +7376,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {
@ -7453,7 +7453,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {
@ -7563,7 +7563,7 @@ qse_char_t* qse_awk_format (
qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG); qse_awk_setrunerrnum (run, QSE_AWK_EFMTARG);
return QSE_NULL; return QSE_NULL;
} }
v = qse_awk_getarg (run, stack_arg_idx); v = qse_awk_rtx_getarg (run, stack_arg_idx);
} }
else else
{ {

View File

@ -369,7 +369,7 @@ static qse_ssize_t awk_eio_pipe (
/*dprint (QSE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type);*/ /*dprint (QSE_T("opening %s of type %d (pipe)\n"), epa->name, epa->type);*/
handle = qse_pio_open ( handle = qse_pio_open (
qse_awk_getrunmmgr(epa->run), qse_awk_rtx_getmmgr(epa->run),
0, 0,
epa->name, epa->name,
flags|QSE_PIO_SHELL|QSE_PIO_TEXT flags|QSE_PIO_SHELL|QSE_PIO_TEXT
@ -454,7 +454,7 @@ static qse_ssize_t awk_eio_file (
/*dprint (QSE_T("opening %s of type %d (file)\n"), epa->name, epa->type);*/ /*dprint (QSE_T("opening %s of type %d (file)\n"), epa->name, epa->type);*/
handle = qse_fio_open ( handle = qse_fio_open (
qse_awk_getrunmmgr(epa->run), qse_awk_rtx_getmmgr(epa->run),
0, 0,
epa->name, epa->name,
flags | QSE_FIO_TEXT, flags | QSE_FIO_TEXT,
@ -544,7 +544,7 @@ static int open_eio_console (qse_awk_eio_t* epa)
qse_sio_t* fp; qse_sio_t* fp;
fp = qse_sio_open ( fp = qse_sio_open (
qse_awk_getrunmmgr(epa->run), qse_awk_rtx_getmmgr(epa->run),
0, 0,
rd->ic.files[rd->ic.index], rd->ic.files[rd->ic.index],
QSE_SIO_READ QSE_SIO_READ
@ -561,7 +561,7 @@ static int open_eio_console (qse_awk_eio_t* epa)
} }
/*dprint (QSE_T(" console(r) - %s\n"), rd->ic.files[rd->ic.index]);*/ /*dprint (QSE_T(" console(r) - %s\n"), rd->ic.files[rd->ic.index]);*/
if (qse_awk_setfilename ( if (qse_awk_rtx_setfilename (
epa->run, rd->ic.files[rd->ic.index], epa->run, rd->ic.files[rd->ic.index],
qse_strlen(rd->ic.files[rd->ic.index])) == -1) qse_strlen(rd->ic.files[rd->ic.index])) == -1)
{ {
@ -579,7 +579,7 @@ static int open_eio_console (qse_awk_eio_t* epa)
{ {
/*dprint (QSE_T(" console(w) - <standard output>\n"));*/ /*dprint (QSE_T(" console(w) - <standard output>\n"));*/
if (qse_awk_setofilename (epa->run, QSE_T(""), 0) == -1) if (qse_awk_rtx_setofilename (epa->run, QSE_T(""), 0) == -1)
{ {
return -1; return -1;
} }
@ -646,7 +646,7 @@ static qse_ssize_t awk_eio_console (
qse_sio_t* fp; qse_sio_t* fp;
fp = qse_sio_open ( fp = qse_sio_open (
qse_awk_getrunmmgr(epa->run), qse_awk_rtx_getmmgr(epa->run),
0, 0,
rd->ic.files[rd->ic.index], rd->ic.files[rd->ic.index],
QSE_SIO_READ QSE_SIO_READ
@ -663,7 +663,7 @@ static qse_ssize_t awk_eio_console (
return -1; return -1;
} }
if (qse_awk_setfilename ( if (qse_awk_rtx_setfilename (
epa->run, rd->ic.files[rd->ic.index], epa->run, rd->ic.files[rd->ic.index],
qse_strlen(rd->ic.files[rd->ic.index])) == -1) qse_strlen(rd->ic.files[rd->ic.index])) == -1)
{ {
@ -671,7 +671,7 @@ static qse_ssize_t awk_eio_console (
return -1; return -1;
} }
if (qse_awk_setglobal ( if (qse_awk_rtx_setglobal (
epa->run, QSE_AWK_GLOBAL_FNR, qse_awk_val_zero) == -1) epa->run, QSE_AWK_GLOBAL_FNR, qse_awk_val_zero) == -1)
{ {
/* need to reset FNR */ /* need to reset FNR */
@ -786,10 +786,10 @@ static int bfn_math_1 (
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
n = qse_awk_valtonum (run, a0, &lv, &rv); n = qse_awk_valtonum (run, a0, &lv, &rv);
if (n == -1) return -1; if (n == -1) return -1;
@ -819,7 +819,7 @@ static int bfn_math_1 (
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -833,11 +833,11 @@ static int bfn_math_2 (
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 2); QSE_ASSERT (nargs == 2);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
a1 = qse_awk_getarg (run, 1); a1 = qse_awk_rtx_getarg (run, 1);
n = qse_awk_valtonum (run, a0, &lv0, &rv0); n = qse_awk_valtonum (run, a0, &lv0, &rv0);
if (n == -1) return -1; if (n == -1) return -1;
@ -871,7 +871,7 @@ static int bfn_math_2 (
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -1012,10 +1012,10 @@ static int bfn_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
qse_awk_val_t* r; qse_awk_val_t* r;
int n; int n;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
n = qse_awk_valtonum (run, a0, &lv, &rv); n = qse_awk_valtonum (run, a0, &lv, &rv);
if (n == -1) return -1; if (n == -1) return -1;
@ -1028,7 +1028,7 @@ static int bfn_int (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -1043,7 +1043,7 @@ static int bfn_rand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -1058,15 +1058,15 @@ static int bfn_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
unsigned int prev; unsigned int prev;
rxtn_t* rxtn; rxtn_t* rxtn;
rxtn = (rxtn_t*)qse_awk_getrundata (run); rxtn = (rxtn_t*)qse_awk_rtx_getdata (run);
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 0 || nargs == 1); QSE_ASSERT (nargs == 0 || nargs == 1);
prev = rxtn->seed; prev = rxtn->seed;
if (nargs == 1) if (nargs == 1)
{ {
a0 = qse_awk_getarg (run, 0); a0 = qse_awk_rtx_getarg (run, 0);
n = qse_awk_valtonum (run, a0, &lv, &rv); n = qse_awk_valtonum (run, a0, &lv, &rv);
if (n == -1) return -1; if (n == -1) return -1;
@ -1091,7 +1091,7 @@ static int bfn_srand (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl)
return -1; return -1;
} }
qse_awk_setretval (run, r); qse_awk_rtx_setretval (run, r);
return 0; return 0;
} }
@ -1103,10 +1103,10 @@ static int bfn_system (qse_awk_rtx_t* run, const qse_char_t* fnm, qse_size_t fnl
qse_size_t len; qse_size_t len;
int n = 0; int n = 0;
nargs = qse_awk_getnargs (run); nargs = qse_awk_rtx_getnargs (run);
QSE_ASSERT (nargs == 1); QSE_ASSERT (nargs == 1);
v = qse_awk_getarg (run, 0); v = qse_awk_rtx_getarg (run, 0);
if (v->type == QSE_AWK_VAL_STR) if (v->type == QSE_AWK_VAL_STR)
{ {
str = ((qse_awk_val_str_t*)v)->ptr; str = ((qse_awk_val_str_t*)v)->ptr;
@ -1180,7 +1180,7 @@ skip_system:
return -1; return -1;
} }
qse_awk_setretval (run, v); qse_awk_rtx_setretval (run, v);
return 0; return 0;
} }