From: Steve Peters Date: Sat, 5 Nov 2005 01:36:17 +0000 (+0000) Subject: Merge pp_andassign, pp_orassign, and pp_dorassign into pp_and, X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=c960fc3b3086016b5cf3008030dd5aa01b2db20d;p=p5sagit%2Fp5-mst-13.2.git Merge pp_andassign, pp_orassign, and pp_dorassign into pp_and, pp_or, and pp_defined, respectively. p4raw-id: //depot/perl@26007 --- diff --git a/mathoms.c b/mathoms.c index 48b9a54..943220d 100644 --- a/mathoms.c +++ b/mathoms.c @@ -1000,6 +1000,21 @@ PP(pp_dor) return pp_defined(); } +PP(pp_andassign) +{ + return pp_and(); +} + +PP(pp_orassign) +{ + return pp_or(); +} + +PP(pp_dorassign) +{ + return pp_defined(); +} + U8 * Perl_uvuni_to_utf8(pTHX_ U8 *d, UV uv) { diff --git a/opcode.h b/opcode.h index 3cec861..3b33935 100644 --- a/opcode.h +++ b/opcode.h @@ -925,8 +925,8 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ MEMBER_TO_FPTR(Perl_pp_range), MEMBER_TO_FPTR(Perl_pp_flip), MEMBER_TO_FPTR(Perl_pp_flop), - MEMBER_TO_FPTR(Perl_pp_and), - MEMBER_TO_FPTR(Perl_pp_or), + MEMBER_TO_FPTR(Perl_pp_and), /* Perl_pp_and */ + MEMBER_TO_FPTR(Perl_pp_or), /* Perl_pp_or */ MEMBER_TO_FPTR(Perl_pp_xor), MEMBER_TO_FPTR(Perl_pp_cond_expr), MEMBER_TO_FPTR(Perl_pp_andassign), @@ -1118,7 +1118,7 @@ EXT Perl_ppaddr_t PL_ppaddr[] /* or perlvars.h */ MEMBER_TO_FPTR(Perl_pp_setstate), MEMBER_TO_FPTR(Perl_pp_method_named), MEMBER_TO_FPTR(Perl_pp_defined), /* Perl_pp_dor */ - MEMBER_TO_FPTR(Perl_pp_dorassign), + MEMBER_TO_FPTR(Perl_pp_defined), /* Perl_pp_dorassign */ } #endif ; diff --git a/opcode.pl b/opcode.pl index 4a099ec..9f12344 100755 --- a/opcode.pl +++ b/opcode.pl @@ -73,7 +73,9 @@ my @raw_alias = ( fteexec)], Perl_pp_shmwrite => [qw(shmread msgsnd msgrcv semop)], Perl_pp_send => ['syswrite'], - Perl_pp_defined => ['dor'], + Perl_pp_defined => [qw(dor dorassign)], + Perl_pp_and => ['and'], + Perl_pp_or => ['or'], ); while (my ($func, $names) = splice @raw_alias, 0, 2) { diff --git a/pp_ctl.c b/pp_ctl.c index cfefefd..4587219 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -1490,56 +1490,6 @@ PP(pp_xor) RETSETNO; } -PP(pp_andassign) -{ - dSP; - if (!SvTRUE(TOPs)) - RETURN; - else - RETURNOP(cLOGOP->op_other); -} - -PP(pp_orassign) -{ - dSP; - if (SvTRUE(TOPs)) - RETURN; - else - RETURNOP(cLOGOP->op_other); -} - -PP(pp_dorassign) -{ - dSP; - register SV* sv; - - sv = TOPs; - if (!sv || !SvANY(sv)) { - RETURNOP(cLOGOP->op_other); - } - - switch (SvTYPE(sv)) { - case SVt_PVAV: - if (AvMAX(sv) >= 0 || SvGMAGICAL(sv) || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied))) - RETURN; - break; - case SVt_PVHV: - if (HvARRAY(sv) || SvGMAGICAL(sv) || (SvRMAGICAL(sv) && mg_find(sv, PERL_MAGIC_tied))) - RETURN; - break; - case SVt_PVCV: - if (CvROOT(sv) || CvXSUB(sv)) - RETURN; - break; - default: - SvGETMAGIC(sv); - if (SvOK(sv)) - RETURN; - } - - RETURNOP(cLOGOP->op_other); -} - PP(pp_caller) { dSP; diff --git a/pp_hot.c b/pp_hot.c index ef20f9e..967f2d5 100644 --- a/pp_hot.c +++ b/pp_hot.c @@ -100,7 +100,8 @@ PP(pp_and) if (!SvTRUE(TOPs)) RETURN; else { - --SP; + if (PL_op->op_type == OP_AND) + --SP; RETURNOP(cLOGOP->op_other); } } @@ -319,7 +320,8 @@ PP(pp_or) if (SvTRUE(TOPs)) RETURN; else { - --SP; + if (PL_op->op_type == OP_OR) + --SP; RETURNOP(cLOGOP->op_other); } } @@ -331,7 +333,7 @@ PP(pp_defined) bool defined = FALSE; const int op_type = PL_op->op_type; - if(op_type == OP_DOR) { + if(op_type == OP_DOR || op_type == OP_DORASSIGN) { sv = TOPs; if (!sv || !SvANY(sv)) { --SP; @@ -362,17 +364,15 @@ PP(pp_defined) defined = TRUE; } - if(defined) { - if(op_type == OP_DOR) - RETURN; - else if (op_type == OP_DEFINED) - RETPUSHYES; - } - - if(op_type == OP_DOR) { - --SP; + if(op_type == OP_DOR || op_type == OP_DORASSIGN) { + if(defined) + RETURN; + if(op_type == OP_DOR) + --SP; RETURNOP(cLOGOP->op_other); } else if (op_type == OP_DEFINED) { + if(defined) + RETPUSHYES; RETPUSHNO; } }