Browse Source

new type 'l_noret' for function that do not return

pull/9/head
Roberto Ierusalimschy 13 years ago
parent
commit
217e67cb22
  1. 11
      ldebug.c
  2. 20
      ldebug.h
  3. 6
      ldo.c
  4. 4
      ldo.h
  5. 15
      llimits.h
  6. 16
      lvm.c

11
ldebug.c

@ -1,5 +1,5 @@
/*
** $Id: ldebug.c,v 2.85 2011/09/13 17:40:20 roberto Exp roberto $
** $Id: ldebug.c,v 2.86 2011/09/13 18:05:59 roberto Exp roberto $
** Debug Interface
** See Copyright Notice in lua.h
*/
@ -520,7 +520,7 @@ void luaG_concaterror (lua_State *L, StkId p1, StkId p2) {
}
void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
l_noret luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
TValue temp;
if (luaV_tonumber(p1, &temp) == NULL)
p2 = p1; /* first operand is wrong */
@ -528,14 +528,13 @@ void luaG_aritherror (lua_State *L, const TValue *p1, const TValue *p2) {
}
int luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
l_noret luaG_ordererror (lua_State *L, const TValue *p1, const TValue *p2) {
const char *t1 = objtypename(p1);
const char *t2 = objtypename(p2);
if (t1 == t2)
luaG_runerror(L, "attempt to compare two %s values", t1);
else
luaG_runerror(L, "attempt to compare %s with %s", t1, t2);
return 0;
}
@ -555,7 +554,7 @@ static void addinfo (lua_State *L, const char *msg) {
}
void luaG_errormsg (lua_State *L) {
l_noret luaG_errormsg (lua_State *L) {
if (L->errfunc != 0) { /* is there an error handling function? */
StkId errfunc = restorestack(L, L->errfunc);
if (!ttisfunction(errfunc)) luaD_throw(L, LUA_ERRERR);
@ -568,7 +567,7 @@ void luaG_errormsg (lua_State *L) {
}
void luaG_runerror (lua_State *L, const char *fmt, ...) {
l_noret luaG_runerror (lua_State *L, const char *fmt, ...) {
va_list argp;
va_start(argp, fmt);
addinfo(L, luaO_pushvfstring(L, fmt, argp));

20
ldebug.h

@ -1,5 +1,5 @@
/*
** $Id: ldebug.h,v 2.5 2009/06/10 16:57:53 roberto Exp roberto $
** $Id: ldebug.h,v 2.6 2011/06/02 19:31:40 roberto Exp roberto $
** Auxiliary functions from Debug Interface module
** See Copyright Notice in lua.h
*/
@ -21,14 +21,14 @@
#define ci_func(ci) (clLvalue((ci)->func))
LUAI_FUNC void luaG_typeerror (lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC void luaG_concaterror (lua_State *L, StkId p1, StkId p2);
LUAI_FUNC void luaG_aritherror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC int luaG_ordererror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC void luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC void luaG_errormsg (lua_State *L);
LUAI_FUNC l_noret luaG_typeerror (lua_State *L, const TValue *o,
const char *opname);
LUAI_FUNC l_noret luaG_concaterror (lua_State *L, StkId p1, StkId p2);
LUAI_FUNC l_noret luaG_aritherror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_ordererror (lua_State *L, const TValue *p1,
const TValue *p2);
LUAI_FUNC l_noret luaG_runerror (lua_State *L, const char *fmt, ...);
LUAI_FUNC l_noret luaG_errormsg (lua_State *L);
#endif

6
ldo.c

@ -1,5 +1,5 @@
/*
** $Id: ldo.c,v 2.99 2011/08/23 17:24:34 roberto Exp roberto $
** $Id: ldo.c,v 2.100 2011/09/12 20:33:03 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -100,7 +100,7 @@ static void seterrorobj (lua_State *L, int errcode, StkId oldtop) {
}
void luaD_throw (lua_State *L, int errcode) {
l_noret luaD_throw (lua_State *L, int errcode) {
if (L->errorJmp) { /* thread has an error handler? */
L->errorJmp->status = errcode; /* set status */
LUAI_THROW(L, L->errorJmp); /* jump to it */
@ -472,7 +472,7 @@ static int recover (lua_State *L, int status) {
** coroutine itself. (Such errors should not be handled by any coroutine
** error handler and should not kill the coroutine.)
*/
static void resume_error (lua_State *L, const char *msg, StkId firstArg) {
static l_noret resume_error (lua_State *L, const char *msg, StkId firstArg) {
L->top = firstArg; /* remove args from the stack */
setsvalue2s(L, L->top, luaS_new(L, msg)); /* push error message */
incr_top(L);

4
ldo.h

@ -1,5 +1,5 @@
/*
** $Id: ldo.h,v 2.17 2009/11/25 15:27:51 roberto Exp roberto $
** $Id: ldo.h,v 2.18 2009/12/17 12:28:57 roberto Exp roberto $
** Stack and Call structure of Lua
** See Copyright Notice in lua.h
*/
@ -38,7 +38,7 @@ LUAI_FUNC void luaD_reallocstack (lua_State *L, int newsize);
LUAI_FUNC void luaD_growstack (lua_State *L, int n);
LUAI_FUNC void luaD_shrinkstack (lua_State *L);
LUAI_FUNC void luaD_throw (lua_State *L, int errcode);
LUAI_FUNC l_noret luaD_throw (lua_State *L, int errcode);
LUAI_FUNC int luaD_rawrunprotected (lua_State *L, Pfunc f, void *ud);
#endif

15
llimits.h

@ -1,5 +1,5 @@
/*
** $Id: llimits.h,v 1.91 2011/09/13 17:39:23 roberto Exp roberto $
** $Id: llimits.h,v 1.92 2011/09/30 12:46:06 roberto Exp roberto $
** Limits, basic types, and some other `installation-dependent' definitions
** See Copyright Notice in lua.h
*/
@ -96,6 +96,19 @@ typedef LUAI_UACNUMBER l_uacNumber;
#define cast_uchar(i) cast(unsigned char, (i))
/*
** non-return type
*/
#if defined(__GNUC__)
#define l_noret void __attribute__((noreturn))
#elif defined(_MSC_VER)
#define l_noret void __declspec(noreturn)
#else
#define l_noret void
#endif
/*
** maximum depth for nested C calls and syntactical nested non-terminals
** in a program. (Value must fit in an unsigned short int.)

16
lvm.c

@ -1,5 +1,5 @@
/*
** $Id: lvm.c,v 2.142 2011/08/09 20:58:29 roberto Exp roberto $
** $Id: lvm.c,v 2.143 2011/08/17 20:26:47 roberto Exp roberto $
** Lua virtual machine
** See Copyright Notice in lua.h
*/
@ -226,9 +226,9 @@ int luaV_lessthan (lua_State *L, const TValue *l, const TValue *r) {
return luai_numlt(L, nvalue(l), nvalue(r));
else if (ttisstring(l) && ttisstring(r))
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) < 0;
else if ((res = call_orderTM(L, l, r, TM_LT)) != -1)
return res;
return luaG_ordererror(L, l, r);
else if ((res = call_orderTM(L, l, r, TM_LT)) < 0)
luaG_ordererror(L, l, r);
return res;
}
@ -238,11 +238,11 @@ int luaV_lessequal (lua_State *L, const TValue *l, const TValue *r) {
return luai_numle(L, nvalue(l), nvalue(r));
else if (ttisstring(l) && ttisstring(r))
return l_strcmp(rawtsvalue(l), rawtsvalue(r)) <= 0;
else if ((res = call_orderTM(L, l, r, TM_LE)) != -1) /* first try `le' */
else if ((res = call_orderTM(L, l, r, TM_LE)) >= 0) /* first try `le' */
return res;
else if ((res = call_orderTM(L, r, l, TM_LT)) != -1) /* else try `lt' */
return !res;
return luaG_ordererror(L, l, r);
else if ((res = call_orderTM(L, r, l, TM_LT)) < 0) /* else try `lt' */
luaG_ordererror(L, l, r);
return !res;
}

Loading…
Cancel
Save