changed quite some accesses to the slot field with macros. wip

This commit is contained in:
hyunghwan.chung 2018-12-19 15:47:52 +00:00
parent 4affb25b28
commit 18aa5c37c0
10 changed files with 74 additions and 78 deletions

View File

@ -2780,7 +2780,7 @@ static int add_string_literal (moo_t* moo, const moo_oocs_t* str, moo_oow_t* ind
if (MOO_CLASSOF(moo, lit) == moo->_string && if (MOO_CLASSOF(moo, lit) == moo->_string &&
MOO_OBJ_GET_SIZE(lit) == str->len && MOO_OBJ_GET_SIZE(lit) == str->len &&
moo_equal_oochars(((moo_oop_char_t)lit)->slot, str->ptr, str->len)) moo_equal_oochars(MOO_OBJ_GET_CHAR_SLOT(lit), str->ptr, str->len))
{ {
*index = i; *index = i;
return 0; return 0;
@ -2958,7 +2958,7 @@ static moo_ooi_t find_class_level_variable (moo_t* moo, moo_oop_class_t self, co
for (index = VAR_INSTANCE; index <= VAR_CLASS; index++) for (index = VAR_INSTANCE; index <= VAR_CLASS; index++)
{ {
v = vv[index]; v = vv[index];
hs.ptr = v->slot; hs.ptr = MOO_OBJ_GET_CHAR_SLOT(v);
hs.len = MOO_OBJ_GET_SIZE(v); hs.len = MOO_OBJ_GET_SIZE(v);
if (find_word_in_string(&hs, name, &pos) >= 0) if (find_word_in_string(&hs, name, &pos) >= 0)
@ -3008,7 +3008,7 @@ static moo_ooi_t find_class_level_variable (moo_t* moo, moo_oop_class_t self, co
for (index = VAR_INSTANCE; index <= VAR_CLASS; index++) for (index = VAR_INSTANCE; index <= VAR_CLASS; index++)
{ {
v = vv[index]; v = vv[index];
hs.ptr = v->slot; hs.ptr = MOO_OBJ_GET_CHAR_SLOT(v);
hs.len = MOO_OBJ_GET_SIZE(v); hs.len = MOO_OBJ_GET_SIZE(v);
if (find_word_in_string(&hs, name, &pos) >= 0) if (find_word_in_string(&hs, name, &pos) >= 0)
@ -4850,10 +4850,9 @@ 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_oop_oop_t)a)->slot[j] = moo->c->arlit.ptr[i]; MOO_STORE_OOP (moo, &((moo_oop_oop_t)a)->slot[j], moo->c->arlit.ptr[i]);
} }
if (rdonly) if (rdonly)
{ {
MOO_ASSERT (moo, MOO_OOP_IS_POINTER(a)); MOO_ASSERT (moo, MOO_OOP_IS_POINTER(a));
@ -6476,7 +6475,7 @@ static int add_compiled_method (moo_t* moo)
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 */
mth->slot[i] = cc->mth.literals.ptr[i]; MOO_STORE_OOP (moo, &mth->slot[i], cc->mth.literals.ptr[i]);
} }
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++; moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
@ -7233,7 +7232,7 @@ static int make_default_initial_values (moo_t* moo, var_type_t var_type)
* initv_count is 1 whereas total_count is 3. */ * initv_count is 1 whereas total_count is 3. */
MOO_ASSERT (moo, initv_count <= cc->var[var_type].total_count); MOO_ASSERT (moo, initv_count <= cc->var[var_type].total_count);
tmp = moo_instantiate (moo, moo->_array, MOO_NULL, cc->var[var_type].total_count); tmp = moo_instantiate(moo, moo->_array, MOO_NULL, cc->var[var_type].total_count);
if (!tmp) return -1; if (!tmp) return -1;
if (super_initv_count > 0) if (super_initv_count > 0)
@ -7250,7 +7249,7 @@ 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_oop_oop_t)tmp)->slot[j] = initv->slot[i]; if (initv->slot[i]) MOO_STORE_OOP (moo, &((moo_oop_oop_t)tmp)->slot[j], initv->slot[i]);
j++; j++;
} }
} }
@ -7263,7 +7262,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_oop_oop_t)tmp)->slot[j] = 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);
j++; j++;
} }
@ -7408,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++)
{ {
cc->self_oop->slot[i] = initv->slot[i]; MOO_STORE_OOP (moo, &cc->self_oop->slot[i], initv->slot[i]);
} }
} }
@ -7426,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++)
{ {
cc->self_oop->slot[j] = cc->var[VAR_CLASS].initv[i].v; MOO_STORE_OOP (moo, &cc->self_oop->slot[j], cc->var[VAR_CLASS].initv[i].v);
j++; j++;
} }
} }
@ -8144,8 +8143,8 @@ static int __compile_class_definition (moo_t* moo, int class_type)
MOO_ASSERT (moo, MOO_CLASSOF(moo, pds) == moo->_string); MOO_ASSERT (moo, MOO_CLASSOF(moo, pds) == moo->_string);
ptr = pds->slot; ptr = MOO_OBJ_GET_CHAR_SLOT(pds);
end = pds->slot + MOO_OBJ_GET_SIZE(pds); end = ptr + MOO_OBJ_GET_SIZE(pds);
/* this loop handles the pooldic string as if it's a pooldic import. /* this loop handles the pooldic string as if it's a pooldic import.
* see compile_class_level_variables() for mostly identical code except token handling */ * see compile_class_level_variables() for mostly identical code except token handling */

View File

@ -37,7 +37,7 @@ void moo_dumpsymtab (moo_t* moo)
for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(moo->symtab->bucket); i++)
{ {
symbol = (moo_oop_char_t)moo->symtab->bucket->slot[i]; symbol = (moo_oop_char_t)MOO_OBJ_GET_OOP_VAL(moo->symtab->bucket, i);
if ((moo_oop_t)symbol != moo->_nil) if ((moo_oop_t)symbol != moo->_nil)
{ {
MOO_DEBUG2 (moo, " %07zu %O\n", i, symbol); MOO_DEBUG2 (moo, " %07zu %O\n", i, symbol);
@ -58,7 +58,7 @@ void moo_dumpdic (moo_t* moo, moo_oop_dic_t dic, const moo_bch_t* title)
for (i = 0; i < MOO_OBJ_GET_SIZE(dic->bucket); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(dic->bucket); i++)
{ {
ass = (moo_oop_association_t)dic->bucket->slot[i]; ass = (moo_oop_association_t)MOO_OBJ_GET_OOP_VAL(dic->bucket, i);
if ((moo_oop_t)ass != moo->_nil) if ((moo_oop_t)ass != moo->_nil)
{ {
MOO_DEBUG2 (moo, " %07zu %O\n", i, ass->key); MOO_DEBUG2 (moo, " %07zu %O\n", i, ass->key);

View File

@ -604,9 +604,8 @@ 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, mth->slot[ip]); MOO_LOG2(moo, DECODE_LOG_MASK, " @%-5zd %O\n", ip, MOO_OBJ_GET_OOP_VAL(mth, ip));
} }
return 0; return 0;
} }

View File

@ -1914,7 +1914,7 @@ static void log_char_object (moo_t* moo, moo_bitmask_t mask, moo_oop_char_t msg)
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(msg) == MOO_OBJ_TYPE_CHAR); MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(msg) == MOO_OBJ_TYPE_CHAR);
rem = MOO_OBJ_GET_SIZE(msg); rem = MOO_OBJ_GET_SIZE(msg);
ptr = msg->slot; ptr = MOO_OBJ_GET_CHAR_SLOT(msg);
start_over: start_over:
while (rem > 0) while (rem > 0)
@ -3458,7 +3458,7 @@ static moo_pfrc_t pf_system_log (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
for (i = 0; i < MOO_OBJ_GET_SIZE(msg); i++) for (i = 0; i < MOO_OBJ_GET_SIZE(msg); i++)
{ {
inner = ((moo_oop_oop_t)msg)->slot[i]; inner = MOO_OBJ_GET_OOP_VAL(msg, i);
if (i > 0) moo_logbfmt (moo, mask, " "); if (i > 0) moo_logbfmt (moo, mask, " ");
if (MOO_OOP_IS_POINTER(inner) && if (MOO_OOP_IS_POINTER(inner) &&

View File

@ -500,28 +500,26 @@ struct moo_obj_word_t
#define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot) #define MOO_OBJ_GET_WORD_SLOT(oop) (((moo_oop_word_t)(oop))->slot)
#define MOO_OBJ_GET_LIWORD_SLOT(oop) (((moo_oop_liword_t)(oop))->slot) #define MOO_OBJ_GET_LIWORD_SLOT(oop) (((moo_oop_liword_t)(oop))->slot)
#if 0 #define MOO_OBJ_GET_OOP_PTR(oop,idx) (&(((moo_oop_oop_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_OOP_SLOT_PTR(oop,idx) (&(((moo_oop_oop_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_CHAR_PTR(oop,idx) (&(((moo_oop_char_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_CHAR_SLOT_PTR(oop,idx) (&(((moo_oop_char_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_BYTE_PTR(oop,idx) (&(((moo_oop_byte_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_BYTE_SLOT_PTR(oop,idx) (&(((moo_oop_byte_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_HALFWORD_PTR(oop,idx) (&(((moo_oop_halfword_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_HALFWORD_SLOT_PTR(oop,idx) (&(((moo_oop_halfword_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_WORD_PTR(oop,idx) (&(((moo_oop_word_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_WORD_SLOT_PTR(oop,idx) (&(((moo_oop_word_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_LIWORD_PTR(oop,idx) (&(((moo_oop_liword_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_LIWORD_SLOT_PTR(oop,idx) (&(((moo_oop_liword_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_OOP_SLOT_VAL(oop,idx) ((((moo_oop_oop_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_OOP_VAL(oop,idx) ((((moo_oop_oop_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_CHAR_SLOT_VAL(oop,idx) ((((moo_oop_char_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_CHAR_VAL(oop,idx) ((((moo_oop_char_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_BYTE_SLOT_VAL(oop,idx) ((((moo_oop_byte_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_BYTE_VAL(oop,idx) ((((moo_oop_byte_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_HALFWORD_SLOT_VAL(oop,idx) ((((moo_oop_halfword_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_HALFWORD_VAL(oop,idx) ((((moo_oop_halfword_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_WORD_SLOT_VAL(oop,idx) ((((moo_oop_word_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_WORD_VAL(oop,idx) ((((moo_oop_word_t)(oop))->slot)[idx])
#define MOO_OBJ_GET_LIWORD_SLOT_VAL(oop,idx) ((((moo_oop_liword_t)(oop))->slot)[idx]) #define MOO_OBJ_GET_LIWORD_VAL(oop,idx) ((((moo_oop_liword_t)(oop))->slot)[idx])
/*#define MOO_OBJ_SET_OOP_SLOT_VAL(oop,idx,val) ((((moo_oop_oop_t)(oop))->slot)[idx] = (val)) - I must use MOO_STORE_OOP() instead.*/ /*#define MOO_OBJ_SET_OOP_VAL(oop,idx,val) ((((moo_oop_oop_t)(oop))->slot)[idx] = (val)) - I must use MOO_STORE_OOP() instead.*/
#define MOO_OBJ_SET_CHAR_SLOT_VAL(oop,idx,val) ((((moo_oop_char_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_CHAR_VAL(oop,idx,val) ((((moo_oop_char_t)(oop))->slot)[idx] = (val))
#define MOO_OBJ_SET_BYTE_SLOT_VAL(oop,idx,val) ((((moo_oop_byte_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_BYTE_VAL(oop,idx,val) ((((moo_oop_byte_t)(oop))->slot)[idx] = (val))
#define MOO_OBJ_SET_HALFWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_halfword_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_HALFWORD_VAL(oop,idx,val) ((((moo_oop_halfword_t)(oop))->slot)[idx] = (val))
#define MOO_OBJ_SET_WORD_SLOT_VAL(oop,idx,val) ((((moo_oop_word_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_WORD_VAL(oop,idx,val) ((((moo_oop_word_t)(oop))->slot)[idx] = (val))
#define MOO_OBJ_SET_LIWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_liword_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_LIWORD_VAL(oop,idx,val) ((((moo_oop_liword_t)(oop))->slot)[idx] = (val))
#endif
typedef struct moo_trailer_t moo_trailer_t; typedef struct moo_trailer_t moo_trailer_t;
struct moo_trailer_t struct moo_trailer_t

View File

@ -142,7 +142,7 @@ static int _equal_objects (moo_t* moo, moo_oop_t rcv, moo_oop_t arg)
/* NOTE: even if the object implements the equality method, /* NOTE: even if the object implements the equality method,
* this primitive method doesn't honor it. */ * this primitive method doesn't honor it. */
n = _equal_objects(moo, ((moo_oop_oop_t)rcv)->slot[i], ((moo_oop_oop_t)arg)->slot[i]); n = _equal_objects(moo, MOO_OBJ_GET_OOP_VAL(rcv, i), MOO_OBJ_GET_OOP_VAL(arg, i));
if (n <= 0) return n; if (n <= 0) return n;
} }
@ -326,25 +326,25 @@ moo_pfrc_t moo_pf_basic_at (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
switch (MOO_OBJ_GET_FLAGS_TYPE(rcv)) switch (MOO_OBJ_GET_FLAGS_TYPE(rcv))
{ {
case MOO_OBJ_TYPE_BYTE: case MOO_OBJ_TYPE_BYTE:
v = MOO_SMOOI_TO_OOP(((moo_oop_byte_t)rcv)->slot[idx]); v = MOO_SMOOI_TO_OOP(MOO_OBJ_GET_BYTE_VAL(rcv, idx));
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
v = MOO_CHAR_TO_OOP(((moo_oop_char_t)rcv)->slot[idx]); v = MOO_CHAR_TO_OOP(MOO_OBJ_GET_CHAR_VAL(rcv, idx));
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
/* TODO: LargeInteger if the halfword is too large */ /* TODO: LargeInteger if the halfword is too large */
v = MOO_SMOOI_TO_OOP(((moo_oop_halfword_t)rcv)->slot[idx]); v = MOO_SMOOI_TO_OOP(MOO_OBJ_GET_HALFWORD_VAL(rcv, idx));
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
v = moo_oowtoint (moo, ((moo_oop_word_t)rcv)->slot[idx]); v = moo_oowtoint(moo, MOO_OBJ_GET_WORD_VAL(rcv, idx));
if (!v) return MOO_PF_FAILURE; if (!v) return MOO_PF_FAILURE;
break; break;
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
v = ((moo_oop_oop_t)rcv)->slot[idx]; v = MOO_OBJ_GET_OOP_VAL(rcv, idx);
break; break;
default: default:
@ -402,7 +402,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
/* TOOD: must I check the range of the value? */ /* TOOD: must I check the range of the value? */
((moo_oop_byte_t)rcv)->slot[idx] = MOO_OOP_TO_SMOOI(val); MOO_OBJ_SET_BYTE_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val));
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
@ -411,7 +411,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
moo_seterrbfmt (moo, MOO_EINVAL, "value not a character - %O", val); moo_seterrbfmt (moo, MOO_EINVAL, "value not a character - %O", val);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
((moo_oop_char_t)rcv)->slot[idx] = MOO_OOP_TO_CHAR(val); MOO_OBJ_SET_CHAR_VAL (rcv, idx, MOO_OOP_TO_CHAR(val));
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
@ -423,7 +423,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
} }
/* if the small integer is too large, it will get truncated */ /* if the small integer is too large, it will get truncated */
((moo_oop_halfword_t)rcv)->slot[idx] = MOO_OOP_TO_SMOOI(val); MOO_OBJ_SET_HALFWORD_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val));
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
@ -436,7 +436,7 @@ moo_pfrc_t moo_pf_basic_at_put (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
moo_seterrbfmt (moo, MOO_EINVAL, "value not a word integer - %O", val); moo_seterrbfmt (moo, MOO_EINVAL, "value not a word integer - %O", val);
return MOO_PF_FAILURE; return MOO_PF_FAILURE;
} }
((moo_oop_word_t)rcv)->slot[idx] = w; MOO_OBJ_SET_WORD_VAL (rcv, idx, MOO_OOP_TO_SMOOI(val));
break; break;
} }
@ -515,29 +515,29 @@ moo_pfrc_t moo_pf_basic_fill (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
case MOO_OBJ_TYPE_BYTE: case MOO_OBJ_TYPE_BYTE:
if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value; if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value;
for (i = sidx; i < end; i++) ((moo_oop_byte_t)rcv)->slot[i] = MOO_OOP_TO_SMOOI(dval); for (i = sidx; i < end; i++) MOO_OBJ_SET_BYTE_VAL (rcv, i, MOO_OOP_TO_SMOOI(dval));
break; break;
case MOO_OBJ_TYPE_CHAR: case MOO_OBJ_TYPE_CHAR:
if (!MOO_OOP_IS_CHAR(dval)) goto invalid_fill_value; if (!MOO_OOP_IS_CHAR(dval)) goto invalid_fill_value;
for (i = sidx; i < end; i++) ((moo_oop_char_t)rcv)->slot[i] = MOO_OOP_TO_CHAR(dval); for (i = sidx; i < end; i++) MOO_OBJ_SET_CHAR_VAL (rcv, i, MOO_OOP_TO_CHAR(dval));
break; break;
case MOO_OBJ_TYPE_HALFWORD: case MOO_OBJ_TYPE_HALFWORD:
if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value; if (!MOO_OOP_IS_SMOOI(dval)) goto invalid_fill_value;
for (i = sidx; i < end; i++) ((moo_oop_halfword_t)rcv)->slot[i] = MOO_OOP_TO_SMOOI(dval); for (i = sidx; i < end; i++) MOO_OBJ_SET_HALFWORD_VAL (rcv, i, MOO_OOP_TO_SMOOI(dval));
break; break;
case MOO_OBJ_TYPE_WORD: case MOO_OBJ_TYPE_WORD:
{ {
moo_oow_t dw; moo_oow_t dw;
if (moo_inttooow(moo, dval, &dw) <= 0) goto invalid_fill_value; if (moo_inttooow(moo, dval, &dw) <= 0) goto invalid_fill_value;
for (i = sidx; i < end; i++) ((moo_oop_word_t)rcv)->slot[i] = dw; for (i = sidx; i < end; i++) MOO_OBJ_SET_WORD_VAL (rcv, i, dw);
break; break;
} }
case MOO_OBJ_TYPE_OOP: case MOO_OBJ_TYPE_OOP:
for (i = sidx; i < end; i++) ((moo_oop_oop_t)rcv)->slot[i] = dval; for (i = sidx; i < end; i++) MOO_STORE_OOP (moo, &((moo_oop_oop_t)rcv)->slot[i], dval);
break; break;
default: default:
@ -645,19 +645,19 @@ moo_pfrc_t moo_pf_basic_shift (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
switch (MOO_OBJ_GET_FLAGS_TYPE(rcv)) switch (MOO_OBJ_GET_FLAGS_TYPE(rcv))
{ {
case MOO_OBJ_TYPE_BYTE: case MOO_OBJ_TYPE_BYTE:
MOO_MEMMOVE (&((moo_oop_byte_t)rcv)->slot[didx], MOO_MEMMOVE (MOO_OBJ_GET_BYTE_PTR(rcv, didx),
&((moo_oop_byte_t)rcv)->slot[sidx], MOO_OBJ_GET_BYTE_PTR(rcv, sidx),
ssz * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); ssz * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0)));
if (didx > sidx) if (didx > sidx)
{ {
MOO_MEMSET (&((moo_oop_byte_t)rcv)->slot[sidx], 0, MOO_MEMSET (MOO_OBJ_GET_BYTE_PTR(rcv, sidx), 0,
(didx - sidx) * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); (didx - sidx) * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0)));
} }
else else
{ {
MOO_MEMSET (&((moo_oop_byte_t)rcv)->slot[didx + ssz - 1], 0, MOO_MEMSET (MOO_OBJ_GET_BYTE_PTR(rcv, didx + ssz - 1), 0,
(sidx - didx) * MOO_SIZEOF(((moo_oop_byte_t)rcv)->slot[0])); (sidx - didx) * MOO_SIZEOF(MOO_OBJ_GET_BYTE_VAL(rcv, 0)));
} }
break; break;

View File

@ -622,7 +622,7 @@ moo_pfrc_t moo_pf_system_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer); MOO_MEMCPY (MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), &rawptr[offset], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -685,7 +685,7 @@ moo_pfrc_t moo_pf_system_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer); MOO_MEMCPY (&rawptr[offset], MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -941,7 +941,7 @@ moo_pfrc_t moo_pf_smptr_get_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], &rawptr[offset], len_in_buffer); MOO_MEMCPY (MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), &rawptr[offset], len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));
@ -999,7 +999,7 @@ moo_pfrc_t moo_pf_smptr_put_bytes (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (len_in_buffer > 0) if (len_in_buffer > 0)
{ {
MOO_MEMCPY (&rawptr[offset], &MOO_OBJ_GET_BYTE_SLOT(tmp)[offset_in_buffer], len_in_buffer); MOO_MEMCPY (&rawptr[offset], MOO_OBJ_GET_BYTE_PTR(tmp, offset_in_buffer), len_in_buffer);
} }
MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer)); MOO_STACK_SETRET (moo, nargs, MOO_SMOOI_TO_OOP(len_in_buffer));

View File

@ -203,7 +203,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
dcReset (ffi->dc); dcReset (ffi->dc);
i = 0; i = 0;
if (i < MOO_OBJ_GET_SIZE(sig) && MOO_OBJ_GET_CHAR_SLOT(sig)[i] == '|') if (i < MOO_OBJ_GET_SIZE(sig) && MOO_OBJ_GET_CHAR_VAL(sig, i) == '|')
{ {
dcMode (ffi->dc, DC_CALL_C_ELLIPSIS); dcMode (ffi->dc, DC_CALL_C_ELLIPSIS);
@ -219,7 +219,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
moo_ooch_t fmtc; moo_ooch_t fmtc;
moo_oop_t arg; moo_oop_t arg;
fmtc = MOO_OBJ_GET_CHAR_SLOT(sig)[i]; fmtc = MOO_OBJ_GET_CHAR_VAL(sig, i);
if (fmtc == ')') if (fmtc == ')')
{ {
@ -325,7 +325,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
/*ptr = moo_dupoochars (moo, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg)); /*ptr = moo_dupoochars (moo, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg));
if (!ptr) goto softfail; */ /* out of system memory or conversion error - soft failure */ if (!ptr) goto softfail; */ /* out of system memory or conversion error - soft failure */
#else #else
ptr = moo_dupootoucharswithheadroom (moo, MOO_SIZEOF_VOID_P, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg), MOO_NULL); ptr = moo_dupootoucharswithheadroom(moo, MOO_SIZEOF_VOID_P, MOO_OBJ_GET_CHAR_SLOT(arg), MOO_OBJ_GET_SIZE(arg), MOO_NULL);
if (!ptr) goto softfail; /* out of system memory or conversion error - soft failure */ if (!ptr) goto softfail; /* out of system memory or conversion error - soft failure */
link_ca (ffi, ptr); link_ca (ffi, ptr);
#endif #endif
@ -343,7 +343,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (i >= MOO_OBJ_GET_SIZE(sig)) goto call_void; if (i >= MOO_OBJ_GET_SIZE(sig)) goto call_void;
switch (((moo_oop_char_t)sig)->slot[i]) switch (MOO_OBJ_GET_CHAR_VAL(sig, i))
{ {
/* TODO: support more types... */ /* TODO: support more types... */
/* TODO: proper return value conversion */ /* TODO: proper return value conversion */
@ -358,7 +358,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
{ {
moo_oop_t r; moo_oop_t r;
r = moo_ooitoint (moo, dcCallInt (ffi->dc, f)); r = moo_ooitoint (moo, dcCallInt(ffi->dc, f));
if (!r) goto hardfail; if (!r) goto hardfail;
MOO_STACK_SETRET (moo, nargs, r); MOO_STACK_SETRET (moo, nargs, r);
break; break;
@ -379,7 +379,7 @@ static moo_pfrc_t pf_call (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
#if (MOO_SIZEOF_LONG_LONG > 0) #if (MOO_SIZEOF_LONG_LONG > 0)
moo_oop_t r; moo_oop_t r;
# if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_OOI_T) # if (MOO_SIZEOF_LONG_LONG <= MOO_SIZEOF_OOI_T)
r = moo_ooitoint (moo, dcCallLongLong (ffi->dc, f)); r = moo_ooitoint (moo, dcCallLongLong(ffi->dc, f));
# else # else
# error UNSUPPORTED MOO_SIZEOF_LONG_LONG # error UNSUPPORTED MOO_SIZEOF_LONG_LONG
# endif # endif

View File

@ -481,7 +481,7 @@ static moo_pfrc_t pf_read_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (length > maxlen - offset) length = maxlen - offset; if (length > maxlen - offset) length = maxlen - offset;
} }
n = recv(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); n = recv(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0);
if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, 0, errno); moo_seterrwithsyserr (moo, 0, errno);
@ -554,7 +554,7 @@ static moo_pfrc_t pf_write_socket (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
if (length > maxlen - offset) length = maxlen - offset; if (length > maxlen - offset) length = maxlen - offset;
} }
n = send(fd, &MOO_OBJ_GET_BYTE_SLOT(buf)[offset], length, 0); n = send(fd, MOO_OBJ_GET_BYTE_PTR(buf, offset), length, 0);
if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN) if (n <= -1 && errno != EWOULDBLOCK && errno != EAGAIN)
{ {
moo_seterrwithsyserr (moo, 0, errno); moo_seterrwithsyserr (moo, 0, errno);

View File

@ -61,17 +61,17 @@ static moo_pfrc_t pf_open (moo_t* moo, moo_mod_t* mod, moo_ooi_t nargs)
#if defined(MOO_OOCH_IS_UCH) #if defined(MOO_OOCH_IS_UCH)
ucslen = MOO_OBJ_GET_SIZE(name); ucslen = MOO_OBJ_GET_SIZE(name);
bcslen = MOO_COUNTOF(namebuf) - 1; bcslen = MOO_COUNTOF(namebuf) - 1;
if (moo_convootobchars (moo, name->slot, &ucslen, namebuf, &bcslen) <= -1) goto softfail; if (moo_convootobchars(moo, MOO_OBJ_GET_CHAR_SLOT(name), &ucslen, namebuf, &bcslen) <= -1) goto softfail;
namebuf[bcslen] = '\0'; namebuf[bcslen] = '\0';
ucslen = MOO_OBJ_GET_SIZE(mode); ucslen = MOO_OBJ_GET_SIZE(mode);
bcslen = MOO_COUNTOF(modebuf) - 1; bcslen = MOO_COUNTOF(modebuf) - 1;
if (moo_convootobchars (moo, mode->slot, &ucslen, modebuf, &bcslen) <= -1) goto softfail; if (moo_convootobchars(moo, MOO_OBJ_GET_CHAR_SLOT(mode), &ucslen, modebuf, &bcslen) <= -1) goto softfail;
modebuf[bcslen] = '\0'; modebuf[bcslen] = '\0';
stdio->fp = fopen (namebuf, modebuf); stdio->fp = fopen (namebuf, modebuf);
#else #else
stdio->fp = fopen (name->slot, mode->slot); stdio->fp = fopen (MOO_OBJ_GET_CHAR_SLOT(name), MOO_OBJ_GET_CHAR_SLOT(mode));
#endif #endif
if (!stdio->fp) if (!stdio->fp)
{ {
@ -150,7 +150,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
bcslen = MOO_COUNTOF(bcs); bcslen = MOO_COUNTOF(bcs);
/* TODO: implement character conversion into stdio and use it instead of vm's conversion facility. */ /* TODO: implement character conversion into stdio and use it instead of vm's conversion facility. */
if ((n = moo_convootobchars (moo, &x->slot[ucspos], &ucslen, bcs, &bcslen)) <= -1) if ((n = moo_convootobchars (moo, MOO_OBJ_GET_CHAR_PTR(x, ucspos), &ucslen, bcs, &bcslen)) <= -1)
{ {
if (n != -2 || ucslen <= 0) goto softfail; if (n != -2 || ucslen <= 0) goto softfail;
} }
@ -167,7 +167,7 @@ static moo_pfrc_t __pf_puts (moo_t* moo, moo_ooi_t nargs, moo_oow_t limit)
} }
#else #else
puts_string: puts_string:
if (fwrite (x->slot, 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x)) if (fwrite (MOO_OBJ_GET_CHAR_SLOT(x), 1, MOO_OBJ_GET_SIZE(x), stdio->fp) < MOO_OBJ_GET_SIZE(x))
{ {
moo_seterrwithsyserr (moo, 0, errno); moo_seterrwithsyserr (moo, 0, errno);
goto softfail; goto softfail;