used more access macros

This commit is contained in:
hyunghwan.chung 2018-12-19 16:57:16 +00:00
parent 18aa5c37c0
commit fb7b226ea8
10 changed files with 69 additions and 64 deletions

View File

@ -2881,7 +2881,7 @@ static int set_class_level_variable_initv (moo_t* moo, var_type_t var_type, moo_
oldcapa = cc->var[var_type].initv_capa; oldcapa = cc->var[var_type].initv_capa;
newcapa = MOO_ALIGN_POW2 ((var_index + 1), 32); newcapa = MOO_ALIGN_POW2 ((var_index + 1), 32);
tmp = moo_reallocmem (moo, cc->var[var_type].initv, newcapa * MOO_SIZEOF(*tmp)); tmp = moo_reallocmem(moo, cc->var[var_type].initv, newcapa * MOO_SIZEOF(*tmp));
if (!tmp) return -1; if (!tmp) return -1;
/*for (i = cc->var[var_type].initv_capa; i < newcapa; i++) tmp[i] = MOO_NULL;*/ /*for (i = cc->var[var_type].initv_capa; i < newcapa; i++) tmp[i] = MOO_NULL;*/
@ -4850,7 +4850,7 @@ static int read_array_literal (moo_t* moo, int rdonly, moo_oop_t* xlit)
for (i = saved_arlit_count, j = 0; i < moo->c->arlit.count; i++, j++) for (i = saved_arlit_count, j = 0; i < moo->c->arlit.count; i++, j++)
{ {
MOO_STORE_OOP (moo, &((moo_oop_oop_t)a)->slot[j], moo->c->arlit.ptr[i]); MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(a, j), moo->c->arlit.ptr[i]);
} }
if (rdonly) if (rdonly)
@ -6466,16 +6466,16 @@ static int add_compiled_method (moo_t* moo)
/* The variadic data part passed to moo_instantiate() is not GC-safe. /* The variadic data part passed to moo_instantiate() is not GC-safe.
* let's delay initialization of variadic data a bit. */ * let's delay initialization of variadic data a bit. */
#if defined(MOO_USE_METHOD_TRAILER) #if defined(MOO_USE_METHOD_TRAILER)
mth = (moo_oop_method_t)moo_instantiatewithtrailer (moo, moo->_method, cc->mth.literals.count, cc->mth.code.ptr, cc->mth.code.len); mth = (moo_oop_method_t)moo_instantiatewithtrailer(moo, moo->_method, cc->mth.literals.count, cc->mth.code.ptr, cc->mth.code.len);
#else #else
mth = (moo_oop_method_t)moo_instantiate (moo, moo->_method, MOO_NULL, cc->mth.literals.count); mth = (moo_oop_method_t)moo_instantiate(moo, moo->_method, MOO_NULL, cc->mth.literals.count);
#endif #endif
if (!mth) goto oops; if (!mth) goto oops;
for (i = 0; i < cc->mth.literals.count; i++) for (i = 0; i < cc->mth.literals.count; i++)
{ {
/* let's do the variadic data initialization here */ /* let's do the variadic data initialization here */
MOO_STORE_OOP (moo, &mth->slot[i], cc->mth.literals.ptr[i]); MOO_STORE_OOP (moo, &mth->literal_frame[i], cc->mth.literals.ptr[i]);
} }
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++; moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
@ -7249,7 +7249,8 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type)
MOO_ASSERT (moo, MOO_CLASSOF(moo, initv) == moo->_array); MOO_ASSERT (moo, MOO_CLASSOF(moo, initv) == moo->_array);
for (i = 0; i < super_initv_count; i++) for (i = 0; i < super_initv_count; i++)
{ {
if (initv->slot[i]) MOO_STORE_OOP (moo, &((moo_oop_oop_t)tmp)->slot[j], initv->slot[i]); if (MOO_OBJ_GET_OOP_VAL(initv, i))
MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(tmp, j), MOO_OBJ_GET_OOP_VAL(initv, i));
j++; j++;
} }
} }
@ -7262,7 +7263,7 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type)
for (i = 0; i < cc->var[var_type].initv_count; i++) for (i = 0; i < cc->var[var_type].initv_count; i++)
{ {
if (cc->var[var_type].initv[i].v) if (cc->var[var_type].initv[i].v)
MOO_STORE_OOP (moo, &((moo_oop_oop_t)tmp)->slot[j], cc->var[var_type].initv[i].v); MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(tmp, j), cc->var[var_type].initv[i].v);
j++; j++;
} }
@ -7324,8 +7325,7 @@ static int make_defined_class (moo_t* moo)
{ {
/* the class variables and class instance variables are placed /* the class variables and class instance variables are placed
* inside the class object after the fixed part. */ * inside the class object after the fixed part. */
tmp = moo_instantiate(moo, moo->_class, MOO_NULL, tmp = moo_instantiate(moo, moo->_class, MOO_NULL, cc->var[VAR_CLASSINST].total_count + cc->var[VAR_CLASS].total_count);
cc->var[VAR_CLASSINST].total_count + cc->var[VAR_CLASS].total_count);
if (!tmp) return -1; if (!tmp) return -1;
just_made = 1; just_made = 1;
@ -7407,7 +7407,7 @@ static int make_defined_class (moo_t* moo)
for (i = 0; i < initv_count; i++) for (i = 0; i < initv_count; i++)
{ {
MOO_STORE_OOP (moo, &cc->self_oop->slot[i], initv->slot[i]); MOO_STORE_OOP (moo, &cc->self_oop->cvar[i], initv->slot[i]);
} }
} }
@ -7425,7 +7425,7 @@ static int make_defined_class (moo_t* moo)
MOO_ASSERT (moo, MOO_CLASS_NAMED_INSTVARS + j + initv_count <= MOO_OBJ_GET_SIZE(cc->self_oop)); MOO_ASSERT (moo, MOO_CLASS_NAMED_INSTVARS + j + initv_count <= MOO_OBJ_GET_SIZE(cc->self_oop));
for (i = 0; i < initv_count; i++) for (i = 0; i < initv_count; i++)
{ {
MOO_STORE_OOP (moo, &cc->self_oop->slot[j], cc->var[VAR_CLASS].initv[i].v); MOO_STORE_OOP (moo, &cc->self_oop->cvar[j], cc->var[VAR_CLASS].initv[i].v);
j++; j++;
} }
} }

View File

@ -32,7 +32,7 @@ void moo_dumpsymtab (moo_t* moo)
moo_oop_char_t symbol; moo_oop_char_t symbol;
MOO_DEBUG0 (moo, "--------------------------------------------\n"); MOO_DEBUG0 (moo, "--------------------------------------------\n");
MOO_DEBUG1 (moo, "Stix Symbol Table %zu\n", MOO_OBJ_GET_SIZE(moo->symtab->bucket)); MOO_DEBUG1 (moo, "MOO Symbol Table %zu\n", MOO_OBJ_GET_SIZE(moo->symtab->bucket));
MOO_DEBUG0 (moo, "--------------------------------------------\n"); MOO_DEBUG0 (moo, "--------------------------------------------\n");
for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++)

View File

@ -604,7 +604,7 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn)
/* print literal frame contents */ /* print literal frame contents */
for (ip = 0; ip < MOO_OBJ_GET_SIZE(mth) - MOO_METHOD_NAMED_INSTVARS; ip++) for (ip = 0; ip < MOO_OBJ_GET_SIZE(mth) - MOO_METHOD_NAMED_INSTVARS; ip++)
{ {
MOO_LOG2(moo, DECODE_LOG_MASK, " @%-5zd %O\n", ip, MOO_OBJ_GET_OOP_VAL(mth, ip)); MOO_LOG2(moo, DECODE_LOG_MASK, " @%-5zd %O\n", ip, mth->literal_frame[ip]);
} }
return 0; return 0;

View File

@ -818,7 +818,7 @@ static moo_oop_process_t signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
* semaphore */ * semaphore */
MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(proc->sp) < (moo_ooi_t)(MOO_OBJ_GET_SIZE(proc) - MOO_PROCESS_NAMED_INSTVARS)); MOO_ASSERT (moo, MOO_OOP_TO_SMOOI(proc->sp) < (moo_ooi_t)(MOO_OBJ_GET_SIZE(proc) - MOO_PROCESS_NAMED_INSTVARS));
sp = MOO_OOP_TO_SMOOI(proc->sp); sp = MOO_OOP_TO_SMOOI(proc->sp);
MOO_STORE_OOP (moo, &proc->slot[sp], (moo_oop_t)sem); MOO_STORE_OOP (moo, &proc->stack[sp], (moo_oop_t)sem);
/* i should decrement the counter as long as the group being /* i should decrement the counter as long as the group being
* signaled contains an IO semaphore */ * signaled contains an IO semaphore */
@ -1588,7 +1588,7 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
{ {
/* place variadic arguments after local temporaries */ /* place variadic arguments after local temporaries */
--j; --j;
MOO_STORE_OOP (moo, &ctx->slot[j], MOO_STACK_GETTOP(moo)); MOO_STORE_OOP (moo, &ctx->stack[j], MOO_STACK_GETTOP(moo));
MOO_STACK_POP (moo); MOO_STACK_POP (moo);
} }
MOO_ASSERT (moo, i == nargs); MOO_ASSERT (moo, i == nargs);
@ -1596,7 +1596,7 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
{ {
/* place normal argument before local temporaries */ /* place normal argument before local temporaries */
--i; --i;
MOO_STORE_OOP (moo, &ctx->slot[i], MOO_STACK_GETTOP(moo)); MOO_STORE_OOP (moo, &ctx->stack[i], MOO_STACK_GETTOP(moo));
MOO_STACK_POP (moo); MOO_STACK_POP (moo);
} }
} }
@ -1606,7 +1606,7 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
{ {
/* place normal argument before local temporaries */ /* place normal argument before local temporaries */
--i; --i;
MOO_STORE_OOP (moo, &ctx->slot[i], MOO_STACK_GETTOP(moo)); MOO_STORE_OOP (moo, &ctx->stack[i], MOO_STACK_GETTOP(moo));
MOO_STACK_POP (moo); MOO_STACK_POP (moo);
} }
} }
@ -2184,7 +2184,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(xarg) == num_first_arg_elems); MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(xarg) == num_first_arg_elems);
for (i = 0; i < num_first_arg_elems; i++) for (i = 0; i < num_first_arg_elems; i++)
{ {
MOO_STORE_OOP (moo, &blkctx->slot[i], xarg->slot[i]); MOO_STORE_OOP (moo, &blkctx->stack[i], xarg->slot[i]);
} }
} }
else else
@ -2193,7 +2193,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
for (i = 0; i < nargs; i++) for (i = 0; i < nargs; i++)
{ {
register moo_oop_t tmp = MOO_STACK_GETARG(moo, nargs, i); register moo_oop_t tmp = MOO_STACK_GETARG(moo, nargs, i);
MOO_STORE_OOP (moo, &blkctx->slot[i], tmp); MOO_STORE_OOP (moo, &blkctx->stack[i], tmp);
} }
} }
MOO_STACK_POPS (moo, nargs + 1); /* pop arguments and receiver */ MOO_STACK_POPS (moo, nargs + 1); /* pop arguments and receiver */
@ -3855,7 +3855,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
/* index to the primitive function identifier in the literal frame */ /* index to the primitive function identifier in the literal frame */
pf_name_index = MOO_METHOD_GET_PREAMBLE_INDEX(preamble); pf_name_index = MOO_METHOD_GET_PREAMBLE_INDEX(preamble);
MOO_ASSERT (moo, pf_name_index >= 0); MOO_ASSERT (moo, pf_name_index >= 0);
pfname = method->slot[pf_name_index]; pfname = method->literal_frame[pf_name_index];
#if defined(MOO_BUILD_DEBUG) #if defined(MOO_BUILD_DEBUG)
LOG_INST1 (moo, "preamble_named_primitive %zd", pf_name_index); LOG_INST1 (moo, "preamble_named_primitive %zd", pf_name_index);
@ -4853,12 +4853,12 @@ static int __execute (moo_t* moo)
{ {
/* push - bit 4 on */ /* push - bit 4 on */
LOG_INST1 (moo, "push_tempvar %zu", b1); LOG_INST1 (moo, "push_tempvar %zu", b1);
MOO_STACK_PUSH (moo, ctx->slot[bx]); MOO_STACK_PUSH (moo, ctx->stack[bx]);
} }
else else
{ {
/* store or pop - bit 5 off */ /* store or pop - bit 5 off */
MOO_STORE_OOP (moo, &ctx->slot[bx], MOO_STACK_GETTOP(moo)); MOO_STORE_OOP (moo, &ctx->stack[bx], MOO_STACK_GETTOP(moo));
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
@ -4891,7 +4891,7 @@ static int __execute (moo_t* moo)
b1 = bcode & 0x7; /* low 3 bits */ b1 = bcode & 0x7; /* low 3 bits */
push_literal: push_literal:
LOG_INST1 (moo, "push_literal @%zu", b1); LOG_INST1 (moo, "push_literal @%zu", b1);
MOO_STACK_PUSH (moo, moo->active_method->slot[b1]); MOO_STACK_PUSH (moo, moo->active_method->literal_frame[b1]);
NEXT_INST(); NEXT_INST();
/* ------------------------------------------------- */ /* ------------------------------------------------- */
@ -4918,7 +4918,7 @@ static int __execute (moo_t* moo)
b1 = bcode & 0x3; /* low 2 bits */ b1 = bcode & 0x3; /* low 2 bits */
handle_object: handle_object:
ass = (moo_oop_association_t)moo->active_method->slot[b1]; ass = (moo_oop_association_t)moo->active_method->literal_frame[b1];
MOO_ASSERT (moo, MOO_CLASSOF(moo, ass) == moo->_association); MOO_ASSERT (moo, MOO_CLASSOF(moo, ass) == moo->_association);
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
@ -5128,7 +5128,7 @@ static int __execute (moo_t* moo)
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
/* store or pop */ /* store or pop */
MOO_STORE_OOP (moo, &ctx->slot[b2], MOO_STACK_GETTOP(moo)); MOO_STORE_OOP (moo, &ctx->stack[b2], MOO_STACK_GETTOP(moo));
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)
{ {
@ -5144,7 +5144,7 @@ static int __execute (moo_t* moo)
else else
{ {
/* push */ /* push */
MOO_STACK_PUSH (moo, ctx->slot[b2]); MOO_STACK_PUSH (moo, ctx->stack[b2]);
LOG_INST2 (moo, "push_ctxtempvar %zu %zu", b1, b2); LOG_INST2 (moo, "push_ctxtempvar %zu %zu", b1, b2);
} }
@ -5180,7 +5180,7 @@ static int __execute (moo_t* moo)
b2 = FETCH_BYTE_CODE(moo); b2 = FETCH_BYTE_CODE(moo);
handle_objvar: handle_objvar:
t = (moo_oop_oop_t)moo->active_method->slot[b2]; t = (moo_oop_oop_t)moo->active_method->literal_frame[b2];
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(t) == MOO_OBJ_TYPE_OOP); MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(t) == MOO_OBJ_TYPE_OOP);
MOO_ASSERT (moo, b1 < MOO_OBJ_GET_SIZE(t)); MOO_ASSERT (moo, b1 < MOO_OBJ_GET_SIZE(t));
@ -5234,7 +5234,7 @@ static int __execute (moo_t* moo)
handle_send_message: handle_send_message:
/* get the selector from the literal frame */ /* get the selector from the literal frame */
selector = (moo_oop_char_t)moo->active_method->slot[b2]; selector = (moo_oop_char_t)moo->active_method->literal_frame[b2];
LOG_INST3 (moo, "send_message%hs %zu @%zu", (((bcode >> 2) & 1)? "_to_super": ""), b1, b2); LOG_INST3 (moo, "send_message%hs %zu @%zu", (((bcode >> 2) & 1)? "_to_super": ""), b1, b2);
if (send_message (moo, selector, ((bcode >> 2) & 1), b1) <= -1) return -1; if (send_message (moo, selector, ((bcode >> 2) & 1), b1) <= -1) return -1;

View File

@ -556,11 +556,11 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_
i = 0; i = 0;
if (i < MOO_OBJ_GET_SIZE(oop)) if (i < MOO_OBJ_GET_SIZE(oop))
{ {
if (print_object(moo, mask, MOO_OBJ_GET_OOP_SLOT(oop)[i], outbfmt) <= -1) return -1; if (print_object(moo, mask, MOO_OBJ_GET_OOP_VAL(oop, i), outbfmt) <= -1) return -1;
for (++i; i < MOO_OBJ_GET_SIZE(oop); i++) for (++i; i < MOO_OBJ_GET_SIZE(oop); i++)
{ {
if (outbfmt(moo, mask, " ") <= -1) return -1; if (outbfmt(moo, mask, " ") <= -1) return -1;
if (print_object(moo, mask, MOO_OBJ_GET_OOP_SLOT(oop)[i], outbfmt) <= -1) return -1; if (print_object(moo, mask, MOO_OBJ_GET_OOP_VAL(oop, i), outbfmt) <= -1) return -1;
} }
} }
if (outbfmt(moo, mask, ")") <= -1) return -1; if (outbfmt(moo, mask, ")") <= -1) return -1;

View File

@ -304,7 +304,7 @@ int main (int argc, char* argv[])
moo_uncatch_termreq (); moo_uncatch_termreq ();
/*moo_dumpsymtab(moo); /*moo_dumpsymtab(moo);
*moo_dumpdic(moo, moo->sysdic, "System dictionary");*/ moo_dumpdic(moo, moo->sysdic, "System dictionary");*/
moo_close (moo); moo_close (moo);
return xret; return xret;

View File

@ -647,7 +647,7 @@ struct moo_compiler_t
#if defined(MOO_USE_METHOD_TRAILER) #if defined(MOO_USE_METHOD_TRAILER)
/* let it point to the trailer of the method */ /* let it point to the trailer of the method */
# define SET_ACTIVE_METHOD_CODE(moo) ((moo)->active_code = (moo_oob_t*)&(moo)->active_method->slot[MOO_OBJ_GET_SIZE((moo)->active_method) + 1 - MOO_METHOD_NAMED_INSTVARS]) # define SET_ACTIVE_METHOD_CODE(moo) ((moo)->active_code = (moo_oob_t*)&(moo)->active_method->literal_frame[MOO_OBJ_GET_SIZE((moo)->active_method) + 1 - MOO_METHOD_NAMED_INSTVARS])
#else #else
/* let it point to the payload of the code byte array */ /* let it point to the payload of the code byte array */
# define SET_ACTIVE_METHOD_CODE(moo) ((moo)->active_code = (moo)->active_method->code->slot) # define SET_ACTIVE_METHOD_CODE(moo) ((moo)->active_code = (moo)->active_method->code->slot)

View File

@ -864,7 +864,7 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
} }
/* store the primitive function name symbol to the literal frame */ /* store the primitive function name symbol to the literal frame */
mth->slot[0] = (moo_oop_t)pfidsym; mth->literal_frame[0] = (moo_oop_t)pfidsym;
/* premable should contain the index to the literal frame which is always 0 */ /* premable should contain the index to the literal frame which is always 0 */
mth->owner = _class; mth->owner = _class;

View File

@ -613,7 +613,7 @@ struct moo_class_t
moo_oop_t initv[2]; moo_oop_t initv[2];
/* indexed part afterwards */ /* indexed part afterwards */
moo_oop_t slot[1]; /* class instance variables and class variables. */ moo_oop_t cvar[1]; /* class instance variables and class variables. */
}; };
#define MOO_ASSOCIATION_NAMED_INSTVARS 2 #define MOO_ASSOCIATION_NAMED_INSTVARS 2
@ -665,7 +665,7 @@ struct moo_method_t
moo_oop_t tmpr_nargs; /* SmallInteger */ moo_oop_t tmpr_nargs; /* SmallInteger */
#if defined(MOO_USE_METHOD_TRAILER) #if defined(MOO_USE_METHOD_TRAILER)
/* no code field is used */ /* no code field is used. it's placed after literal_frame. */
#else #else
moo_oop_byte_t code; /* ByteArray */ moo_oop_byte_t code; /* ByteArray */
#endif #endif
@ -673,7 +673,9 @@ struct moo_method_t
moo_oop_t source; /* TODO: what should I put? */ moo_oop_t source; /* TODO: what should I put? */
/* == variable indexed part == */ /* == variable indexed part == */
moo_oop_t slot[1]; /* it stores literals */ moo_oop_t literal_frame[1]; /* it stores literals */
/* after the literal frame comes the actual byte code, if MOO_USE_METHOD_TRAILER is defined */
}; };
#if defined(MOO_USE_METHOD_TRAILER) #if defined(MOO_USE_METHOD_TRAILER)
@ -807,7 +809,7 @@ struct moo_context_t
moo_oop_context_t origin; moo_oop_context_t origin;
/* variable indexed part - actual arguments and temporaries are placed here */ /* variable indexed part - actual arguments and temporaries are placed here */
moo_oop_t slot[1]; /* stack */ moo_oop_t stack[1]; /* context stack that stores arguments and temporaries */
}; };
@ -852,7 +854,7 @@ struct moo_process_t
moo_oop_t asyncsg; moo_oop_t asyncsg;
/* == variable indexed part == */ /* == variable indexed part == */
moo_oop_t slot[1]; /* process stack */ moo_oop_t stack[1]; /* process stack */
}; };
enum moo_semaphore_subtype_t enum moo_semaphore_subtype_t
@ -1645,14 +1647,15 @@ struct moo_t
do { \ do { \
(moo)->sp = (moo)->sp + 1; \ (moo)->sp = (moo)->sp + 1; \
MOO_ASSERT (moo, (moo)->sp < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); \ MOO_ASSERT (moo, (moo)->sp < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); \
(moo)->processor->active->slot[(moo)->sp] = v; \ MOO_STORE_OOP (moo, &(moo)->processor->active->stack[(moo)->sp], v); \
} while(0) } while(0)
#define MOO_STACK_GET(moo,v_sp) ((moo)->processor->active->slot[v_sp]) #define MOO_STACK_GET(moo,v_sp) ((moo)->processor->active->stack[v_sp])
#define MOO_STACK_SET(moo,v_sp,v_obj) \ #define MOO_STACK_SET(moo,v_sp,v_obj) \
do { \ do { \
MOO_ASSERT (moo, (v_sp) < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); \ MOO_ASSERT (moo, (v_sp) < (moo_ooi_t)(MOO_OBJ_GET_SIZE((moo)->processor->active) - MOO_PROCESS_NAMED_INSTVARS)); \
(moo)->processor->active->slot[v_sp] = v_obj; \ MOO_STORE_OOP (moo, &(moo)->processor->active->stack[v_sp], v_obj); \
} while(0) } while(0)
#define MOO_STACK_GETTOP(moo) MOO_STACK_GET(moo, (moo)->sp) #define MOO_STACK_GETTOP(moo) MOO_STACK_GET(moo, (moo)->sp)

View File

@ -441,7 +441,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
} }
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
MOO_STORE_OOP (moo, &((moo_oop_oop_t)rcv)->slot[idx], val); /*((moo_oop_oop_t)rcv)->slot[idx] = val;*/ MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(rcv, idx), val); /*((moo_oop_oop_t)rcv)->slot[idx] = val;*/
break; break;
default: default:
@ -537,7 +537,7 @@ moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
} }
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
for (i = sidx; i < end; i++) MOO_STORE_OOP (moo, &((moo_oop_oop_t)rcv)->slot[i], dval); for (i = sidx; i < end; i++) MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(rcv, i), dval);
break; break;
default: default:
@ -662,53 +662,53 @@ moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
MOO_MEMMOVE (&((moo_oop_char_t)rcv)->slot[didx], MOO_MEMMOVE (MOO_OBJ_GET_CHAR_PTR(rcv, didx),
&((moo_oop_char_t)rcv)->slot[sidx], MOO_OBJ_GET_CHAR_PTR(rcv, sidx),
ssz * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); ssz * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0)));
if (didx > sidx) if (didx > sidx)
{ {
MOO_MEMSET (&((moo_oop_char_t)rcv)->slot[sidx], 0, MOO_MEMSET (MOO_OBJ_GET_CHAR_PTR(rcv, sidx), 0,
(didx - sidx) * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0)));
} }
else else
{ {
MOO_MEMSET (&((moo_oop_char_t)rcv)->slot[didx + ssz - 1], 0, MOO_MEMSET (MOO_OBJ_GET_CHAR_PTR(rcv, didx + ssz - 1), 0,
(sidx - didx) * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0)));
} }
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
MOO_MEMMOVE (&((moo_oop_halfword_t)rcv)->slot[didx], MOO_MEMMOVE (MOO_OBJ_GET_HALFWORD_PTR(rcv, didx),
&((moo_oop_halfword_t)rcv)->slot[sidx], MOO_OBJ_GET_HALFWORD_PTR(rcv, sidx),
ssz * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); ssz * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0)));
if (didx > sidx) if (didx > sidx)
{ {
MOO_MEMSET (&((moo_oop_halfword_t)rcv)->slot[sidx], 0, MOO_MEMSET (MOO_OBJ_GET_HALFWORD_PTR(rcv, sidx), 0,
(didx - sidx) * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0)));
} }
else else
{ {
MOO_MEMSET (&((moo_oop_halfword_t)rcv)->slot[didx + ssz - 1], 0, MOO_MEMSET (MOO_OBJ_GET_HALFWORD_PTR(rcv, didx + ssz - 1), 0,
(sidx - didx) * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0)));
} }
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
MOO_MEMMOVE (&((moo_oop_word_t)rcv)->slot[didx], MOO_MEMMOVE (MOO_OBJ_GET_WORD_PTR(rcv, didx),
&((moo_oop_word_t)rcv)->slot[sidx], MOO_OBJ_GET_WORD_PTR(rcv, sidx),
ssz * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); ssz * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0)));
if (didx > sidx) if (didx > sidx)
{ {
MOO_MEMSET (&((moo_oop_word_t)rcv)->slot[sidx], 0, MOO_MEMSET (MOO_OBJ_GET_WORD_PTR(rcv, sidx), 0,
(didx - sidx) * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0)));
} }
else else
{ {
MOO_MEMSET (&((moo_oop_word_t)rcv)->slot[didx + ssz - 1], 0, MOO_MEMSET (MOO_OBJ_GET_WORD_PTR(rcv, didx + ssz - 1), 0,
(sidx - didx) * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0)));
} }
break; break;
@ -719,10 +719,12 @@ moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (didx > sidx) if (didx > sidx)
{ {
/* no need to use MOO_STORE_OOP because moo->_nil is the assigning value */
while (sidx < didx) ((moo_oop_oop_t)rcv)->slot[sidx++] = moo->_nil; while (sidx < didx) ((moo_oop_oop_t)rcv)->slot[sidx++] = moo->_nil;
} }
else else
{ {
/* no need to use MOO_STORE_OOP because moo->_nil is the assigning value */
while (didx > sidx) ((moo_oop_oop_t)rcv)->slot[(didx++) + ssz] = moo->_nil; while (didx > sidx) ((moo_oop_oop_t)rcv)->slot[(didx++) + ssz] = moo->_nil;
} }
break; break;