diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-11-28 18:13:13 -0200 |
| commit | 72659a06050632da1a9b4c492302be46ac283f6b (patch) | |
| tree | bac06b4ea523ba5443564d0869e392180d4b7b77 /ldebug.c | |
| parent | dfaf8c5291fa8aef5bedbfa375853475364ac76e (diff) | |
| download | lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.gz lua-72659a06050632da1a9b4c492302be46ac283f6b.tar.bz2 lua-72659a06050632da1a9b4c492302be46ac283f6b.zip | |
no more explicit support for wide-chars; too much troble...
Diffstat (limited to '')
| -rw-r--r-- | ldebug.c | 87 |
1 files changed, 43 insertions, 44 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 1.91 2001/10/25 19:14:14 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.92 2001/10/31 19:58:11 roberto Exp $ |
| 3 | ** Debug Interface | 3 | ** Debug Interface |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -7,7 +7,6 @@ | |||
| 7 | 7 | ||
| 8 | #include <stdlib.h> | 8 | #include <stdlib.h> |
| 9 | 9 | ||
| 10 | #define LUA_PRIVATE | ||
| 11 | #include "lua.h" | 10 | #include "lua.h" |
| 12 | 11 | ||
| 13 | #include "lapi.h" | 12 | #include "lapi.h" |
| @@ -26,8 +25,8 @@ | |||
| 26 | 25 | ||
| 27 | 26 | ||
| 28 | 27 | ||
| 29 | static const l_char *getfuncname (lua_State *L, CallInfo *ci, | 28 | static const char *getfuncname (lua_State *L, CallInfo *ci, |
| 30 | const l_char **name); | 29 | const char **name); |
| 31 | 30 | ||
| 32 | 31 | ||
| 33 | 32 | ||
| @@ -139,8 +138,8 @@ static Proto *getluaproto (CallInfo *ci) { | |||
| 139 | } | 138 | } |
| 140 | 139 | ||
| 141 | 140 | ||
| 142 | LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | 141 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
| 143 | const l_char *name; | 142 | const char *name; |
| 144 | CallInfo *ci; | 143 | CallInfo *ci; |
| 145 | Proto *fp; | 144 | Proto *fp; |
| 146 | lua_lock(L); | 145 | lua_lock(L); |
| @@ -157,8 +156,8 @@ LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 157 | } | 156 | } |
| 158 | 157 | ||
| 159 | 158 | ||
| 160 | LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | 159 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { |
| 161 | const l_char *name; | 160 | const char *name; |
| 162 | CallInfo *ci; | 161 | CallInfo *ci; |
| 163 | Proto *fp; | 162 | Proto *fp; |
| 164 | lua_lock(L); | 163 | lua_lock(L); |
| @@ -168,7 +167,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 168 | L->top--; /* pop new value */ | 167 | L->top--; /* pop new value */ |
| 169 | if (fp) { /* is a Lua function? */ | 168 | if (fp) { /* is a Lua function? */ |
| 170 | name = luaF_getlocalname(fp, n, currentpc(ci)); | 169 | name = luaF_getlocalname(fp, n, currentpc(ci)); |
| 171 | if (!name || name[0] == l_c('(')) /* `(' starts private locals */ | 170 | if (!name || name[0] == '(') /* `(' starts private locals */ |
| 172 | name = NULL; | 171 | name = NULL; |
| 173 | else | 172 | else |
| 174 | setobj(ci->base+(n-1), L->top); | 173 | setobj(ci->base+(n-1), L->top); |
| @@ -181,7 +180,7 @@ LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 181 | static void infoLproto (lua_Debug *ar, Proto *f) { | 180 | static void infoLproto (lua_Debug *ar, Proto *f) { |
| 182 | ar->source = getstr(f->source); | 181 | ar->source = getstr(f->source); |
| 183 | ar->linedefined = f->lineDefined; | 182 | ar->linedefined = f->lineDefined; |
| 184 | ar->what = l_s("Lua"); | 183 | ar->what = "Lua"; |
| 185 | } | 184 | } |
| 186 | 185 | ||
| 187 | 186 | ||
| @@ -190,23 +189,23 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { | |||
| 190 | if (ttype(func) == LUA_TFUNCTION) | 189 | if (ttype(func) == LUA_TFUNCTION) |
| 191 | cl = clvalue(func); | 190 | cl = clvalue(func); |
| 192 | else { | 191 | else { |
| 193 | luaD_error(L, l_s("value for `lua_getinfo' is not a function")); | 192 | luaD_error(L, "value for `lua_getinfo' is not a function"); |
| 194 | cl = NULL; /* to avoid warnings */ | 193 | cl = NULL; /* to avoid warnings */ |
| 195 | } | 194 | } |
| 196 | if (cl->c.isC) { | 195 | if (cl->c.isC) { |
| 197 | ar->source = l_s("=C"); | 196 | ar->source = "=C"; |
| 198 | ar->linedefined = -1; | 197 | ar->linedefined = -1; |
| 199 | ar->what = l_s("C"); | 198 | ar->what = "C"; |
| 200 | } | 199 | } |
| 201 | else | 200 | else |
| 202 | infoLproto(ar, cl->l.p); | 201 | infoLproto(ar, cl->l.p); |
| 203 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); | 202 | luaO_chunkid(ar->short_src, ar->source, LUA_IDSIZE); |
| 204 | if (ar->linedefined == 0) | 203 | if (ar->linedefined == 0) |
| 205 | ar->what = l_s("main"); | 204 | ar->what = "main"; |
| 206 | } | 205 | } |
| 207 | 206 | ||
| 208 | 207 | ||
| 209 | static const l_char *travtagmethods (global_State *G, const TObject *o) { | 208 | static const char *travtagmethods (global_State *G, const TObject *o) { |
| 210 | if (ttype(o) == LUA_TFUNCTION) { | 209 | if (ttype(o) == LUA_TFUNCTION) { |
| 211 | int e; | 210 | int e; |
| 212 | for (e=0; e<TM_N; e++) { | 211 | for (e=0; e<TM_N; e++) { |
| @@ -220,7 +219,7 @@ static const l_char *travtagmethods (global_State *G, const TObject *o) { | |||
| 220 | } | 219 | } |
| 221 | 220 | ||
| 222 | 221 | ||
| 223 | static const l_char *travglobals (lua_State *L, const TObject *o) { | 222 | static const char *travglobals (lua_State *L, const TObject *o) { |
| 224 | Table *g = hvalue(&L->gt); | 223 | Table *g = hvalue(&L->gt); |
| 225 | int i = sizenode(g); | 224 | int i = sizenode(g); |
| 226 | while (i--) { | 225 | while (i--) { |
| @@ -235,20 +234,20 @@ static const l_char *travglobals (lua_State *L, const TObject *o) { | |||
| 235 | static void getname (lua_State *L, const TObject *f, lua_Debug *ar) { | 234 | static void getname (lua_State *L, const TObject *f, lua_Debug *ar) { |
| 236 | /* try to find a name for given function */ | 235 | /* try to find a name for given function */ |
| 237 | if ((ar->name = travglobals(L, f)) != NULL) | 236 | if ((ar->name = travglobals(L, f)) != NULL) |
| 238 | ar->namewhat = l_s("global"); | 237 | ar->namewhat = "global"; |
| 239 | /* not found: try tag methods */ | 238 | /* not found: try tag methods */ |
| 240 | else if ((ar->name = travtagmethods(G(L), f)) != NULL) | 239 | else if ((ar->name = travtagmethods(G(L), f)) != NULL) |
| 241 | ar->namewhat = l_s("tag-method"); | 240 | ar->namewhat = "tag-method"; |
| 242 | else ar->namewhat = l_s(""); /* not found at all */ | 241 | else ar->namewhat = ""; /* not found at all */ |
| 243 | } | 242 | } |
| 244 | 243 | ||
| 245 | 244 | ||
| 246 | LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) { | 245 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { |
| 247 | StkId f; | 246 | StkId f; |
| 248 | CallInfo *ci; | 247 | CallInfo *ci; |
| 249 | int status = 1; | 248 | int status = 1; |
| 250 | lua_lock(L); | 249 | lua_lock(L); |
| 251 | if (*what != l_c('>')) { /* function is active? */ | 250 | if (*what != '>') { /* function is active? */ |
| 252 | ci = ar->_ci; | 251 | ci = ar->_ci; |
| 253 | f = ci->base - 1; | 252 | f = ci->base - 1; |
| 254 | } | 253 | } |
| @@ -259,25 +258,25 @@ LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) { | |||
| 259 | } | 258 | } |
| 260 | for (; *what; what++) { | 259 | for (; *what; what++) { |
| 261 | switch (*what) { | 260 | switch (*what) { |
| 262 | case l_c('S'): { | 261 | case 'S': { |
| 263 | funcinfo(L, ar, f); | 262 | funcinfo(L, ar, f); |
| 264 | break; | 263 | break; |
| 265 | } | 264 | } |
| 266 | case l_c('l'): { | 265 | case 'l': { |
| 267 | ar->currentline = currentline(ci); | 266 | ar->currentline = currentline(ci); |
| 268 | break; | 267 | break; |
| 269 | } | 268 | } |
| 270 | case l_c('u'): { | 269 | case 'u': { |
| 271 | ar->nups = (ttype(f) == LUA_TFUNCTION) ? clvalue(f)->c.nupvalues : 0; | 270 | ar->nups = (ttype(f) == LUA_TFUNCTION) ? clvalue(f)->c.nupvalues : 0; |
| 272 | break; | 271 | break; |
| 273 | } | 272 | } |
| 274 | case l_c('n'): { | 273 | case 'n': { |
| 275 | ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; | 274 | ar->namewhat = (ci) ? getfuncname(L, ci, &ar->name) : NULL; |
| 276 | if (ar->namewhat == NULL) | 275 | if (ar->namewhat == NULL) |
| 277 | getname(L, f, ar); | 276 | getname(L, f, ar); |
| 278 | break; | 277 | break; |
| 279 | } | 278 | } |
| 280 | case l_c('f'): { | 279 | case 'f': { |
| 281 | setobj(L->top, f); | 280 | setobj(L->top, f); |
| 282 | incr_top; /* push function */ | 281 | incr_top; /* push function */ |
| 283 | break; | 282 | break; |
| @@ -470,7 +469,7 @@ int luaG_checkcode (const Proto *pt) { | |||
| 470 | } | 469 | } |
| 471 | 470 | ||
| 472 | 471 | ||
| 473 | static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { | 472 | static const char *getobjname (lua_State *L, StkId obj, const char **name) { |
| 474 | CallInfo *ci = ci_stack(L, obj); | 473 | CallInfo *ci = ci_stack(L, obj); |
| 475 | if (isLmark(ci)) { /* an active Lua function? */ | 474 | if (isLmark(ci)) { /* an active Lua function? */ |
| 476 | Proto *p = ci_func(ci)->l.p; | 475 | Proto *p = ci_func(ci)->l.p; |
| @@ -479,14 +478,14 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { | |||
| 479 | Instruction i; | 478 | Instruction i; |
| 480 | *name = luaF_getlocalname(p, stackpos+1, pc); | 479 | *name = luaF_getlocalname(p, stackpos+1, pc); |
| 481 | if (*name) /* is a local? */ | 480 | if (*name) /* is a local? */ |
| 482 | return l_s("local"); | 481 | return "local"; |
| 483 | i = luaG_symbexec(p, pc, stackpos); /* try symbolic execution */ | 482 | i = luaG_symbexec(p, pc, stackpos); /* try symbolic execution */ |
| 484 | lua_assert(pc != -1); | 483 | lua_assert(pc != -1); |
| 485 | switch (GET_OPCODE(i)) { | 484 | switch (GET_OPCODE(i)) { |
| 486 | case OP_GETGLOBAL: { | 485 | case OP_GETGLOBAL: { |
| 487 | lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING); | 486 | lua_assert(ttype(&p->k[GETARG_Bc(i)]) == LUA_TSTRING); |
| 488 | *name = svalue(&p->k[GETARG_Bc(i)]); | 487 | *name = svalue(&p->k[GETARG_Bc(i)]); |
| 489 | return l_s("global"); | 488 | return "global"; |
| 490 | } | 489 | } |
| 491 | case OP_MOVE: { | 490 | case OP_MOVE: { |
| 492 | int a = GETARG_A(i); | 491 | int a = GETARG_A(i); |
| @@ -500,7 +499,7 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { | |||
| 500 | int c = GETARG_C(i) - MAXSTACK; | 499 | int c = GETARG_C(i) - MAXSTACK; |
| 501 | if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) { | 500 | if (c >= 0 && ttype(&p->k[c]) == LUA_TSTRING) { |
| 502 | *name = svalue(&p->k[c]); | 501 | *name = svalue(&p->k[c]); |
| 503 | return l_s("field"); | 502 | return "field"; |
| 504 | } | 503 | } |
| 505 | break; | 504 | break; |
| 506 | } | 505 | } |
| @@ -511,8 +510,8 @@ static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { | |||
| 511 | } | 510 | } |
| 512 | 511 | ||
| 513 | 512 | ||
| 514 | static const l_char *getfuncname (lua_State *L, CallInfo *ci, | 513 | static const char *getfuncname (lua_State *L, CallInfo *ci, |
| 515 | const l_char **name) { | 514 | const char **name) { |
| 516 | ci = ci->prev; /* calling function */ | 515 | ci = ci->prev; /* calling function */ |
| 517 | if (ci == &L->basefunc || !isLmark(ci)) | 516 | if (ci == &L->basefunc || !isLmark(ci)) |
| 518 | return NULL; /* not an active Lua function */ | 517 | return NULL; /* not an active Lua function */ |
| @@ -529,22 +528,22 @@ static const l_char *getfuncname (lua_State *L, CallInfo *ci, | |||
| 529 | } | 528 | } |
| 530 | 529 | ||
| 531 | 530 | ||
| 532 | void luaG_typeerror (lua_State *L, StkId o, const l_char *op) { | 531 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { |
| 533 | const l_char *name; | 532 | const char *name; |
| 534 | const l_char *kind = getobjname(L, o, &name); | 533 | const char *kind = getobjname(L, o, &name); |
| 535 | const l_char *t = luaT_typename(G(L), o); | 534 | const char *t = luaT_typename(G(L), o); |
| 536 | if (kind) | 535 | if (kind) |
| 537 | luaO_verror(L, l_s("attempt to %.30s %.20s `%.40s' (a %.10s value)"), | 536 | luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", |
| 538 | op, kind, name, t); | 537 | op, kind, name, t); |
| 539 | else | 538 | else |
| 540 | luaO_verror(L, l_s("attempt to %.30s a %.10s value"), op, t); | 539 | luaO_verror(L, "attempt to %.30s a %.10s value", op, t); |
| 541 | } | 540 | } |
| 542 | 541 | ||
| 543 | 542 | ||
| 544 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { | 543 | void luaG_concaterror (lua_State *L, StkId p1, StkId p2) { |
| 545 | if (ttype(p1) == LUA_TSTRING) p1 = p2; | 544 | if (ttype(p1) == LUA_TSTRING) p1 = p2; |
| 546 | lua_assert(ttype(p1) != LUA_TSTRING); | 545 | lua_assert(ttype(p1) != LUA_TSTRING); |
| 547 | luaG_typeerror(L, p1, l_s("concat")); | 546 | luaG_typeerror(L, p1, "concat"); |
| 548 | } | 547 | } |
| 549 | 548 | ||
| 550 | 549 | ||
| @@ -552,16 +551,16 @@ void luaG_aritherror (lua_State *L, StkId p1, TObject *p2) { | |||
| 552 | TObject temp; | 551 | TObject temp; |
| 553 | if (luaV_tonumber(p1, &temp) != NULL) | 552 | if (luaV_tonumber(p1, &temp) != NULL) |
| 554 | p1 = p2; /* first operand is OK; error is in the second */ | 553 | p1 = p2; /* first operand is OK; error is in the second */ |
| 555 | luaG_typeerror(L, p1, l_s("perform arithmetic on")); | 554 | luaG_typeerror(L, p1, "perform arithmetic on"); |
| 556 | } | 555 | } |
| 557 | 556 | ||
| 558 | 557 | ||
| 559 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { | 558 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { |
| 560 | const l_char *t1 = luaT_typename(G(L), p1); | 559 | const char *t1 = luaT_typename(G(L), p1); |
| 561 | const l_char *t2 = luaT_typename(G(L), p2); | 560 | const char *t2 = luaT_typename(G(L), p2); |
| 562 | if (t1[2] == t2[2]) | 561 | if (t1[2] == t2[2]) |
| 563 | luaO_verror(L, l_s("attempt to compare two %.10s values"), t1); | 562 | luaO_verror(L, "attempt to compare two %.10s values", t1); |
| 564 | else | 563 | else |
| 565 | luaO_verror(L, l_s("attempt to compare %.10s with %.10s"), t1, t2); | 564 | luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2); |
| 566 | } | 565 | } |
| 567 | 566 | ||
