diff --git a/lapi.c b/lapi.c index 3c05942e..27148928 100644 --- a/lapi.c +++ b/lapi.c @@ -1,5 +1,5 @@ /* -** $Id: lapi.c,v 2.50 2005/09/20 17:55:10 roberto Exp roberto $ +** $Id: lapi.c,v 2.51 2005/10/20 11:35:50 roberto Exp roberto $ ** Lua API ** See Copyright Notice in lua.h */ @@ -153,7 +153,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { LUA_API int lua_gettop (lua_State *L) { - return cast(int, L->top - L->base); + return cast_int(L->top - L->base); } @@ -430,7 +430,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { lua_lock(L); - setnvalue(L->top, cast(lua_Number, n)); + setnvalue(L->top, cast_num(n)); api_incr_top(L); lua_unlock(L); } @@ -910,11 +910,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { } case LUA_GCCOUNT: { /* GC values are expressed in Kbytes: #bytes/2^10 */ - res = cast(int, g->totalbytes >> 10); + res = cast_int(g->totalbytes >> 10); break; } case LUA_GCCOUNTB: { - res = cast(int, g->totalbytes & 0x3ff); + res = cast_int(g->totalbytes & 0x3ff); break; } case LUA_GCSTEP: { @@ -983,7 +983,7 @@ LUA_API void lua_concat (lua_State *L, int n) { api_checknelems(L, n); if (n >= 2) { luaC_checkGC(L); - luaV_concat(L, n, cast(int, L->top - L->base) - 1); + luaV_concat(L, n, cast_int(L->top - L->base) - 1); L->top -= (n-1); } else if (n == 0) { /* push empty string */ diff --git a/lcode.c b/lcode.c index 58325b5b..feaad660 100644 --- a/lcode.c +++ b/lcode.c @@ -1,5 +1,5 @@ /* -** $Id: lcode.c,v 2.22 2005/11/16 11:55:27 roberto Exp roberto $ +** $Id: lcode.c,v 2.23 2005/11/25 13:29:32 roberto Exp roberto $ ** Code generator for Lua ** See Copyright Notice in lua.h */ @@ -196,7 +196,7 @@ void luaK_checkstack (FuncState *fs, int n) { if (newstack > fs->f->maxstacksize) { if (newstack >= MAXSTACK) luaX_syntaxerror(fs->ls, "function or expression too complex"); - fs->f->maxstacksize = cast(lu_byte, newstack); + fs->f->maxstacksize = cast_byte(newstack); } } @@ -227,11 +227,11 @@ static int addk (FuncState *fs, TValue *k, TValue *v) { Proto *f = fs->f; int oldsize = f->sizek; if (ttisnumber(idx)) { - lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); - return cast(int, nvalue(idx)); + lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); + return cast_int(nvalue(idx)); } else { /* constant not found; create a new entry */ - setnvalue(idx, cast(lua_Number, fs->nk)); + setnvalue(idx, cast_num(fs->nk)); luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, MAXARG_Bx, "constant table overflow"); while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); diff --git a/ldebug.c b/ldebug.c index 2ba11f3c..4fa42ac9 100644 --- a/ldebug.c +++ b/ldebug.c @@ -1,5 +1,5 @@ /* -** $Id: ldebug.c,v 2.27 2005/10/06 20:43:44 roberto Exp roberto $ +** $Id: ldebug.c,v 2.28 2005/11/01 16:08:52 roberto Exp roberto $ ** Debug Interface ** See Copyright Notice in lua.h */ @@ -61,7 +61,7 @@ LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { L->hook = func; L->basehookcount = count; resethookcount(L); - L->hookmask = cast(lu_byte, mask); + L->hookmask = cast_byte(mask); return 1; } @@ -92,7 +92,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { } if (level == 0 && ci > L->base_ci) { /* level found? */ status = 1; - ar->i_ci = cast(int, ci - L->base_ci); + ar->i_ci = cast_int(ci - L->base_ci); } else if (level < 0) { /* level is of a lost tail call? */ status = 1; @@ -550,7 +550,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { const char *name = NULL; const char *t = luaT_typenames[ttype(o)]; const char *kind = (isinstack(L->ci, o)) ? - getobjname(L, L->ci, cast(int, o - L->base), &name) : + getobjname(L, L->ci, cast_int(o - L->base), &name) : NULL; if (kind) luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", diff --git a/ldo.c b/ldo.c index a73c024f..e8346009 100644 --- a/ldo.c +++ b/ldo.c @@ -1,5 +1,5 @@ /* -** $Id: ldo.c,v 2.35 2005/10/14 16:23:33 roberto Exp roberto $ +** $Id: ldo.c,v 2.36 2005/10/23 17:52:42 roberto Exp roberto $ ** Stack and Call structure of Lua ** See Copyright Notice in lua.h */ @@ -71,7 +71,7 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { static void restore_stack_limit (lua_State *L) { lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ - int inuse = cast(int, L->ci - L->base_ci); + int inuse = cast_int(L->ci - L->base_ci); if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ luaD_reallocCI(L, LUAI_MAXCALLS); } @@ -97,7 +97,7 @@ void luaD_throw (lua_State *L, int errcode) { LUAI_THROW(L, L->errorJmp); } else { - L->status = cast(lu_byte, errcode); + L->status = cast_byte(errcode); if (G(L)->panic) { resetstack(L, errcode); lua_unlock(L); @@ -189,7 +189,7 @@ void luaD_callhook (lua_State *L, int event, int line) { if (event == LUA_HOOKTAILRET) ar.i_ci = 0; /* tail call; no debug information about it */ else - ar.i_ci = cast(int, L->ci - L->base_ci); + ar.i_ci = cast_int(L->ci - L->base_ci); luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ L->ci->top = L->top + LUA_MINSTACK; lua_assert(L->ci->top <= L->stack_last); @@ -221,8 +221,7 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { for (i=0; itop - nvar + i); /* store counter in field `n' */ - setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), - cast(lua_Number, nvar)); + setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); } #endif /* move fixed parameters to final position */ @@ -282,7 +281,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { L->top = base + p->numparams; } else { /* vararg function */ - int nargs = cast(int, L->top - func) - 1; + int nargs = cast_int(L->top - func) - 1; base = adjust_varargs(L, p, nargs); func = restorestack(L, funcr); /* previous call may change the stack */ } @@ -401,7 +400,7 @@ static void resume (lua_State *L, void *ud) { L->base = L->ci->base; } L->status = 0; - luaV_execute(L, cast(int, L->ci - L->base_ci)); + luaV_execute(L, cast_int(L->ci - L->base_ci)); } @@ -427,7 +426,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) { lua_assert(L->errfunc == 0 && L->nCcalls == 0); status = luaD_rawrunprotected(L, resume, L->top - nargs); if (status != 0) { /* error? */ - L->status = cast(lu_byte, status); /* mark thread as `dead' */ + L->status = cast_byte(status); /* mark thread as `dead' */ luaD_seterrorobj(L, status, L->top); L->ci->top = L->top; } diff --git a/lfunc.c b/lfunc.c index cfdfe7f5..8c3b811a 100644 --- a/lfunc.c +++ b/lfunc.c @@ -1,5 +1,5 @@ /* -** $Id: lfunc.c,v 2.10 2005/04/29 13:54:05 roberto Exp roberto $ +** $Id: lfunc.c,v 2.11 2005/05/05 20:47:02 roberto Exp roberto $ ** Auxiliary functions to manipulate prototypes and closures ** See Copyright Notice in lua.h */ @@ -25,7 +25,7 @@ Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { luaC_link(L, obj2gco(c), LUA_TFUNCTION); c->c.isC = 1; c->c.env = e; - c->c.nupvalues = cast(lu_byte, nelems); + c->c.nupvalues = cast_byte(nelems); return c; } @@ -35,7 +35,7 @@ Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { luaC_link(L, obj2gco(c), LUA_TFUNCTION); c->l.isC = 0; c->l.env = e; - c->l.nupvalues = cast(lu_byte, nelems); + c->l.nupvalues = cast_byte(nelems); while (nelems--) c->l.upvals[nelems] = NULL; return c; } diff --git a/lgc.c b/lgc.c index 577bc855..5ed34b95 100644 --- a/lgc.c +++ b/lgc.c @@ -1,5 +1,5 @@ /* -** $Id: lgc.c,v 2.35 2005/08/04 13:37:38 roberto Exp roberto $ +** $Id: lgc.c,v 2.36 2005/08/24 17:06:36 roberto Exp roberto $ ** Garbage Collector ** See Copyright Notice in lua.h */ @@ -29,11 +29,10 @@ #define GCFINALIZECOST 100 -#define maskmarks \ - cast(lu_byte, ~(bitmask(BLACKBIT)|WHITEBITS)) +#define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) #define makewhite(g,x) \ - ((x)->gch.marked = ((x)->gch.marked & maskmarks) | luaC_white(g)) + ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) #define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) #define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) @@ -169,8 +168,8 @@ static int traversetable (global_State *g, Table *h) { weakvalue = (strchr(svalue(mode), 'v') != NULL); if (weakkey || weakvalue) { /* is really weak? */ h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ - h->marked |= cast(lu_byte, (weakkey << KEYWEAKBIT) | - (weakvalue << VALUEWEAKBIT)); + h->marked |= cast_byte((weakkey << KEYWEAKBIT) | + (weakvalue << VALUEWEAKBIT)); h->gclist = g->weak; /* must be cleared after GC, ... */ g->weak = obj2gco(h); /* ... so put in the appropriate list */ } @@ -240,8 +239,8 @@ static void traverseclosure (global_State *g, Closure *cl) { static void checkstacksizes (lua_State *L, StkId max) { - int ci_used = cast(int, L->ci - L->base_ci); /* number of `ci' in use */ - int s_used = cast(int, max - L->stack); /* part of stack in use */ + int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ + int s_used = cast_int(max - L->stack); /* part of stack in use */ if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ return; /* do not touch the stacks */ if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) @@ -544,7 +543,7 @@ static void atomic (lua_State *L) { propagateall(g); /* remark, to propagate `preserveness' */ cleartable(g->weak); /* remove collected objects from weak tables */ /* flip current white */ - g->currentwhite = cast(lu_byte, otherwhite(g)); + g->currentwhite = cast_byte(otherwhite(g)); g->sweepstrgc = 0; g->sweepgc = &g->rootgc; g->gcstate = GCSsweepstring; diff --git a/llex.c b/llex.c index c4d185db..51882814 100644 --- a/llex.c +++ b/llex.c @@ -1,5 +1,5 @@ /* -** $Id: llex.c,v 2.15 2005/12/07 15:43:05 roberto Exp roberto $ +** $Id: llex.c,v 2.16 2005/12/08 15:50:54 roberto Exp roberto $ ** Lexical Analyzer ** See Copyright Notice in lua.h */ @@ -66,7 +66,7 @@ void luaX_init (lua_State *L) { TString *ts = luaS_new(L, luaX_tokens[i]); luaS_fix(ts); /* reserved words are never collected */ lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN); - ts->tsv.reserved = cast(lu_byte, i+1); /* reserved word */ + ts->tsv.reserved = cast_byte(i+1); /* reserved word */ } } diff --git a/llimits.h b/llimits.h index ccffb3dc..fce32902 100644 --- a/llimits.h +++ b/llimits.h @@ -1,5 +1,5 @@ /* -** $Id: llimits.h,v 1.66 2005/08/04 13:37:10 roberto Exp roberto $ +** $Id: llimits.h,v 1.67 2005/08/24 16:15:49 roberto Exp roberto $ ** Limits, basic types, and some other `installation-dependent' definitions ** See Copyright Notice in lua.h */ @@ -66,6 +66,10 @@ typedef LUAI_UACNUMBER l_uacNumber; #define cast(t, exp) ((t)(exp)) #endif +#define cast_byte(i) cast(lu_byte, (i)) +#define cast_num(i) cast(lua_Number, (i)) +#define cast_int(i) cast(int, (i)) + /* diff --git a/lobject.c b/lobject.c index be3236f5..e866c25c 100644 --- a/lobject.c +++ b/lobject.c @@ -1,5 +1,5 @@ /* -** $Id: lobject.c,v 2.18 2005/08/01 04:22:23 roberto Exp roberto $ +** $Id: lobject.c,v 2.19 2005/10/24 17:37:52 roberto Exp roberto $ ** Some generic functions over Lua objects ** See Copyright Notice in lua.h */ @@ -39,7 +39,7 @@ int luaO_int2fb (unsigned int x) { e++; } if (x < 8) return x; - else return ((e+1) << 3) | (cast(int, x) - 8); + else return ((e+1) << 3) | (cast_int(x) - 8); } @@ -129,12 +129,12 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { break; } case 'd': { - setnvalue(L->top, cast(lua_Number, va_arg(argp, int))); + setnvalue(L->top, cast_num(va_arg(argp, int))); incr_top(L); break; } case 'f': { - setnvalue(L->top, cast(lua_Number, va_arg(argp, l_uacNumber))); + setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); incr_top(L); break; } @@ -161,7 +161,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { fmt = e+2; } pushstr(L, fmt); - luaV_concat(L, n+1, cast(int, L->top - L->base) - 1); + luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); L->top -= n; return svalue(L->top - 1); } diff --git a/loslib.c b/loslib.c index cc6a28b3..804d0696 100644 --- a/loslib.c +++ b/loslib.c @@ -1,5 +1,5 @@ /* -** $Id: loslib.c,v 1.14 2005/10/21 13:47:42 roberto Exp roberto $ +** $Id: loslib.c,v 1.15 2005/12/15 18:17:49 roberto Exp roberto $ ** Standard Operating System library ** See Copyright Notice in lua.h */ @@ -179,7 +179,7 @@ static int os_time (lua_State *L) { if (t == (time_t)(-1)) lua_pushnil(L); else - lua_pushnumber(L, t); + lua_pushnumber(L, (lua_Number)t); return 1; } diff --git a/lparser.c b/lparser.c index b23ebd6f..39619125 100644 --- a/lparser.c +++ b/lparser.c @@ -1,5 +1,5 @@ /* -** $Id: lparser.c,v 2.38 2005/10/24 17:38:47 roberto Exp roberto $ +** $Id: lparser.c,v 2.39 2005/12/07 15:43:05 roberto Exp roberto $ ** Lua Parser ** See Copyright Notice in lua.h */ @@ -166,7 +166,7 @@ static void new_localvar (LexState *ls, TString *name, int n) { static void adjustlocalvars (LexState *ls, int nvars) { FuncState *fs = ls->fs; - fs->nactvar = cast(lu_byte, fs->nactvar + nvars); + fs->nactvar = cast_byte(fs->nactvar + nvars); for (; nvars; nvars--) { getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; } @@ -198,8 +198,8 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { f->upvalues[f->nups] = name; luaC_objbarrier(fs->L, f, name); lua_assert(v->k == VLOCAL || v->k == VUPVAL); - fs->upvalues[f->nups].k = cast(lu_byte, v->k); - fs->upvalues[f->nups].info = cast(lu_byte, v->u.s.info); + fs->upvalues[f->nups].k = cast_byte(v->k); + fs->upvalues[f->nups].info = cast_byte(v->u.s.info); return f->nups++; } @@ -567,7 +567,7 @@ static void parlist (LexState *ls) { } while (!f->is_vararg && testnext(ls, ',')); } adjustlocalvars(ls, nparams); - f->numparams = fs->nactvar - (f->is_vararg & VARARG_HASARG); + f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ } diff --git a/lstring.c b/lstring.c index 768d064f..08dbe87f 100644 --- a/lstring.c +++ b/lstring.c @@ -1,5 +1,5 @@ /* -** $Id: lstring.c,v 2.6 2005/01/18 17:18:09 roberto Exp roberto $ +** $Id: lstring.c,v 2.7 2005/02/18 12:40:02 roberto Exp roberto $ ** String table (keeps all strings handled by Lua) ** See Copyright Notice in lua.h */ @@ -35,7 +35,7 @@ void luaS_resize (lua_State *L, int newsize) { GCObject *next = p->gch.next; /* save next */ unsigned int h = gco2ts(p)->hash; int h1 = lmod(h, newsize); /* new position */ - lua_assert(cast(int, h%newsize) == lmod(h, newsize)); + lua_assert(cast_int(h%newsize) == lmod(h, newsize)); p->gch.next = newhash[h1]; /* chain it */ newhash[h1] = p; p = next; diff --git a/ltable.c b/ltable.c index 9ad52cfe..aa9822ab 100644 --- a/ltable.c +++ b/ltable.c @@ -1,5 +1,5 @@ /* -** $Id: ltable.c,v 2.27 2005/10/24 17:37:52 roberto Exp roberto $ +** $Id: ltable.c,v 2.28 2005/11/25 13:29:32 roberto Exp roberto $ ** Lua tables (hash) ** See Copyright Notice in lua.h */ @@ -66,7 +66,7 @@ /* ** number of ints inside a lua_Number */ -#define numints cast(int, sizeof(lua_Number)/sizeof(int)) +#define numints cast_int(sizeof(lua_Number)/sizeof(int)) @@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) { lua_Number n = nvalue(key); int k; lua_number2int(k, n); - if (luai_numeq(cast(lua_Number, k), nvalue(key))) + if (luai_numeq(cast_num(k), nvalue(key))) return k; } return -1; /* `key' did not match some condition */ @@ -145,7 +145,7 @@ static int findindex (lua_State *L, Table *t, StkId key) { if (luaO_rawequalObj(key2tval(n), key) || (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && gcvalue(gkey(n)) == gcvalue(key))) { - i = cast(int, n - gnode(t, 0)); /* key index in hash table */ + i = cast_int(n - gnode(t, 0)); /* key index in hash table */ /* hash elements are numbered after array ones */ return i + t->sizearray; } @@ -161,7 +161,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) { int i = findindex(L, t, key); /* find original element */ for (i++; i < t->sizearray; i++) { /* try first array part */ if (!ttisnil(&t->array[i])) { /* a non-nil value? */ - setnvalue(key, cast(lua_Number, i+1)); + setnvalue(key, cast_num(i+1)); setobj2s(L, key+1, &t->array[i]); return 1; } @@ -286,7 +286,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { setnilvalue(gval(gnode(t, i))); } } - t->lsizenode = cast(lu_byte, lsize); + t->lsizenode = cast_byte(lsize); t->lastfree = gnode(t, size); /* all positions are free */ } @@ -356,7 +356,7 @@ Table *luaH_new (lua_State *L, int narray, int nhash) { Table *t = luaM_new(L, Table); luaC_link(L, obj2gco(t), LUA_TTABLE); t->metatable = NULL; - t->flags = cast(lu_byte, ~0); + t->flags = cast_byte(~0); /* temporary values (kept only if some malloc fails) */ t->array = NULL; t->sizearray = 0; @@ -434,7 +434,7 @@ const TValue *luaH_getnum (Table *t, int key) { if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) return &t->array[key-1]; else { - lua_Number nk = cast(lua_Number, key); + lua_Number nk = cast_num(key); Node *n = hashnum(t, nk); do { /* check whether `key' is somewhere in the chain */ if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) @@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { int k; lua_Number n = nvalue(key); lua_number2int(k, n); - if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is int? */ + if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ return luaH_getnum(t, k); /* use specialized version */ /* else go through */ } @@ -508,7 +508,7 @@ TValue *luaH_setnum (lua_State *L, Table *t, int key) { return cast(TValue *, p); else { TValue k; - setnvalue(&k, cast(lua_Number, key)); + setnvalue(&k, cast_num(key)); return newkey(L, t, &k); } } diff --git a/ltests.c b/ltests.c index 372246e6..fe30b966 100644 --- a/ltests.c +++ b/ltests.c @@ -1,5 +1,5 @@ /* -** $Id: ltests.c,v 2.32 2005/09/20 17:55:10 roberto Exp roberto $ +** $Id: ltests.c,v 2.33 2005/10/06 20:47:32 roberto Exp roberto $ ** Internal Module for Debugging of the Lua Implementation ** See Copyright Notice in lua.h */ @@ -798,7 +798,7 @@ static int getnum_aux (lua_State *L, const char **pc) { int sig = 1; skip(pc); if (**pc == '.') { - res = cast(int, lua_tonumber(L, -1)); + res = cast_int(lua_tonumber(L, -1)); lua_pop(L, 1); (*pc)++; return res; @@ -807,7 +807,7 @@ static int getnum_aux (lua_State *L, const char **pc) { sig = -1; (*pc)++; } - while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - '0'; + while (isdigit(cast_int(**pc))) res = res*10 + (*(*pc)++) - '0'; return sig*res; } @@ -994,7 +994,7 @@ static int testC (lua_State *L) { #ifndef luaL_setn else if EQ("setn") { int i = getindex; - int n = cast(int, lua_tonumber(L1, -1)); + int n = cast_int(lua_tonumber(L1, -1)); luaL_setn(L1, i, n); lua_pop(L1, 1); } diff --git a/ltm.c b/ltm.c index e9dc0d87..04773840 100644 --- a/ltm.c +++ b/ltm.c @@ -1,5 +1,5 @@ /* -** $Id: ltm.c,v 2.5 2005/05/05 15:34:03 roberto Exp roberto $ +** $Id: ltm.c,v 2.6 2005/05/20 15:53:42 roberto Exp roberto $ ** Tag methods ** See Copyright Notice in lua.h */ @@ -51,7 +51,7 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { const TValue *tm = luaH_getstr(events, ename); lua_assert(event <= TM_EQ); if (ttisnil(tm)) { /* no tag method? */ - events->flags |= cast(lu_byte, 1u<flags |= cast_byte(1u<len)); + setnvalue(ra, cast_num(tsvalue(rb)->len)); break; } default: { /* try metamethod */ @@ -693,10 +693,10 @@ void luaV_execute (lua_State *L, int nexeccalls) { int last; Table *h; if (n == 0) { - n = cast(int, L->top - ra) - 1; + n = cast_int(L->top - ra) - 1; L->top = L->ci->top; } - if (c == 0) c = cast(int, *pc++); + if (c == 0) c = cast_int(*pc++); runtime_check(L, ttistable(ra)); h = hvalue(ra); last = ((c-1)*LFIELDS_PER_FLUSH) + n; @@ -737,7 +737,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { int b = GETARG_B(i) - 1; int j; CallInfo *ci = L->ci; - int n = cast(int, ci->base - ci->func) - cl->p->numparams - 1; + int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; if (b == LUA_MULTRET) { Protect(luaD_checkstack(L, n)); ra = RA(i); /* previous call may change the stack */