RETURN;
}
-PP(pp_scalar)
-{
- return NORMAL;
-}
-
/* Pushy stuff. */
PP(pp_padav)
RETURN;
}
-PP(pp_padany)
-{
- DIE(aTHX_ "NOT IMPL LINE %d",__LINE__);
-}
-
/* Translations. */
PP(pp_rv2gv)
const char *pv;
SV * const sv = POPs;
- if (sv && SvGMAGICAL(sv))
- mg_get(sv);
+ if (sv)
+ SvGETMAGIC(sv);
if (!sv || !SvROK(sv))
RETPUSHNO;
if (ssv && !SvGMAGICAL(ssv) && !SvAMAGIC(ssv) && SvROK(ssv))
Perl_croak(aTHX_ "Attempt to bless into a reference");
ptr = SvPV_const(ssv,len);
- if (ckWARN(WARN_MISC) && len == 0)
+ if (len == 0 && ckWARN(WARN_MISC))
Perl_warner(aTHX_ packWARN(WARN_MISC),
"Explicit blessing to '' (assuming package main)");
stash = gv_stashpvn(ptr, len, TRUE);
RETPUSHYES;
break;
default:
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvOK(sv))
RETPUSHYES;
}
hv_undef((HV*)sv);
break;
case SVt_PVCV:
- if (ckWARN(WARN_MISC) && cv_const_sv((CV*)sv))
+ if (cv_const_sv((CV*)sv) && ckWARN(WARN_MISC))
Perl_warner(aTHX_ packWARN(WARN_MISC), "Constant subroutine %s undefined",
CvANON((CV*)sv) ? "(anonymous)" : GvENAME(CvGV((CV*)sv)));
/* FALL THROUGH */
we're sure it is safe; otherwise we call pow() and try to convert to
integer afterwards. */
{
- SvIV_please(TOPm1s);
- if (SvIOK(TOPm1s)) {
- bool baseuok = SvUOK(TOPm1s);
- UV baseuv;
+ SvIV_please(TOPs);
+ if (SvIOK(TOPs)) {
+ SvIV_please(TOPm1s);
+ if (SvIOK(TOPm1s)) {
+ UV power;
+ bool baseuok;
+ UV baseuv;
- if (baseuok) {
- baseuv = SvUVX(TOPm1s);
- } else {
- const IV iv = SvIVX(TOPm1s);
- if (iv >= 0) {
- baseuv = iv;
- baseuok = TRUE; /* effectively it's a UV now */
- } else {
- baseuv = -iv; /* abs, baseuok == false records sign */
- }
- }
- SvIV_please(TOPs);
- if (SvIOK(TOPs)) {
- UV power;
+ if (SvUOK(TOPs)) {
+ power = SvUVX(TOPs);
+ } else {
+ const IV iv = SvIVX(TOPs);
+ if (iv >= 0) {
+ power = iv;
+ } else {
+ goto float_it; /* Can't do negative powers this way. */
+ }
+ }
- if (SvUOK(TOPs)) {
- power = SvUVX(TOPs);
- } else {
- IV iv = SvIVX(TOPs);
- if (iv >= 0) {
- power = iv;
- } else {
- goto float_it; /* Can't do negative powers this way. */
- }
- }
+ baseuok = SvUOK(TOPm1s);
+ if (baseuok) {
+ baseuv = SvUVX(TOPm1s);
+ } else {
+ const IV iv = SvIVX(TOPm1s);
+ if (iv >= 0) {
+ baseuv = iv;
+ baseuok = TRUE; /* effectively it's a UV now */
+ } else {
+ baseuv = -iv; /* abs, baseuok == false records sign */
+ }
+ }
/* now we have integer ** positive integer. */
is_int = 1;
programmers to notice ** not doing what they mean. */
NV result = 1.0;
NV base = baseuok ? baseuv : -(NV)baseuv;
- int n = 0;
-
- for (; power; base *= base, n++) {
- /* Do I look like I trust gcc with long longs here?
- Do I hell. */
- const UV bit = (UV)1 << (UV)n;
- if (power & bit) {
- result *= base;
- /* Only bother to clear the bit if it is set. */
- power -= bit;
- /* Avoid squaring base again if we're done. */
- if (power == 0) break;
- }
- }
+
+ if (power & 1) {
+ result *= base;
+ }
+ while (power >>= 1) {
+ base *= base;
+ if (power & 1) {
+ result *= base;
+ }
+ }
SP--;
SETn( result );
SvIV_please(TOPs);
RETURN;
} else {
register unsigned int highbit = 8 * sizeof(UV);
- register unsigned int lowbit = 0;
- register unsigned int diff;
- bool odd_power = (bool)(power & 1);
- while ((diff = (highbit - lowbit) >> 1)) {
- if (baseuv & ~((1 << (lowbit + diff)) - 1))
- lowbit += diff;
- else
- highbit -= diff;
+ register unsigned int diff = 8 * sizeof(UV);
+ while (diff >>= 1) {
+ highbit -= diff;
+ if (baseuv >> highbit) {
+ highbit += diff;
+ }
}
/* we now have baseuv < 2 ** highbit */
if (power * highbit <= 8 * sizeof(UV)) {
on same algorithm as above */
register UV result = 1;
register UV base = baseuv;
- register int n = 0;
- for (; power; base *= base, n++) {
- register const UV bit = (UV)1 << (UV)n;
- if (power & bit) {
+ const bool odd_power = (bool)(power & 1);
+ if (odd_power) {
+ result *= base;
+ }
+ while (power >>= 1) {
+ base *= base;
+ if (power & 1) {
result *= base;
- power -= bit;
- if (power == 0) break;
}
}
SP--;
{
register IV count;
dPOPss;
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvIOKp(sv)) {
if (SvUOK(sv)) {
const UV uv = SvUV(sv);
dSP; dATARGET; tryAMAGICbin(band,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = SvIV_nomg(left) & SvIV_nomg(right);
dSP; dATARGET; tryAMAGICbin(bxor,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) ^ SvIV_nomg(right);
dSP; dATARGET; tryAMAGICbin(bor,opASSIGN);
{
dPOPTOPssrl;
- if (SvGMAGICAL(left)) mg_get(left);
- if (SvGMAGICAL(right)) mg_get(right);
+ SvGETMAGIC(left);
+ SvGETMAGIC(right);
if (SvNIOKp(left) || SvNIOKp(right)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = (USE_LEFT(left) ? SvIV_nomg(left) : 0) | SvIV_nomg(right);
{
dTOPss;
const int flags = SvFLAGS(sv);
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if ((flags & SVf_IOK) || ((flags & (SVp_IOK | SVp_NOK)) == SVp_IOK)) {
/* It's publicly an integer, or privately an integer-not-float */
oops_its_an_int:
dSP; dTARGET; tryAMAGICun(compl);
{
dTOPss;
- if (SvGMAGICAL(sv))
- mg_get(sv);
+ SvGETMAGIC(sv);
if (SvNIOKp(sv)) {
if (PL_op->op_private & HINT_INTEGER) {
const IV i = ~SvIV_nomg(sv);
} else{
const NV value = TOPn;
if (value < 0.0)
- SETn(value);
- else
SETn(-value);
+ else
+ SETn(value);
}
}
RETURN;
}
s = (U8*)SvPV_force_nomg(sv, len);
if (len) {
- const register U8 *send = s + len;
+ register const U8 *send = s + len;
if (IN_LOCALE_RUNTIME) {
TAINT;
dSP; dTARGET;
SV * const sv = TOPs;
STRLEN len;
- const register char *s = SvPV_const(sv,len);
+ register const char *s = SvPV_const(sv,len);
SvUTF8_off(TARG); /* decontaminate */
if (len) {
RETURN;
}
-PP(pp_values)
-{
- return do_kv();
-}
-
-PP(pp_keys)
-{
- return do_kv();
-}
-
PP(pp_delete)
{
dSP;
call_method("PUSH",G_SCALAR|G_DISCARD);
LEAVE;
SPAGAIN;
+ SP = ORIGMARK;
+ PUSHi( AvFILL(ary) + 1 );
}
else {
- /* Why no pre-extend of ary here ? */
for (++MARK; MARK <= SP; MARK++) {
SV * const sv = NEWSV(51, 0);
if (*MARK)
sv_setsv(sv, *MARK);
- av_push(ary, sv);
+ av_store(ary, AvFILLp(ary)+1, sv);
}
+ SP = ORIGMARK;
+ PUSHi( AvFILLp(ary) + 1 );
}
- SP = ORIGMARK;
- PUSHi( AvFILL(ary) + 1 );
RETURN;
}
RETURN;
}
-PP(pp_threadsv)
+
+PP(unimplemented_op)
{
- DIE(aTHX_ "tried to access per-thread data in non-threaded perl");
+ DIE(aTHX_ "panic: unimplemented op %s (#%d) called", OP_NAME(PL_op),
+ PL_op->op_type);
}
/*