diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-08 16:06:59 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-06-08 16:06:59 -0300 |
| commit | 6f2b8e21c4ea9d730ccfe7e41bfc178704d1fc75 (patch) | |
| tree | 8c95c0decfca59a1ad9b82f925ae8d3045f40220 | |
| parent | c5dc521d654cbe9b04310a633e94dbcf1927e0f6 (diff) | |
| download | lua-6f2b8e21c4ea9d730ccfe7e41bfc178704d1fc75.tar.gz lua-6f2b8e21c4ea9d730ccfe7e41bfc178704d1fc75.tar.bz2 lua-6f2b8e21c4ea9d730ccfe7e41bfc178704d1fc75.zip | |
added 'const' to 'Proto*' when possible
| -rw-r--r-- | ldebug.c | 35 | ||||
| -rw-r--r-- | ldebug.h | 4 | ||||
| -rw-r--r-- | ltm.c | 4 | ||||
| -rw-r--r-- | ltm.h | 4 |
4 files changed, 24 insertions, 23 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.156 2018/03/16 15:33:34 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.157 2018/05/02 18:17:59 roberto Exp roberto $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -55,7 +55,7 @@ static int currentpc (CallInfo *ci) { | |||
| 55 | ** case is when there is no absolute info or the instruction is before | 55 | ** case is when there is no absolute info or the instruction is before |
| 56 | ** the first absolute one. | 56 | ** the first absolute one. |
| 57 | */ | 57 | */ |
| 58 | static int getbaseline (Proto *f, int pc, int *basepc) { | 58 | static int getbaseline (const Proto *f, int pc, int *basepc) { |
| 59 | if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) { | 59 | if (f->sizeabslineinfo == 0 || pc < f->abslineinfo[0].pc) { |
| 60 | *basepc = -1; /* start from the beginning */ | 60 | *basepc = -1; /* start from the beginning */ |
| 61 | return f->linedefined; | 61 | return f->linedefined; |
| @@ -86,7 +86,7 @@ static int getbaseline (Proto *f, int pc, int *basepc) { | |||
| 86 | ** first gets a base line and from there does the increments until | 86 | ** first gets a base line and from there does the increments until |
| 87 | ** the desired instruction. | 87 | ** the desired instruction. |
| 88 | */ | 88 | */ |
| 89 | int luaG_getfuncline (Proto *f, int pc) { | 89 | int luaG_getfuncline (const Proto *f, int pc) { |
| 90 | if (f->lineinfo == NULL) /* no debug information? */ | 90 | if (f->lineinfo == NULL) /* no debug information? */ |
| 91 | return -1; | 91 | return -1; |
| 92 | else { | 92 | else { |
| @@ -180,7 +180,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | 182 | ||
| 183 | static const char *upvalname (Proto *p, int uv) { | 183 | static const char *upvalname (const Proto *p, int uv) { |
| 184 | TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); | 184 | TString *s = check_exp(uv < p->sizeupvalues, p->upvalues[uv].name); |
| 185 | if (s == NULL) return "?"; | 185 | if (s == NULL) return "?"; |
| 186 | else return getstr(s); | 186 | else return getstr(s); |
| @@ -265,7 +265,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) { | |||
| 265 | ar->what = "C"; | 265 | ar->what = "C"; |
| 266 | } | 266 | } |
| 267 | else { | 267 | else { |
| 268 | Proto *p = cl->l.p; | 268 | const Proto *p = cl->l.p; |
| 269 | ar->source = p->source ? getstr(p->source) : "=?"; | 269 | ar->source = p->source ? getstr(p->source) : "=?"; |
| 270 | ar->linedefined = p->linedefined; | 270 | ar->linedefined = p->linedefined; |
| 271 | ar->lastlinedefined = p->lastlinedefined; | 271 | ar->lastlinedefined = p->lastlinedefined; |
| @@ -275,7 +275,7 @@ static void funcinfo (lua_Debug *ar, Closure *cl) { | |||
| 275 | } | 275 | } |
| 276 | 276 | ||
| 277 | 277 | ||
| 278 | static int nextline (Proto *p, int currentline, int pc) { | 278 | static int nextline (const Proto *p, int currentline, int pc) { |
| 279 | if (p->lineinfo[pc] != ABSLINEINFO) | 279 | if (p->lineinfo[pc] != ABSLINEINFO) |
| 280 | return currentline + p->lineinfo[pc]; | 280 | return currentline + p->lineinfo[pc]; |
| 281 | else | 281 | else |
| @@ -291,7 +291,7 @@ static void collectvalidlines (lua_State *L, Closure *f) { | |||
| 291 | else { | 291 | else { |
| 292 | int i; | 292 | int i; |
| 293 | TValue v; | 293 | TValue v; |
| 294 | Proto *p = f->l.p; | 294 | const Proto *p = f->l.p; |
| 295 | int currentline = p->linedefined; | 295 | int currentline = p->linedefined; |
| 296 | Table *t = luaH_new(L); /* new table to store active lines */ | 296 | Table *t = luaH_new(L); /* new table to store active lines */ |
| 297 | sethvalue2s(L, L->top, t); /* push it on stack */ | 297 | 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) { | |||
| 411 | ** ======================================================= | 411 | ** ======================================================= |
| 412 | */ | 412 | */ |
| 413 | 413 | ||
| 414 | static const char *getobjname (Proto *p, int lastpc, int reg, | 414 | static const char *getobjname (const Proto *p, int lastpc, int reg, |
| 415 | const char **name); | 415 | const char **name); |
| 416 | 416 | ||
| 417 | 417 | ||
| 418 | /* | 418 | /* |
| 419 | ** Find a "name" for the constant 'c'. | 419 | ** Find a "name" for the constant 'c'. |
| 420 | */ | 420 | */ |
| 421 | static void kname (Proto *p, int c, const char **name) { | 421 | static void kname (const Proto *p, int c, const char **name) { |
| 422 | TValue *kvalue = &p->k[c]; | 422 | TValue *kvalue = &p->k[c]; |
| 423 | *name = (ttisstring(kvalue)) ? svalue(kvalue) : "?"; | 423 | *name = (ttisstring(kvalue)) ? svalue(kvalue) : "?"; |
| 424 | } | 424 | } |
| @@ -427,7 +427,7 @@ static void kname (Proto *p, int c, const char **name) { | |||
| 427 | /* | 427 | /* |
| 428 | ** Find a "name" for the register 'c'. | 428 | ** Find a "name" for the register 'c'. |
| 429 | */ | 429 | */ |
| 430 | static void rname (Proto *p, int pc, int c, const char **name) { | 430 | static void rname (const Proto *p, int pc, int c, const char **name) { |
| 431 | const char *what = getobjname(p, pc, c, name); /* search for 'c' */ | 431 | const char *what = getobjname(p, pc, c, name); /* search for 'c' */ |
| 432 | if (!(what && *what == 'c')) /* did not find a constant name? */ | 432 | if (!(what && *what == 'c')) /* did not find a constant name? */ |
| 433 | *name = "?"; | 433 | *name = "?"; |
| @@ -437,7 +437,7 @@ static void rname (Proto *p, int pc, int c, const char **name) { | |||
| 437 | /* | 437 | /* |
| 438 | ** Find a "name" for a 'C' value in an RK instruction. | 438 | ** Find a "name" for a 'C' value in an RK instruction. |
| 439 | */ | 439 | */ |
| 440 | static void rkname (Proto *p, int pc, Instruction i, const char **name) { | 440 | static void rkname (const Proto *p, int pc, Instruction i, const char **name) { |
| 441 | int c = GETARG_C(i); /* key index */ | 441 | int c = GETARG_C(i); /* key index */ |
| 442 | if (GETARG_k(i)) /* is 'c' a constant? */ | 442 | if (GETARG_k(i)) /* is 'c' a constant? */ |
| 443 | kname(p, c, name); | 443 | kname(p, c, name); |
| @@ -456,7 +456,7 @@ static int filterpc (int pc, int jmptarget) { | |||
| 456 | /* | 456 | /* |
| 457 | ** try to find last instruction before 'lastpc' that modified register 'reg' | 457 | ** try to find last instruction before 'lastpc' that modified register 'reg' |
| 458 | */ | 458 | */ |
| 459 | static int findsetreg (Proto *p, int lastpc, int reg) { | 459 | static int findsetreg (const Proto *p, int lastpc, int reg) { |
| 460 | int pc; | 460 | int pc; |
| 461 | int setreg = -1; /* keep last instruction that changed 'reg' */ | 461 | int setreg = -1; /* keep last instruction that changed 'reg' */ |
| 462 | int jmptarget = 0; /* any code before this address is conditional */ | 462 | int jmptarget = 0; /* any code before this address is conditional */ |
| @@ -504,7 +504,7 @@ static int findsetreg (Proto *p, int lastpc, int reg) { | |||
| 504 | ** Check whether table being indexed by instruction 'i' is the | 504 | ** Check whether table being indexed by instruction 'i' is the |
| 505 | ** environment '_ENV' | 505 | ** environment '_ENV' |
| 506 | */ | 506 | */ |
| 507 | static const char *gxf (Proto *p, int pc, Instruction i, int isup) { | 507 | static const char *gxf (const Proto *p, int pc, Instruction i, int isup) { |
| 508 | int t = GETARG_B(i); /* table index */ | 508 | int t = GETARG_B(i); /* table index */ |
| 509 | const char *name; /* name of indexed variable */ | 509 | const char *name; /* name of indexed variable */ |
| 510 | if (isup) /* is an upvalue? */ | 510 | if (isup) /* is an upvalue? */ |
| @@ -515,7 +515,8 @@ static const char *gxf (Proto *p, int pc, Instruction i, int isup) { | |||
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | 517 | ||
| 518 | const char *getobjname (Proto *p, int lastpc, int reg, const char **name) { | 518 | const char *getobjname (const Proto *p, int lastpc, int reg, |
| 519 | const char **name) { | ||
| 519 | int pc; | 520 | int pc; |
| 520 | *name = luaF_getlocalname(p, reg + 1, lastpc); | 521 | *name = luaF_getlocalname(p, reg + 1, lastpc); |
| 521 | if (*name) /* is a local? */ | 522 | if (*name) /* is a local? */ |
| @@ -585,7 +586,7 @@ static const char *gxf (Proto *p, int pc, Instruction i, int isup) { | |||
| 585 | static const char *funcnamefromcode (lua_State *L, CallInfo *ci, | 586 | static const char *funcnamefromcode (lua_State *L, CallInfo *ci, |
| 586 | const char **name) { | 587 | const char **name) { |
| 587 | TMS tm = (TMS)0; /* (initial value avoids warnings) */ | 588 | TMS tm = (TMS)0; /* (initial value avoids warnings) */ |
| 588 | Proto *p = ci_func(ci)->p; /* calling function */ | 589 | const Proto *p = ci_func(ci)->p; /* calling function */ |
| 589 | int pc = currentpc(ci); /* calling instruction index */ | 590 | int pc = currentpc(ci); /* calling instruction index */ |
| 590 | Instruction i = p->code[pc]; /* calling instruction */ | 591 | Instruction i = p->code[pc]; /* calling instruction */ |
| 591 | if (ci->callstatus & CIST_HOOKED) { /* was it called inside a hook? */ | 592 | 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, ...) { | |||
| 774 | ** Check whether new instruction 'newpc' is in a different line from | 775 | ** Check whether new instruction 'newpc' is in a different line from |
| 775 | ** previous instruction 'oldpc'. | 776 | ** previous instruction 'oldpc'. |
| 776 | */ | 777 | */ |
| 777 | static int changedline (Proto *p, int oldpc, int newpc) { | 778 | static int changedline (const Proto *p, int oldpc, int newpc) { |
| 778 | while (oldpc++ < newpc) { | 779 | while (oldpc++ < newpc) { |
| 779 | if (p->lineinfo[oldpc] != 0) | 780 | if (p->lineinfo[oldpc] != 0) |
| 780 | return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc)); | 781 | return (luaG_getfuncline(p, oldpc - 1) != luaG_getfuncline(p, newpc)); |
| @@ -807,7 +808,7 @@ int luaG_traceexec (lua_State *L, const Instruction *pc) { | |||
| 807 | if (counthook) | 808 | if (counthook) |
| 808 | luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ | 809 | luaD_hook(L, LUA_HOOKCOUNT, -1, 0, 0); /* call count hook */ |
| 809 | if (mask & LUA_MASKLINE) { | 810 | if (mask & LUA_MASKLINE) { |
| 810 | Proto *p = ci_func(ci)->p; | 811 | const Proto *p = ci_func(ci)->p; |
| 811 | int npci = pcRel(pc, p); | 812 | int npci = pcRel(pc, p); |
| 812 | if (npci == 0 || /* call linehook when enter a new function, */ | 813 | if (npci == 0 || /* call linehook when enter a new function, */ |
| 813 | pc <= L->oldpc || /* when jump back (loop), or when */ | 814 | pc <= L->oldpc || /* when jump back (loop), or when */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.h,v 2.16 2018/01/28 15:13:26 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 2.17 2018/05/02 18:17:59 roberto Exp roberto $ |
| 3 | ** Auxiliary functions from Debug Interface module | 3 | ** Auxiliary functions from Debug Interface module |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -21,7 +21,7 @@ | |||
| 21 | */ | 21 | */ |
| 22 | #define ABSLINEINFO (-0x80) | 22 | #define ABSLINEINFO (-0x80) |
| 23 | 23 | ||
| 24 | LUAI_FUNC int luaG_getfuncline (Proto *f, int pc); | 24 | LUAI_FUNC int luaG_getfuncline (const Proto *f, int pc); |
| 25 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, | 25 | LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o, |
| 26 | const char *opname); | 26 | const char *opname); |
| 27 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, | 27 | LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.67 2018/04/04 14:23:41 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.68 2018/06/01 17:40:38 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -217,7 +217,7 @@ int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, | |||
| 217 | 217 | ||
| 218 | 218 | ||
| 219 | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, | 219 | void luaT_adjustvarargs (lua_State *L, int nfixparams, CallInfo *ci, |
| 220 | Proto *p) { | 220 | const Proto *p) { |
| 221 | int i; | 221 | int i; |
| 222 | int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */ | 222 | int actual = cast_int(L->top - ci->func) - 1; /* number of arguments */ |
| 223 | int nextra = actual - nfixparams; /* number of extra arguments */ | 223 | int nextra = actual - nfixparams; /* number of extra arguments */ |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.h,v 2.36 2018/05/23 14:41:20 roberto Exp roberto $ | 2 | ** $Id: ltm.h,v 2.37 2018/06/01 16:51:34 roberto Exp roberto $ |
| 3 | ** Tag methods | 3 | ** Tag methods |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -84,7 +84,7 @@ LUAI_FUNC int luaT_callorderiTM (lua_State *L, const TValue *p1, int v2, | |||
| 84 | int inv, TMS event); | 84 | int inv, TMS event); |
| 85 | 85 | ||
| 86 | LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, | 86 | LUAI_FUNC void luaT_adjustvarargs (lua_State *L, int nfixparams, |
| 87 | struct CallInfo *ci, Proto *p); | 87 | struct CallInfo *ci, const Proto *p); |
| 88 | LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, | 88 | LUAI_FUNC void luaT_getvarargs (lua_State *L, struct CallInfo *ci, |
| 89 | StkId where, int wanted); | 89 | StkId where, int wanted); |
| 90 | 90 | ||
