more use of MOO_STORE_OOP

This commit is contained in:
hyunghwan.chung 2018-12-16 17:35:46 +00:00
parent 3d57095c4a
commit 4affb25b28
7 changed files with 153 additions and 151 deletions

View File

@ -215,7 +215,7 @@ static int is_normalized_integer (moo_t* moo, moo_oop_t oop)
sz = MOO_OBJ_GET_SIZE(oop); sz = MOO_OBJ_GET_SIZE(oop);
MOO_ASSERT (moo, sz >= 1); MOO_ASSERT (moo, sz >= 1);
return ((moo_oop_liword_t)oop)->slot[sz - 1] == 0? 0: 1; return MOO_OBJ_GET_LIWORD_SLOT(oop)[sz - 1] == 0? 0: 1;
} }
} }
@ -247,7 +247,7 @@ static MOO_INLINE int bigint_to_oow (moo_t* moo, moo_oop_t num, moo_oow_t* w)
MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(num) >= 1); MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(num) >= 1);
if (MOO_OBJ_GET_SIZE(num) == 1) if (MOO_OBJ_GET_SIZE(num) == 1)
{ {
*w = ((moo_oop_word_t)num)->slot[0]; *w = MOO_OBJ_GET_WORD_SLOT(num)[0];
return (IS_NBIGINT(moo, num))? -1: 1; return (IS_NBIGINT(moo, num))? -1: 1;
} }
@ -260,7 +260,7 @@ static MOO_INLINE int bigint_to_oow (moo_t* moo, moo_oop_t num, moo_oow_t* w)
MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(num) >= 2); MOO_ASSERT (moo, MOO_OBJ_GET_SIZE(num) >= 2);
if (MOO_OBJ_GET_SIZE(num) == 2) if (MOO_OBJ_GET_SIZE(num) == 2)
{ {
*w = MAKE_WORD (((moo_oop_halfword_t)num)->slot[0], ((moo_oop_halfword_t)num)->slot[1]); *w = MAKE_WORD (MOO_OBJ_GET_HALFWORD_SLOT(num)[0], MOO_OBJ_GET_HALFWORD_SLOT(num)[1]);
return (IS_NBIGINT(moo, num))? -1: 1; return (IS_NBIGINT(moo, num))? -1: 1;
} }
#else #else
@ -434,7 +434,7 @@ static MOO_INLINE moo_oop_t make_bloated_bigint_with_ooi (moo_t* moo, moo_ooi_t
} }
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
((moo_oop_liword_t)z)->slot[0] = w; MOO_OBJ_GET_LIWORD_SLOT(z)[0] = w;
return z; return z;
#elif (MOO_LIW_BITS == MOO_OOHW_BITS) #elif (MOO_LIW_BITS == MOO_OOHW_BITS)
@ -460,8 +460,8 @@ static MOO_INLINE moo_oop_t make_bloated_bigint_with_ooi (moo_t* moo, moo_ooi_t
} }
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
((moo_oop_liword_t)z)->slot[0] = hw[0]; MOO_OBJ_GET_LIWORD_SLOT(z)[0] = hw[0];
if (hw[1] > 0) ((moo_oop_liword_t)z)->slot[1] = hw[1]; if (hw[1] > 0) MOO_OBJ_GET_LIWORD_SLOT(z)[1] = hw[1];
return z; return z;
#else #else
# error UNSUPPORTED LIW BIT SIZE # error UNSUPPORTED LIW BIT SIZE
@ -538,7 +538,7 @@ static MOO_INLINE moo_oop_t expand_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)oop)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(oop)[i];
} }
return z; return z;
} }
@ -559,7 +559,7 @@ static MOO_INLINE moo_oop_t _clone_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)oop)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(oop)[i];
} }
return z; return z;
} }
@ -610,7 +610,7 @@ static MOO_INLINE moo_oow_t count_effective_digits (moo_oop_t oop)
for (i = MOO_OBJ_GET_SIZE(oop); i > 1; ) for (i = MOO_OBJ_GET_SIZE(oop); i > 1; )
{ {
--i; --i;
if (((moo_oop_liword_t)oop)->slot[i]) return i + 1; if (MOO_OBJ_GET_LIWORD_SLOT(oop)[i]) return i + 1;
} }
return 1; return 1;
@ -628,7 +628,7 @@ static moo_oop_t normalize_bigint (moo_t* moo, moo_oop_t oop)
{ {
moo_oow_t w; moo_oow_t w;
w = ((moo_oop_liword_t)oop)->slot[0]; w = MOO_OBJ_GET_LIWORD_SLOT(oop)[0];
if (IS_PBIGINT(moo, oop)) if (IS_PBIGINT(moo, oop))
{ {
if (w <= MOO_SMOOI_MAX) return MOO_SMOOI_TO_OOP(w); if (w <= MOO_SMOOI_MAX) return MOO_SMOOI_TO_OOP(w);
@ -646,19 +646,19 @@ static moo_oop_t normalize_bigint (moo_t* moo, moo_oop_t oop)
{ {
if (IS_PBIGINT(moo, oop)) if (IS_PBIGINT(moo, oop))
{ {
return MOO_SMOOI_TO_OOP(((moo_oop_liword_t)oop)->slot[0]); return MOO_SMOOI_TO_OOP(MOO_OBJ_GET_LIWORD_SLOT(oop)[0]);
} }
else else
{ {
MOO_ASSERT (moo, IS_NBIGINT(moo, oop)); MOO_ASSERT (moo, IS_NBIGINT(moo, oop));
return MOO_SMOOI_TO_OOP(-(moo_ooi_t)((moo_oop_liword_t)oop)->slot[0]); return MOO_SMOOI_TO_OOP(-(moo_ooi_t)MOO_OBJ_GET_LIWORD_SLOT(oop)[0]);
} }
} }
else if (count == 2) /* 2 half-words */ else if (count == 2) /* 2 half-words */
{ {
moo_oow_t w; moo_oow_t w;
w = MAKE_WORD (((moo_oop_liword_t)oop)->slot[0], ((moo_oop_liword_t)oop)->slot[1]); w = MAKE_WORD (MOO_OBJ_GET_LIWORD_SLOT(oop)[0], MOO_OBJ_GET_LIWORD_SLOT(oop)[1]);
if (IS_PBIGINT(moo, oop)) if (IS_PBIGINT(moo, oop))
{ {
if (w <= MOO_SMOOI_MAX) return MOO_SMOOI_TO_OOP(w); if (w <= MOO_SMOOI_MAX) return MOO_SMOOI_TO_OOP(w);
@ -699,8 +699,8 @@ static MOO_INLINE int is_less_unsigned_array (const moo_liw_t* x, moo_oow_t xs,
static MOO_INLINE int is_less_unsigned (moo_oop_t x, moo_oop_t y) static MOO_INLINE int is_less_unsigned (moo_oop_t x, moo_oop_t y)
{ {
return is_less_unsigned_array ( return is_less_unsigned_array (
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y)); MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y));
} }
static MOO_INLINE int is_less (moo_t* moo, moo_oop_t x, moo_oop_t y) static MOO_INLINE int is_less (moo_t* moo, moo_oop_t x, moo_oop_t y)
@ -737,8 +737,8 @@ static MOO_INLINE int is_greater_unsigned_array (const moo_liw_t* x, moo_oow_t x
static MOO_INLINE int is_greater_unsigned (moo_oop_t x, moo_oop_t y) static MOO_INLINE int is_greater_unsigned (moo_oop_t x, moo_oop_t y)
{ {
return is_greater_unsigned_array( return is_greater_unsigned_array(
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y)); MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y));
} }
static MOO_INLINE int is_greater (moo_t* moo, moo_oop_t x, moo_oop_t y) static MOO_INLINE int is_greater (moo_t* moo, moo_oop_t x, moo_oop_t y)
@ -762,7 +762,7 @@ static MOO_INLINE int is_equal (moo_t* moo, moo_oop_t x, moo_oop_t y)
{ {
/* check if two large integers are equal to each other */ /* check if two large integers are equal to each other */
return MOO_OBJ_GET_CLASS(x) == MOO_OBJ_GET_CLASS(y) && MOO_OBJ_GET_SIZE(x) == MOO_OBJ_GET_SIZE(y) && return MOO_OBJ_GET_CLASS(x) == MOO_OBJ_GET_CLASS(y) && MOO_OBJ_GET_SIZE(x) == MOO_OBJ_GET_SIZE(y) &&
MOO_MEMCMP(((moo_oop_liword_t)x)->slot, ((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(x) * MOO_SIZEOF(moo_liw_t)) == 0; MOO_MEMCMP(MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(x) * MOO_SIZEOF(moo_liw_t)) == 0;
} }
static void complement2_unsigned_array (moo_t* moo, const moo_liw_t* x, moo_oow_t xs, moo_liw_t* z) static void complement2_unsigned_array (moo_t* moo, const moo_liw_t* x, moo_oow_t xs, moo_liw_t* z)
@ -1510,9 +1510,9 @@ static moo_oop_t add_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y)
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
add_unsigned_array ( add_unsigned_array (
((moo_oop_liword_t)x)->slot, as, MOO_OBJ_GET_LIWORD_SLOT(x), as,
((moo_oop_liword_t)y)->slot, bs, MOO_OBJ_GET_LIWORD_SLOT(y), bs,
((moo_oop_liword_t)z)->slot MOO_OBJ_GET_LIWORD_SLOT(z)
); );
return z; return z;
@ -1531,9 +1531,9 @@ static moo_oop_t subtract_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
subtract_unsigned_array (moo, subtract_unsigned_array (moo,
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y), MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y),
((moo_oop_liword_t)z)->slot); MOO_OBJ_GET_LIWORD_SLOT(z));
return z; return z;
} }
@ -1562,18 +1562,18 @@ static moo_oop_t multiply_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t
{ {
#endif #endif
multiply_unsigned_array ( multiply_unsigned_array (
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y), MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y),
((moo_oop_liword_t)z)->slot); MOO_OBJ_GET_LIWORD_SLOT(z));
#if defined(MOO_ENABLE_KARATSUBA) #if defined(MOO_ENABLE_KARATSUBA)
} }
else else
{ {
if (multiply_unsigned_array_karatsuba ( if (multiply_unsigned_array_karatsuba (
moo, moo,
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y), MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y),
((moo_oop_liword_t)z)->slot) == 0) return MOO_NULL; MOO_OBJ_GET_LIWORD_SLOT(z)) == 0) return MOO_NULL;
} }
#endif #endif
return z; return z;
@ -1600,9 +1600,9 @@ static moo_oop_t divide_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y,
if (!rr) return MOO_NULL; if (!rr) return MOO_NULL;
divide_unsigned_array (moo, divide_unsigned_array (moo,
((moo_oop_liword_t)x)->slot, MOO_OBJ_GET_SIZE(x), MOO_OBJ_GET_LIWORD_SLOT(x), MOO_OBJ_GET_SIZE(x),
((moo_oop_liword_t)y)->slot, MOO_OBJ_GET_SIZE(y), MOO_OBJ_GET_LIWORD_SLOT(y), MOO_OBJ_GET_SIZE(y),
((moo_oop_liword_t)qq)->slot, ((moo_oop_liword_t)rr)->slot); MOO_OBJ_GET_LIWORD_SLOT(qq), MOO_OBJ_GET_LIWORD_SLOT(rr));
*r = rr; *r = rr;
return qq; return qq;
@ -2232,7 +2232,7 @@ moo_oop_t moo_bitatint (moo_t* moo, moo_oop_t x, moo_oop_t y)
if (IS_PBIGINT(moo, x)) if (IS_PBIGINT(moo, x))
{ {
if (wp >= xs) return MOO_SMOOI_TO_OOP(0); if (wp >= xs) return MOO_SMOOI_TO_OOP(0);
v = (((moo_oop_liword_t)x)->slot[wp] >> bp) & 1; v = (MOO_OBJ_GET_LIWORD_SLOT(x)[wp] >> bp) & 1;
} }
else else
{ {
@ -2244,7 +2244,7 @@ moo_oop_t moo_bitatint (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i <= wp; i++) for (i = 0; i <= wp; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
} }
v = ((moo_oow_t)w >> bp) & 1; v = ((moo_oow_t)w >> bp) & 1;
@ -2316,7 +2316,7 @@ moo_oop_t moo_bitatint (moo_t* moo, moo_oop_t x, moo_oop_t y)
if (IS_PBIGINT(moo, x)) if (IS_PBIGINT(moo, x))
{ {
if (wp >= xs) return MOO_SMOOI_TO_OOP(0); if (wp >= xs) return MOO_SMOOI_TO_OOP(0);
v = (((moo_oop_liword_t)x)->slot[wp] >> bp) & 1; v = (MOO_OBJ_GET_LIWORD_SLOT(x)[wp] >> bp) & 1;
} }
else else
{ {
@ -2328,7 +2328,7 @@ moo_oop_t moo_bitatint (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i <= wp; i++) for (i = 0; i <= wp; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
} }
v = ((moo_oow_t)w >> bp) & 1; v = ((moo_oow_t)w >> bp) & 1;
@ -2452,13 +2452,13 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* 2's complement on both x and y and perform bitwise-and */ /* 2's complement on both x and y and perform bitwise-and */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
w[1] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry[1]; w[1] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry[1];
carry[1] = w[1] >> MOO_LIW_BITS; carry[1] = w[1] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0] & (moo_liw_t)w[1]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0] & (moo_liw_t)w[1];
} }
MOO_ASSERT (moo, carry[1] == 0); MOO_ASSERT (moo, carry[1] == 0);
@ -2466,20 +2466,20 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
* in y is treated as if they are all 1s. */ * in y is treated as if they are all 1s. */
for (; i < xs; i++) for (; i < xs; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0];
} }
MOO_ASSERT (moo, carry[0] == 0); MOO_ASSERT (moo, carry[0] == 0);
/* 2's complement on the final result */ /* 2's complement on the final result */
((moo_oop_liword_t)z)->slot[zs] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[zs] = ~(moo_liw_t)0;
carry[0] = 1; carry[0] = 1;
for (i = 0; i <= zs; i++) for (i = 0; i <= zs; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)z)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0];
} }
MOO_ASSERT (moo, carry[0] == 0); MOO_ASSERT (moo, carry[0] == 0);
@ -2493,9 +2493,9 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w & ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w & MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
/* the lacking part in y is all 0's. the remaining part in x is /* the lacking part in y is all 0's. the remaining part in x is
@ -2511,9 +2511,9 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] & (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] & (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
@ -2536,7 +2536,7 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
*/ */
for (; i < xs; i++) for (; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i];
} }
} }
else else
@ -2544,7 +2544,7 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* both are positive */ /* both are positive */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] & ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] & MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
} }
@ -2672,13 +2672,13 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* 2's complement on both x and y and perform bitwise-and */ /* 2's complement on both x and y and perform bitwise-and */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
w[1] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry[1]; w[1] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry[1];
carry[1] = w[1] >> MOO_LIW_BITS; carry[1] = w[1] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0] | (moo_liw_t)w[1]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0] | (moo_liw_t)w[1];
} }
MOO_ASSERT (moo, carry[1] == 0); MOO_ASSERT (moo, carry[1] == 0);
@ -2688,13 +2688,13 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
adjust_to_negative: adjust_to_negative:
/* 2's complement on the final result */ /* 2's complement on the final result */
((moo_oop_liword_t)z)->slot[zs] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[zs] = ~(moo_liw_t)0;
carry[0] = 1; carry[0] = 1;
for (i = 0; i <= zs; i++) for (i = 0; i <= zs; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)z)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0];
} }
MOO_ASSERT (moo, carry[0] == 0); MOO_ASSERT (moo, carry[0] == 0);
@ -2708,16 +2708,16 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w | ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w | MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
for (; i < xs; i++) for (; i < xs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
@ -2732,9 +2732,9 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] | (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] | (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
@ -2747,7 +2747,7 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
* redundant. * redundant.
for (; i < xs; i++) for (; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = ~(moo_liw_t)0;
} }
*/ */
goto adjust_to_negative; goto adjust_to_negative;
@ -2757,12 +2757,12 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* both are positive */ /* both are positive */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] | ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] | MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
for (; i < xs; i++) for (; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i];
} }
} }
@ -2890,22 +2890,22 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* 2's complement on both x and y and perform bitwise-and */ /* 2's complement on both x and y and perform bitwise-and */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
w[1] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry[1]; w[1] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry[1];
carry[1] = w[1] >> MOO_LIW_BITS; carry[1] = w[1] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0] ^ (moo_liw_t)w[1]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0] ^ (moo_liw_t)w[1];
} }
MOO_ASSERT (moo, carry[1] == 0); MOO_ASSERT (moo, carry[1] == 0);
/* treat the lacking part in y as all 1s */ /* treat the lacking part in y as all 1s */
for (; i < xs; i++) for (; i < xs; i++)
{ {
w[0] = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry[0]; w[0] = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry[0];
carry[0] = w[0] >> MOO_LIW_BITS; carry[0] = w[0] >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w[0] ^ (~(moo_liw_t)0); MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w[0] ^ (~(moo_liw_t)0);
} }
MOO_ASSERT (moo, carry[0] == 0); MOO_ASSERT (moo, carry[0] == 0);
} }
@ -2917,29 +2917,29 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w ^ ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w ^ MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
/* treat the lacking part in y as all 0s */ /* treat the lacking part in y as all 0s */
for (; i < xs; i++) for (; i < xs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
adjust_to_negative: adjust_to_negative:
/* 2's complement on the final result */ /* 2's complement on the final result */
((moo_oop_liword_t)z)->slot[zs] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[zs] = ~(moo_liw_t)0;
carry = 1; carry = 1;
for (i = 0; i <= zs; i++) for (i = 0; i <= zs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)z)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
@ -2954,16 +2954,16 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
carry = 1; carry = 1;
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)y)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(y)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] ^ (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] ^ (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
/* treat the lacking part in y as all 1s */ /* treat the lacking part in y as all 1s */
for (; i < xs; i++) for (; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] ^ (~(moo_liw_t)0); MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] ^ (~(moo_liw_t)0);
} }
goto adjust_to_negative; goto adjust_to_negative;
@ -2973,13 +2973,13 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
/* both are positive */ /* both are positive */
for (i = 0; i < ys; i++) for (i = 0; i < ys; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i] ^ ((moo_oop_liword_t)y)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i] ^ MOO_OBJ_GET_LIWORD_SLOT(y)[i];
} }
/* treat the lacking part in y as all 0s */ /* treat the lacking part in y as all 0s */
for (; i < xs; i++) for (; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ((moo_oop_liword_t)x)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = MOO_OBJ_GET_LIWORD_SLOT(x)[i];
} }
} }
@ -3044,9 +3044,9 @@ moo_oop_t moo_bitinvint (moo_t* moo, moo_oop_t x)
carry = 1; carry = 1;
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = ~(moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = ~(moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
} }
@ -3057,28 +3057,28 @@ moo_oop_t moo_bitinvint (moo_t* moo, moo_oop_t x)
#if 0 #if 0
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ~((moo_oop_liword_t)x)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = ~MOO_OBJ_GET_LIWORD_SLOT(x)[i];
} }
((moo_oop_liword_t)z)->slot[zs] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[zs] = ~(moo_liw_t)0;
carry = 1; carry = 1;
for (i = 0; i <= zs; i++) for (i = 0; i <= zs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)z)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
#else #else
carry = 1; carry = 1;
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
w = (moo_lidw_t)(((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)(MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, i == zs); MOO_ASSERT (moo, i == zs);
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)carry; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)carry;
MOO_ASSERT (moo, (carry >> MOO_LIW_BITS) == 0); MOO_ASSERT (moo, (carry >> MOO_LIW_BITS) == 0);
#endif #endif
@ -3113,40 +3113,40 @@ static MOO_INLINE moo_oop_t rshift_negative_bigint (moo_t* moo, moo_oop_t x, moo
carry = 1; carry = 1;
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)x)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(x)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = ~(moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = ~(moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
/* shift to the right */ /* shift to the right */
rshift_unsigned_array (((moo_oop_liword_t)z)->slot, xs, shift); rshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), xs, shift);
/* the following lines roughly for 'z = moo_bitinv (moo, z)' */ /* the following lines roughly for 'z = moo_bitinv (moo, z)' */
#if 0 #if 0
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
((moo_oop_liword_t)z)->slot[i] = ~((moo_oop_liword_t)z)->slot[i]; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = ~MOO_OBJ_GET_LIWORD_SLOT(z)[i];
} }
((moo_oop_liword_t)z)->slot[xs] = ~(moo_liw_t)0; MOO_OBJ_GET_LIWORD_SLOT(z)[xs] = ~(moo_liw_t)0;
carry = 1; carry = 1;
for (i = 0; i <= xs; i++) for (i = 0; i <= xs; i++)
{ {
w = (moo_lidw_t)((moo_liw_t)~((moo_oop_liword_t)z)->slot[i]) + carry; w = (moo_lidw_t)((moo_liw_t)~MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
MOO_ASSERT (moo, carry == 0); MOO_ASSERT (moo, carry == 0);
#else #else
carry = 1; carry = 1;
for (i = 0; i < xs; i++) for (i = 0; i < xs; i++)
{ {
w = (moo_lidw_t)(((moo_oop_liword_t)z)->slot[i]) + carry; w = (moo_lidw_t)(MOO_OBJ_GET_LIWORD_SLOT(z)[i]) + carry;
carry = w >> MOO_LIW_BITS; carry = w >> MOO_LIW_BITS;
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)w; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)w;
} }
((moo_oop_liword_t)z)->slot[i] = (moo_liw_t)carry; MOO_OBJ_GET_LIWORD_SLOT(z)[i] = (moo_liw_t)carry;
MOO_ASSERT (moo, (carry >> MOO_LIW_BITS) == 0); MOO_ASSERT (moo, (carry >> MOO_LIW_BITS) == 0);
#endif #endif
@ -3258,9 +3258,9 @@ static MOO_INLINE moo_oop_t rshift_positive_bigint_and_normalize (moo_t* moo, mo
shift = MOO_SMOOI_MAX; shift = MOO_SMOOI_MAX;
do do
{ {
rshift_unsigned_array (((moo_oop_liword_t)z)->slot, zs, shift); rshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), zs, shift);
if (count_effective (((moo_oop_liword_t)z)->slot, zs) == 1 && if (count_effective (MOO_OBJ_GET_LIWORD_SLOT(z), zs) == 1 &&
((moo_oop_liword_t)z)->slot[0] == 0) MOO_OBJ_GET_LIWORD_SLOT(z)[0] == 0)
{ {
/* if z is 0, i don't have to go on */ /* if z is 0, i don't have to go on */
break; break;
@ -3313,7 +3313,7 @@ static MOO_INLINE moo_oop_t lshift_bigint_and_normalize (moo_t* moo, moo_oop_t x
moo_poptmp (moo); moo_poptmp (moo);
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
lshift_unsigned_array (((moo_oop_liword_t)z)->slot, MOO_OBJ_GET_SIZE(z), shift); lshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), MOO_OBJ_GET_SIZE(z), shift);
moo_pushtmp (moo, &y); moo_pushtmp (moo, &y);
x = normalize_bigint (moo, z); x = normalize_bigint (moo, z);
@ -3376,7 +3376,7 @@ moo_oop_t moo_bitshiftint (moo_t* moo, moo_oop_t x, moo_oop_t y)
z = make_bloated_bigint_with_ooi (moo, v1, wshift); z = make_bloated_bigint_with_ooi (moo, v1, wshift);
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
lshift_unsigned_array (((moo_oop_liword_t)z)->slot, MOO_OBJ_GET_SIZE(z), v2); lshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), MOO_OBJ_GET_SIZE(z), v2);
return normalize_bigint (moo, z); return normalize_bigint (moo, z);
} }
else else
@ -3534,7 +3534,7 @@ moo_oop_t moo_bitshiftint (moo_t* moo, moo_oop_t x, moo_oop_t y)
z = expand_bigint (moo, x, wshift); z = expand_bigint (moo, x, wshift);
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
lshift_unsigned_array (((moo_oop_liword_t)z)->slot, MOO_OBJ_GET_SIZE(z), shift); lshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), MOO_OBJ_GET_SIZE(z), shift);
} }
else else
{ {
@ -3552,7 +3552,7 @@ moo_oop_t moo_bitshiftint (moo_t* moo, moo_oop_t x, moo_oop_t y)
{ {
z = clone_bigint (moo, x, MOO_OBJ_GET_SIZE(x)); z = clone_bigint (moo, x, MOO_OBJ_GET_SIZE(x));
if (!z) return MOO_NULL; if (!z) return MOO_NULL;
rshift_unsigned_array (((moo_oop_liword_t)z)->slot, MOO_OBJ_GET_SIZE(z), shift); rshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), MOO_OBJ_GET_SIZE(z), shift);
} }
} }
@ -4201,7 +4201,7 @@ moo_oop_t moo_inttostr (moo_t* moo, moo_oop_t num, int radix)
w = 0; w = 0;
while (w < as) while (w < as)
{ {
acc |= (moo_lidw_t)((moo_oop_liword_t)num)->slot[w] << accbits; acc |= (moo_lidw_t)MOO_OBJ_GET_LIWORD_SLOT(num)[w] << accbits;
accbits += MOO_LIW_BITS; accbits += MOO_LIW_BITS;
w++; w++;
@ -4274,7 +4274,7 @@ moo_oop_t moo_inttostr (moo_t* moo, moo_oop_t num, int radix)
q = &t[as]; q = &t[as];
r = &t[as * 2]; r = &t[as * 2];
MOO_MEMCPY (a, ((moo_oop_liword_t)num)->slot, MOO_SIZEOF(*a) * as); MOO_MEMCPY (a, MOO_OBJ_GET_LIWORD_SLOT(num), MOO_SIZEOF(*a) * as);
do do
{ {

View File

@ -76,7 +76,7 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
key = (moo_oop_char_t)ass->key; key = (moo_oop_char_t)ass->key;
MOO_ASSERT (moo, MOO_CLASSOF(moo,key) == moo->_symbol); MOO_ASSERT (moo, MOO_CLASSOF(moo,key) == moo->_symbol);
index = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)) % newsz; index = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(key), MOO_OBJ_GET_SIZE(key)) % newsz;
while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz; while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz;
MOO_STORE_OOP (moo, &newbuc->slot[index], (moo_oop_t)ass); /* newbuc->slot[index] = (moo_oop_t)ass; */ MOO_STORE_OOP (moo, &newbuc->slot[index], (moo_oop_t)ass); /* newbuc->slot[index] = (moo_oop_t)ass; */
@ -100,7 +100,7 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
MOO_ASSERT (moo, MOO_CLASSOF(moo,dic->tally) == moo->_small_integer); MOO_ASSERT (moo, MOO_CLASSOF(moo,dic->tally) == moo->_small_integer);
MOO_ASSERT (moo, MOO_CLASSOF(moo,dic->bucket) == moo->_array); MOO_ASSERT (moo, MOO_CLASSOF(moo,dic->bucket) == moo->_array);
hv = moo_hashoochars(key->slot, MOO_OBJ_GET_SIZE(key)); hv = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(key), MOO_OBJ_GET_SIZE(key));
index = hv % MOO_OBJ_GET_SIZE(dic->bucket); index = hv % MOO_OBJ_GET_SIZE(dic->bucket);
/* find */ /* find */

View File

@ -552,7 +552,7 @@ static MOO_INLINE void chain_into_semaphore (moo_t* moo, moo_oop_process_t proc,
MOO_APPEND_TO_OOP_LIST (moo, &sem->waiting, moo_oop_process_t, proc, sem_wait); MOO_APPEND_TO_OOP_LIST (moo, &sem->waiting, moo_oop_process_t, proc, sem_wait);
proc->sem = (moo_oop_t)sem; MOO_STORE_OOP (moo, &proc->sem, (moo_oop_t)sem);
} }
static MOO_INLINE void unchain_from_semaphore (moo_t* moo, moo_oop_process_t proc) static MOO_INLINE void unchain_from_semaphore (moo_t* moo, moo_oop_process_t proc)
@ -597,7 +597,7 @@ static void terminate_process (moo_t* moo, moo_oop_process_t proc)
unchain_from_processor (moo, proc, PROC_STATE_TERMINATED); unchain_from_processor (moo, proc, PROC_STATE_TERMINATED);
proc->sp = MOO_SMOOI_TO_OOP(-1); /* invalidate the process stack */ proc->sp = MOO_SMOOI_TO_OOP(-1); /* invalidate the process stack */
proc->current_context = proc->initial_context; /* not needed but just in case */ MOO_STORE_OOP (moo, (moo_oop_t*)&proc->current_context, (moo_oop_t)proc->initial_context); /* not needed but just in case */
/* a runnable or running process must not be chanined to the /* a runnable or running process must not be chanined to the
* process list of a semaphore */ * process list of a semaphore */
@ -673,7 +673,7 @@ static void resume_process (moo_t* moo, moo_oop_process_t proc)
/* don't switch to this process. just change the state to RUNNABLE. /* don't switch to this process. just change the state to RUNNABLE.
* process switching should be triggerd by the process scheduler. */ * process switching should be triggerd by the process scheduler. */
chain_into_processor (moo, proc, PROC_STATE_RUNNABLE); chain_into_processor (moo, proc, PROC_STATE_RUNNABLE);
/*proc->current_context = proc->initial_context;*/ /*MOO_STORE_OOP (moo, &proc->current_context = proc->initial_context);*/
} }
#if 0 #if 0
else if (proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNABLE)) else if (proc->state == MOO_SMOOI_TO_OOP(PROC_STATE_RUNNABLE))
@ -775,7 +775,7 @@ static int async_signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
moo_oop_semaphore_t* tmp; moo_oop_semaphore_t* tmp;
new_capa = moo->sem_list_capa + SEM_LIST_INC; /* TODO: overflow check.. */ new_capa = moo->sem_list_capa + SEM_LIST_INC; /* TODO: overflow check.. */
tmp = moo_reallocmem (moo, moo->sem_list, MOO_SIZEOF(moo_oop_semaphore_t) * new_capa); tmp = moo_reallocmem(moo, moo->sem_list, MOO_SIZEOF(moo_oop_semaphore_t) * new_capa);
if (!tmp) return -1; if (!tmp) return -1;
moo->sem_list = tmp; moo->sem_list = tmp;
@ -1532,7 +1532,7 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
moo_poptmp (moo); moo_poptmp (moo);
if (!ctx) return -1; if (!ctx) return -1;
MOO_STORE_OOP (moo, &ctx->sender, moo->active_context); MOO_STORE_OOP (moo, (moo_oop_t*)&ctx->sender, (moo_oop_t)moo->active_context);
ctx->ip = MOO_SMOOI_TO_OOP(0); ctx->ip = MOO_SMOOI_TO_OOP(0);
/* ctx->sp will be set further down */ /* ctx->sp will be set further down */
@ -1559,7 +1559,7 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
MOO_STORE_OOP (moo, &ctx->method_or_nargs, (moo_oop_t)mth); MOO_STORE_OOP (moo, &ctx->method_or_nargs, (moo_oop_t)mth);
/* the 'home' field of a method context is always moo->_nil. /* the 'home' field of a method context is always moo->_nil.
ctx->home = moo->_nil;*/ ctx->home = moo->_nil;*/
MOO_STORE_OOP (moo, &ctx->origin, ctx); /* point to self */ MOO_STORE_OOP (moo, (moo_oop_t*)&ctx->origin, (moo_oop_t)ctx); /* point to self */
/* /*
* Assume this message sending expression: * Assume this message sending expression:
@ -1834,8 +1834,8 @@ TODO: overcome this problem - accept parameters....
ctx->ip = MOO_SMOOI_TO_OOP(0); /* point to the beginning */ ctx->ip = MOO_SMOOI_TO_OOP(0); /* point to the beginning */
ctx->sp = MOO_SMOOI_TO_OOP(-1); /* pointer to -1 below the bottom */ ctx->sp = MOO_SMOOI_TO_OOP(-1); /* pointer to -1 below the bottom */
ctx->origin = ctx; /* point to self */ MOO_STORE_OOP (moo, (moo_oop_t*)&ctx->origin, (moo_oop_t)ctx); /* point to self */
ctx->method_or_nargs = (moo_oop_t)mth; /* fake. help SWITCH_ACTIVE_CONTEXT() not fail. TODO: create a static fake method and use it... instead of 'mth' */ MOO_STORE_OOP (moo, (moo_oop_t*)&ctx->method_or_nargs, (moo_oop_t)mth); /* fake. help SWITCH_ACTIVE_CONTEXT() not fail. TODO: create a static fake method and use it... instead of 'mth' */
/* [NOTE] /* [NOTE]
* the receiver field and the sender field of ctx are nils. * the receiver field and the sender field of ctx are nils.
@ -2161,7 +2161,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
/* shallow-copy the named part including home, origin, etc. */ /* shallow-copy the named part including home, origin, etc. */
for (i = 0; i < MOO_CONTEXT_NAMED_INSTVARS; i++) for (i = 0; i < MOO_CONTEXT_NAMED_INSTVARS; i++)
{ {
((moo_oop_oop_t)blkctx)->slot[i] = ((moo_oop_oop_t)rcv_blkctx)->slot[i]; MOO_STORE_OOP (moo, &((moo_oop_oop_t)blkctx)->slot[i], ((moo_oop_oop_t)rcv_blkctx)->slot[i]);
} }
#else #else
blkctx->ip = rcv_blkctx->ip; blkctx->ip = rcv_blkctx->ip;
@ -2169,7 +2169,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
MOO_STORE_OOP (moo, &blkctx->method_or_nargs, rcv_blkctx->method_or_nargs); MOO_STORE_OOP (moo, &blkctx->method_or_nargs, rcv_blkctx->method_or_nargs);
MOO_STORE_OOP (moo, &blkctx->receiver_or_source, (moo_oop_t)rcv_blkctx); MOO_STORE_OOP (moo, &blkctx->receiver_or_source, (moo_oop_t)rcv_blkctx);
MOO_STORE_OOP (moo, &blkctx->home, rcv_blkctx->home); MOO_STORE_OOP (moo, &blkctx->home, rcv_blkctx->home);
MOO_STORE_OOP (moo, &blkctx->origin, rcv_blkctx->origin); MOO_STORE_OOP (moo, (moo_oop_t*)&blkctx->origin, (moo_oop_t)rcv_blkctx->origin);
#endif #endif
/* TODO: check the stack size of a block context to see if it's large enough to hold arguments */ /* TODO: check the stack size of a block context to see if it's large enough to hold arguments */
@ -2200,7 +2200,7 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
MOO_ASSERT (moo, blkctx->home != moo->_nil); MOO_ASSERT (moo, blkctx->home != moo->_nil);
blkctx->sp = MOO_SMOOI_TO_OOP(-1); /* not important at all */ blkctx->sp = MOO_SMOOI_TO_OOP(-1); /* not important at all */
MOO_STORE_OOP (moo, &blkctx->sender, moo->active_context); MOO_STORE_OOP (moo, (moo_oop_t*)&blkctx->sender, (moo_oop_t)moo->active_context);
*pblkctx = blkctx; *pblkctx = blkctx;
return MOO_PF_SUCCESS; return MOO_PF_SUCCESS;
@ -2622,7 +2622,7 @@ static moo_pfrc_t pf_semaphore_group_add_semaphore (moo_t* moo, moo_mod_t* mod,
sems_idx = MOO_OOP_TO_SMOOI(sem->count) > 0? MOO_SEMAPHORE_GROUP_SEMS_SIG: MOO_SEMAPHORE_GROUP_SEMS_UNSIG; sems_idx = MOO_OOP_TO_SMOOI(sem->count) > 0? MOO_SEMAPHORE_GROUP_SEMS_SIG: MOO_SEMAPHORE_GROUP_SEMS_UNSIG;
MOO_APPEND_TO_OOP_LIST (moo, &sg->sems[sems_idx], moo_oop_semaphore_t, sem, grm); MOO_APPEND_TO_OOP_LIST (moo, &sg->sems[sems_idx], moo_oop_semaphore_t, sem, grm);
sem->group = sg; MOO_STORE_OOP (moo, (moo_oop_t*)&sem->group, (moo_oop_t)sg);
count = MOO_OOP_TO_SMOOI(sg->sem_count); count = MOO_OOP_TO_SMOOI(sg->sem_count);
MOO_ASSERT (moo, count >= 0); MOO_ASSERT (moo, count >= 0);
@ -4626,11 +4626,11 @@ static MOO_INLINE int make_block (moo_t* moo)
blkctx->ntmprs = MOO_SMOOI_TO_OOP(b2); blkctx->ntmprs = MOO_SMOOI_TO_OOP(b2);
/* set the home context where it's defined */ /* set the home context where it's defined */
blkctx->home = (moo_oop_t)moo->active_context; MOO_STORE_OOP (moo, &blkctx->home, (moo_oop_t)moo->active_context);
/* no source for a base block context. */ /* no source for a base block context. */
blkctx->receiver_or_source = moo->_nil; blkctx->receiver_or_source = moo->_nil;
blkctx->origin = moo->active_context->origin; MOO_STORE_OOP (moo, (moo_oop_t*)&blkctx->origin, (moo_oop_t)moo->active_context->origin);
/* push the new block context to the stack of the active context */ /* push the new block context to the stack of the active context */
MOO_STACK_PUSH (moo, (moo_oop_t)blkctx); MOO_STACK_PUSH (moo, (moo_oop_t)blkctx);
@ -4736,7 +4736,7 @@ static int __execute (moo_t* moo)
store_instvar: store_instvar:
LOG_INST1 (moo, "store_into_instvar %zu", b1); LOG_INST1 (moo, "store_into_instvar %zu", b1);
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(moo->active_context->receiver_or_source) == MOO_OBJ_TYPE_OOP); MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(moo->active_context->receiver_or_source) == MOO_OBJ_TYPE_OOP);
((moo_oop_oop_t)moo->active_context->origin->receiver_or_source)->slot[b1] = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &((moo_oop_oop_t)moo->active_context->origin->receiver_or_source)->slot[b1], MOO_STACK_GETTOP(moo));
NEXT_INST(); NEXT_INST();
/* ------------------------------------------------- */ /* ------------------------------------------------- */
@ -4755,7 +4755,7 @@ static int __execute (moo_t* moo)
pop_into_instvar: pop_into_instvar:
LOG_INST1 (moo, "pop_into_instvar %zu", b1); LOG_INST1 (moo, "pop_into_instvar %zu", b1);
MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(moo->active_context->receiver_or_source) == MOO_OBJ_TYPE_OOP); MOO_ASSERT (moo, MOO_OBJ_GET_FLAGS_TYPE(moo->active_context->receiver_or_source) == MOO_OBJ_TYPE_OOP);
((moo_oop_oop_t)moo->active_context->origin->receiver_or_source)->slot[b1] = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &((moo_oop_oop_t)moo->active_context->origin->receiver_or_source)->slot[b1], MOO_STACK_GETTOP(moo));
MOO_STACK_POP (moo); MOO_STACK_POP (moo);
NEXT_INST(); NEXT_INST();
@ -4858,7 +4858,7 @@ static int __execute (moo_t* moo)
else else
{ {
/* store or pop - bit 5 off */ /* store or pop - bit 5 off */
ctx->slot[bx] = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &ctx->slot[bx], MOO_STACK_GETTOP(moo));
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
@ -4924,7 +4924,7 @@ static int __execute (moo_t* moo)
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
/* store or pop */ /* store or pop */
ass->value = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &ass->value, MOO_STACK_GETTOP(moo));
if ((bcode >> 2) & 1) if ((bcode >> 2) & 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 */
ctx->slot[b2] = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &ctx->slot[b2], MOO_STACK_GETTOP(moo));
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)
{ {
@ -5187,7 +5187,7 @@ static int __execute (moo_t* moo)
if ((bcode >> 3) & 1) if ((bcode >> 3) & 1)
{ {
/* store or pop */ /* store or pop */
t->slot[b1] = MOO_STACK_GETTOP(moo); MOO_STORE_OOP (moo, &t->slot[b1], MOO_STACK_GETTOP(moo));
if ((bcode >> 2) & 1) if ((bcode >> 2) & 1)
{ {
@ -5381,7 +5381,7 @@ static int __execute (moo_t* moo)
t1 = MOO_STACK_GETTOP(moo); t1 = MOO_STACK_GETTOP(moo);
MOO_STACK_POP (moo); MOO_STACK_POP (moo);
t2 = MOO_STACK_GETTOP(moo); t2 = MOO_STACK_GETTOP(moo);
((moo_oop_oop_t)t2)->slot[b1] = t1; MOO_STORE_OOP (moo, &((moo_oop_oop_t)t2)->slot[b1], t1);
NEXT_INST(); NEXT_INST();
} }
@ -5529,7 +5529,7 @@ static int __execute (moo_t* moo)
* the number of temporaries of a home context */ * the number of temporaries of a home context */
blkctx->ntmprs = MOO_SMOOI_TO_OOP(ntmprs); blkctx->ntmprs = MOO_SMOOI_TO_OOP(ntmprs);
blkctx->home = (moo_oop_t)rctx; MOO_STORE_OOP (moo, &blkctx->home, (moo_oop_t)rctx);
blkctx->receiver_or_source = moo->_nil; blkctx->receiver_or_source = moo->_nil;
/* [NOTE] /* [NOTE]
@ -5547,7 +5547,7 @@ static int __execute (moo_t* moo)
* if it is a block context, the following condition is true. * if it is a block context, the following condition is true.
* MOO_CLASSOF(moo, rctx) == moo->_block_context * MOO_CLASSOF(moo, rctx) == moo->_block_context
*/ */
blkctx->origin = rctx->origin; MOO_STORE_OOP (moo, (moo_oop_t*)&blkctx->origin, (moo_oop_t)rctx->origin);
MOO_STACK_SETTOP (moo, (moo_oop_t)blkctx); MOO_STACK_SETTOP (moo, (moo_oop_t)blkctx);
NEXT_INST(); NEXT_INST();

View File

@ -546,7 +546,7 @@ static int ignite_3 (moo_t* moo)
if (!sym) return -1; if (!sym) return -1;
cls = *(moo_oop_class_t*)((moo_uint8_t*)moo + kernel_classes[i].offset); cls = *(moo_oop_class_t*)((moo_uint8_t*)moo + kernel_classes[i].offset);
cls->name = (moo_oop_char_t)sym; MOO_STORE_OOP (moo, (moo_oop_t*)&cls->name, sym);
cls->nsup = moo->sysdic; cls->nsup = moo->sysdic;
if (!moo_putatsysdic(moo, sym, (moo_oop_t)cls)) return -1; if (!moo_putatsysdic(moo, sym, (moo_oop_t)cls)) return -1;

View File

@ -500,6 +500,7 @@ 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_SLOT_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_SLOT_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_SLOT_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])
@ -520,6 +521,7 @@ struct moo_obj_word_t
#define MOO_OBJ_SET_HALFWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_halfword_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_WORD_SLOT_VAL(oop,idx,val) ((((moo_oop_word_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_LIWORD_SLOT_VAL(oop,idx,val) ((((moo_oop_liword_t)(oop))->slot)[idx] = (val)) #define MOO_OBJ_SET_LIWORD_SLOT_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

@ -98,13 +98,13 @@ moo_oop_t moo_allocoopobjwithtrailer (moo_t* moo, moo_oow_t size, const moo_oob_
hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned); hdr = (moo_oop_oop_t)moo_allocbytes(moo, MOO_SIZEOF(moo_obj_t) + nbytes_aligned);
if (!hdr) return MOO_NULL; if (!hdr) return MOO_NULL;
hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, moo->igniting, 0, 0, 1); hdr->_flags = MOO_OBJ_MAKE_FLAGS(MOO_OBJ_TYPE_OOP, MOO_SIZEOF(moo_oop_t), 0, 0, moo->igniting, 0, 0, 1); /* TRAILER bit -> 1 */
MOO_OBJ_SET_SIZE (hdr, size); MOO_OBJ_SET_SIZE (hdr, size);
MOO_OBJ_SET_CLASS (hdr, moo->_nil); MOO_OBJ_SET_CLASS (hdr, moo->_nil);
for (i = 0; i < size; i++) hdr->slot[i] = moo->_nil; for (i = 0; i < size; i++) hdr->slot[i] = moo->_nil;
/* [NOTE] this is not converted to a SmallInteger object */ /* [NOTE] this is not converted to a SmallInteger object. it is a special slot handled by GC for an object with the TRAILER bit set */
hdr->slot[size] = (moo_oop_t)blen; hdr->slot[size] = (moo_oop_t)blen;
if (bptr) if (bptr)
@ -275,7 +275,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
while (i > 0) while (i > 0)
{ {
--i; --i;
((moo_oop_oop_t)oop)->slot[i] = ((moo_oop_oop_t)_class->initv[0])->slot[i]; MOO_STORE_OOP (moo, &((moo_oop_oop_t)oop)->slot[i], ((moo_oop_oop_t)_class->initv[0])->slot[i]);
} }
} }
} }
@ -361,7 +361,7 @@ moo_oop_t moo_instantiatewithtrailer (moo_t* moo, moo_oop_class_t _class, moo_oo
while (i > 0) while (i > 0)
{ {
--i; --i;
((moo_oop_oop_t)oop)->slot[i] = ((moo_oop_oop_t)_class->initv[0])->slot[i]; MOO_STORE_OOP (moo, &((moo_oop_oop_t)oop)->slot[i], ((moo_oop_oop_t)_class->initv[0])->slot[i]);
} }
} }
} }

View File

@ -53,7 +53,7 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
if (inc_max > 0) inc = inc_max; if (inc_max > 0) inc = inc_max;
else else
{ {
moo_seterrnum (moo, MOO_EOOMEM); moo_seterrbfmt (moo, MOO_EOOMEM, "unable to grow symbol table");
return MOO_NULL; return MOO_NULL;
} }
} }
@ -73,9 +73,9 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol); MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol);
/*MOO_ASSERT (moo, sym->size > 0);*/ /*MOO_ASSERT (moo, sym->size > 0);*/
index = moo_hashoochars(symbol->slot, MOO_OBJ_GET_SIZE(symbol)) % newsz; index = moo_hashoochars(MOO_OBJ_GET_CHAR_SLOT(symbol), MOO_OBJ_GET_SIZE(symbol)) % newsz;
while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz; while (newbuc->slot[index] != moo->_nil) index = (index + 1) % newsz;
newbuc->slot[index] = (moo_oop_t)symbol; MOO_STORE_OOP (moo, &newbuc->slot[index], (moo_oop_t)symbol);
} }
} }
@ -98,7 +98,7 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow
MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol); MOO_ASSERT (moo, MOO_CLASSOF(moo,symbol) == moo->_symbol);
if (len == MOO_OBJ_GET_SIZE(symbol) && if (len == MOO_OBJ_GET_SIZE(symbol) &&
moo_equal_oochars (ptr, symbol->slot, len)) moo_equal_oochars(ptr, MOO_OBJ_GET_CHAR_SLOT(symbol), len))
{ {
return (moo_oop_t)symbol; return (moo_oop_t)symbol;
} }
@ -119,7 +119,7 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow
{ {
/* this built-in table is not allowed to hold more than /* this built-in table is not allowed to hold more than
* MOO_SMOOI_MAX items for efficiency sake */ * MOO_SMOOI_MAX items for efficiency sake */
moo_seterrnum (moo, MOO_EDFULL); moo_seterrbfmt (moo, MOO_EDFULL, "unable to add a symbol %.*js - symbol table full", len, ptr);
return MOO_NULL; return MOO_NULL;
} }
@ -157,7 +157,7 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow
{ {
MOO_ASSERT (moo, tally < MOO_SMOOI_MAX); MOO_ASSERT (moo, tally < MOO_SMOOI_MAX);
moo->symtab->tally = MOO_SMOOI_TO_OOP(tally + 1); moo->symtab->tally = MOO_SMOOI_TO_OOP(tally + 1);
moo->symtab->bucket->slot[index] = (moo_oop_t)symbol; MOO_STORE_OOP (moo, &moo->symtab->bucket->slot[index], (moo_oop_t)symbol);
} }
return (moo_oop_t)symbol; return (moo_oop_t)symbol;
@ -165,12 +165,12 @@ static moo_oop_t find_or_make_symbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow
moo_oop_t moo_makesymbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len) moo_oop_t moo_makesymbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len)
{ {
return find_or_make_symbol (moo, ptr, len, 1); return find_or_make_symbol(moo, ptr, len, 1);
} }
moo_oop_t moo_findsymbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len) moo_oop_t moo_findsymbol (moo_t* moo, const moo_ooch_t* ptr, moo_oow_t len)
{ {
return find_or_make_symbol (moo, ptr, len, 0); return find_or_make_symbol(moo, ptr, len, 0);
} }
moo_oop_t moo_makestringwithbchars (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len) moo_oop_t moo_makestringwithbchars (moo_t* moo, const moo_bch_t* ptr, moo_oow_t len)
@ -180,7 +180,7 @@ moo_oop_t moo_makestringwithbchars (moo_t* moo, const moo_bch_t* ptr, moo_oow_t
moo_oop_t obj; moo_oop_t obj;
inlen = len; inlen = len;
if (moo_convbtouchars (moo, ptr, &inlen, MOO_NULL, &outlen) <= -1) return MOO_NULL; if (moo_convbtouchars(moo, ptr, &inlen, MOO_NULL, &outlen) <= -1) return MOO_NULL;
obj = moo_instantiate(moo, moo->_string, MOO_NULL, outlen); obj = moo_instantiate(moo, moo->_string, MOO_NULL, outlen);
if (!obj) return MOO_NULL; if (!obj) return MOO_NULL;
@ -201,7 +201,7 @@ moo_oop_t moo_makestringwithuchars (moo_t* moo, const moo_uch_t* ptr, moo_oow_t
moo_oop_t obj; moo_oop_t obj;
inlen = len; inlen = len;
if (moo_convutobchars (moo, ptr, &inlen, MOO_NULL, &outlen) <= -1) return MOO_NULL; if (moo_convutobchars(moo, ptr, &inlen, MOO_NULL, &outlen) <= -1) return MOO_NULL;
obj = moo_instantiate(moo, moo->_string, MOO_NULL, outlen); obj = moo_instantiate(moo, moo->_string, MOO_NULL, outlen);
if (!obj) return MOO_NULL; if (!obj) return MOO_NULL;