Prev Code Coverage - Tales From the Trenches Next

Devel::Cover's runops

     static int runops_cover(pTHX)
     {
         SV   **count;
         IV     c;
         char  *ch;
         HV    *Files;
         int    collecting_here = 1;
         char  *lastfile        = 0;
         for (;;)
         {
             if (!(PL_op = CALL_FPTR(PL_op->op_ppaddr)(aTHX)))
             {
                 break;
             }
             if (Got_condition)
             {
                 Got_condition = 0;
                 continue;
             }
             PERL_ASYNC_CHECK();
             if (!Covering)
                 continue;
             /* Check to see whether we are interested in this file */
             if (PL_op->op_type == OP_NEXTSTATE)
             {
                 char *file = CopFILE(cCOP);
                 if (file && (!lastfile || lastfile && strNE(lastfile, file)))
                 {
                     Files = get_hv("Devel::Cover::Files", FALSE);
                     if (Files)
                     {
                         SV **f = hv_fetch(Files, file, strlen(file), 0);
                         collecting_here = f ? SvIV(*f) : 1;
                      }
                     lastfile = file;
                 }
             }
             if (!collecting_here)
                 continue;
             /*
              * We are about the run the op PL_op, so we'll collect
              * information for it now.
              */
             switch (PL_op->op_type)
             {
                 case OP_SETSTATE:
                 case OP_NEXTSTATE:
                 case OP_DBSTATE:
                 {
                     if (collecting(Statement))
                     {
                         ch    = get_key(PL_op);
                         count = hv_fetch(Statements, ch, ch_sz, 1);
                         c     = SvTRUE(*count) ? SvIV(*count) + 1 : 1;
                         sv_setiv(*count, c);
                     }
                     break;
                 }
                 case OP_COND_EXPR:
                 {
                     cover_cond();
                     break;
                 }
                 case OP_AND:
                 case OP_OR:
                 case OP_ANDASSIGN:
                 case OP_ORASSIGN:
                 case OP_XOR:
                 {
                     cover_logop();
                     break;
                 }
                 default:
                     ;  /* IBM's xlC compiler on AIX is very picky */
             }
         }
         TAINT_NOT;
         return 0;
     }


Slide 63 YAPC::Europe::2003 Copyright © 2003 Paul Johnson