added the mod parameter to primitive functions

This commit is contained in:
hyunghwan.chung 2018-05-07 16:52:51 +00:00
parent a78594d24f
commit b891d31e8b
7 changed files with 222 additions and 205 deletions

View File

@ -3865,14 +3865,14 @@ static int compile_method_pragma (moo_t* moo)
tlen = TOKEN_NAME_LEN(moo) - 1; tlen = TOKEN_NAME_LEN(moo) - 1;
/* attempt get a primitive function number by name */ /* attempt get a primitive function number by name */
pfbase = moo_getpfnum (moo, tptr, tlen, &pfnum); pfbase = moo_getpfnum(moo, tptr, tlen, &pfnum);
if (!pfbase) if (!pfbase)
{ {
/* a built-in primitive function is not found /* a built-in primitive function is not found
* check if it is a primitive function identifier */ * check if it is a primitive function identifier */
moo_oow_t lit_idx; moo_oow_t lit_idx;
if (!moo_rfind_oochar (tptr, tlen, '.')) if (!moo_rfind_oochar(tptr, tlen, '.'))
{ {
/* wrong primitive function identifier */ /* wrong primitive function identifier */
moo_setsynerr (moo, MOO_SYNERR_PFIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo)); moo_setsynerr (moo, MOO_SYNERR_PFIDINVAL, TOKEN_LOC(moo), TOKEN_NAME(moo));
@ -3882,7 +3882,7 @@ static int compile_method_pragma (moo_t* moo)
/* external named primitive containing a period. */ /* external named primitive containing a period. */
/* perform some sanity checks. see compile_method_definition() for similar checks */ /* perform some sanity checks. see compile_method_definition() for similar checks */
pfbase = moo_querymod (moo, tptr, tlen); pfbase = moo_querymod(moo, tptr, tlen, MOO_NULL);
if (!pfbase) if (!pfbase)
{ {
MOO_DEBUG2 (moo, "Cannot find module primitive function - %.*js\n", tlen, tptr); MOO_DEBUG2 (moo, "Cannot find module primitive function - %.*js\n", tlen, tptr);
@ -6358,8 +6358,10 @@ static int add_compiled_method (moo_t* moo)
mth->owner = moo->c->cls.self_oop; mth->owner = moo->c->cls.self_oop;
mth->name = name; mth->name = name;
mth->preamble = MOO_SMOOI_TO_OOP(MOO_METHOD_MAKE_PREAMBLE(preamble_code, preamble_index, preamble_flags)); mth->preamble = MOO_SMOOI_TO_OOP(MOO_METHOD_MAKE_PREAMBLE(preamble_code, preamble_index, preamble_flags));
mth->preamble_data[0] = MOO_SMOOI_TO_OOP(0); /*mth->preamble_data[0] = MOO_SMOOI_TO_OOP(0);
mth->preamble_data[1] = MOO_SMOOI_TO_OOP(0); mth->preamble_data[1] = MOO_SMOOI_TO_OOP(0);*/
mth->preamble_data[0] = MOO_SMPTR_TO_OOP(0);
mth->preamble_data[1] = MOO_SMPTR_TO_OOP(0);
mth->tmpr_count = MOO_SMOOI_TO_OOP(moo->c->mth.tmpr_count); mth->tmpr_count = MOO_SMOOI_TO_OOP(moo->c->mth.tmpr_count);
mth->tmpr_nargs = MOO_SMOOI_TO_OOP(moo->c->mth.tmpr_nargs); mth->tmpr_nargs = MOO_SMOOI_TO_OOP(moo->c->mth.tmpr_nargs);
@ -6618,7 +6620,7 @@ static int __compile_method_definition (moo_t* moo)
/* check if the primitive function exists at the compile time and perform some checks. /* check if the primitive function exists at the compile time and perform some checks.
* see compile_method_primitive() for similar checks */ * see compile_method_primitive() for similar checks */
pfbase = moo_querymod (moo, &moo->c->cls.modname.ptr[savedlen], moo->c->cls.modname.len - savedlen); pfbase = moo_querymod(moo, &moo->c->cls.modname.ptr[savedlen], moo->c->cls.modname.len - savedlen, MOO_NULL);
if (!pfbase) if (!pfbase)
{ {
MOO_DEBUG2 (moo, "Cannot find module primitive function - %.*js\n", MOO_DEBUG2 (moo, "Cannot find module primitive function - %.*js\n",
@ -7702,7 +7704,7 @@ static int __compile_class_definition (moo_t* moo, int extend)
* memory(not part of the object memory) to moo_importmod(). * memory(not part of the object memory) to moo_importmod().
* no big overhead as it's already available. but Accessing * no big overhead as it's already available. but Accessing
* this extra module name, i'm free from GC headache */ * this extra module name, i'm free from GC headache */
if (moo_importmod (moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1) if (moo_importmod(moo, moo->c->cls.self_oop, moo->c->cls.modname.ptr, moo->c->cls.modname.len) <= -1)
{ {
const moo_ooch_t* oldmsg = moo_backuperrmsg(moo); const moo_ooch_t* oldmsg = moo_backuperrmsg(moo);
moo_setsynerrbfmt (moo, MOO_SYNERR_MODIMPFAIL, &moo->c->cls.modname_loc, &moo->c->cls.modname, moo_setsynerrbfmt (moo, MOO_SYNERR_MODIMPFAIL, &moo->c->cls.modname_loc, &moo->c->cls.modname,

View File

@ -1823,7 +1823,7 @@ oops:
} }
/* ------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------- */
static moo_pfrc_t pf_dump (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_dump (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_ooi_t i; moo_ooi_t i;
@ -1879,7 +1879,7 @@ start_over:
} }
} }
static moo_pfrc_t pf_add_to_be_finalized (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_add_to_be_finalized (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/* TODO: check if it has already been added */ /* TODO: check if it has already been added */
moo_regfinalizable (moo, MOO_STACK_GETRCV(moo,nargs)); moo_regfinalizable (moo, MOO_STACK_GETRCV(moo,nargs));
@ -1887,7 +1887,7 @@ static moo_pfrc_t pf_add_to_be_finalized (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_remove_to_be_finalized (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_remove_to_be_finalized (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/* TODO: check if it has already been added */ /* TODO: check if it has already been added */
moo_deregfinalizable (moo, MOO_STACK_GETRCV(moo,nargs)); moo_deregfinalizable (moo, MOO_STACK_GETRCV(moo,nargs));
@ -1895,7 +1895,7 @@ static moo_pfrc_t pf_remove_to_be_finalized (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_hash (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_hash (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_oow_t hv; moo_oow_t hv;
@ -1969,7 +1969,7 @@ static moo_pfrc_t pf_hash (moo_t* moo, moo_ooi_t nargs)
} }
static moo_pfrc_t pf_perform (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_perform (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t /*rcv,*/ selector; moo_oop_t /*rcv,*/ selector;
moo_oow_t ssp, esp, i; moo_oow_t ssp, esp, i;
@ -2003,7 +2003,7 @@ static moo_pfrc_t pf_perform (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_context_goto (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_context_goto (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_oop_t pc; moo_oop_t pc;
@ -2141,7 +2141,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_block_value (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_block_value (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_pfrc_t x; moo_pfrc_t x;
moo_oop_context_t rcv_blkctx, blkctx; moo_oop_context_t rcv_blkctx, blkctx;
@ -2156,7 +2156,7 @@ static moo_pfrc_t pf_block_value (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_block_new_process (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_block_new_process (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/* create a new process from a block context. /* create a new process from a block context.
* the receiver must be be a block. * the receiver must be be a block.
@ -2218,7 +2218,7 @@ static moo_pfrc_t pf_block_new_process (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_process_sp (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_process_sp (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2232,7 +2232,7 @@ static moo_pfrc_t pf_process_sp (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_process_resume (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_process_resume (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2247,7 +2247,7 @@ static moo_pfrc_t pf_process_resume (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_process_terminate (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_process_terminate (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2264,7 +2264,7 @@ static moo_pfrc_t pf_process_terminate (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_process_yield (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_process_yield (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2279,7 +2279,7 @@ static moo_pfrc_t pf_process_yield (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_process_suspend (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_process_suspend (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2295,7 +2295,7 @@ static moo_pfrc_t pf_process_suspend (moo_t* moo, moo_ooi_t nargs)
} }
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_semaphore_signal (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_semaphore_signal (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2313,7 +2313,7 @@ static moo_pfrc_t pf_semaphore_signal (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_semaphore_wait (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_semaphore_wait (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
@ -2336,7 +2336,7 @@ static moo_pfrc_t pf_semaphore_wait (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_semaphore_group_add_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_semaphore_group_add_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_semaphore_group_t sg; moo_oop_semaphore_group_t sg;
moo_oop_semaphore_t sem; moo_oop_semaphore_t sem;
@ -2414,7 +2414,7 @@ static moo_pfrc_t pf_semaphore_group_add_semaphore (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_semaphore_group_remove_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_semaphore_group_remove_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_semaphore_group_t rcv; moo_oop_semaphore_group_t rcv;
moo_oop_semaphore_t sem; moo_oop_semaphore_t sem;
@ -2490,7 +2490,7 @@ static moo_pfrc_t pf_semaphore_group_remove_semaphore (moo_t* moo, moo_ooi_t nar
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
static moo_pfrc_t pf_semaphore_group_wait (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_semaphore_group_wait (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, sem; moo_oop_t rcv, sem;
@ -2522,7 +2522,7 @@ static moo_pfrc_t pf_semaphore_group_wait (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_system_add_gcfin_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_add_gcfin_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_semaphore_t sem; moo_oop_semaphore_t sem;
@ -2544,7 +2544,7 @@ static moo_pfrc_t pf_system_add_gcfin_semaphore (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_system_add_timed_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_add_timed_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t sec, nsec; moo_oop_t sec, nsec;
moo_oop_semaphore_t sem; moo_oop_semaphore_t sem;
@ -2660,17 +2660,17 @@ static moo_pfrc_t __system_add_io_semaphore (moo_t* moo, moo_ooi_t nargs, moo_se
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_system_add_input_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_add_input_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return __system_add_io_semaphore (moo, nargs, MOO_SEMAPHORE_IO_TYPE_INPUT); return __system_add_io_semaphore (moo, nargs, MOO_SEMAPHORE_IO_TYPE_INPUT);
} }
static moo_pfrc_t pf_system_add_output_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_add_output_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return __system_add_io_semaphore (moo, nargs, MOO_SEMAPHORE_IO_TYPE_OUTPUT); return __system_add_io_semaphore (moo, nargs, MOO_SEMAPHORE_IO_TYPE_OUTPUT);
} }
static moo_pfrc_t pf_system_remove_semaphore (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_remove_semaphore (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/* remove a semaphore from processor's signal scheduling */ /* remove a semaphore from processor's signal scheduling */
@ -2725,7 +2725,7 @@ static moo_pfrc_t pf_system_remove_semaphore (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_system_return_value_to_context (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_return_value_to_context (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t ret, ctx; moo_oop_t ret, ctx;
@ -2756,7 +2756,7 @@ static moo_pfrc_t pf_system_return_value_to_context (moo_t* moo, moo_ooi_t nargs
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_integer_add (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_add (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2772,7 +2772,7 @@ static moo_pfrc_t pf_integer_add (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_sub (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_sub (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2788,7 +2788,7 @@ static moo_pfrc_t pf_integer_sub (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_mul (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_mul (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2804,7 +2804,7 @@ static moo_pfrc_t pf_integer_mul (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_div (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_div (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, quo; moo_oop_t rcv, arg, quo;
@ -2821,7 +2821,7 @@ static moo_pfrc_t pf_integer_div (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_rem (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_rem (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, quo, rem; moo_oop_t rcv, arg, quo, rem;
@ -2837,7 +2837,7 @@ static moo_pfrc_t pf_integer_rem (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_mdiv (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_mdiv (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, quo; moo_oop_t rcv, arg, quo;
@ -2853,7 +2853,7 @@ static moo_pfrc_t pf_integer_mdiv (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_mod (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_mod (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, quo, rem; moo_oop_t rcv, arg, quo, rem;
@ -2869,7 +2869,7 @@ static moo_pfrc_t pf_integer_mod (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_negated (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_negated (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, res; moo_oop_t rcv, res;
@ -2884,7 +2884,7 @@ static moo_pfrc_t pf_integer_negated (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitat (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitat (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2900,7 +2900,7 @@ static moo_pfrc_t pf_integer_bitat (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitand (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitand (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2916,7 +2916,7 @@ static moo_pfrc_t pf_integer_bitand (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitor (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitor (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2932,7 +2932,7 @@ static moo_pfrc_t pf_integer_bitor (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitxor (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitxor (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2948,7 +2948,7 @@ static moo_pfrc_t pf_integer_bitxor (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitinv (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitinv (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, res; moo_oop_t rcv, res;
@ -2963,7 +2963,7 @@ static moo_pfrc_t pf_integer_bitinv (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_bitshift (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_bitshift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2979,7 +2979,7 @@ static moo_pfrc_t pf_integer_bitshift (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_eq (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_eq (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -2995,7 +2995,7 @@ static moo_pfrc_t pf_integer_eq (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_ne (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_ne (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3011,7 +3011,7 @@ static moo_pfrc_t pf_integer_ne (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_lt (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_lt (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3027,7 +3027,7 @@ static moo_pfrc_t pf_integer_lt (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_gt (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_gt (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3043,7 +3043,7 @@ static moo_pfrc_t pf_integer_gt (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_le (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_le (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3059,7 +3059,7 @@ static moo_pfrc_t pf_integer_le (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_ge (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_ge (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3075,7 +3075,7 @@ static moo_pfrc_t pf_integer_ge (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_integer_inttostr (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_integer_inttostr (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, str; moo_oop_t rcv, arg, str;
moo_ooi_t radix; moo_ooi_t radix;
@ -3098,7 +3098,7 @@ static moo_pfrc_t pf_integer_inttostr (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_character_eq (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_eq (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3114,7 +3114,7 @@ static moo_pfrc_t pf_character_eq (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_ne (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_ne (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3130,7 +3130,7 @@ static moo_pfrc_t pf_character_ne (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_lt (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_lt (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3148,7 +3148,7 @@ static moo_pfrc_t pf_character_lt (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_gt (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_gt (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3166,7 +3166,7 @@ static moo_pfrc_t pf_character_gt (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_le (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_le (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3184,7 +3184,7 @@ static moo_pfrc_t pf_character_le (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_ge (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_ge (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, res; moo_oop_t rcv, arg, res;
@ -3204,7 +3204,7 @@ static moo_pfrc_t pf_character_ge (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_character_as_error (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_as_error (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t c; moo_ooi_t c;
@ -3219,7 +3219,7 @@ static moo_pfrc_t pf_character_as_error (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_character_as_smooi (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_character_as_smooi (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t c; moo_ooi_t c;
@ -3234,7 +3234,7 @@ static moo_pfrc_t pf_character_as_smooi (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_smooi_as_character (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_smooi_as_character (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t ec; moo_ooi_t ec;
@ -3250,7 +3250,7 @@ static moo_pfrc_t pf_smooi_as_character (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_smooi_as_error (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_smooi_as_error (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t ec; moo_ooi_t ec;
@ -3268,7 +3268,7 @@ static moo_pfrc_t pf_smooi_as_error (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_error_as_character (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_error_as_character (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t ec; moo_ooi_t ec;
@ -3284,7 +3284,7 @@ static moo_pfrc_t pf_error_as_character (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_error_as_integer (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_error_as_integer (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
moo_ooi_t ec; moo_ooi_t ec;
@ -3300,7 +3300,7 @@ static moo_pfrc_t pf_error_as_integer (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_error_as_string (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_error_as_string (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, ss; moo_oop_t rcv, ss;
moo_ooi_t ec; moo_ooi_t ec;
@ -3323,7 +3323,7 @@ static moo_pfrc_t pf_error_as_string (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
static moo_pfrc_t pf_strlen (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_strlen (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, ret; moo_oop_t rcv, ret;
moo_oow_t i, limit; moo_oow_t i, limit;
@ -3351,7 +3351,7 @@ static moo_pfrc_t pf_strlen (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------ */ /* ------------------------------------------------------------------ */
static moo_pfrc_t pf_system_log (moo_t* moo, moo_ooi_t nargs) static moo_pfrc_t pf_system_log (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t msg, level; moo_oop_t msg, level;
moo_bitmask_t mask; moo_bitmask_t mask;
@ -3749,7 +3749,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
} }
moo_pushtmp (moo, (moo_oop_t*)&method); moo_pushtmp (moo, (moo_oop_t*)&method);
n = pftab[pfnum].pfbase.handler (moo, nargs); n = pftab[pfnum].pfbase.handler(moo, MOO_NULL, nargs); /* builtin numbered primitive. the second parameter is MOO_NULL */
moo_poptmp (moo); moo_poptmp (moo);
if (n <= MOO_PF_HARD_FAILURE) if (n <= MOO_PF_HARD_FAILURE)
{ {
@ -3778,7 +3778,8 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
moo_ooi_t pf_name_index; moo_ooi_t pf_name_index;
moo_pfbase_t* pfbase; moo_pfbase_t* pfbase;
moo_oop_t pfname; moo_oop_t pfname;
moo_oow_t w; /*moo_oow_t w;*/
moo_mod_t* mod;
stack_base = moo->sp - nargs - 1; /* stack base before receiver and arguments */ stack_base = moo->sp - nargs - 1; /* stack base before receiver and arguments */
@ -3795,19 +3796,28 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
MOO_ASSERT (moo, MOO_CLASSOF(moo,pfname) == moo->_symbol); MOO_ASSERT (moo, MOO_CLASSOF(moo,pfname) == moo->_symbol);
/* merge two SmallIntegers to get a full pointer from the cached data */ /* merge two SmallIntegers to get a full pointer from the cached data */
w = (moo_oow_t)MOO_OOP_TO_SMOOI(method->preamble_data[0]) << (MOO_OOW_BITS / 2) | /*w = (moo_oow_t)MOO_OOP_TO_SMOOI(method->preamble_data[0]) << (MOO_OOW_BITS / 2) |
(moo_oow_t)MOO_OOP_TO_SMOOI(method->preamble_data[1]); (moo_oow_t)MOO_OOP_TO_SMOOI(method->preamble_data[1]);
pfbase = (moo_pfbase_t*)w; pfbase = (moo_pfbase_t*)w;*/
if (pfbase) goto exec_handler; /* skip moo_querymod() */ pfbase = MOO_OOP_TO_SMPTR(method->preamble_data[1]);
if (pfbase)
{
mod = MOO_OOP_TO_SMPTR(method->preamble_data[0]);
goto exec_handler; /* skip moo_querymod() */
}
pfbase = moo_querymod (moo, MOO_OBJ_GET_CHAR_SLOT(pfname), MOO_OBJ_GET_SIZE(pfname)); pfbase = moo_querymod(moo, MOO_OBJ_GET_CHAR_SLOT(pfname), MOO_OBJ_GET_SIZE(pfname), &mod);
if (pfbase) if (pfbase)
{ {
int n; int n;
/* split a pointer to two OOP fields as SmallIntegers for storing/caching. */ /* split a pointer to two OOP fields as SmallIntegers for storing/caching. */
method->preamble_data[0] = MOO_SMOOI_TO_OOP((moo_oow_t)pfbase >> (MOO_OOW_BITS / 2)); /*method->preamble_data[0] = MOO_SMOOI_TO_OOP((moo_oow_t)pfbase >> (MOO_OOW_BITS / 2));
method->preamble_data[1] = MOO_SMOOI_TO_OOP((moo_oow_t)pfbase & MOO_LBMASK(moo_oow_t, MOO_OOW_BITS / 2)); method->preamble_data[1] = MOO_SMOOI_TO_OOP((moo_oow_t)pfbase & MOO_LBMASK(moo_oow_t, MOO_OOW_BITS / 2));*/
MOO_ASSERT (moo, MOO_IN_SMPTR_RANGE(mod));
MOO_ASSERT (moo, MOO_IN_SMPTR_RANGE(pfbase));
method->preamble_data[0] = MOO_SMPTR_TO_OOP(mod);
method->preamble_data[1] = MOO_SMPTR_TO_OOP(pfbase);
exec_handler: exec_handler:
if (nargs < pfbase->minargs || nargs > pfbase->maxargs) if (nargs < pfbase->minargs || nargs > pfbase->maxargs)
@ -3831,7 +3841,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
* arguments are copied to the back. */ * arguments are copied to the back. */
moo_seterrnum (moo, MOO_ENOERR); moo_seterrnum (moo, MOO_ENOERR);
n = pfbase->handler (moo, nargs); n = pfbase->handler(moo, mod, nargs);
moo_poptmp (moo); moo_poptmp (moo);
if (n <= MOO_PF_HARD_FAILURE) if (n <= MOO_PF_HARD_FAILURE)

View File

@ -1382,87 +1382,88 @@ int moo_importmod (
moo_pfbase_t* moo_querymod ( moo_pfbase_t* moo_querymod (
moo_t* moo, moo_t* moo,
const moo_ooch_t* pfid, const moo_ooch_t* pfid,
moo_oow_t pfidlen moo_oow_t pfidlen,
moo_mod_t** mod
); );
/* ========================================================================= */ /* ========================================================================= */
/* pf-basic.c */ /* pf-basic.c */
/* ========================================================================= */ /* ========================================================================= */
moo_pfrc_t moo_pf_identical (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_identical (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_not_identical (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_not_identical (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_equal (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_equal (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_not_equal (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_not_equal (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_new (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_new (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_shallow_copy (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_shallow_copy (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_class (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_class (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_size (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_size (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_is_kind_of (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_is_kind_of (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_responds_to (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_responds_to (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
/* ========================================================================= */ /* ========================================================================= */
/* pf-sys.c */ /* pf-sys.c */
/* ========================================================================= */ /* ========================================================================= */
moo_pfrc_t moo_pf_system_collect_garbage (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_collect_garbage (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_pop_collectable (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_pop_collectable (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_malloc (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_malloc (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_calloc (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_calloc (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_free (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_free (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_free (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_free (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_int8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_int16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_int32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_int64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_uint8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_uint16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_uint32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_uint64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_int8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_int16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_int32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_int64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_uint8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_uint16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_uint32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_uint64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_int8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_int16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_int32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_int64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_uint8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_uint16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_uint32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_uint64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_int8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_int16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_int32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_int64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_uint8 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_uint16 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_uint32 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_uint64 (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
moo_pfrc_t moo_pf_smptr_as_string (moo_t* moo, moo_ooi_t nargs); moo_pfrc_t moo_pf_smptr_as_string (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs);
/* TODO: remove the following debugging functions */ /* TODO: remove the following debugging functions */
/* ========================================================================= */ /* ========================================================================= */

View File

@ -680,7 +680,7 @@ int moo_importmod (moo_t* moo, moo_oop_class_t _class, const moo_ooch_t* name, m
moo_pushtmp (moo, (moo_oop_t*)&_class); moo_pushtmp (moo, (moo_oop_t*)&_class);
pair = moo_rbt_search (&moo->modtab, name, len); pair = moo_rbt_search(&moo->modtab, name, len);
if (pair) if (pair)
{ {
mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair); mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair);
@ -691,7 +691,7 @@ int moo_importmod (moo_t* moo, moo_oop_class_t _class, const moo_ooch_t* name, m
goto done2; goto done2;
} }
mdp = moo_openmod (moo, name, len, MOO_MOD_LOAD_FOR_IMPORT); mdp = moo_openmod(moo, name, len, MOO_MOD_LOAD_FOR_IMPORT);
if (!mdp) goto done2; if (!mdp) goto done2;
if (!mdp->mod.import) if (!mdp->mod.import)
@ -701,7 +701,7 @@ int moo_importmod (moo_t* moo, moo_oop_class_t _class, const moo_ooch_t* name, m
goto done; goto done;
} }
if (mdp->mod.import (moo, &mdp->mod, _class) <= -1) if (mdp->mod.import(moo, &mdp->mod, _class) <= -1)
{ {
MOO_DEBUG1 (moo, "Cannot import module [%js] - module's import() returned failure\n", mdp->mod.name); MOO_DEBUG1 (moo, "Cannot import module [%js] - module's import() returned failure\n", mdp->mod.name);
goto done; goto done;
@ -721,7 +721,7 @@ done2:
return r; return r;
} }
moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidlen) moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidlen, moo_mod_t** mod)
{ {
/* primitive function identifier /* primitive function identifier
* _funcname * _funcname
@ -734,7 +734,7 @@ moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidle
moo_oow_t mod_name_len; moo_oow_t mod_name_len;
moo_pfbase_t* pfbase; moo_pfbase_t* pfbase;
sep = moo_rfind_oochar (pfid, pfidlen, '.'); sep = moo_rfind_oochar(pfid, pfidlen, '.');
if (!sep) if (!sep)
{ {
/* i'm writing a conservative code here. the compiler should /* i'm writing a conservative code here. the compiler should
@ -752,7 +752,7 @@ moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidle
* module id. the last segment is the primitive function name. * module id. the last segment is the primitive function name.
* for instance, in con.window.open, con.window is a module id and * for instance, in con.window.open, con.window is a module id and
* open is the primitive function name. */ * open is the primitive function name. */
pair = moo_rbt_search (&moo->modtab, pfid, mod_name_len); pair = moo_rbt_search(&moo->modtab, pfid, mod_name_len);
if (pair) if (pair)
{ {
mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair); mdp = (moo_mod_data_t*)MOO_RBT_VPTR(pair);
@ -761,11 +761,11 @@ moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidle
else else
{ {
/* open a module using the part before the last period */ /* open a module using the part before the last period */
mdp = moo_openmod (moo, pfid, mod_name_len, 0); mdp = moo_openmod(moo, pfid, mod_name_len, 0);
if (!mdp) return MOO_NULL; if (!mdp) return MOO_NULL;
} }
if ((pfbase = mdp->mod.query (moo, &mdp->mod, sep + 1, pfidlen - mod_name_len - 1)) == MOO_NULL) if ((pfbase = mdp->mod.query(moo, &mdp->mod, sep + 1, pfidlen - mod_name_len - 1)) == MOO_NULL)
{ {
/* the primitive function is not found. but keep the module open even if it's opened above */ /* the primitive function is not found. but keep the module open even if it's opened above */
MOO_DEBUG3 (moo, "Cannot find a primitive function [%.*js] in a module [%js]\n", pfidlen - mod_name_len - 1, sep + 1, mdp->mod.name); MOO_DEBUG3 (moo, "Cannot find a primitive function [%.*js] in a module [%js]\n", pfidlen - mod_name_len - 1, sep + 1, mdp->mod.name);
@ -773,6 +773,8 @@ moo_pfbase_t* moo_querymod (moo_t* moo, const moo_ooch_t* pfid, moo_oow_t pfidle
return MOO_NULL; return MOO_NULL;
} }
if (mod) *mod = &mdp->mod;
MOO_DEBUG4 (moo, "Found a primitive function [%.*js] in a module [%js] - %p\n", MOO_DEBUG4 (moo, "Found a primitive function [%.*js] in a module [%js] - %p\n",
pfidlen - mod_name_len - 1, sep + 1, mdp->mod.name, pfbase); pfidlen - mod_name_len - 1, sep + 1, mdp->mod.name, pfbase);
return pfbase; return pfbase;
@ -870,8 +872,10 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
mth->name = mnsym; mth->name = mnsym;
if (variadic) preamble_flags |= MOO_METHOD_PREAMBLE_FLAG_VARIADIC; if (variadic) preamble_flags |= MOO_METHOD_PREAMBLE_FLAG_VARIADIC;
mth->preamble = MOO_SMOOI_TO_OOP(MOO_METHOD_MAKE_PREAMBLE(MOO_METHOD_PREAMBLE_NAMED_PRIMITIVE, 0, preamble_flags)); mth->preamble = MOO_SMOOI_TO_OOP(MOO_METHOD_MAKE_PREAMBLE(MOO_METHOD_PREAMBLE_NAMED_PRIMITIVE, 0, preamble_flags));
mth->preamble_data[0] = MOO_SMOOI_TO_OOP(0); /*mth->preamble_data[0] = MOO_SMOOI_TO_OOP(0);
mth->preamble_data[1] = MOO_SMOOI_TO_OOP(0); mth->preamble_data[1] = MOO_SMOOI_TO_OOP(0);*/
mth->preamble_data[0] = MOO_SMPTR_TO_OOP(0);
mth->preamble_data[1] = MOO_SMPTR_TO_OOP(0);
mth->tmpr_count = MOO_SMOOI_TO_OOP(arg_count); mth->tmpr_count = MOO_SMOOI_TO_OOP(arg_count);
mth->tmpr_nargs = MOO_SMOOI_TO_OOP(arg_count); mth->tmpr_nargs = MOO_SMOOI_TO_OOP(arg_count);

View File

@ -39,6 +39,7 @@
#define MOO_USE_METHOD_TRAILER #define MOO_USE_METHOD_TRAILER
typedef struct moo_mod_t moo_mod_t;
typedef unsigned int moo_bitmask_t; typedef unsigned int moo_bitmask_t;
/* ========================================================================== */ /* ========================================================================== */
@ -1154,6 +1155,7 @@ typedef enum moo_pfrc_t moo_pfrc_t;
/* primitive function implementation type */ /* primitive function implementation type */
typedef moo_pfrc_t (*moo_pfimpl_t) ( typedef moo_pfrc_t (*moo_pfimpl_t) (
moo_t* moo, moo_t* moo,
moo_mod_t* mod,
moo_ooi_t nargs moo_ooi_t nargs
); );
@ -1196,8 +1198,6 @@ struct moo_pfinfo_t
* ========================================================================= */ * ========================================================================= */
#define MOO_MOD_NAME_LEN_MAX 120 #define MOO_MOD_NAME_LEN_MAX 120
typedef struct moo_mod_t moo_mod_t;
enum moo_mod_hint_t enum moo_mod_hint_t
{ {
MOO_MOD_LOAD_FOR_IMPORT = (1 << 0) MOO_MOD_LOAD_FOR_IMPORT = (1 << 0)

View File

@ -31,7 +31,7 @@
* COMPARISON * COMPARISON
* -------------------------------------------------------------------------------- */ * -------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_identical (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_identical (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, b; moo_oop_t rcv, arg, b;
@ -46,7 +46,7 @@ moo_pfrc_t moo_pf_identical (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_not_identical (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_not_identical (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg, b; moo_oop_t rcv, arg, b;
@ -155,7 +155,7 @@ static int _equal_objects (moo_t* moo, moo_oop_t rcv, moo_oop_t arg)
} }
} }
moo_pfrc_t moo_pf_equal (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_equal (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg; moo_oop_t rcv, arg;
int n; int n;
@ -170,7 +170,7 @@ moo_pfrc_t moo_pf_equal (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_not_equal (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_not_equal (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, arg; moo_oop_t rcv, arg;
int n; int n;
@ -190,7 +190,7 @@ moo_pfrc_t moo_pf_not_equal (moo_t* moo, moo_ooi_t nargs)
* INSTANTIATION * INSTANTIATION
* -------------------------------------------------------------------------------- */ * -------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_basic_new (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_new (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_class_t _class; moo_oop_class_t _class;
moo_oop_t szoop, obj; moo_oop_t szoop, obj;
@ -240,7 +240,7 @@ moo_pfrc_t moo_pf_basic_new (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_shallow_copy (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_shallow_copy (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, obj; moo_oop_t rcv, obj;
@ -259,7 +259,7 @@ moo_pfrc_t moo_pf_shallow_copy (moo_t* moo, moo_ooi_t nargs)
* BASIC ACCESS * BASIC ACCESS
* -------------------------------------------------------------------------------- */ * -------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_class (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_class (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
rcv = MOO_STACK_GETRCV(moo, nargs); rcv = MOO_STACK_GETRCV(moo, nargs);
@ -268,7 +268,7 @@ moo_pfrc_t moo_pf_class (moo_t* moo, moo_ooi_t nargs)
} }
moo_pfrc_t moo_pf_basic_size (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_size (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/* return the number of indexable fields */ /* return the number of indexable fields */
@ -294,7 +294,7 @@ moo_pfrc_t moo_pf_basic_size (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, pos, v; moo_oop_t rcv, pos, v;
moo_oow_t idx; moo_oow_t idx;
@ -356,7 +356,7 @@ moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, pos, val; moo_oop_t rcv, pos, val;
moo_oow_t idx; moo_oow_t idx;
@ -454,7 +454,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, spos, dval, slen; moo_oop_t rcv, spos, dval, slen;
moo_oow_t sidx, ssz, maxlen, end, i; moo_oow_t sidx, ssz, maxlen, end, i;
@ -571,7 +571,7 @@ invalid_fill_value:
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, spos, dpos, slen; moo_oop_t rcv, spos, dpos, slen;
moo_oow_t sidx, ssz, didx; moo_oow_t sidx, ssz, didx;
@ -757,7 +757,7 @@ done:
* BASIC QUERY * BASIC QUERY
* -------------------------------------------------------------------------------- */ * -------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_is_kind_of (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_is_kind_of (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, _class; moo_oop_t rcv, _class;
@ -778,7 +778,7 @@ moo_pfrc_t moo_pf_is_kind_of (moo_t* moo, moo_ooi_t nargs)
} }
moo_pfrc_t moo_pf_responds_to (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_responds_to (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv, selector; moo_oop_t rcv, selector;
moo_oocs_t mthname; moo_oocs_t mthname;

View File

@ -29,14 +29,14 @@
moo_pfrc_t moo_pf_system_collect_garbage (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_collect_garbage (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_gc (moo); moo_gc (moo);
MOO_STACK_SETRETTORCV (moo, nargs); MOO_STACK_SETRETTORCV (moo, nargs);
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_system_pop_collectable (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_pop_collectable (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
if (moo->collectable.first) if (moo->collectable.first)
{ {
@ -94,19 +94,19 @@ static MOO_INLINE moo_pfrc_t _system_alloc (moo_t* moo, moo_ooi_t nargs, int cle
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_system_calloc (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_calloc (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/*MOO_PF_CHECK_RCV (moo, MOO_STACK_GETRCV(moo, nargs) == (moo_oop_t)moo->_system);*/ /*MOO_PF_CHECK_RCV (moo, MOO_STACK_GETRCV(moo, nargs) == (moo_oop_t)moo->_system);*/
return _system_alloc (moo, nargs, 1); return _system_alloc (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_system_malloc (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_malloc (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
/*MOO_PF_CHECK_RCV (moo, MOO_STACK_GETRCV(moo, nargs) == (moo_oop_t)moo->_system);*/ /*MOO_PF_CHECK_RCV (moo, MOO_STACK_GETRCV(moo, nargs) == (moo_oop_t)moo->_system);*/
return _system_alloc (moo, nargs, 0); return _system_alloc (moo, nargs, 0);
} }
moo_pfrc_t moo_pf_system_free (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_free (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t tmp; moo_oop_t tmp;
void* rawptr; void* rawptr;
@ -129,7 +129,7 @@ moo_pfrc_t moo_pf_system_free (moo_t* moo, moo_ooi_t nargs)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_smptr_free (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_free (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t tmp; moo_oop_t tmp;
@ -418,42 +418,42 @@ static moo_pfrc_t _get_system_uint (moo_t* moo, moo_ooi_t nargs, int size)
} }
moo_pfrc_t moo_pf_system_get_int8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_int (moo, nargs, 1); return _get_system_int (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_system_get_int16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_int (moo, nargs, 2); return _get_system_int (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_system_get_int32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_int (moo, nargs, 4); return _get_system_int (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_system_get_int64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_int (moo, nargs, 8); return _get_system_int (moo, nargs, 8);
} }
moo_pfrc_t moo_pf_system_get_uint8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_uint (moo, nargs, 1); return _get_system_uint (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_system_get_uint16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_uint (moo, nargs, 2); return _get_system_uint (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_system_get_uint32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_uint (moo, nargs, 4); return _get_system_uint (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_system_get_uint64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_system_uint (moo, nargs, 8); return _get_system_uint (moo, nargs, 8);
} }
@ -524,42 +524,42 @@ static moo_pfrc_t _put_system_uint (moo_t* moo, moo_ooi_t nargs, int size)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_system_put_int8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_int (moo, nargs, 1); return _put_system_int (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_system_put_int16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_int (moo, nargs, 2); return _put_system_int (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_system_put_int32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_int (moo, nargs, 4); return _put_system_int (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_system_put_int64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_int (moo, nargs, 8); return _put_system_int (moo, nargs, 8);
} }
moo_pfrc_t moo_pf_system_put_uint8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_uint (moo, nargs, 1); return _put_system_uint (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_system_put_uint16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_uint (moo, nargs, 2); return _put_system_uint (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_system_put_uint32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_uint (moo, nargs, 4); return _put_system_uint (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_system_put_uint64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_system_uint (moo, nargs, 8); return _put_system_uint (moo, nargs, 8);
} }
@ -567,7 +567,7 @@ moo_pfrc_t moo_pf_system_put_uint64 (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_uint8_t* rawptr; moo_uint8_t* rawptr;
moo_oow_t offset, offset_in_buffer, len_in_buffer; moo_oow_t offset, offset_in_buffer, len_in_buffer;
@ -630,7 +630,7 @@ moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_ooi_t nargs)
} }
moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_uint8_t* rawptr; moo_uint8_t* rawptr;
moo_oow_t offset, offset_in_buffer, len_in_buffer; moo_oow_t offset, offset_in_buffer, len_in_buffer;
@ -750,42 +750,42 @@ static moo_pfrc_t _get_smptr_uint (moo_t* moo, moo_ooi_t nargs, int size)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_smptr_get_int8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_int (moo, nargs, 1); return _get_smptr_int (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_smptr_get_int16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_int (moo, nargs, 2); return _get_smptr_int (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_smptr_get_int32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_int (moo, nargs, 4); return _get_smptr_int (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_smptr_get_int64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_int (moo, nargs, 8); return _get_smptr_int (moo, nargs, 8);
} }
moo_pfrc_t moo_pf_smptr_get_uint8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_uint (moo, nargs, 1); return _get_smptr_uint (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_smptr_get_uint16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_uint (moo, nargs, 2); return _get_smptr_uint (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_smptr_get_uint32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_uint (moo, nargs, 4); return _get_smptr_uint (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_smptr_get_uint64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _get_smptr_uint (moo, nargs, 8); return _get_smptr_uint (moo, nargs, 8);
} }
@ -848,42 +848,42 @@ static moo_pfrc_t _put_smptr_uint (moo_t* moo, moo_ooi_t nargs, int size)
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
} }
moo_pfrc_t moo_pf_smptr_put_int8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_int8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_int (moo, nargs, 1); return _put_smptr_int (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_smptr_put_int16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_int16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_int (moo, nargs, 2); return _put_smptr_int (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_smptr_put_int32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_int32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_int (moo, nargs, 4); return _put_smptr_int (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_smptr_put_int64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_int64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_int (moo, nargs, 8); return _put_smptr_int (moo, nargs, 8);
} }
moo_pfrc_t moo_pf_smptr_put_uint8 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_uint8 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_uint (moo, nargs, 1); return _put_smptr_uint (moo, nargs, 1);
} }
moo_pfrc_t moo_pf_smptr_put_uint16 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_uint16 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_uint (moo, nargs, 2); return _put_smptr_uint (moo, nargs, 2);
} }
moo_pfrc_t moo_pf_smptr_put_uint32 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_uint32 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_uint (moo, nargs, 4); return _put_smptr_uint (moo, nargs, 4);
} }
moo_pfrc_t moo_pf_smptr_put_uint64 (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_uint64 (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
return _put_smptr_uint (moo, nargs, 8); return _put_smptr_uint (moo, nargs, 8);
} }
@ -891,7 +891,7 @@ moo_pfrc_t moo_pf_smptr_put_uint64 (moo_t* moo, moo_ooi_t nargs)
/* ------------------------------------------------------------------------------------- */ /* ------------------------------------------------------------------------------------- */
moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_uint8_t* rawptr; moo_uint8_t* rawptr;
moo_oow_t offset, offset_in_buffer, len_in_buffer; moo_oow_t offset, offset_in_buffer, len_in_buffer;
@ -949,7 +949,7 @@ moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_ooi_t nargs)
} }
moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_uint8_t* rawptr; moo_uint8_t* rawptr;
moo_oow_t offset, offset_in_buffer, len_in_buffer; moo_oow_t offset, offset_in_buffer, len_in_buffer;
@ -1035,7 +1035,7 @@ static void sprintptr (moo_ooch_t* nbuf, moo_oow_t num, moo_oow_t *lenp)
} }
} }
moo_pfrc_t moo_pf_smptr_as_string (moo_t* moo, moo_ooi_t nargs) moo_pfrc_t moo_pf_smptr_as_string (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t rcv; moo_oop_t rcv;
void* ptr; void* ptr;