From fb7b226ea831ab6eec4107b6502afa84caccbda2 Mon Sep 17 00:00:00 2001 From: "hyunghwan.chung" Date: Wed, 19 Dec 2018 16:57:16 +0000 Subject: [PATCH] used more access macros --- moo/lib/comp.c | 22 ++++++++++----------- moo/lib/debug.c | 2 +- moo/lib/decode.c | 2 +- moo/lib/exec.c | 30 ++++++++++++++--------------- moo/lib/logfmt.c | 4 ++-- moo/lib/main.c | 2 +- moo/lib/moo-prv.h | 2 +- moo/lib/moo.c | 2 +- moo/lib/moo.h | 19 ++++++++++-------- moo/lib/pf-basic.c | 48 ++++++++++++++++++++++++---------------------- 10 files changed, 69 insertions(+), 64 deletions(-) diff --git a/moo/lib/comp.c b/moo/lib/comp.c index 3718bc1..874e86d 100644 --- a/moo/lib/comp.c +++ b/moo/lib/comp.c @@ -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; 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; /*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++) { - 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) @@ -6466,16 +6466,16 @@ static int add_compiled_method (moo_t* moo) /* The variadic data part passed to moo_instantiate() is not GC-safe. * let's delay initialization of variadic data a bit. */ #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 - 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 if (!mth) goto oops; for (i = 0; i < cc->mth.literals.count; i++) { /* 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++; @@ -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); 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++; } } @@ -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++) { 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++; } @@ -7324,8 +7325,7 @@ static int make_defined_class (moo_t* moo) { /* the class variables and class instance variables are placed * inside the class object after the fixed part. */ - tmp = moo_instantiate(moo, moo->_class, MOO_NULL, - cc->var[VAR_CLASSINST].total_count + cc->var[VAR_CLASS].total_count); + tmp = moo_instantiate(moo, moo->_class, MOO_NULL, cc->var[VAR_CLASSINST].total_count + cc->var[VAR_CLASS].total_count); if (!tmp) return -1; just_made = 1; @@ -7407,7 +7407,7 @@ static int make_defined_class (moo_t* moo) 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)); 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++; } } diff --git a/moo/lib/debug.c b/moo/lib/debug.c index 3729a7a..fd6aa72 100644 --- a/moo/lib/debug.c +++ b/moo/lib/debug.c @@ -32,7 +32,7 @@ void moo_dumpsymtab (moo_t* moo) moo_oop_char_t symbol; 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"); for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++) diff --git a/moo/lib/decode.c b/moo/lib/decode.c index 952f96c..f495eba 100644 --- a/moo/lib/decode.c +++ b/moo/lib/decode.c @@ -604,7 +604,7 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn) /* print literal frame contents */ 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; diff --git a/moo/lib/exec.c b/moo/lib/exec.c index 9ce6352..d417239 100644 --- a/moo/lib/exec.c +++ b/moo/lib/exec.c @@ -818,7 +818,7 @@ static moo_oop_process_t signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem) * semaphore */ 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); - 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 * 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 */ --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_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 */ --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); } } @@ -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 */ --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); } } @@ -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); 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 @@ -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++) { 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 */ @@ -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 */ pf_name_index = MOO_METHOD_GET_PREAMBLE_INDEX(preamble); 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) LOG_INST1 (moo, "preamble_named_primitive %zd", pf_name_index); @@ -4853,12 +4853,12 @@ static int __execute (moo_t* moo) { /* push - bit 4 on */ LOG_INST1 (moo, "push_tempvar %zu", b1); - MOO_STACK_PUSH (moo, ctx->slot[bx]); + MOO_STACK_PUSH (moo, ctx->stack[bx]); } else { /* 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) { @@ -4891,7 +4891,7 @@ static int __execute (moo_t* moo) b1 = bcode & 0x7; /* low 3 bits */ push_literal: 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(); /* ------------------------------------------------- */ @@ -4918,7 +4918,7 @@ static int __execute (moo_t* moo) b1 = bcode & 0x3; /* low 2 bits */ 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); if ((bcode >> 3) & 1) @@ -5128,7 +5128,7 @@ static int __execute (moo_t* moo) if ((bcode >> 3) & 1) { /* 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) { @@ -5144,7 +5144,7 @@ static int __execute (moo_t* moo) else { /* push */ - MOO_STACK_PUSH (moo, ctx->slot[b2]); + MOO_STACK_PUSH (moo, ctx->stack[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); 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, b1 < MOO_OBJ_GET_SIZE(t)); @@ -5234,7 +5234,7 @@ static int __execute (moo_t* moo) handle_send_message: /* 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); if (send_message (moo, selector, ((bcode >> 2) & 1), b1) <= -1) return -1; diff --git a/moo/lib/logfmt.c b/moo/lib/logfmt.c index db3cd2c..c128f98 100644 --- a/moo/lib/logfmt.c +++ b/moo/lib/logfmt.c @@ -556,11 +556,11 @@ static int print_object (moo_t* moo, moo_bitmask_t mask, moo_oop_t oop, outbfmt_ i = 0; 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++) { 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; diff --git a/moo/lib/main.c b/moo/lib/main.c index 74f8bfd..971f340 100644 --- a/moo/lib/main.c +++ b/moo/lib/main.c @@ -304,7 +304,7 @@ int main (int argc, char* argv[]) moo_uncatch_termreq (); /*moo_dumpsymtab(moo); - *moo_dumpdic(moo, moo->sysdic, "System dictionary");*/ + moo_dumpdic(moo, moo->sysdic, "System dictionary");*/ moo_close (moo); return xret; diff --git a/moo/lib/moo-prv.h b/moo/lib/moo-prv.h index 2b24a93..aaa1268 100644 --- a/moo/lib/moo-prv.h +++ b/moo/lib/moo-prv.h @@ -647,7 +647,7 @@ struct moo_compiler_t #if defined(MOO_USE_METHOD_TRAILER) /* 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 /* 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) diff --git a/moo/lib/moo.c b/moo/lib/moo.c index 50791fb..427e4d7 100644 --- a/moo/lib/moo.c +++ b/moo/lib/moo.c @@ -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 */ - 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 */ mth->owner = _class; diff --git a/moo/lib/moo.h b/moo/lib/moo.h index 684f3b8..03fa2bf 100644 --- a/moo/lib/moo.h +++ b/moo/lib/moo.h @@ -613,7 +613,7 @@ struct moo_class_t moo_oop_t initv[2]; /* 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 @@ -665,7 +665,7 @@ struct moo_method_t moo_oop_t tmpr_nargs; /* SmallInteger */ #if defined(MOO_USE_METHOD_TRAILER) - /* no code field is used */ + /* no code field is used. it's placed after literal_frame. */ #else moo_oop_byte_t code; /* ByteArray */ #endif @@ -673,7 +673,9 @@ struct moo_method_t moo_oop_t source; /* TODO: what should I put? */ /* == 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) @@ -807,7 +809,7 @@ struct moo_context_t moo_oop_context_t origin; /* 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; /* == variable indexed part == */ - moo_oop_t slot[1]; /* process stack */ + moo_oop_t stack[1]; /* process stack */ }; enum moo_semaphore_subtype_t @@ -1645,14 +1647,15 @@ struct moo_t do { \ (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)->processor->active->slot[(moo)->sp] = v; \ + MOO_STORE_OOP (moo, &(moo)->processor->active->stack[(moo)->sp], v); \ } 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) \ do { \ 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) #define MOO_STACK_GETTOP(moo) MOO_STACK_GET(moo, (moo)->sp) diff --git a/moo/lib/pf-basic.c b/moo/lib/pf-basic.c index 86d2e0e..08c2879 100644 --- a/moo/lib/pf-basic.c +++ b/moo/lib/pf-basic.c @@ -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: - 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; 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: - 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; default: @@ -662,53 +662,53 @@ moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs) break; case MOO_OBJ_TYPE_CHAR: - MOO_MEMMOVE (&((moo_oop_char_t)rcv)->slot[didx], - &((moo_oop_char_t)rcv)->slot[sidx], - ssz * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); + MOO_MEMMOVE (MOO_OBJ_GET_CHAR_PTR(rcv, didx), + MOO_OBJ_GET_CHAR_PTR(rcv, sidx), + ssz * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0))); if (didx > sidx) { - MOO_MEMSET (&((moo_oop_char_t)rcv)->slot[sidx], 0, - (didx - sidx) * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_CHAR_PTR(rcv, sidx), 0, + (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0))); } else { - MOO_MEMSET (&((moo_oop_char_t)rcv)->slot[didx + ssz - 1], 0, - (sidx - didx) * MOO_SIZEOF(((moo_oop_char_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_CHAR_PTR(rcv, didx + ssz - 1), 0, + (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_CHAR_VAL(rcv, 0))); } break; case MOO_OBJ_TYPE_HALFWORD: - MOO_MEMMOVE (&((moo_oop_halfword_t)rcv)->slot[didx], - &((moo_oop_halfword_t)rcv)->slot[sidx], - ssz * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); + MOO_MEMMOVE (MOO_OBJ_GET_HALFWORD_PTR(rcv, didx), + MOO_OBJ_GET_HALFWORD_PTR(rcv, sidx), + ssz * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0))); if (didx > sidx) { - MOO_MEMSET (&((moo_oop_halfword_t)rcv)->slot[sidx], 0, - (didx - sidx) * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_HALFWORD_PTR(rcv, sidx), 0, + (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0))); } else { - MOO_MEMSET (&((moo_oop_halfword_t)rcv)->slot[didx + ssz - 1], 0, - (sidx - didx) * MOO_SIZEOF(((moo_oop_halfword_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_HALFWORD_PTR(rcv, didx + ssz - 1), 0, + (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_HALFWORD_VAL(rcv, 0))); } break; case MOO_OBJ_TYPE_WORD: - MOO_MEMMOVE (&((moo_oop_word_t)rcv)->slot[didx], - &((moo_oop_word_t)rcv)->slot[sidx], - ssz * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); + MOO_MEMMOVE (MOO_OBJ_GET_WORD_PTR(rcv, didx), + MOO_OBJ_GET_WORD_PTR(rcv, sidx), + ssz * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0))); if (didx > sidx) { - MOO_MEMSET (&((moo_oop_word_t)rcv)->slot[sidx], 0, - (didx - sidx) * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_WORD_PTR(rcv, sidx), 0, + (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0))); } else { - MOO_MEMSET (&((moo_oop_word_t)rcv)->slot[didx + ssz - 1], 0, - (sidx - didx) * MOO_SIZEOF(((moo_oop_word_t)rcv)->slot[0])); + MOO_MEMSET (MOO_OBJ_GET_WORD_PTR(rcv, didx + ssz - 1), 0, + (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_WORD_VAL(rcv, 0))); } 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) { + /* 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; } 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; } break;