Browse Source

added 'const' to 'Proto*' when possible

pull/19/head
Roberto Ierusalimschy 7 years ago
parent
commit
6f2b8e21c4
  1. 35
      ldebug.c
  2. 4
      ldebug.h
  3. 4
      ltm.c
  4. 4
      ltm.h

35
ldebug.c

@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.156 2018/03/16 15:33:34 roberto Exp roberto $
** $Id: ldebug.c,v 2.157 2018/05/02 18:17:59 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@ -55,7 +55,7 @@ static int currentpc (CallInfo *ci) {
** case is when there is no absolute info or the instruction is before
** the first absolute one.
*/
static int getbaseline (Proto *f, int pc, int *basepc) {
static int getbaseline (const Proto *f, int pc, int *basepc) {
if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) {
*basepc = -1; /* start from the beginning */
return f->linedefined;
@ -86,7 +86,7 @@ static int getbaseline (Proto *f, int pc, int *basepc) {
** first gets a base line and from there does the increments until
** the desired instruction.
*/
int luaG_getfuncline (Proto *f, int pc) {
int luaG_getfuncline (const Proto *f, int pc) {
if (f->lineinfo == NULL) /* no debug information? */
return -1;
else {
@ -180,7 +180,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) {
}
static const char *upvalname (Proto *p, int uv) {
static const char *upvalname (const Proto *p, int uv) {
TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name);
if (s == NULL) return "?";
else return getstr(s);
@ -265,7 +265,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) {
ar->what = "C";
}
else {
Proto *p = cl->l.p;
const Proto *p = cl->l.p;
ar->source = p->source ? getstr(p->source) : "=?";
ar->linedefined = p->linedefined;
ar->lastlinedefined = p->lastlinedefined;
@ -275,7 +275,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) {
}
static int nextline (Proto *p, int currentline, int pc) {
static int nextline (const Proto *p, int currentline, int pc) {
if (p->lineinfo[pc] != ABSLINEINFO)
return currentline + p->lineinfo[pc];
else
@ -291,7 +291,7 @@ static void collectvalidlines (lua_State *L, Closure *f) {
else {
int i;
TValue v;
Proto *p = f->l.p;
const Proto *p = f->l.p;
int currentline = p->linedefined;
Table *t = luaH_new(L); /* new table to store active lines */
sethvalue2s(L, L->top, t); /* push it on stack */
@ -411,14 +411,14 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
** =======================================================
*/
static const char *getobjname (Proto *p, int lastpc, int reg,
static const char *getobjname (const Proto *p, int lastpc, int reg,
const char **name);
/*
** Find a "name" for the constant 'c'.
*/
static void kname (Proto *p, int c, const char **name) {
static void kname (const Proto *p, int c, const char **name) {
TValue *kvalue = &p->k[c];
*name = (ttisstring(kvalue)) ? svalue(kvalue) : "?";
}
@ -427,7 +427,7 @@ static void kname (Proto *p, int c, const char **name) {
/*
** Find a "name" for the register 'c'.
*/
static void rname (Proto *p, int pc, int c, const char **name) {
static void rname (const Proto *p, int pc, int c, const char **name) {
const char *what = getobjname(p, pc, c, name); /* search for 'c' */
if (!(what && *what == 'c')) /* did not find a constant name? */
*name = "?";
@ -437,7 +437,7 @@ static void rname (Proto *p, int pc, int c, const char **name) {
/*
** Find a "name" for a 'C' value in an RK instruction.
*/
static void rkname (Proto *p, int pc, Instruction i, const char **name) {
static void rkname (const Proto *p, int pc, Instruction i, const char **name) {
int c = GETARG_C(i); /* key index */
if (GETARG_k(i)) /* is 'c' a constant? */
kname(p, c, name);
@ -456,7 +456,7 @@ static int filterpc (int pc, int jmptarget) {
/*
** try to find last instruction before 'lastpc' that modified register 'reg'
*/
static int findsetreg (Proto *p, int lastpc, int reg) {
static int findsetreg (const Proto *p, int lastpc, int reg) {
int pc;
int setreg = -1; /* keep last instruction that changed 'reg' */
int jmptarget = 0; /* any code before this address is conditional */
@ -504,7 +504,7 @@ static int findsetreg (Proto *p, int lastpc, int reg) {
** Check whether table being indexed by instruction 'i' is the
** environment '_ENV'
*/
static const char *gxf (Proto *p, int pc, Instruction i, int isup) {
static const char *gxf (const Proto *p, int pc, Instruction i, int isup) {
int t = GETARG_B(i); /* table index */
const char *name; /* name of indexed variable */
if (isup) /* is an upvalue? */
@ -515,7 +515,8 @@ static const char *gxf (Proto *p, int pc, Instruction i, int isup) {
}
const char *getobjname (Proto *p, int lastpc, int reg, const char **name) {
const char *getobjname (const Proto *p, int lastpc, int reg,
const char **name) {
int pc;
*name = luaF_getlocalname(p, reg + 1, lastpc);
if (*name) /* is a local? */
@ -585,7 +586,7 @@ static const char *gxf (Proto *p, int pc, Instruction i, int isup) {
static const char *funcnamefromcode (lua_State *L, CallInfo *ci,
const char **name) {
TMS tm = (TMS)0; /* (initial value avoids warnings) */
Proto *p = ci_func(ci)->p; /* calling function */
const Proto *p = ci_func(ci)->p; /* calling function */
int pc = currentpc(ci); /* calling instruction index */
Instruction i = p->code[pc]; /* calling instruction */
if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */
@ -774,7 +775,7 @@ l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
** Check whether new instruction 'newpc' is in a different line from
** previous instruction 'oldpc'.
*/
static int changedline (Proto *p, int oldpc, int newpc) {
static int changedline (const Proto *p, int oldpc, int newpc) {
while (oldpc++ < newpc) {
if (p->lineinfo[oldpc] != 0)
return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc));
@ -807,7 +808,7 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) {
if (counthook)
luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */
if (mask & LUA_MASKLINE) {
Proto *p = ci_func(ci)->p;
const Proto *p = ci_func(ci)->p;
int npci = pcRel(pc, p);
if (npci == 0 || /* call linehook when enter a new function, */
pc <= L->oldpc || /* when jump back (loop), or when */

4
ldebug.h

@ -1,5 +1,5 @@
/*
** $Id: ldebug.h,v 2.16 2018/01/28 15:13:26 roberto Exp roberto $
** $Id: ldebug.h,v 2.17 2018/05/02 18:17:59 roberto Exp roberto $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
@ -21,7 +21,7 @@
*/
#define ABSLINEINFO (-0x80)
LUAI_FUNC int luaG_getfuncline (Proto *f, int pc);
LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc);
LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1,

4
ltm.c

@ -1,5 +1,5 @@
/*
** $Id: ltm.c,v 2.67 2018/04/04 14:23:41 roberto Exp roberto $
** $Id: ltm.c,v 2.68 2018/06/01 17:40:38 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@ -217,7 +217,7 @@ int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci,
Proto *p) {
const Proto *p) {
int i;
int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */
int nextra = actual - nfixparams; /* number of extra arguments */

4
ltm.h

@ -1,5 +1,5 @@
/*
** $Id: ltm.h,v 2.36 2018/05/23 14:41:20 roberto Exp roberto $
** $Id: ltm.h,v 2.37 2018/06/01 16:51:34 roberto Exp roberto $
** Tag methods
** See Copyright Notice in lua.h
*/
@ -84,7 +84,7 @@ LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2,
int inv, TMS event);
LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams,
struct CallInfo *ci, Proto *p);
struct CallInfo *ci, const Proto *p);
LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci,
StkId where, int wanted);

Loading…
Cancel
Save