new way to handle errors

This commit is contained in:
Roberto Ierusalimschy
2002-04-22 11:40:23 -03:00
parent 30ad4c75db
commit f388ee4a82
8 changed files with 32 additions and 34 deletions

16
lvm.c
View File

@@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 1.224 2002/04/09 19:47:44 roberto Exp roberto $
** $Id: lvm.c,v 1.225 2002/04/10 12:11:07 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@@ -134,7 +134,7 @@ void luaV_gettable (lua_State *L, const TObject *t, TObject *key, StkId res) {
if (ttype(tm) == LUA_TFUNCTION)
callTMres(L, tm, t, key, res);
else {
if (++loop == MAXTAGLOOP) luaD_error(L, "loop in gettable");
if (++loop == MAXTAGLOOP) luaD_runerror(L, "loop in gettable");
t = tm;
goto init; /* return luaV_gettable(L, tm, key, res); */
}
@@ -164,7 +164,7 @@ void luaV_settable (lua_State *L, const TObject *t, TObject *key, StkId val) {
if (ttype(tm) == LUA_TFUNCTION)
callTM(L, tm, t, key, val);
else {
if (++loop == MAXTAGLOOP) luaD_error(L, "loop in settable");
if (++loop == MAXTAGLOOP) luaD_runerror(L, "loop in settable");
t = tm;
goto init; /* luaV_settable(L, tm, key, val); */
}
@@ -241,7 +241,7 @@ void luaV_strconc (lua_State *L, int total, int last) {
tl += tsvalue(top-n-1)->tsv.len;
n++;
}
if (tl > MAX_SIZET) luaD_error(L, "string size overflow");
if (tl > MAX_SIZET) luaD_runerror(L, "string size overflow");
buffer = luaO_openspace(L, tl, char);
tl = 0;
for (i=n; i>0; i--) { /* concat all strings */
@@ -266,7 +266,7 @@ static void powOp (lua_State *L, StkId ra, StkId rb, StkId rc) {
setsvalue(&o, luaS_newliteral(L, "pow"));
luaV_gettable(L, gt(L), &o, &f);
if (ttype(&f) != LUA_TFUNCTION)
luaD_error(L, "`pow' (for `^' operator) is not a function");
luaD_runerror(L, "`pow' (for `^' operator) is not a function");
callTMres(L, &f, b, c, ra);
}
else
@@ -535,11 +535,11 @@ StkId luaV_execute (lua_State *L) {
const TObject *plimit = ra+1;
const TObject *pstep = ra+2;
if (ttype(ra) != LUA_TNUMBER)
luaD_error(L, "`for' initial value must be a number");
luaD_runerror(L, "`for' initial value must be a number");
if (!tonumber(plimit, ra+1))
luaD_error(L, "`for' limit must be a number");
luaD_runerror(L, "`for' limit must be a number");
if (!tonumber(pstep, ra+2))
luaD_error(L, "`for' step must be a number");
luaD_runerror(L, "`for' step must be a number");
step = nvalue(pstep);
index = nvalue(ra) + step; /* increment index */
limit = nvalue(plimit);