Fix newSVrv so sv_setref_foo work better:
[p5sagit/p5-mst-13.2.git] / run.c
CommitLineData
a0d0e21e 1/* run.c
2 *
9607fc9c 3 * Copyright (c) 1991-1997, Larry Wall
a0d0e21e 4 *
5 * You may distribute under the terms of either the GNU General Public
6 * License or the Artistic License, as specified in the README file.
7 *
8 */
9
79072805 10#include "EXTERN.h"
11#include "perl.h"
12
a0d0e21e 13/*
14 * "Away now, Shadowfax! Run, greatheart, run as you have never run before!
15 * Now we are come to the lands where you were foaled, and every stone you
16 * know. Run now! Hope is in speed!" --Gandalf
17 */
18
4633a7c4 19dEXT char **watchaddr = 0;
20dEXT char *watchok;
79072805 21
a0d0e21e 22int
8ac85365 23runops_standard(void) {
11343788 24 dTHR;
a0d0e21e 25
11343788 26 while ( op = (*op->op_ppaddr)(ARGS) ) ;
fd18d308 27
28 TAINT_NOT;
a0d0e21e 29 return 0;
79072805 30}
31
2ddcc7aa 32#ifdef DEBUGGING
11343788 33static void debprof _((OP*o));
a0d0e21e 34
35int
8ac85365 36runops_debug(void) {
11343788 37 dTHR;
79072805 38 if (!op) {
39 warn("NULL OP IN RUN");
a0d0e21e 40 return 0;
79072805 41 }
a0d0e21e 42
79072805 43 do {
44 if (debug) {
45 if (watchaddr != 0 && *watchaddr != watchok)
760ac839 46 PerlIO_printf(Perl_debug_log, "WARNING: %lx changed from %lx to %lx\n",
a0d0e21e 47 (long)watchaddr, (long)watchok, (long)*watchaddr);
79072805 48 DEBUG_s(debstack());
49 DEBUG_t(debop(op));
a0d0e21e 50 DEBUG_P(debprof(op));
79072805 51 }
11343788 52 } while ( op = (*op->op_ppaddr)(ARGS) );
fd18d308 53
54 TAINT_NOT;
a0d0e21e 55 return 0;
79072805 56}
57
79072805 58I32
8ac85365 59debop(OP *o)
79072805 60{
61 SV *sv;
11343788 62 deb("%s", op_name[o->op_type]);
63 switch (o->op_type) {
79072805 64 case OP_CONST:
5dc0d613 65 PerlIO_printf(Perl_debug_log, "(%s)", SvPEEK(cSVOPo->op_sv));
79072805 66 break;
67 case OP_GVSV:
68 case OP_GV:
11343788 69 if (cGVOPo->op_gv) {
79072805 70 sv = NEWSV(0,0);
5dc0d613 71 gv_fullname3(sv, cGVOPo->op_gv, Nullch);
760ac839 72 PerlIO_printf(Perl_debug_log, "(%s)", SvPV(sv, na));
8990e307 73 SvREFCNT_dec(sv);
79072805 74 }
75 else
760ac839 76 PerlIO_printf(Perl_debug_log, "(NULL)");
79072805 77 break;
a0d0e21e 78 default:
79 break;
79072805 80 }
760ac839 81 PerlIO_printf(Perl_debug_log, "\n");
79072805 82 return 0;
83}
84
85void
8ac85365 86watch(char **addr)
79072805 87{
88 watchaddr = addr;
89 watchok = *addr;
760ac839 90 PerlIO_printf(Perl_debug_log, "WATCHING, %lx is currently %lx\n",
a0d0e21e 91 (long)watchaddr, (long)watchok);
79072805 92}
a0d0e21e 93
94static void
8ac85365 95debprof(OP *o)
a0d0e21e 96{
97 if (!profiledata)
98 New(000, profiledata, MAXO, U32);
11343788 99 ++profiledata[o->op_type];
a0d0e21e 100}
101
102void
8ac85365 103debprofdump(void)
a0d0e21e 104{
9607fc9c 105 unsigned i;
a0d0e21e 106 if (!profiledata)
107 return;
108 for (i = 0; i < MAXO; i++) {
109 if (profiledata[i])
9607fc9c 110 PerlIO_printf(Perl_debug_log,
111 "%u\t%lu\n", i, (unsigned long)profiledata[i]);
a0d0e21e 112 }
113}
114
115#endif
116