renamed moo_pushtmp()/poptmp()/poptmps() to moo_pushvolat()/popvolat()/popvolats()

This commit is contained in:
hyunghwan.chung 2018-12-28 08:29:27 +00:00
parent 53c0783da8
commit fc3a725bb8
12 changed files with 213 additions and 215 deletions

View File

@ -10,6 +10,6 @@
#include 'Stream.moo'.
(* -------------------------------------------------------------------------- *)
## #include 'FFI.moo'.
#include 'FFI.moo'.
#include 'Stdio.moo'.
## #include 'Console.moo'.

View File

@ -530,9 +530,9 @@ static MOO_INLINE moo_oop_t expand_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t
return MOO_NULL;
}
moo_pushtmp (moo, &oop);
moo_pushvolat (moo, &oop);
z = moo_instantiate(moo, MOO_OBJ_GET_CLASS(oop), MOO_NULL, count + inc);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
for (i = 0; i < count; i++)
@ -551,9 +551,9 @@ static MOO_INLINE moo_oop_t _clone_bigint (moo_t* moo, moo_oop_t oop, moo_oow_t
MOO_ASSERT (moo, MOO_OOP_IS_POINTER(oop));
if (count <= 0) count = MOO_OBJ_GET_SIZE(oop);
moo_pushtmp (moo, &oop);
moo_pushvolat (moo, &oop);
z = moo_instantiate(moo, _class, MOO_NULL, count);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
for (i = 0; i < count; i++)
@ -1502,10 +1502,10 @@ static moo_oop_t add_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y)
}
zs++;
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, MOO_OBJ_GET_CLASS(x), MOO_NULL, zs);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
add_unsigned_array (
@ -1523,10 +1523,10 @@ static moo_oop_t subtract_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t
MOO_ASSERT (moo, !is_less_unsigned(x, y));
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, MOO_OBJ_GET_SIZE(x));
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
subtract_unsigned_array (moo,
@ -1550,10 +1550,10 @@ static moo_oop_t multiply_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t
return MOO_NULL;
}
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, xs + ys);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
#if defined(MOO_ENABLE_KARATSUBA)
@ -1584,18 +1584,18 @@ static moo_oop_t divide_unsigned_integers (moo_t* moo, moo_oop_t x, moo_oop_t y,
/* the caller must ensure that x >= y */
MOO_ASSERT (moo, !is_less_unsigned (x, y));
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
qq = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, MOO_OBJ_GET_SIZE(x));
if (!qq)
{
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
return MOO_NULL;
}
moo_pushtmp (moo, &qq);
moo_pushvolat (moo, &qq);
rr = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, MOO_OBJ_GET_SIZE(x));
moo_poptmps (moo, 3);
moo_popvolats (moo, 3);
if (!rr) return MOO_NULL;
divide_unsigned_array (moo,
@ -1636,9 +1636,9 @@ moo_oop_t moo_addints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(x);
if (v == 0) return clone_bigint (moo, y, MOO_OBJ_GET_SIZE(y));
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi(moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
}
else if (MOO_OOP_IS_SMOOI(y))
@ -1648,9 +1648,9 @@ moo_oop_t moo_addints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(y);
if (v == 0) return clone_bigint (moo, x, MOO_OBJ_GET_SIZE(x));
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi(moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
}
else
@ -1744,9 +1744,9 @@ moo_oop_t moo_subints (moo_t* moo, moo_oop_t x, moo_oop_t y)
return clone_bigint_negated(moo, y, MOO_OBJ_GET_SIZE(y));
}
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi(moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
}
else if (MOO_OOP_IS_SMOOI(y))
@ -1756,9 +1756,9 @@ moo_oop_t moo_subints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(y);
if (v == 0) return clone_bigint(moo, x, MOO_OBJ_GET_SIZE(x));
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi(moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
}
else
@ -1822,14 +1822,14 @@ moo_oop_t moo_mulints (moo_t* moo, moo_oop_t x, moo_oop_t y)
{
/* overflowed - convert x and y normal objects and carry on */
/* no need to call moo_pushtmp before creating x because
/* no need to call moo_pushvolat before creating x because
* xv and yv contains actual values needed */
x = make_bigint_with_ooi (moo, xv);
if (!x) return MOO_NULL;
moo_pushtmp (moo, &x); /* protect x made above */
moo_pushvolat (moo, &x); /* protect x made above */
y = make_bigint_with_ooi(moo, yv);
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
goto normal;
@ -1844,6 +1844,7 @@ moo_oop_t moo_mulints (moo_t* moo, moo_oop_t x, moo_oop_t y)
else
{
moo_ooi_t v;
int neg;
if (MOO_OOP_IS_SMOOI(x))
{
@ -1860,9 +1861,9 @@ moo_oop_t moo_mulints (moo_t* moo, moo_oop_t x, moo_oop_t y)
return clone_bigint_negated(moo, y, MOO_OBJ_GET_SIZE(y));
}
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi(moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
}
else if (MOO_OOP_IS_SMOOI(y))
@ -1880,9 +1881,9 @@ moo_oop_t moo_mulints (moo_t* moo, moo_oop_t x, moo_oop_t y)
return clone_bigint_negated(moo, x, MOO_OBJ_GET_SIZE(x));
}
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
}
else
@ -1892,16 +1893,13 @@ moo_oop_t moo_mulints (moo_t* moo, moo_oop_t x, moo_oop_t y)
}
normal:
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
z = multiply_unsigned_integers (moo, x, y);
moo_poptmps (moo, 2);
neg = (MOO_OBJ_GET_CLASS(x) != MOO_OBJ_GET_CLASS(y)); /* checking sign before multication. no need to preserve x and y */
z = multiply_unsigned_integers(moo, x, y);
if (!z) return MOO_NULL;
if (MOO_OBJ_GET_CLASS(x) != MOO_OBJ_GET_CLASS(y))
MOO_OBJ_SET_CLASS(z, moo->_large_negative_integer);
if (neg) MOO_OBJ_SET_CLASS(z, moo->_large_negative_integer);
}
return normalize_bigint (moo, z);
return normalize_bigint(moo, z);
oops_einval:
moo_seterrbfmt (moo, MOO_EINVAL, "invalid parameters - %O, %O", x, y);
@ -2028,9 +2026,9 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
return MOO_SMOOI_TO_OOP(0);
}
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
}
else if (MOO_OOP_IS_SMOOI(y))
@ -2073,9 +2071,9 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
*/
}
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
}
else
@ -2088,10 +2086,10 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
x_neg = (MOO_POINTER_IS_NBIGINT(moo, x));
y_neg = (MOO_POINTER_IS_NBIGINT(moo, y));
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = divide_unsigned_integers (moo, x, y, &r);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
if (x_neg)
@ -2105,30 +2103,30 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
{
MOO_OBJ_SET_CLASS(z, moo->_large_negative_integer);
moo_pushtmp (moo, &z);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &z);
moo_pushvolat (moo, &y);
r = normalize_bigint (moo, r);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!r) return MOO_NULL;
if (r != MOO_SMOOI_TO_OOP(0) && modulo)
{
if (rem)
{
moo_pushtmp (moo, &z);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &z);
moo_pushvolat (moo, &y);
r = moo_addints (moo, r, y);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!r) return MOO_NULL;
moo_pushtmp (moo, &r);
moo_pushvolat (moo, &r);
z = normalize_bigint (moo, z);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
moo_pushtmp (moo, &r);
moo_pushvolat (moo, &r);
z = moo_subints (moo, z, MOO_SMOOI_TO_OOP(1));
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
*rem = r;
@ -2146,9 +2144,9 @@ moo_oop_t moo_divints (moo_t* moo, moo_oop_t x, moo_oop_t y, int modulo, moo_oop
}
else
{
moo_pushtmp (moo, &z);
moo_pushvolat (moo, &z);
r = normalize_bigint (moo, r);
moo_poptmp (moo);
moo_popvolat (moo);
if (!r) return MOO_NULL;
}
@ -2296,9 +2294,9 @@ moo_oop_t moo_bitatint (moo_t* moo, moo_oop_t x, moo_oop_t y)
MOO_ASSERT (moo, sign == 0);
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
quo = moo_divints (moo, y, MOO_SMOOI_TO_OOP(MOO_LIW_BITS), 0, &rem);
moo_poptmp (moo);
moo_popvolat (moo);
if (!quo) return MOO_NULL;
sign = integer_to_oow (moo, quo, &wp);
@ -2367,9 +2365,9 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(x);
if (v == 0) return MOO_SMOOI_TO_OOP(0);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2383,9 +2381,9 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(y);
if (v == 0) return MOO_SMOOI_TO_OOP(0);
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2437,10 +2435,10 @@ moo_oop_t moo_bitandints (moo_t* moo, moo_oop_t x, moo_oop_t y)
zs = ys;
}
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, zalloc);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
if (negx && negy)
@ -2580,9 +2578,9 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(x);
if (v == 0) return clone_bigint(moo, y, MOO_OBJ_GET_SIZE(y));
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2596,9 +2594,9 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(y);
if (v == 0) return clone_bigint(moo, x, MOO_OBJ_GET_SIZE(x));
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2657,10 +2655,10 @@ moo_oop_t moo_bitorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
return MOO_NULL;
}
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, zalloc);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
if (negx && negy)
@ -2798,9 +2796,9 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(x);
if (v == 0) return clone_bigint(moo, y, MOO_OBJ_GET_SIZE(y));
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2814,9 +2812,9 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
v = MOO_OOP_TO_SMOOI(y);
if (v == 0) return clone_bigint(moo, x, MOO_OBJ_GET_SIZE(x));
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -2875,10 +2873,10 @@ moo_oop_t moo_bitxorints (moo_t* moo, moo_oop_t x, moo_oop_t y)
return MOO_NULL;
}
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, zalloc);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!z) return MOO_NULL;
if (negx && negy)
@ -3034,9 +3032,9 @@ moo_oop_t moo_bitinvint (moo_t* moo, moo_oop_t x)
return MOO_NULL;
}
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
z = moo_instantiate(moo, moo->_large_positive_integer, MOO_NULL, zalloc);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
if (negx)
@ -3105,10 +3103,10 @@ static MOO_INLINE moo_oop_t rshift_negative_bigint (moo_t* moo, moo_oop_t x, moo
MOO_ASSERT (moo, MOO_POINTER_IS_NBIGINT(moo, x));
xs = MOO_OBJ_GET_SIZE(x);
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
/* +1 for the second inversion below */
z = moo_instantiate(moo, moo->_large_negative_integer, MOO_NULL, xs + 1);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
/* the following lines roughly for 'z = moo_bitinv (moo, x)' */
@ -3175,15 +3173,15 @@ static MOO_INLINE moo_oop_t rshift_negative_bigint_and_normalize (moo_t* moo, mo
shift = MOO_SMOOI_MAX;
do
{
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
z = rshift_negative_bigint (moo, x, shift);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
/* y is a negative number. use moo_addints() until it becomes 0 */
moo_pushtmp (moo, &z);
moo_pushvolat (moo, &z);
y = moo_addints (moo, y, MOO_SMOOI_TO_OOP(shift));
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
sign = integer_to_oow (moo, y, &shift);
@ -3198,9 +3196,9 @@ static MOO_INLINE moo_oop_t rshift_negative_bigint_and_normalize (moo_t* moo, mo
MOO_ASSERT (moo, sign <= -1);
}
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = normalize_bigint (moo, z);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
if (MOO_OOP_IS_SMOOI(x))
@ -3248,9 +3246,9 @@ static MOO_INLINE moo_oop_t rshift_positive_bigint_and_normalize (moo_t* moo, mo
zs = MOO_OBJ_GET_SIZE(x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
z = clone_bigint (moo, x, zs);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
/* for convenience in subtraction below.
@ -3269,9 +3267,9 @@ static MOO_INLINE moo_oop_t rshift_positive_bigint_and_normalize (moo_t* moo, mo
}
/* y is a negative number. use moo_addints() until it becomes 0 */
moo_pushtmp (moo, &z);
moo_pushvolat (moo, &z);
y = moo_addints (moo, y, MOO_SMOOI_TO_OOP(shift));
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
sign = integer_to_oow (moo, y, &shift);
@ -3310,21 +3308,21 @@ static MOO_INLINE moo_oop_t lshift_bigint_and_normalize (moo_t* moo, moo_oop_t x
wshift = shift / MOO_LIW_BITS;
if (shift > wshift * MOO_LIW_BITS) wshift++;
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
z = expand_bigint (moo, x, wshift);
moo_poptmp (moo);
moo_popvolat (moo);
if (!z) return MOO_NULL;
lshift_unsigned_array (MOO_OBJ_GET_LIWORD_SLOT(z), MOO_OBJ_GET_SIZE(z), shift);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = normalize_bigint (moo, z);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
moo_pushtmp (moo, &x);
moo_pushvolat (moo, &x);
y = moo_subints (moo, y, MOO_SMOOI_TO_OOP(shift));
moo_poptmp (moo);
moo_popvolat (moo);
if (!y) return MOO_NULL;
sign = integer_to_oow (moo, y, &shift);
@ -3446,9 +3444,9 @@ moo_oop_t moo_bitshiftint (moo_t* moo, moo_oop_t x, moo_oop_t y)
return (v < 0)? MOO_SMOOI_TO_OOP(-1): MOO_SMOOI_TO_OOP(0);
}
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &y);
x = make_bigint_with_ooi (moo, v);
moo_poptmp (moo);
moo_popvolat (moo);
if (!x) return MOO_NULL;
goto bigint_and_bigint;
@ -3639,7 +3637,7 @@ moo_oop_t moo_strtoint (moo_t* moo, const moo_ooch_t* str, moo_oow_t len, int ra
#elif defined(__GNUC__) && (defined(__x86_64) || defined(__amd64) || defined(__i386) || defined(i386))
/* use the Bit Scan Forward instruction */
__asm__ volatile (
__asm__ volat (
"bsf %1,%0\n\t"
: "=r"(exp) /* output */
: "r"(radix) /* input */
@ -3651,7 +3649,7 @@ moo_oop_t moo_strtoint (moo_t* moo, const moo_ooch_t* str, moo_oow_t len, int ra
* count trailing zeros or something similar. using RBIT with CLZ
* would be good in ARMv6T2 and above to avoid further calculation
* afte CLZ */
__asm__ volatile (
__asm__ volat (
"clz %0,%1\n\t"
: "=r"(exp) /* output */
: "r"(radix) /* input */
@ -4011,11 +4009,11 @@ moo_oop_t moo_sqrtint (moo_t* moo, moo_oop_t x)
m = moo->_nil;
m2 = moo->_nil;
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &a);
moo_pushtmp (moo, &b);
moo_pushtmp (moo, &m);
moo_pushtmp (moo, &m2);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &a);
moo_pushvolat (moo, &b);
moo_pushvolat (moo, &m);
moo_pushvolat (moo, &m2);
a = moo_ltints(moo, x, MOO_SMOOI_TO_OOP(0));
if (!a) goto oops;
@ -4061,7 +4059,7 @@ moo_oop_t moo_sqrtint (moo_t* moo, moo_oop_t x)
}
}
moo_poptmps (moo, 5);
moo_popvolats (moo, 5);
x = moo_subints(moo, a, MOO_SMOOI_TO_OOP(1));
if (!x) return MOO_NULL;
@ -4069,7 +4067,7 @@ moo_oop_t moo_sqrtint (moo_t* moo, moo_oop_t x)
return x;
oops:
moo_poptmps (moo, 5);
moo_popvolats (moo, 5);
return MOO_NULL;
}

View File

@ -3186,17 +3186,17 @@ static moo_oop_nsdic_t add_namespace (moo_t* moo, moo_oop_nsdic_t dic, const moo
moo_oop_nsdic_t nsdic;
moo_oop_association_t ass;
moo_pushtmp (moo, (moo_oop_t*)&dic); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&dic); tmp_count++;
sym = (moo_oop_char_t)moo_makesymbol(moo, name->ptr, name->len);
if (!sym) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&sym); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&sym); tmp_count++;
nsdic = moo_makensdic(moo, moo->_namespace, NAMESPACE_SIZE);
if (!nsdic) goto oops;
/*moo_pushtmp (moo, &ns); tmp_count++;*/
/*moo_pushvolat (moo, &ns); tmp_count++;*/
ass = moo_putatdic(moo, (moo_oop_dic_t)dic, (moo_oop_t)sym, (moo_oop_t)nsdic);
if (!ass) goto oops;
@ -3204,11 +3204,11 @@ static moo_oop_nsdic_t add_namespace (moo_t* moo, moo_oop_nsdic_t dic, const moo
nsdic->nsup = (moo_oop_t)dic;
nsdic->name = sym;
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return nsdic;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return MOO_NULL;
}
@ -3217,7 +3217,7 @@ static moo_oop_nsdic_t attach_nsdic_to_class (moo_t* moo, moo_oop_class_t c)
moo_oow_t tmp_count = 0;
moo_oop_nsdic_t nsdic;
moo_pushtmp (moo, (moo_oop_t*)&c); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&c); tmp_count++;
nsdic = moo_makensdic(moo, moo->_namespace, NAMESPACE_SIZE);
if (!nsdic) goto oops;
@ -3226,11 +3226,11 @@ static moo_oop_nsdic_t attach_nsdic_to_class (moo_t* moo, moo_oop_class_t c)
nsdic->name = c->name; /* for convenience only */
c->nsdic = nsdic;
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return nsdic;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return MOO_NULL;
}
@ -6461,7 +6461,7 @@ static int add_compiled_method (moo_t* moo)
name = (moo_oop_char_t)moo_makesymbol(moo, cc->mth.name.ptr, cc->mth.name.len);
if (!name) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&name); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&name); tmp_count++;
/* The variadic data part passed to moo_instantiate() is not GC-safe.
* let's delay initialization of variadic data a bit. */
@ -6477,14 +6477,14 @@ static int add_compiled_method (moo_t* moo)
/* let's do the variadic data initialization here */
MOO_STORE_OOP (moo, &mth->literal_frame[i], cc->mth.literals.ptr[i]);
}
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&mth); tmp_count++;
#if defined(MOO_USE_METHOD_TRAILER)
/* do nothing */
#else
code = (moo_oop_byte_t)moo_instantiate(moo, moo->_byte_array, cc->mth.code.ptr, cc->mth.code.len);
if (!code) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&code); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&code); tmp_count++;
#endif
preamble_code = MOO_METHOD_PREAMBLE_NONE;
@ -6673,12 +6673,12 @@ need to write code to collect string.
if (!moo_putatdic(moo, cc->self_oop->mthdic[cc->mth.type], (moo_oop_t)name, (moo_oop_t)mth)) goto oops;
}
moo_poptmps (moo, tmp_count); tmp_count = 0;
moo_popvolats (moo, tmp_count); tmp_count = 0;
return 0;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return -1;
}
@ -8336,11 +8336,11 @@ static int add_method_signature (moo_t* moo)
name = (moo_oop_char_t)moo_makesymbol(moo, ifce->mth.name.ptr, ifce->mth.name.len);
if (!name) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&name); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&name); tmp_count++;
mth = (moo_oop_methsig_t)moo_instantiate(moo, moo->_methsig, MOO_NULL, 0);
if (!mth) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&mth); tmp_count++;
mth->owner = ifce->self_oop;
mth->name = name;
@ -8368,11 +8368,11 @@ static int add_method_signature (moo_t* moo)
if (!moo_putatdic(moo, ifce->self_oop->mthdic[ifce->mth.type], (moo_oop_t)name, (moo_oop_t)mth)) goto oops;
}
moo_poptmps (moo, tmp_count); tmp_count = 0;
moo_popvolats (moo, tmp_count); tmp_count = 0;
return 0;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return -1;
}

View File

@ -61,9 +61,9 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
newsz = oldsz + inc;
}
moo_pushtmp (moo, (moo_oop_t*)&oldbuc);
moo_pushvolat (moo, (moo_oop_t*)&oldbuc);
newbuc = (moo_oop_oop_t)moo_instantiate(moo, moo->_array, MOO_NULL, newsz);
moo_poptmp (moo);
moo_popvolat (moo);
if (!newbuc) return MOO_NULL;
while (oldsz > 0)
@ -142,9 +142,9 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
return MOO_NULL;
}
moo_pushtmp (moo, (moo_oop_t*)&dic); tmp_count++;
moo_pushtmp (moo, (moo_oop_t*)&key); tmp_count++;
moo_pushtmp (moo, &value); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&dic); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&key); tmp_count++;
moo_pushvolat (moo, &value); tmp_count++;
/* no conversion to moo_oow_t is necessary for tally + 1.
* the maximum value of tally is checked to be MOO_SMOOI_MAX - 1.
@ -188,11 +188,11 @@ static moo_oop_association_t find_or_upsert (moo_t* moo, moo_oop_dic_t dic, moo_
dic->tally = MOO_SMOOI_TO_OOP(tally + 1); /* no need to use MOO_STORE_OOP as the value is not a pointer object */
MOO_STORE_OOP (moo, MOO_OBJ_GET_OOP_PTR(dic->bucket, index), (moo_oop_t)ass);
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return ass;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return MOO_NULL;
}
@ -374,9 +374,9 @@ moo_oop_dic_t moo_makedic (moo_t* moo, moo_oop_class_t _class, moo_oow_t size)
dic = (moo_oop_dic_t)moo_instantiate(moo, _class, MOO_NULL, 0);
if (!dic) return MOO_NULL;
moo_pushtmp (moo, (moo_oop_t*)&dic);
moo_pushvolat (moo, (moo_oop_t*)&dic);
tmp = moo_instantiate(moo, moo->_array, MOO_NULL, size);
moo_poptmp (moo);
moo_popvolat (moo);
if (!tmp) return MOO_NULL;
dic->tally = MOO_SMOOI_TO_OOP(0);

View File

@ -323,9 +323,9 @@ static moo_oop_process_t make_process (moo_t* moo, moo_oop_context_t c)
if (moo->proc_map_free_first <= -1 && prepare_to_alloc_pid(moo) <= -1) return MOO_NULL;
moo_pushtmp (moo, (moo_oop_t*)&c);
moo_pushvolat (moo, (moo_oop_t*)&c);
proc = (moo_oop_process_t)moo_instantiate(moo, moo->_process, MOO_NULL, moo->option.dfl_procstk_size);
moo_poptmp (moo);
moo_popvolat (moo);
if (!proc) return MOO_NULL;
proc->state = MOO_SMOOI_TO_OOP(PROC_STATE_SUSPENDED);
@ -860,7 +860,7 @@ static moo_oop_process_t signal_semaphore (moo_t* moo, moo_oop_semaphore_t sem)
{
proc = sem->waiting.first;
/* [NOTE] no GC must occur as 'proc' isn't protected with moo_pushtmp(). */
/* [NOTE] no GC must occur as 'proc' isn't protected with moo_pushvolat(). */
/* detach a process from a semaphore's waiting list and
* make it runnable */
@ -1229,9 +1229,9 @@ static int add_sem_to_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, moo_ooi
new_mask = ((moo_ooi_t)1 << io_type);
moo_pushtmp (moo, (moo_oop_t*)&sem);
moo_pushvolat (moo, (moo_oop_t*)&sem);
n = moo->vmprim.vm_muxadd(moo, io_handle, new_mask);
moo_poptmp (moo);
moo_popvolat (moo);
}
else
{
@ -1244,9 +1244,9 @@ static int add_sem_to_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, moo_ooi
new_mask = moo->sem_io_tuple[index].mask; /* existing mask */
new_mask |= ((moo_ooi_t)1 << io_type);
moo_pushtmp (moo, (moo_oop_t*)&sem);
moo_pushvolat (moo, (moo_oop_t*)&sem);
n = moo->vmprim.vm_muxmod(moo, io_handle, new_mask);
moo_poptmp (moo);
moo_popvolat (moo);
}
if (n <= -1)
@ -1312,10 +1312,10 @@ static int delete_sem_from_sem_io_tuple (moo_t* moo, moo_oop_semaphore_t sem, in
new_mask = moo->sem_io_tuple[index].mask;
new_mask &= ~((moo_ooi_t)1 << io_type); /* this is the new mask after deletion */
moo_pushtmp (moo, (moo_oop_t*)&sem);
moo_pushvolat (moo, (moo_oop_t*)&sem);
x = new_mask? moo->vmprim.vm_muxmod(moo, io_handle, new_mask):
moo->vmprim.vm_muxdel(moo, io_handle);
moo_poptmp (moo);
moo_popvolat (moo);
if (x <= -1)
{
MOO_LOG3 (moo, MOO_LOG_WARN, "Failed to delete an IO semaphored handle %zd at index %zd for %hs\n", io_handle, index, io_type_str[io_type]);
@ -1527,9 +1527,9 @@ static MOO_INLINE int activate_new_method (moo_t* moo, moo_oop_method_t mth, moo
}
else actual_ntmprs = ntmprs;
moo_pushtmp (moo, (moo_oop_t*)&mth);
moo_pushvolat (moo, (moo_oop_t*)&mth);
ctx = (moo_oop_context_t)moo_instantiate(moo, moo->_method_context, MOO_NULL, actual_ntmprs);
moo_poptmp (moo);
moo_popvolat (moo);
if (!ctx) return -1;
MOO_STORE_OOP (moo, (moo_oop_t*)&ctx->sender, (moo_oop_t)moo->active_context);
@ -1784,8 +1784,8 @@ TODO: overcome this problem - accept parameters....
return -1;
}
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
moo_pushtmp (moo, (moo_oop_t*)&ass); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&mth); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&ass); tmp_count++;
#else
startup.ptr = str_startup;
startup.len = 7;
@ -1804,22 +1804,22 @@ TODO: overcome this problem - accept parameters....
}
/* TODO: check if it's variadic.... it should be. and accept more than 2... */
moo_pushtmp (moo, (moo_oop_t*)&mth); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&mth); tmp_count++;
s1 = moo_makesymbol(moo, objname->ptr, objname->len);
if (!s1) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&s1); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&s1); tmp_count++;
s2 = moo_makesymbol(moo, mthname->ptr, mthname->len);
if (!s2) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&s2); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&s2); tmp_count++;
#endif
/* create a fake initial context. */
ctx = (moo_oop_context_t)moo_instantiate(moo, moo->_method_context, MOO_NULL, MOO_OOP_TO_SMOOI(mth->tmpr_nargs));
if (!ctx) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&ctx); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&ctx); tmp_count++;
/* TODO: handle preamble */
@ -1856,7 +1856,7 @@ TODO: overcome this problem - accept parameters....
moo->active_context = ctx;
proc = start_initial_process (moo, ctx);
moo_poptmps (moo, tmp_count); tmp_count = 0;
moo_popvolats (moo, tmp_count); tmp_count = 0;
if (!proc) goto oops;
#if defined(INVOKE_DIRECTLY)
@ -1881,7 +1881,7 @@ TODO: overcome this problem - accept parameters....
#endif
oops:
if (tmp_count > 0) moo_poptmps (moo, tmp_count);
if (tmp_count > 0) moo_popvolats (moo, tmp_count);
return -1;
}
@ -2151,9 +2151,9 @@ static moo_pfrc_t __block_value (moo_t* moo, moo_oop_context_t rcv_blkctx, moo_o
MOO_ASSERT (moo, local_ntmprs >= actual_arg_count);
/* create a new block context to clone rcv_blkctx */
moo_pushtmp (moo, (moo_oop_t*)&rcv_blkctx);
moo_pushvolat (moo, (moo_oop_t*)&rcv_blkctx);
blkctx = (moo_oop_context_t) moo_instantiate(moo, moo->_block_context, MOO_NULL, local_ntmprs);
moo_poptmp (moo);
moo_popvolat (moo);
if (!blkctx) return MOO_PF_FAILURE;
#if 0
@ -3841,9 +3841,9 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
goto activate_primitive_method_body;
}
moo_pushtmp (moo, (moo_oop_t*)&method);
moo_pushvolat (moo, (moo_oop_t*)&method);
n = pftab[pfnum].pfbase.handler(moo, MOO_NULL, nargs); /* builtin numbered primitive. the second parameter is MOO_NULL */
moo_poptmp (moo);
moo_popvolat (moo);
if (n <= MOO_PF_HARD_FAILURE)
{
MOO_LOG3 (moo, MOO_LOG_DEBUG,
@ -3925,7 +3925,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
goto activate_primitive_method_body;
}
moo_pushtmp (moo, (moo_oop_t*)&method);
moo_pushvolat (moo, (moo_oop_t*)&method);
/* the primitive handler is executed without activating the method itself.
* one major difference between the primitive function and the normal method
@ -3936,7 +3936,7 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
moo_seterrnum (moo, MOO_ENOERR);
n = pfbase->handler(moo, mod, nargs);
moo_poptmp (moo);
moo_popvolat (moo);
if (n <= MOO_PF_HARD_FAILURE)
{
MOO_LOG4 (moo, MOO_LOG_DEBUG,
@ -3977,9 +3977,9 @@ static int start_method (moo_t* moo, moo_oop_method_t method, moo_oow_t nargs)
* is it really a good idea to compose a string here which
* is not really failure safe without losing integrity???? */
moo_oop_t tmp;
moo_pushtmp (moo, (moo_oop_t*)&method);
moo_pushvolat (moo, (moo_oop_t*)&method);
tmp = moo_makestring(moo, moo->errmsg.buf, moo->errmsg.len);
moo_poptmp (moo);
moo_popvolat (moo);
/* [NOTE] carry on even if instantiation fails */
moo->processor->active->perrmsg = tmp? tmp: moo->_nil; /* TODO: set to nil or set to an empty string if instantiation fails? */
}
@ -4152,7 +4152,7 @@ static MOO_INLINE int switch_process_if_needed (moo_t* moo)
/* waited long enough. signal the semaphore */
proc = signal_semaphore (moo, moo->sem_heap[0]);
/* [NOTE] no moo_pushtmp() on proc. no GC must occur
/* [NOTE] no moo_pushvolat() on proc. no GC must occur
* in the following line until it's used for
* wake_process() below. */
delete_from_sem_heap (moo, 0); /* moo->sem_heap_count is decremented in delete_from_sem_heap() */

View File

@ -1023,7 +1023,7 @@ void moo_gc (moo_t* moo)
moo->heap->curspace.base, moo->heap->curspace.ptr, moo->heap->newspace.base, moo->heap->newspace.ptr);
}
void moo_pushtmp (moo_t* moo, moo_oop_t* oop_ptr)
void moo_pushvolat (moo_t* moo, moo_oop_t* oop_ptr)
{
/* if you have too many temporaries pushed, something must be wrong.
* change your code not to exceede the stack limit */
@ -1031,13 +1031,13 @@ void moo_pushtmp (moo_t* moo, moo_oop_t* oop_ptr)
moo->tmp_stack[moo->tmp_count++] = oop_ptr;
}
void moo_poptmp (moo_t* moo)
void moo_popvolat (moo_t* moo)
{
MOO_ASSERT (moo, moo->tmp_count > 0);
moo->tmp_count--;
}
void moo_poptmps (moo_t* moo, moo_oow_t count)
void moo_popvolats (moo_t* moo, moo_oow_t count)
{
MOO_ASSERT (moo, moo->tmp_count >= count);
moo->tmp_count -= count;
@ -1052,9 +1052,9 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop)
moo_oop_class_t c;
c = MOO_OBJ_GET_CLASS(oop);
moo_pushtmp (moo, &oop);
moo_pushvolat (moo, &oop);
z = moo_instantiate(moo, (moo_oop_t)c, MOO_NULL, MOO_OBJ_GET_SIZE(oop) - MOO_CLASS_SPEC_NAMED_INSTVARS(MOO_OOP_TO_SMOOI(c->spec)));
moo_poptmp(moo);
moo_popvolat(moo);
if (!z) return z;
@ -1068,9 +1068,9 @@ moo_oop_t moo_shallowcopy (moo_t* moo, moo_oop_t oop)
total_bytes = MOO_SIZEOF(moo_obj_t) + get_payload_bytes(moo, oop);
moo_pushtmp (moo, &oop);
moo_pushvolat (moo, &oop);
z = (moo_oop_t)moo_allocbytes(moo, total_bytes);
moo_poptmp(moo);
moo_popvolat(moo);
MOO_MEMCPY (z, oop, total_bytes);
return z;

View File

@ -1260,9 +1260,9 @@ static MOO_INLINE int print_formatted (moo_t* moo, moo_ooi_t nargs, moo_fmtout_t
/* the given number for integer output is a fixed-point decimal.
* i will drop all digits after the fixed point */
moo_pushtmp (moo, &arg);
moo_pushvolat (moo, &arg);
nv = moo_truncfpdecval(moo, fa->value, MOO_OOP_TO_SMOOI(fa->scale), 0);
moo_poptmp (moo);
moo_popvolat (moo);
if (!nv)
{
MOO_LOG1 (moo, MOO_LOG_WARN | MOO_LOG_UNTYPED, "unable to truncate a fixed-point number %O to an integer for output\n", arg);

View File

@ -685,7 +685,7 @@ int moo_importmod (moo_t* moo, moo_oop_class_t _class, const moo_ooch_t* name, m
* i need to protect _class in case the user-defined callback allocates
* a OOP memory chunk and GC occurs. */
moo_pushtmp (moo, (moo_oop_t*)&_class);
moo_pushvolat (moo, (moo_oop_t*)&_class);
pair = moo_rbt_search(&moo->modtab, name, len);
if (pair)
@ -724,7 +724,7 @@ done:
moo_closemod (moo, mdp);
done2:
moo_poptmp (moo);
moo_popvolat (moo);
return r;
}
@ -807,7 +807,7 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
if (!pfname) pfname = mthname;
moo_pushtmp (moo, (moo_oop_t*)&_class); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&_class); tmp_count++;
MOO_ASSERT (moo, MOO_CLASSOF(moo, (moo_oop_t)_class->mthdic[type]) == moo->_method_dictionary);
for (i = 0; mthname[i]; i++)
@ -840,7 +840,7 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
mnsym = (moo_oop_char_t)moo_makesymbol (moo, mthname, i);
if (!mnsym) goto oops;
moo_pushtmp (moo, (moo_oop_t*)&mnsym); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&mnsym); tmp_count++;
/* compose a full primitive function identifier to VM's string buffer.
* pfid => mod->name + '.' + pfname */
@ -858,7 +858,7 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
MOO_DEBUG2 (moo, "Cannot generate primitive function method [%js] in [%O] - symbol instantiation failure\n", mthname, _class->name);
goto oops;
}
moo_pushtmp (moo, (moo_oop_t*)&pfidsym); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&pfidsym); tmp_count++;
#if defined(MOO_USE_METHOD_TRAILER)
mth = (moo_oop_method_t)moo_instantiatewithtrailer (moo, moo->_method, 1, MOO_NULL, 0);
@ -894,11 +894,11 @@ int moo_genpfmethod (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, moo_met
MOO_DEBUG2 (moo, "Generated primitive function method [%js] in [%O]\n", mthname, _class->name);
moo_poptmps (moo, tmp_count); tmp_count = 0;
moo_popvolats (moo, tmp_count); tmp_count = 0;
return 0;
oops:
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return -1;
}
@ -907,7 +907,7 @@ int moo_genpfmethods (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, const
int ret = 0;
moo_oow_t i;
moo_pushtmp (moo, (moo_oop_t*)&_class);
moo_pushvolat (moo, (moo_oop_t*)&_class);
for (i = 0; i < pfcount; i++)
{
if (moo_genpfmethod (moo, mod, _class, pfinfo[i].type, pfinfo[i].mthname, pfinfo[i].variadic, MOO_NULL) <= -1)
@ -918,7 +918,7 @@ int moo_genpfmethods (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, const
}
}
moo_poptmp (moo);
moo_popvolat (moo);
return ret;
}
#endif

View File

@ -2195,18 +2195,18 @@ MOO_EXPORT void* moo_getobjtrailer (
);
/* =========================================================================
* TEMPORARY OOP MANAGEMENT FUNCTIONS
* VOLATILE OOP MANAGEMENT FUNCTIONS
* ========================================================================= */
MOO_EXPORT void moo_pushtmp (
MOO_EXPORT void moo_pushvolat (
moo_t* moo,
moo_oop_t* oop_ptr
);
MOO_EXPORT void moo_poptmp (
MOO_EXPORT void moo_popvolat (
moo_t* moo
);
MOO_EXPORT void moo_poptmps (
MOO_EXPORT void moo_popvolats (
moo_t* moo,
moo_oow_t count
);

View File

@ -41,9 +41,9 @@ moo_oop_t moo_makefpdec (moo_t* moo, moo_oop_t value, moo_ooi_t scale)
return MOO_NULL;
}
moo_pushtmp (moo, &value);
moo_pushvolat (moo, &value);
fpdec = (moo_oop_fpdec_t)moo_instantiate(moo, moo->_fixed_point_decimal, MOO_NULL, 0);
moo_poptmp (moo);
moo_popvolat (moo);
if (!fpdec) return MOO_NULL;
MOO_STORE_OOP (moo, &fpdec->value, value);
@ -153,17 +153,17 @@ moo_oop_t moo_addnums (moo_t* moo, moo_oop_t x, moo_oop_t y)
moo_oop_t v;
moo_ooi_t scale;
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
scale = equalize_scale(moo, &x, &y);
if (scale <= -1)
{
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
return MOO_NULL;
}
v = moo_addints(moo, ((moo_oop_fpdec_t)x)->value, ((moo_oop_fpdec_t)y)->value);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!v) return MOO_NULL;
return moo_makefpdec(moo, v, scale);
@ -182,17 +182,17 @@ moo_oop_t moo_subnums (moo_t* moo, moo_oop_t x, moo_oop_t y)
moo_oop_t v;
moo_ooi_t scale;
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
scale = equalize_scale(moo, &x, &y);
if (scale <= -1)
{
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
return MOO_NULL;
}
v = moo_subints(moo, ((moo_oop_fpdec_t)x)->value, ((moo_oop_fpdec_t)y)->value);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
if (!v) return MOO_NULL;
return moo_makefpdec(moo, v, scale);
@ -295,19 +295,19 @@ moo_oop_t moo_divnums (moo_t* moo, moo_oop_t x, moo_oop_t y)
nv = xv;
moo_pushtmp (moo, &yv);
moo_pushvolat (moo, &yv);
for (i = 0; i < ys; i++)
{
nv = moo_mulints(moo, nv, MOO_SMOOI_TO_OOP(10));
if (!nv)
{
moo_poptmp (moo);
moo_popvolat (moo);
return MOO_NULL;
}
}
nv = moo_divints(moo, nv, yv, 0, MOO_NULL);
moo_poptmp (moo);
moo_popvolat (moo);
if (!nv) return MOO_NULL;
return moo_makefpdec(moo, nv, xs);
@ -325,17 +325,17 @@ static moo_oop_t comp_nums (moo_t* moo, moo_oop_t x, moo_oop_t y, moo_oop_t (*co
moo_oop_t v;
moo_ooi_t scale;
moo_pushtmp (moo, &x);
moo_pushtmp (moo, &y);
moo_pushvolat (moo, &x);
moo_pushvolat (moo, &y);
scale = equalize_scale(moo, &x, &y);
if (scale <= -1)
{
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
return MOO_NULL;
}
v = comper(moo, ((moo_oop_fpdec_t)x)->value, ((moo_oop_fpdec_t)y)->value);
moo_poptmps (moo, 2);
moo_popvolats (moo, 2);
return v;
}
}
@ -388,7 +388,7 @@ moo_oop_t moo_sqrtnum (moo_t* moo, moo_oop_t x)
v = moo_mulints(moo, v, MOO_SMOOI_TO_OOP(10));
if (!v)
{
moo_poptmp (moo);
moo_popvolat (moo);
return MOO_NULL;
}
}

View File

@ -260,7 +260,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
if (decode_spec(moo, _class, vlen, &type, &alloclen) <= -1) return MOO_NULL;
moo_pushtmp (moo, (moo_oop_t*)&_class); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&_class); tmp_count++;
switch (type)
{
@ -300,7 +300,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
}
For the above code to work, it should protect the elements of
the vptr array with moo_pushtmp(). So it might be better
the vptr array with moo_pushvolat(). So it might be better
to disallow a non-NULL vptr when indexed_type is OOP. See
the assertion above this comment block.
*/
@ -333,7 +333,7 @@ moo_oop_t moo_instantiate (moo_t* moo, moo_oop_class_t _class, const void* vptr,
MOO_OBJ_SET_CLASS (oop, (moo_oop_t)_class);
if (MOO_CLASS_SPEC_IS_IMMUTABLE(MOO_OOP_TO_SMOOI(_class->spec))) MOO_OBJ_SET_FLAGS_RDONLY (oop, 1);
}
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return oop;
}
@ -348,7 +348,7 @@ moo_oop_t moo_instantiatewithtrailer (moo_t* moo, moo_oop_class_t _class, moo_oo
if (decode_spec(moo, _class, vlen, &type, &alloclen) <= -1) return MOO_NULL;
moo_pushtmp (moo, (moo_oop_t*)&_class); tmp_count++;
moo_pushvolat (moo, (moo_oop_t*)&_class); tmp_count++;
switch (type)
{
@ -392,6 +392,6 @@ moo_oop_t moo_instantiatewithtrailer (moo_t* moo, moo_oop_class_t _class, moo_oo
MOO_OBJ_SET_CLASS (oop, _class);
if (MOO_CLASS_SPEC_IS_IMMUTABLE(MOO_OOP_TO_SMOOI(_class->spec))) MOO_OBJ_SET_FLAGS_RDONLY (oop, 1);
}
moo_poptmps (moo, tmp_count);
moo_popvolats (moo, tmp_count);
return oop;
}

View File

@ -60,9 +60,9 @@ static moo_oop_oop_t expand_bucket (moo_t* moo, moo_oop_oop_t oldbuc)
newsz = oldsz + inc;
}
moo_pushtmp (moo, (moo_oop_t*)&oldbuc);
moo_pushvolat (moo, (moo_oop_t*)&oldbuc);
newbuc = (moo_oop_oop_t)moo_instantiate(moo, moo->_array, MOO_NULL, newsz);
moo_poptmp (moo);
moo_popvolat (moo);
if (!newbuc) return MOO_NULL;
while (oldsz > 0)