diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-02-23 14:17:25 -0300 |
| commit | 39b79783297bee79db9853b63d199e120a009a8f (patch) | |
| tree | c738c621c4c28d8822c2f785400786301985273b /ldebug.c | |
| parent | d164e2294f73d8e69f00d95a66014514b2dd0ec0 (diff) | |
| download | lua-39b79783297bee79db9853b63d199e120a009a8f.tar.gz lua-39b79783297bee79db9853b63d199e120a009a8f.tar.bz2 lua-39b79783297bee79db9853b63d199e120a009a8f.zip | |
first (big) step to support wide chars
Diffstat (limited to 'ldebug.c')
| -rw-r--r-- | ldebug.c | 80 |
1 files changed, 40 insertions, 40 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 1.67 2001/02/21 16:52:09 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 1.68 2001/02/22 18:59: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 | */ |
| @@ -24,7 +24,7 @@ | |||
| 24 | 24 | ||
| 25 | 25 | ||
| 26 | 26 | ||
| 27 | static const char *getfuncname (lua_State *L, StkId f, const char **name); | 27 | static const l_char *getfuncname (lua_State *L, StkId f, const l_char **name); |
| 28 | 28 | ||
| 29 | 29 | ||
| 30 | static void setnormalized (TObject *d, const TObject *s) { | 30 | static void setnormalized (TObject *d, const TObject *s) { |
| @@ -158,8 +158,8 @@ static Proto *getluaproto (StkId f) { | |||
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | 160 | ||
| 161 | LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | 161 | LUA_API const l_char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { |
| 162 | const char *name; | 162 | const l_char *name; |
| 163 | StkId f; | 163 | StkId f; |
| 164 | Proto *fp; | 164 | Proto *fp; |
| 165 | LUA_LOCK(L); | 165 | LUA_LOCK(L); |
| @@ -176,8 +176,8 @@ LUA_API const char *lua_getlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 176 | } | 176 | } |
| 177 | 177 | ||
| 178 | 178 | ||
| 179 | LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | 179 | LUA_API const l_char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { |
| 180 | const char *name; | 180 | const l_char *name; |
| 181 | StkId f; | 181 | StkId f; |
| 182 | Proto *fp; | 182 | Proto *fp; |
| 183 | LUA_LOCK(L); | 183 | LUA_LOCK(L); |
| @@ -187,7 +187,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 187 | L->top--; /* pop new value */ | 187 | L->top--; /* pop new value */ |
| 188 | if (fp) { /* `f' is a Lua function? */ | 188 | if (fp) { /* `f' is a Lua function? */ |
| 189 | name = luaF_getlocalname(fp, n, currentpc(f)); | 189 | name = luaF_getlocalname(fp, n, currentpc(f)); |
| 190 | if (!name || name[0] == '(') /* `(' starts private locals */ | 190 | if (!name || name[0] == l_c('(')) /* `(' starts private locals */ |
| 191 | name = NULL; | 191 | name = NULL; |
| 192 | else | 192 | else |
| 193 | setobj((f+1)+(n-1), L->top); | 193 | setobj((f+1)+(n-1), L->top); |
| @@ -200,7 +200,7 @@ LUA_API const char *lua_setlocal (lua_State *L, const lua_Debug *ar, int n) { | |||
| 200 | static void infoLproto (lua_Debug *ar, Proto *f) { | 200 | static void infoLproto (lua_Debug *ar, Proto *f) { |
| 201 | ar->source = getstr(f->source); | 201 | ar->source = getstr(f->source); |
| 202 | ar->linedefined = f->lineDefined; | 202 | ar->linedefined = f->lineDefined; |
| 203 | ar->what = "Lua"; | 203 | ar->what = l_s("Lua"); |
| 204 | } | 204 | } |
| 205 | 205 | ||
| 206 | 206 | ||
| @@ -214,22 +214,22 @@ static void funcinfo (lua_State *L, lua_Debug *ar, StkId func) { | |||
| 214 | cl = infovalue(func)->func; | 214 | cl = infovalue(func)->func; |
| 215 | break; | 215 | break; |
| 216 | default: | 216 | default: |
| 217 | luaD_error(L, "value for `lua_getinfo' is not a function"); | 217 | luaD_error(L, l_s("value for `lua_getinfo' is not a function")); |
| 218 | } | 218 | } |
| 219 | if (cl->isC) { | 219 | if (cl->isC) { |
| 220 | ar->source = "=C"; | 220 | ar->source = l_s("=C"); |
| 221 | ar->linedefined = -1; | 221 | ar->linedefined = -1; |
| 222 | ar->what = "C"; | 222 | ar->what = l_s("C"); |
| 223 | } | 223 | } |
| 224 | else | 224 | else |
| 225 | infoLproto(ar, cl->f.l); | 225 | infoLproto(ar, cl->f.l); |
| 226 | luaO_chunkid(ar->short_src, ar->source, sizeof(ar->short_src)); | 226 | luaO_chunkid(ar->short_src, ar->source, sizeof(ar->short_src)); |
| 227 | if (ar->linedefined == 0) | 227 | if (ar->linedefined == 0) |
| 228 | ar->what = "main"; | 228 | ar->what = l_s("main"); |
| 229 | } | 229 | } |
| 230 | 230 | ||
| 231 | 231 | ||
| 232 | static const char *travtagmethods (global_State *G, const TObject *o) { | 232 | static const l_char *travtagmethods (global_State *G, const TObject *o) { |
| 233 | if (ttype(o) == LUA_TFUNCTION) { | 233 | if (ttype(o) == LUA_TFUNCTION) { |
| 234 | int e; | 234 | int e; |
| 235 | for (e=0; e<TM_N; e++) { | 235 | for (e=0; e<TM_N; e++) { |
| @@ -243,7 +243,7 @@ static const char *travtagmethods (global_State *G, const TObject *o) { | |||
| 243 | } | 243 | } |
| 244 | 244 | ||
| 245 | 245 | ||
| 246 | static const char *travglobals (lua_State *L, const TObject *o) { | 246 | static const l_char *travglobals (lua_State *L, const TObject *o) { |
| 247 | Hash *g = L->gt; | 247 | Hash *g = L->gt; |
| 248 | int i; | 248 | int i; |
| 249 | for (i=0; i<g->size; i++) { | 249 | for (i=0; i<g->size; i++) { |
| @@ -260,20 +260,20 @@ static void getname (lua_State *L, StkId f, lua_Debug *ar) { | |||
| 260 | setnormalized(&o, f); | 260 | setnormalized(&o, f); |
| 261 | /* try to find a name for given function */ | 261 | /* try to find a name for given function */ |
| 262 | if ((ar->name = travglobals(L, &o)) != NULL) | 262 | if ((ar->name = travglobals(L, &o)) != NULL) |
| 263 | ar->namewhat = "global"; | 263 | ar->namewhat = l_s("global"); |
| 264 | /* not found: try tag methods */ | 264 | /* not found: try tag methods */ |
| 265 | else if ((ar->name = travtagmethods(G(L), &o)) != NULL) | 265 | else if ((ar->name = travtagmethods(G(L), &o)) != NULL) |
| 266 | ar->namewhat = "tag-method"; | 266 | ar->namewhat = l_s("tag-method"); |
| 267 | else ar->namewhat = ""; /* not found at all */ | 267 | else ar->namewhat = l_s(""); /* not found at all */ |
| 268 | } | 268 | } |
| 269 | 269 | ||
| 270 | 270 | ||
| 271 | LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | 271 | LUA_API int lua_getinfo (lua_State *L, const l_char *what, lua_Debug *ar) { |
| 272 | StkId func; | 272 | StkId func; |
| 273 | int isactive; | 273 | int isactive; |
| 274 | int status = 1; | 274 | int status = 1; |
| 275 | LUA_LOCK(L); | 275 | LUA_LOCK(L); |
| 276 | isactive = (*what != '>'); | 276 | isactive = (*what != l_c('>')); |
| 277 | if (isactive) | 277 | if (isactive) |
| 278 | func = ar->_func; | 278 | func = ar->_func; |
| 279 | else { | 279 | else { |
| @@ -282,25 +282,25 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) { | |||
| 282 | } | 282 | } |
| 283 | for (; *what; what++) { | 283 | for (; *what; what++) { |
| 284 | switch (*what) { | 284 | switch (*what) { |
| 285 | case 'S': { | 285 | case l_c('S'): { |
| 286 | funcinfo(L, ar, func); | 286 | funcinfo(L, ar, func); |
| 287 | break; | 287 | break; |
| 288 | } | 288 | } |
| 289 | case 'l': { | 289 | case l_c('l'): { |
| 290 | ar->currentline = currentline(func); | 290 | ar->currentline = currentline(func); |
| 291 | break; | 291 | break; |
| 292 | } | 292 | } |
| 293 | case 'u': { | 293 | case l_c('u'): { |
| 294 | ar->nups = nups(func); | 294 | ar->nups = nups(func); |
| 295 | break; | 295 | break; |
| 296 | } | 296 | } |
| 297 | case 'n': { | 297 | case l_c('n'): { |
| 298 | ar->namewhat = (isactive) ? getfuncname(L, func, &ar->name) : NULL; | 298 | ar->namewhat = (isactive) ? getfuncname(L, func, &ar->name) : NULL; |
| 299 | if (ar->namewhat == NULL) | 299 | if (ar->namewhat == NULL) |
| 300 | getname(L, func, ar); | 300 | getname(L, func, ar); |
| 301 | break; | 301 | break; |
| 302 | } | 302 | } |
| 303 | case 'f': { | 303 | case l_c('f'): { |
| 304 | setnormalized(L->top, func); | 304 | setnormalized(L->top, func); |
| 305 | incr_top; /* push function */ | 305 | incr_top; /* push function */ |
| 306 | break; | 306 | break; |
| @@ -543,7 +543,7 @@ int luaG_checkcode (lua_State *L, const Proto *pt) { | |||
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | 545 | ||
| 546 | static const char *getobjname (lua_State *L, StkId obj, const char **name) { | 546 | static const l_char *getobjname (lua_State *L, StkId obj, const l_char **name) { |
| 547 | StkId func = aux_stackedfunction(L, 0, obj); | 547 | StkId func = aux_stackedfunction(L, 0, obj); |
| 548 | if (!isLmark(func)) | 548 | if (!isLmark(func)) |
| 549 | return NULL; /* not an active Lua function */ | 549 | return NULL; /* not an active Lua function */ |
| @@ -556,17 +556,17 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) { | |||
| 556 | switch (GET_OPCODE(i)) { | 556 | switch (GET_OPCODE(i)) { |
| 557 | case OP_GETGLOBAL: { | 557 | case OP_GETGLOBAL: { |
| 558 | *name = getstr(p->kstr[GETARG_U(i)]); | 558 | *name = getstr(p->kstr[GETARG_U(i)]); |
| 559 | return "global"; | 559 | return l_s("global"); |
| 560 | } | 560 | } |
| 561 | case OP_GETLOCAL: { | 561 | case OP_GETLOCAL: { |
| 562 | *name = luaF_getlocalname(p, GETARG_U(i)+1, pc); | 562 | *name = luaF_getlocalname(p, GETARG_U(i)+1, pc); |
| 563 | lua_assert(*name); | 563 | lua_assert(*name); |
| 564 | return "local"; | 564 | return l_s("local"); |
| 565 | } | 565 | } |
| 566 | case OP_PUSHSELF: | 566 | case OP_PUSHSELF: |
| 567 | case OP_GETDOTTED: { | 567 | case OP_GETDOTTED: { |
| 568 | *name = getstr(p->kstr[GETARG_U(i)]); | 568 | *name = getstr(p->kstr[GETARG_U(i)]); |
| 569 | return "field"; | 569 | return l_s("field"); |
| 570 | } | 570 | } |
| 571 | default: | 571 | default: |
| 572 | return NULL; /* no useful name found */ | 572 | return NULL; /* no useful name found */ |
| @@ -575,7 +575,7 @@ static const char *getobjname (lua_State *L, StkId obj, const char **name) { | |||
| 575 | } | 575 | } |
| 576 | 576 | ||
| 577 | 577 | ||
| 578 | static const char *getfuncname (lua_State *L, StkId f, const char **name) { | 578 | static const l_char *getfuncname (lua_State *L, StkId f, const l_char **name) { |
| 579 | StkId func = aux_stackedfunction(L, 0, f); /* calling function */ | 579 | StkId func = aux_stackedfunction(L, 0, f); /* calling function */ |
| 580 | if (!isLmark(func)) | 580 | if (!isLmark(func)) |
| 581 | return NULL; /* not an active Lua function */ | 581 | return NULL; /* not an active Lua function */ |
| @@ -595,19 +595,19 @@ static const char *getfuncname (lua_State *L, StkId f, const char **name) { | |||
| 595 | } | 595 | } |
| 596 | 596 | ||
| 597 | 597 | ||
| 598 | void luaG_typeerror (lua_State *L, StkId o, const char *op) { | 598 | void luaG_typeerror (lua_State *L, StkId o, const l_char *op) { |
| 599 | const char *name; | 599 | const l_char *name; |
| 600 | const char *kind = getobjname(L, o, &name); | 600 | const l_char *kind = getobjname(L, o, &name); |
| 601 | const char *t = luaT_typename(G(L), o); | 601 | const l_char *t = luaT_typename(G(L), o); |
| 602 | if (kind) | 602 | if (kind) |
| 603 | luaO_verror(L, "attempt to %.30s %.20s `%.40s' (a %.10s value)", | 603 | luaO_verror(L, l_s("attempt to %.30s %.20s `%.40s' (a %.10s value)"), |
| 604 | op, kind, name, t); | 604 | op, kind, name, t); |
| 605 | else | 605 | else |
| 606 | luaO_verror(L, "attempt to %.30s a %.10s value", op, t); | 606 | luaO_verror(L, l_s("attempt to %.30s a %.10s value"), op, t); |
| 607 | } | 607 | } |
| 608 | 608 | ||
| 609 | 609 | ||
| 610 | void luaG_binerror (lua_State *L, StkId p1, int t, const char *op) { | 610 | void luaG_binerror (lua_State *L, StkId p1, int t, const l_char *op) { |
| 611 | if (ttype(p1) == t) p1++; | 611 | if (ttype(p1) == t) p1++; |
| 612 | lua_assert(ttype(p1) != t); | 612 | lua_assert(ttype(p1) != t); |
| 613 | luaG_typeerror(L, p1, op); | 613 | luaG_typeerror(L, p1, op); |
| @@ -615,11 +615,11 @@ void luaG_binerror (lua_State *L, StkId p1, int t, const char *op) { | |||
| 615 | 615 | ||
| 616 | 616 | ||
| 617 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { | 617 | void luaG_ordererror (lua_State *L, const TObject *p1, const TObject *p2) { |
| 618 | const char *t1 = luaT_typename(G(L), p1); | 618 | const l_char *t1 = luaT_typename(G(L), p1); |
| 619 | const char *t2 = luaT_typename(G(L), p2); | 619 | const l_char *t2 = luaT_typename(G(L), p2); |
| 620 | if (t1[2] == t2[2]) | 620 | if (t1[2] == t2[2]) |
| 621 | luaO_verror(L, "attempt to compare two %.10s values", t1); | 621 | luaO_verror(L, l_s("attempt to compare two %.10s values"), t1); |
| 622 | else | 622 | else |
| 623 | luaO_verror(L, "attempt to compare %.10s with %.10s", t1, t2); | 623 | luaO_verror(L, l_s("attempt to compare %.10s with %.10s"), t1, t2); |
| 624 | } | 624 | } |
| 625 | 625 | ||
