diff options
| -rw-r--r-- | ldebug.c | 30 | ||||
| -rw-r--r-- | ldebug.h | 4 | ||||
| -rw-r--r-- | ltm.c | 4 |
3 files changed, 26 insertions, 12 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.c,v 2.93 2013/04/26 16:03:50 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.94 2013/04/29 16:58:10 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 | */ |
| @@ -498,10 +498,9 @@ static const char *getupvalname (CallInfo *ci, const TValue *o, | |||
| 498 | } | 498 | } |
| 499 | 499 | ||
| 500 | 500 | ||
| 501 | l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | 501 | static const char *varinfo (lua_State *L, const TValue *o) { |
| 502 | const char *name; | ||
| 502 | CallInfo *ci = L->ci; | 503 | CallInfo *ci = L->ci; |
| 503 | const char *name = NULL; | ||
| 504 | const char *t = objtypename(o); | ||
| 505 | const char *kind = NULL; | 504 | const char *kind = NULL; |
| 506 | if (isLua(ci)) { | 505 | if (isLua(ci)) { |
| 507 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ | 506 | kind = getupvalname(ci, o, &name); /* check whether 'o' is an upvalue */ |
| @@ -509,17 +508,19 @@ l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | |||
| 509 | kind = getobjname(ci_func(ci)->p, currentpc(ci), | 508 | kind = getobjname(ci_func(ci)->p, currentpc(ci), |
| 510 | cast_int(o - ci->u.l.base), &name); | 509 | cast_int(o - ci->u.l.base), &name); |
| 511 | } | 510 | } |
| 512 | if (kind) | 511 | return (kind) ? luaO_pushfstring(L, " (%s " LUA_QS ")", kind, name) : ""; |
| 513 | luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", | 512 | } |
| 514 | op, kind, name, t); | 513 | |
| 515 | else | 514 | |
| 516 | luaG_runerror(L, "attempt to %s a %s value", op, t); | 515 | l_noret luaG_typeerror (lua_State *L, const TValue *o, const char *op) { |
| 516 | const char *t = objtypename(o); | ||
| 517 | luaG_runerror(L, "attempt to %s a %s value%s", op, t, varinfo(L, o)); | ||
| 517 | } | 518 | } |
| 518 | 519 | ||
| 519 | 520 | ||
| 520 | l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { | 521 | l_noret luaG_concaterror (lua_State *L, const TValue *p1, const TValue *p2) { |
| 521 | if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; | 522 | if (ttisstring(p1) || ttisnumber(p1)) p1 = p2; |
| 522 | lua_assert(!ttisstring(p1) && !ttisnumber(p2)); | 523 | lua_assert(!ttisstring(p1) && !ttisnumber(p1)); |
| 523 | luaG_typeerror(L, p1, "concatenate"); | 524 | luaG_typeerror(L, p1, "concatenate"); |
| 524 | } | 525 | } |
| 525 | 526 | ||
| @@ -532,6 +533,15 @@ l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) { | |||
| 532 | } | 533 | } |
| 533 | 534 | ||
| 534 | 535 | ||
| 536 | l_noret luaG_tointerror (lua_State *L, const TValue *p1, const TValue *p2) { | ||
| 537 | lua_Integer temp; | ||
| 538 | if (!tointeger(p1, &temp)) | ||
| 539 | p2 = p1; | ||
| 540 | luaG_runerror(L, "attempt to convert an out of range float%s to an integer", | ||
| 541 | varinfo(L, p2)); | ||
| 542 | } | ||
| 543 | |||
| 544 | |||
| 535 | l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { | 545 | l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) { |
| 536 | const char *t1 = objtypename(p1); | 546 | const char *t1 = objtypename(p1); |
| 537 | const char *t2 = objtypename(p2); | 547 | const char *t2 = objtypename(p2); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ldebug.h,v 2.8 2013/04/25 15:59:42 roberto Exp roberto $ | 2 | ** $Id: ldebug.h,v 2.9 2013/04/29 16:58:10 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 | */ |
| @@ -27,6 +27,8 @@ LUAI_FUNC l_noret luaG_concaterror (lua_State *L, const TValue *p1, | |||
| 27 | const TValue *p2); | 27 | const TValue *p2); |
| 28 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, | 28 | LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1, |
| 29 | const TValue *p2); | 29 | const TValue *p2); |
| 30 | LUAI_FUNC l_noret luaG_tointerror (lua_State *L, const TValue *p1, | ||
| 31 | const TValue *p2); | ||
| 30 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, | 32 | LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1, |
| 31 | const TValue *p2); | 33 | const TValue *p2); |
| 32 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); | 34 | LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...); |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: ltm.c,v 2.18 2013/04/26 13:07:53 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.19 2013/04/29 16:56:50 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 | */ |
| @@ -112,6 +112,8 @@ void luaT_trybinTM (lua_State *L, const TValue *p1, const TValue *p2, | |||
| 112 | if (!luaT_callbinTM(L, p1, p2, res, event)) { | 112 | if (!luaT_callbinTM(L, p1, p2, res, event)) { |
| 113 | if (event == TM_CONCAT) | 113 | if (event == TM_CONCAT) |
| 114 | luaG_concaterror(L, p1, p2); | 114 | luaG_concaterror(L, p1, p2); |
| 115 | else if (event == TM_IDIV && ttisnumber(p1) && ttisnumber(p2)) | ||
| 116 | luaG_tointerror(L, p1, p2); | ||
| 115 | else | 117 | else |
| 116 | luaG_aritherror(L, p1, p2); | 118 | luaG_aritherror(L, p1, p2); |
| 117 | } | 119 | } |
