lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]



After more carefully studying the 5.4 base, I believe the code should be as follows. Can anyone verify this?

static void
printLines(lua_State* L, Proto* p)
{
   int i;
   int absLineIx = 0;
   int line = p->linedefined;
   for (i = 0; i < p->sizelineinfo; i++)
   {
      int lineDiff=p->lineinfo[i];
      if(ABSLINEINFO == lineDiff )
      {
         if(absLineIx < p->sizeabslineinfo)
         {
            line = p->abslineinfo[absLineIx++].line;
         }
         else
         {
            assert(0); /* should not be possible ?? */
            return;
         }
      }
      else
      {
         line += lineDiff;
      }
      printf("\t%4d : %4d\n", line, lineDiff);
   }
   for (i = 0; i < p->sizep; i++)
   {
      printf("Func %d", i);
      printLines(L, p->p[i]);
   }
}


Hello,

I have some code coverage code I used with Lua 5.3 that no longer works with 5.4. I am trying to wrap my head around the new Proto structure.

The original 5.3 compatible recursive code used lineinfo as follows:

addActiveLines(lua_State* L, Proto *p)
{
   int i;
   for (i = 0; i < p->sizelineinfo; i++)
   {
      >>>>> SAVE the line p->lineinfo[i]
   }
   for (i = 0; i < p->sizep; i++)
   {
      addActiveLines(L, p->p[i]);
   }
}

How do I make the above compatible with 5.4?

Thanks,
Wilfred