diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-12-22 14:19:56 -0200 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2005-12-22 14:19:56 -0200 |
commit | c505f341d638f8f0adcef4df85bcc8def6c930a3 (patch) | |
tree | bfa689a7545e47cfd154066cd8d962daa6bc611e | |
parent | 428325baecb2f514ea3eb6c87405f93872fb8430 (diff) | |
download | lua-c505f341d638f8f0adcef4df85bcc8def6c930a3.tar.gz lua-c505f341d638f8f0adcef4df85bcc8def6c930a3.tar.bz2 lua-c505f341d638f8f0adcef4df85bcc8def6c930a3.zip |
small changes in casts
-rw-r--r-- | lapi.c | 12 | ||||
-rw-r--r-- | lcode.c | 10 | ||||
-rw-r--r-- | ldebug.c | 8 | ||||
-rw-r--r-- | ldo.c | 17 | ||||
-rw-r--r-- | lfunc.c | 6 | ||||
-rw-r--r-- | lgc.c | 17 | ||||
-rw-r--r-- | llex.c | 4 | ||||
-rw-r--r-- | llimits.h | 6 | ||||
-rw-r--r-- | lobject.c | 10 | ||||
-rw-r--r-- | loslib.c | 4 | ||||
-rw-r--r-- | lparser.c | 10 | ||||
-rw-r--r-- | lstring.c | 4 | ||||
-rw-r--r-- | ltable.c | 20 | ||||
-rw-r--r-- | ltests.c | 8 | ||||
-rw-r--r-- | ltm.c | 4 | ||||
-rw-r--r-- | lvm.c | 12 |
16 files changed, 77 insertions, 75 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lapi.c,v 2.50 2005/09/20 17:55:10 roberto Exp roberto $ | 2 | ** $Id: lapi.c,v 2.51 2005/10/20 11:35:50 roberto Exp roberto $ |
3 | ** Lua API | 3 | ** Lua API |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -153,7 +153,7 @@ LUA_API lua_State *lua_newthread (lua_State *L) { | |||
153 | 153 | ||
154 | 154 | ||
155 | LUA_API int lua_gettop (lua_State *L) { | 155 | LUA_API int lua_gettop (lua_State *L) { |
156 | return cast(int, L->top - L->base); | 156 | return cast_int(L->top - L->base); |
157 | } | 157 | } |
158 | 158 | ||
159 | 159 | ||
@@ -430,7 +430,7 @@ LUA_API void lua_pushnumber (lua_State *L, lua_Number n) { | |||
430 | 430 | ||
431 | LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { | 431 | LUA_API void lua_pushinteger (lua_State *L, lua_Integer n) { |
432 | lua_lock(L); | 432 | lua_lock(L); |
433 | setnvalue(L->top, cast(lua_Number, n)); | 433 | setnvalue(L->top, cast_num(n)); |
434 | api_incr_top(L); | 434 | api_incr_top(L); |
435 | lua_unlock(L); | 435 | lua_unlock(L); |
436 | } | 436 | } |
@@ -910,11 +910,11 @@ LUA_API int lua_gc (lua_State *L, int what, int data) { | |||
910 | } | 910 | } |
911 | case LUA_GCCOUNT: { | 911 | case LUA_GCCOUNT: { |
912 | /* GC values are expressed in Kbytes: #bytes/2^10 */ | 912 | /* GC values are expressed in Kbytes: #bytes/2^10 */ |
913 | res = cast(int, g->totalbytes >> 10); | 913 | res = cast_int(g->totalbytes >> 10); |
914 | break; | 914 | break; |
915 | } | 915 | } |
916 | case LUA_GCCOUNTB: { | 916 | case LUA_GCCOUNTB: { |
917 | res = cast(int, g->totalbytes & 0x3ff); | 917 | res = cast_int(g->totalbytes & 0x3ff); |
918 | break; | 918 | break; |
919 | } | 919 | } |
920 | case LUA_GCSTEP: { | 920 | case LUA_GCSTEP: { |
@@ -983,7 +983,7 @@ LUA_API void lua_concat (lua_State *L, int n) { | |||
983 | api_checknelems(L, n); | 983 | api_checknelems(L, n); |
984 | if (n >= 2) { | 984 | if (n >= 2) { |
985 | luaC_checkGC(L); | 985 | luaC_checkGC(L); |
986 | luaV_concat(L, n, cast(int, L->top - L->base) - 1); | 986 | luaV_concat(L, n, cast_int(L->top - L->base) - 1); |
987 | L->top -= (n-1); | 987 | L->top -= (n-1); |
988 | } | 988 | } |
989 | else if (n == 0) { /* push empty string */ | 989 | else if (n == 0) { /* push empty string */ |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lcode.c,v 2.22 2005/11/16 11:55:27 roberto Exp roberto $ | 2 | ** $Id: lcode.c,v 2.23 2005/11/25 13:29:32 roberto Exp roberto $ |
3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -196,7 +196,7 @@ void luaK_checkstack (FuncState *fs, int n) { | |||
196 | if (newstack > fs->f->maxstacksize) { | 196 | if (newstack > fs->f->maxstacksize) { |
197 | if (newstack >= MAXSTACK) | 197 | if (newstack >= MAXSTACK) |
198 | luaX_syntaxerror(fs->ls, "function or expression too complex"); | 198 | luaX_syntaxerror(fs->ls, "function or expression too complex"); |
199 | fs->f->maxstacksize = cast(lu_byte, newstack); | 199 | fs->f->maxstacksize = cast_byte(newstack); |
200 | } | 200 | } |
201 | } | 201 | } |
202 | 202 | ||
@@ -227,11 +227,11 @@ static int addk (FuncState *fs, TValue *k, TValue *v) { | |||
227 | Proto *f = fs->f; | 227 | Proto *f = fs->f; |
228 | int oldsize = f->sizek; | 228 | int oldsize = f->sizek; |
229 | if (ttisnumber(idx)) { | 229 | if (ttisnumber(idx)) { |
230 | lua_assert(luaO_rawequalObj(&fs->f->k[cast(int, nvalue(idx))], v)); | 230 | lua_assert(luaO_rawequalObj(&fs->f->k[cast_int(nvalue(idx))], v)); |
231 | return cast(int, nvalue(idx)); | 231 | return cast_int(nvalue(idx)); |
232 | } | 232 | } |
233 | else { /* constant not found; create a new entry */ | 233 | else { /* constant not found; create a new entry */ |
234 | setnvalue(idx, cast(lua_Number, fs->nk)); | 234 | setnvalue(idx, cast_num(fs->nk)); |
235 | luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, | 235 | luaM_growvector(L, f->k, fs->nk, f->sizek, TValue, |
236 | MAXARG_Bx, "constant table overflow"); | 236 | MAXARG_Bx, "constant table overflow"); |
237 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); | 237 | while (oldsize < f->sizek) setnilvalue(&f->k[oldsize++]); |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldebug.c,v 2.27 2005/10/06 20:43:44 roberto Exp roberto $ | 2 | ** $Id: ldebug.c,v 2.28 2005/11/01 16:08:52 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 | */ |
@@ -61,7 +61,7 @@ LUA_API int lua_sethook (lua_State *L, lua_Hook func, int mask, int count) { | |||
61 | L->hook = func; | 61 | L->hook = func; |
62 | L->basehookcount = count; | 62 | L->basehookcount = count; |
63 | resethookcount(L); | 63 | resethookcount(L); |
64 | L->hookmask = cast(lu_byte, mask); | 64 | L->hookmask = cast_byte(mask); |
65 | return 1; | 65 | return 1; |
66 | } | 66 | } |
67 | 67 | ||
@@ -92,7 +92,7 @@ LUA_API int lua_getstack (lua_State *L, int level, lua_Debug *ar) { | |||
92 | } | 92 | } |
93 | if (level == 0 && ci > L->base_ci) { /* level found? */ | 93 | if (level == 0 && ci > L->base_ci) { /* level found? */ |
94 | status = 1; | 94 | status = 1; |
95 | ar->i_ci = cast(int, ci - L->base_ci); | 95 | ar->i_ci = cast_int(ci - L->base_ci); |
96 | } | 96 | } |
97 | else if (level < 0) { /* level is of a lost tail call? */ | 97 | else if (level < 0) { /* level is of a lost tail call? */ |
98 | status = 1; | 98 | status = 1; |
@@ -550,7 +550,7 @@ void luaG_typeerror (lua_State *L, const TValue *o, const char *op) { | |||
550 | const char *name = NULL; | 550 | const char *name = NULL; |
551 | const char *t = luaT_typenames[ttype(o)]; | 551 | const char *t = luaT_typenames[ttype(o)]; |
552 | const char *kind = (isinstack(L->ci, o)) ? | 552 | const char *kind = (isinstack(L->ci, o)) ? |
553 | getobjname(L, L->ci, cast(int, o - L->base), &name) : | 553 | getobjname(L, L->ci, cast_int(o - L->base), &name) : |
554 | NULL; | 554 | NULL; |
555 | if (kind) | 555 | if (kind) |
556 | luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", | 556 | luaG_runerror(L, "attempt to %s %s " LUA_QS " (a %s value)", |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ldo.c,v 2.35 2005/10/14 16:23:33 roberto Exp roberto $ | 2 | ** $Id: ldo.c,v 2.36 2005/10/23 17:52:42 roberto Exp roberto $ |
3 | ** Stack and Call structure of Lua | 3 | ** Stack and Call structure of Lua |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -71,7 +71,7 @@ void luaD_seterrorobj (lua_State *L, int errcode, StkId oldtop) { | |||
71 | static void restore_stack_limit (lua_State *L) { | 71 | static void restore_stack_limit (lua_State *L) { |
72 | lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); | 72 | lua_assert(L->stack_last - L->stack == L->stacksize - EXTRA_STACK - 1); |
73 | if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ | 73 | if (L->size_ci > LUAI_MAXCALLS) { /* there was an overflow? */ |
74 | int inuse = cast(int, L->ci - L->base_ci); | 74 | int inuse = cast_int(L->ci - L->base_ci); |
75 | if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ | 75 | if (inuse + 1 < LUAI_MAXCALLS) /* can `undo' overflow? */ |
76 | luaD_reallocCI(L, LUAI_MAXCALLS); | 76 | luaD_reallocCI(L, LUAI_MAXCALLS); |
77 | } | 77 | } |
@@ -97,7 +97,7 @@ void luaD_throw (lua_State *L, int errcode) { | |||
97 | LUAI_THROW(L, L->errorJmp); | 97 | LUAI_THROW(L, L->errorJmp); |
98 | } | 98 | } |
99 | else { | 99 | else { |
100 | L->status = cast(lu_byte, errcode); | 100 | L->status = cast_byte(errcode); |
101 | if (G(L)->panic) { | 101 | if (G(L)->panic) { |
102 | resetstack(L, errcode); | 102 | resetstack(L, errcode); |
103 | lua_unlock(L); | 103 | lua_unlock(L); |
@@ -189,7 +189,7 @@ void luaD_callhook (lua_State *L, int event, int line) { | |||
189 | if (event == LUA_HOOKTAILRET) | 189 | if (event == LUA_HOOKTAILRET) |
190 | ar.i_ci = 0; /* tail call; no debug information about it */ | 190 | ar.i_ci = 0; /* tail call; no debug information about it */ |
191 | else | 191 | else |
192 | ar.i_ci = cast(int, L->ci - L->base_ci); | 192 | ar.i_ci = cast_int(L->ci - L->base_ci); |
193 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ | 193 | luaD_checkstack(L, LUA_MINSTACK); /* ensure minimum stack size */ |
194 | L->ci->top = L->top + LUA_MINSTACK; | 194 | L->ci->top = L->top + LUA_MINSTACK; |
195 | lua_assert(L->ci->top <= L->stack_last); | 195 | lua_assert(L->ci->top <= L->stack_last); |
@@ -221,8 +221,7 @@ static StkId adjust_varargs (lua_State *L, Proto *p, int actual) { | |||
221 | for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */ | 221 | for (i=0; i<nvar; i++) /* put extra arguments into `arg' table */ |
222 | setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i); | 222 | setobj2n(L, luaH_setnum(L, htab, i+1), L->top - nvar + i); |
223 | /* store counter in field `n' */ | 223 | /* store counter in field `n' */ |
224 | setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), | 224 | setnvalue(luaH_setstr(L, htab, luaS_newliteral(L, "n")), cast_num(nvar)); |
225 | cast(lua_Number, nvar)); | ||
226 | } | 225 | } |
227 | #endif | 226 | #endif |
228 | /* move fixed parameters to final position */ | 227 | /* move fixed parameters to final position */ |
@@ -282,7 +281,7 @@ int luaD_precall (lua_State *L, StkId func, int nresults) { | |||
282 | L->top = base + p->numparams; | 281 | L->top = base + p->numparams; |
283 | } | 282 | } |
284 | else { /* vararg function */ | 283 | else { /* vararg function */ |
285 | int nargs = cast(int, L->top - func) - 1; | 284 | int nargs = cast_int(L->top - func) - 1; |
286 | base = adjust_varargs(L, p, nargs); | 285 | base = adjust_varargs(L, p, nargs); |
287 | func = restorestack(L, funcr); /* previous call may change the stack */ | 286 | func = restorestack(L, funcr); /* previous call may change the stack */ |
288 | } | 287 | } |
@@ -401,7 +400,7 @@ static void resume (lua_State *L, void *ud) { | |||
401 | L->base = L->ci->base; | 400 | L->base = L->ci->base; |
402 | } | 401 | } |
403 | L->status = 0; | 402 | L->status = 0; |
404 | luaV_execute(L, cast(int, L->ci - L->base_ci)); | 403 | luaV_execute(L, cast_int(L->ci - L->base_ci)); |
405 | } | 404 | } |
406 | 405 | ||
407 | 406 | ||
@@ -427,7 +426,7 @@ LUA_API int lua_resume (lua_State *L, int nargs) { | |||
427 | lua_assert(L->errfunc == 0 && L->nCcalls == 0); | 426 | lua_assert(L->errfunc == 0 && L->nCcalls == 0); |
428 | status = luaD_rawrunprotected(L, resume, L->top - nargs); | 427 | status = luaD_rawrunprotected(L, resume, L->top - nargs); |
429 | if (status != 0) { /* error? */ | 428 | if (status != 0) { /* error? */ |
430 | L->status = cast(lu_byte, status); /* mark thread as `dead' */ | 429 | L->status = cast_byte(status); /* mark thread as `dead' */ |
431 | luaD_seterrorobj(L, status, L->top); | 430 | luaD_seterrorobj(L, status, L->top); |
432 | L->ci->top = L->top; | 431 | L->ci->top = L->top; |
433 | } | 432 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lfunc.c,v 2.10 2005/04/29 13:54:05 roberto Exp roberto $ | 2 | ** $Id: lfunc.c,v 2.11 2005/05/05 20:47:02 roberto Exp roberto $ |
3 | ** Auxiliary functions to manipulate prototypes and closures | 3 | ** Auxiliary functions to manipulate prototypes and closures |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -25,7 +25,7 @@ Closure *luaF_newCclosure (lua_State *L, int nelems, Table *e) { | |||
25 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); | 25 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); |
26 | c->c.isC = 1; | 26 | c->c.isC = 1; |
27 | c->c.env = e; | 27 | c->c.env = e; |
28 | c->c.nupvalues = cast(lu_byte, nelems); | 28 | c->c.nupvalues = cast_byte(nelems); |
29 | return c; | 29 | return c; |
30 | } | 30 | } |
31 | 31 | ||
@@ -35,7 +35,7 @@ Closure *luaF_newLclosure (lua_State *L, int nelems, Table *e) { | |||
35 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); | 35 | luaC_link(L, obj2gco(c), LUA_TFUNCTION); |
36 | c->l.isC = 0; | 36 | c->l.isC = 0; |
37 | c->l.env = e; | 37 | c->l.env = e; |
38 | c->l.nupvalues = cast(lu_byte, nelems); | 38 | c->l.nupvalues = cast_byte(nelems); |
39 | while (nelems--) c->l.upvals[nelems] = NULL; | 39 | while (nelems--) c->l.upvals[nelems] = NULL; |
40 | return c; | 40 | return c; |
41 | } | 41 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lgc.c,v 2.35 2005/08/04 13:37:38 roberto Exp roberto $ | 2 | ** $Id: lgc.c,v 2.36 2005/08/24 17:06:36 roberto Exp roberto $ |
3 | ** Garbage Collector | 3 | ** Garbage Collector |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -29,11 +29,10 @@ | |||
29 | #define GCFINALIZECOST 100 | 29 | #define GCFINALIZECOST 100 |
30 | 30 | ||
31 | 31 | ||
32 | #define maskmarks \ | 32 | #define maskmarks cast_byte(~(bitmask(BLACKBIT)|WHITEBITS)) |
33 | cast(lu_byte, ~(bitmask(BLACKBIT)|WHITEBITS)) | ||
34 | 33 | ||
35 | #define makewhite(g,x) \ | 34 | #define makewhite(g,x) \ |
36 | ((x)->gch.marked = ((x)->gch.marked & maskmarks) | luaC_white(g)) | 35 | ((x)->gch.marked = cast_byte(((x)->gch.marked & maskmarks) | luaC_white(g))) |
37 | 36 | ||
38 | #define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) | 37 | #define white2gray(x) reset2bits((x)->gch.marked, WHITE0BIT, WHITE1BIT) |
39 | #define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) | 38 | #define black2gray(x) resetbit((x)->gch.marked, BLACKBIT) |
@@ -169,8 +168,8 @@ static int traversetable (global_State *g, Table *h) { | |||
169 | weakvalue = (strchr(svalue(mode), 'v') != NULL); | 168 | weakvalue = (strchr(svalue(mode), 'v') != NULL); |
170 | if (weakkey || weakvalue) { /* is really weak? */ | 169 | if (weakkey || weakvalue) { /* is really weak? */ |
171 | h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ | 170 | h->marked &= ~(KEYWEAK | VALUEWEAK); /* clear bits */ |
172 | h->marked |= cast(lu_byte, (weakkey << KEYWEAKBIT) | | 171 | h->marked |= cast_byte((weakkey << KEYWEAKBIT) | |
173 | (weakvalue << VALUEWEAKBIT)); | 172 | (weakvalue << VALUEWEAKBIT)); |
174 | h->gclist = g->weak; /* must be cleared after GC, ... */ | 173 | h->gclist = g->weak; /* must be cleared after GC, ... */ |
175 | g->weak = obj2gco(h); /* ... so put in the appropriate list */ | 174 | g->weak = obj2gco(h); /* ... so put in the appropriate list */ |
176 | } | 175 | } |
@@ -240,8 +239,8 @@ static void traverseclosure (global_State *g, Closure *cl) { | |||
240 | 239 | ||
241 | 240 | ||
242 | static void checkstacksizes (lua_State *L, StkId max) { | 241 | static void checkstacksizes (lua_State *L, StkId max) { |
243 | int ci_used = cast(int, L->ci - L->base_ci); /* number of `ci' in use */ | 242 | int ci_used = cast_int(L->ci - L->base_ci); /* number of `ci' in use */ |
244 | int s_used = cast(int, max - L->stack); /* part of stack in use */ | 243 | int s_used = cast_int(max - L->stack); /* part of stack in use */ |
245 | if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ | 244 | if (L->size_ci > LUAI_MAXCALLS) /* handling overflow? */ |
246 | return; /* do not touch the stacks */ | 245 | return; /* do not touch the stacks */ |
247 | if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) | 246 | if (4*ci_used < L->size_ci && 2*BASIC_CI_SIZE < L->size_ci) |
@@ -544,7 +543,7 @@ static void atomic (lua_State *L) { | |||
544 | propagateall(g); /* remark, to propagate `preserveness' */ | 543 | propagateall(g); /* remark, to propagate `preserveness' */ |
545 | cleartable(g->weak); /* remove collected objects from weak tables */ | 544 | cleartable(g->weak); /* remove collected objects from weak tables */ |
546 | /* flip current white */ | 545 | /* flip current white */ |
547 | g->currentwhite = cast(lu_byte, otherwhite(g)); | 546 | g->currentwhite = cast_byte(otherwhite(g)); |
548 | g->sweepstrgc = 0; | 547 | g->sweepstrgc = 0; |
549 | g->sweepgc = &g->rootgc; | 548 | g->sweepgc = &g->rootgc; |
550 | g->gcstate = GCSsweepstring; | 549 | g->gcstate = GCSsweepstring; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llex.c,v 2.15 2005/12/07 15:43:05 roberto Exp roberto $ | 2 | ** $Id: llex.c,v 2.16 2005/12/08 15:50:54 roberto Exp roberto $ |
3 | ** Lexical Analyzer | 3 | ** Lexical Analyzer |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -66,7 +66,7 @@ void luaX_init (lua_State *L) { | |||
66 | TString *ts = luaS_new(L, luaX_tokens[i]); | 66 | TString *ts = luaS_new(L, luaX_tokens[i]); |
67 | luaS_fix(ts); /* reserved words are never collected */ | 67 | luaS_fix(ts); /* reserved words are never collected */ |
68 | lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN); | 68 | lua_assert(strlen(luaX_tokens[i])+1 <= TOKEN_LEN); |
69 | ts->tsv.reserved = cast(lu_byte, i+1); /* reserved word */ | 69 | ts->tsv.reserved = cast_byte(i+1); /* reserved word */ |
70 | } | 70 | } |
71 | } | 71 | } |
72 | 72 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: llimits.h,v 1.66 2005/08/04 13:37:10 roberto Exp roberto $ | 2 | ** $Id: llimits.h,v 1.67 2005/08/24 16:15:49 roberto Exp roberto $ |
3 | ** Limits, basic types, and some other `installation-dependent' definitions | 3 | ** Limits, basic types, and some other `installation-dependent' definitions |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -66,6 +66,10 @@ typedef LUAI_UACNUMBER l_uacNumber; | |||
66 | #define cast(t, exp) ((t)(exp)) | 66 | #define cast(t, exp) ((t)(exp)) |
67 | #endif | 67 | #endif |
68 | 68 | ||
69 | #define cast_byte(i) cast(lu_byte, (i)) | ||
70 | #define cast_num(i) cast(lua_Number, (i)) | ||
71 | #define cast_int(i) cast(int, (i)) | ||
72 | |||
69 | 73 | ||
70 | 74 | ||
71 | /* | 75 | /* |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lobject.c,v 2.18 2005/08/01 04:22:23 roberto Exp roberto $ | 2 | ** $Id: lobject.c,v 2.19 2005/10/24 17:37:52 roberto Exp roberto $ |
3 | ** Some generic functions over Lua objects | 3 | ** Some generic functions over Lua objects |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -39,7 +39,7 @@ int luaO_int2fb (unsigned int x) { | |||
39 | e++; | 39 | e++; |
40 | } | 40 | } |
41 | if (x < 8) return x; | 41 | if (x < 8) return x; |
42 | else return ((e+1) << 3) | (cast(int, x) - 8); | 42 | else return ((e+1) << 3) | (cast_int(x) - 8); |
43 | } | 43 | } |
44 | 44 | ||
45 | 45 | ||
@@ -129,12 +129,12 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
129 | break; | 129 | break; |
130 | } | 130 | } |
131 | case 'd': { | 131 | case 'd': { |
132 | setnvalue(L->top, cast(lua_Number, va_arg(argp, int))); | 132 | setnvalue(L->top, cast_num(va_arg(argp, int))); |
133 | incr_top(L); | 133 | incr_top(L); |
134 | break; | 134 | break; |
135 | } | 135 | } |
136 | case 'f': { | 136 | case 'f': { |
137 | setnvalue(L->top, cast(lua_Number, va_arg(argp, l_uacNumber))); | 137 | setnvalue(L->top, cast_num(va_arg(argp, l_uacNumber))); |
138 | incr_top(L); | 138 | incr_top(L); |
139 | break; | 139 | break; |
140 | } | 140 | } |
@@ -161,7 +161,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
161 | fmt = e+2; | 161 | fmt = e+2; |
162 | } | 162 | } |
163 | pushstr(L, fmt); | 163 | pushstr(L, fmt); |
164 | luaV_concat(L, n+1, cast(int, L->top - L->base) - 1); | 164 | luaV_concat(L, n+1, cast_int(L->top - L->base) - 1); |
165 | L->top -= n; | 165 | L->top -= n; |
166 | return svalue(L->top - 1); | 166 | return svalue(L->top - 1); |
167 | } | 167 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: loslib.c,v 1.14 2005/10/21 13:47:42 roberto Exp roberto $ | 2 | ** $Id: loslib.c,v 1.15 2005/12/15 18:17:49 roberto Exp roberto $ |
3 | ** Standard Operating System library | 3 | ** Standard Operating System library |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -179,7 +179,7 @@ static int os_time (lua_State *L) { | |||
179 | if (t == (time_t)(-1)) | 179 | if (t == (time_t)(-1)) |
180 | lua_pushnil(L); | 180 | lua_pushnil(L); |
181 | else | 181 | else |
182 | lua_pushnumber(L, t); | 182 | lua_pushnumber(L, (lua_Number)t); |
183 | return 1; | 183 | return 1; |
184 | } | 184 | } |
185 | 185 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.c,v 2.38 2005/10/24 17:38:47 roberto Exp roberto $ | 2 | ** $Id: lparser.c,v 2.39 2005/12/07 15:43:05 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -166,7 +166,7 @@ static void new_localvar (LexState *ls, TString *name, int n) { | |||
166 | 166 | ||
167 | static void adjustlocalvars (LexState *ls, int nvars) { | 167 | static void adjustlocalvars (LexState *ls, int nvars) { |
168 | FuncState *fs = ls->fs; | 168 | FuncState *fs = ls->fs; |
169 | fs->nactvar = cast(lu_byte, fs->nactvar + nvars); | 169 | fs->nactvar = cast_byte(fs->nactvar + nvars); |
170 | for (; nvars; nvars--) { | 170 | for (; nvars; nvars--) { |
171 | getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; | 171 | getlocvar(fs, fs->nactvar - nvars).startpc = fs->pc; |
172 | } | 172 | } |
@@ -198,8 +198,8 @@ static int indexupvalue (FuncState *fs, TString *name, expdesc *v) { | |||
198 | f->upvalues[f->nups] = name; | 198 | f->upvalues[f->nups] = name; |
199 | luaC_objbarrier(fs->L, f, name); | 199 | luaC_objbarrier(fs->L, f, name); |
200 | lua_assert(v->k == VLOCAL || v->k == VUPVAL); | 200 | lua_assert(v->k == VLOCAL || v->k == VUPVAL); |
201 | fs->upvalues[f->nups].k = cast(lu_byte, v->k); | 201 | fs->upvalues[f->nups].k = cast_byte(v->k); |
202 | fs->upvalues[f->nups].info = cast(lu_byte, v->u.s.info); | 202 | fs->upvalues[f->nups].info = cast_byte(v->u.s.info); |
203 | return f->nups++; | 203 | return f->nups++; |
204 | } | 204 | } |
205 | 205 | ||
@@ -567,7 +567,7 @@ static void parlist (LexState *ls) { | |||
567 | } while (!f->is_vararg && testnext(ls, ',')); | 567 | } while (!f->is_vararg && testnext(ls, ',')); |
568 | } | 568 | } |
569 | adjustlocalvars(ls, nparams); | 569 | adjustlocalvars(ls, nparams); |
570 | f->numparams = fs->nactvar - (f->is_vararg & VARARG_HASARG); | 570 | f->numparams = cast_byte(fs->nactvar - (f->is_vararg & VARARG_HASARG)); |
571 | luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ | 571 | luaK_reserveregs(fs, fs->nactvar); /* reserve register for parameters */ |
572 | } | 572 | } |
573 | 573 | ||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lstring.c,v 2.6 2005/01/18 17:18:09 roberto Exp roberto $ | 2 | ** $Id: lstring.c,v 2.7 2005/02/18 12:40:02 roberto Exp roberto $ |
3 | ** String table (keeps all strings handled by Lua) | 3 | ** String table (keeps all strings handled by Lua) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -35,7 +35,7 @@ void luaS_resize (lua_State *L, int newsize) { | |||
35 | GCObject *next = p->gch.next; /* save next */ | 35 | GCObject *next = p->gch.next; /* save next */ |
36 | unsigned int h = gco2ts(p)->hash; | 36 | unsigned int h = gco2ts(p)->hash; |
37 | int h1 = lmod(h, newsize); /* new position */ | 37 | int h1 = lmod(h, newsize); /* new position */ |
38 | lua_assert(cast(int, h%newsize) == lmod(h, newsize)); | 38 | lua_assert(cast_int(h%newsize) == lmod(h, newsize)); |
39 | p->gch.next = newhash[h1]; /* chain it */ | 39 | p->gch.next = newhash[h1]; /* chain it */ |
40 | newhash[h1] = p; | 40 | newhash[h1] = p; |
41 | p = next; | 41 | p = next; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltable.c,v 2.27 2005/10/24 17:37:52 roberto Exp roberto $ | 2 | ** $Id: ltable.c,v 2.28 2005/11/25 13:29:32 roberto Exp roberto $ |
3 | ** Lua tables (hash) | 3 | ** Lua tables (hash) |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -66,7 +66,7 @@ | |||
66 | /* | 66 | /* |
67 | ** number of ints inside a lua_Number | 67 | ** number of ints inside a lua_Number |
68 | */ | 68 | */ |
69 | #define numints cast(int, sizeof(lua_Number)/sizeof(int)) | 69 | #define numints cast_int(sizeof(lua_Number)/sizeof(int)) |
70 | 70 | ||
71 | 71 | ||
72 | 72 | ||
@@ -120,7 +120,7 @@ static int arrayindex (const TValue *key) { | |||
120 | lua_Number n = nvalue(key); | 120 | lua_Number n = nvalue(key); |
121 | int k; | 121 | int k; |
122 | lua_number2int(k, n); | 122 | lua_number2int(k, n); |
123 | if (luai_numeq(cast(lua_Number, k), nvalue(key))) | 123 | if (luai_numeq(cast_num(k), nvalue(key))) |
124 | return k; | 124 | return k; |
125 | } | 125 | } |
126 | return -1; /* `key' did not match some condition */ | 126 | return -1; /* `key' did not match some condition */ |
@@ -145,7 +145,7 @@ static int findindex (lua_State *L, Table *t, StkId key) { | |||
145 | if (luaO_rawequalObj(key2tval(n), key) || | 145 | if (luaO_rawequalObj(key2tval(n), key) || |
146 | (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && | 146 | (ttype(gkey(n)) == LUA_TDEADKEY && iscollectable(key) && |
147 | gcvalue(gkey(n)) == gcvalue(key))) { | 147 | gcvalue(gkey(n)) == gcvalue(key))) { |
148 | i = cast(int, n - gnode(t, 0)); /* key index in hash table */ | 148 | i = cast_int(n - gnode(t, 0)); /* key index in hash table */ |
149 | /* hash elements are numbered after array ones */ | 149 | /* hash elements are numbered after array ones */ |
150 | return i + t->sizearray; | 150 | return i + t->sizearray; |
151 | } | 151 | } |
@@ -161,7 +161,7 @@ int luaH_next (lua_State *L, Table *t, StkId key) { | |||
161 | int i = findindex(L, t, key); /* find original element */ | 161 | int i = findindex(L, t, key); /* find original element */ |
162 | for (i++; i < t->sizearray; i++) { /* try first array part */ | 162 | for (i++; i < t->sizearray; i++) { /* try first array part */ |
163 | if (!ttisnil(&t->array[i])) { /* a non-nil value? */ | 163 | if (!ttisnil(&t->array[i])) { /* a non-nil value? */ |
164 | setnvalue(key, cast(lua_Number, i+1)); | 164 | setnvalue(key, cast_num(i+1)); |
165 | setobj2s(L, key+1, &t->array[i]); | 165 | setobj2s(L, key+1, &t->array[i]); |
166 | return 1; | 166 | return 1; |
167 | } | 167 | } |
@@ -286,7 +286,7 @@ static void setnodevector (lua_State *L, Table *t, int size) { | |||
286 | setnilvalue(gval(gnode(t, i))); | 286 | setnilvalue(gval(gnode(t, i))); |
287 | } | 287 | } |
288 | } | 288 | } |
289 | t->lsizenode = cast(lu_byte, lsize); | 289 | t->lsizenode = cast_byte(lsize); |
290 | t->lastfree = gnode(t, size); /* all positions are free */ | 290 | t->lastfree = gnode(t, size); /* all positions are free */ |
291 | } | 291 | } |
292 | 292 | ||
@@ -356,7 +356,7 @@ Table *luaH_new (lua_State *L, int narray, int nhash) { | |||
356 | Table *t = luaM_new(L, Table); | 356 | Table *t = luaM_new(L, Table); |
357 | luaC_link(L, obj2gco(t), LUA_TTABLE); | 357 | luaC_link(L, obj2gco(t), LUA_TTABLE); |
358 | t->metatable = NULL; | 358 | t->metatable = NULL; |
359 | t->flags = cast(lu_byte, ~0); | 359 | t->flags = cast_byte(~0); |
360 | /* temporary values (kept only if some malloc fails) */ | 360 | /* temporary values (kept only if some malloc fails) */ |
361 | t->array = NULL; | 361 | t->array = NULL; |
362 | t->sizearray = 0; | 362 | t->sizearray = 0; |
@@ -434,7 +434,7 @@ const TValue *luaH_getnum (Table *t, int key) { | |||
434 | if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) | 434 | if (cast(unsigned int, key-1) < cast(unsigned int, t->sizearray)) |
435 | return &t->array[key-1]; | 435 | return &t->array[key-1]; |
436 | else { | 436 | else { |
437 | lua_Number nk = cast(lua_Number, key); | 437 | lua_Number nk = cast_num(key); |
438 | Node *n = hashnum(t, nk); | 438 | Node *n = hashnum(t, nk); |
439 | do { /* check whether `key' is somewhere in the chain */ | 439 | do { /* check whether `key' is somewhere in the chain */ |
440 | if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) | 440 | if (ttisnumber(gkey(n)) && luai_numeq(nvalue(gkey(n)), nk)) |
@@ -471,7 +471,7 @@ const TValue *luaH_get (Table *t, const TValue *key) { | |||
471 | int k; | 471 | int k; |
472 | lua_Number n = nvalue(key); | 472 | lua_Number n = nvalue(key); |
473 | lua_number2int(k, n); | 473 | lua_number2int(k, n); |
474 | if (luai_numeq(cast(lua_Number, k), nvalue(key))) /* index is int? */ | 474 | if (luai_numeq(cast_num(k), nvalue(key))) /* index is int? */ |
475 | return luaH_getnum(t, k); /* use specialized version */ | 475 | return luaH_getnum(t, k); /* use specialized version */ |
476 | /* else go through */ | 476 | /* else go through */ |
477 | } | 477 | } |
@@ -508,7 +508,7 @@ TValue *luaH_setnum (lua_State *L, Table *t, int key) { | |||
508 | return cast(TValue *, p); | 508 | return cast(TValue *, p); |
509 | else { | 509 | else { |
510 | TValue k; | 510 | TValue k; |
511 | setnvalue(&k, cast(lua_Number, key)); | 511 | setnvalue(&k, cast_num(key)); |
512 | return newkey(L, t, &k); | 512 | return newkey(L, t, &k); |
513 | } | 513 | } |
514 | } | 514 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltests.c,v 2.32 2005/09/20 17:55:10 roberto Exp roberto $ | 2 | ** $Id: ltests.c,v 2.33 2005/10/06 20:47:32 roberto Exp roberto $ |
3 | ** Internal Module for Debugging of the Lua Implementation | 3 | ** Internal Module for Debugging of the Lua Implementation |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -798,7 +798,7 @@ static int getnum_aux (lua_State *L, const char **pc) { | |||
798 | int sig = 1; | 798 | int sig = 1; |
799 | skip(pc); | 799 | skip(pc); |
800 | if (**pc == '.') { | 800 | if (**pc == '.') { |
801 | res = cast(int, lua_tonumber(L, -1)); | 801 | res = cast_int(lua_tonumber(L, -1)); |
802 | lua_pop(L, 1); | 802 | lua_pop(L, 1); |
803 | (*pc)++; | 803 | (*pc)++; |
804 | return res; | 804 | return res; |
@@ -807,7 +807,7 @@ static int getnum_aux (lua_State *L, const char **pc) { | |||
807 | sig = -1; | 807 | sig = -1; |
808 | (*pc)++; | 808 | (*pc)++; |
809 | } | 809 | } |
810 | while (isdigit(cast(int, **pc))) res = res*10 + (*(*pc)++) - '0'; | 810 | while (isdigit(cast_int(**pc))) res = res*10 + (*(*pc)++) - '0'; |
811 | return sig*res; | 811 | return sig*res; |
812 | } | 812 | } |
813 | 813 | ||
@@ -994,7 +994,7 @@ static int testC (lua_State *L) { | |||
994 | #ifndef luaL_setn | 994 | #ifndef luaL_setn |
995 | else if EQ("setn") { | 995 | else if EQ("setn") { |
996 | int i = getindex; | 996 | int i = getindex; |
997 | int n = cast(int, lua_tonumber(L1, -1)); | 997 | int n = cast_int(lua_tonumber(L1, -1)); |
998 | luaL_setn(L1, i, n); | 998 | luaL_setn(L1, i, n); |
999 | lua_pop(L1, 1); | 999 | lua_pop(L1, 1); |
1000 | } | 1000 | } |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: ltm.c,v 2.5 2005/05/05 15:34:03 roberto Exp roberto $ | 2 | ** $Id: ltm.c,v 2.6 2005/05/20 15:53:42 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 | */ |
@@ -51,7 +51,7 @@ const TValue *luaT_gettm (Table *events, TMS event, TString *ename) { | |||
51 | const TValue *tm = luaH_getstr(events, ename); | 51 | const TValue *tm = luaH_getstr(events, ename); |
52 | lua_assert(event <= TM_EQ); | 52 | lua_assert(event <= TM_EQ); |
53 | if (ttisnil(tm)) { /* no tag method? */ | 53 | if (ttisnil(tm)) { /* no tag method? */ |
54 | events->flags |= cast(lu_byte, 1u<<event); /* cache this fact */ | 54 | events->flags |= cast_byte(1u<<event); /* cache this fact */ |
55 | return NULL; | 55 | return NULL; |
56 | } | 56 | } |
57 | else return tm; | 57 | else return tm; |
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.58 2005/10/24 17:37:52 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.59 2005/11/01 16:08:45 roberto Exp roberto $ |
3 | ** Lua virtual machine | 3 | ** Lua virtual machine |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -509,11 +509,11 @@ void luaV_execute (lua_State *L, int nexeccalls) { | |||
509 | const TValue *rb = RB(i); | 509 | const TValue *rb = RB(i); |
510 | switch (ttype(rb)) { | 510 | switch (ttype(rb)) { |
511 | case LUA_TTABLE: { | 511 | case LUA_TTABLE: { |
512 | setnvalue(ra, cast(lua_Number, luaH_getn(hvalue(rb)))); | 512 | setnvalue(ra, cast_num(luaH_getn(hvalue(rb)))); |
513 | break; | 513 | break; |
514 | } | 514 | } |
515 | case LUA_TSTRING: { | 515 | case LUA_TSTRING: { |
516 | setnvalue(ra, cast(lua_Number, tsvalue(rb)->len)); | 516 | setnvalue(ra, cast_num(tsvalue(rb)->len)); |
517 | break; | 517 | break; |
518 | } | 518 | } |
519 | default: { /* try metamethod */ | 519 | default: { /* try metamethod */ |
@@ -693,10 +693,10 @@ void luaV_execute (lua_State *L, int nexeccalls) { | |||
693 | int last; | 693 | int last; |
694 | Table *h; | 694 | Table *h; |
695 | if (n == 0) { | 695 | if (n == 0) { |
696 | n = cast(int, L->top - ra) - 1; | 696 | n = cast_int(L->top - ra) - 1; |
697 | L->top = L->ci->top; | 697 | L->top = L->ci->top; |
698 | } | 698 | } |
699 | if (c == 0) c = cast(int, *pc++); | 699 | if (c == 0) c = cast_int(*pc++); |
700 | runtime_check(L, ttistable(ra)); | 700 | runtime_check(L, ttistable(ra)); |
701 | h = hvalue(ra); | 701 | h = hvalue(ra); |
702 | last = ((c-1)*LFIELDS_PER_FLUSH) + n; | 702 | last = ((c-1)*LFIELDS_PER_FLUSH) + n; |
@@ -737,7 +737,7 @@ void luaV_execute (lua_State *L, int nexeccalls) { | |||
737 | int b = GETARG_B(i) - 1; | 737 | int b = GETARG_B(i) - 1; |
738 | int j; | 738 | int j; |
739 | CallInfo *ci = L->ci; | 739 | CallInfo *ci = L->ci; |
740 | int n = cast(int, ci->base - ci->func) - cl->p->numparams - 1; | 740 | int n = cast_int(ci->base - ci->func) - cl->p->numparams - 1; |
741 | if (b == LUA_MULTRET) { | 741 | if (b == LUA_MULTRET) { |
742 | Protect(luaD_checkstack(L, n)); | 742 | Protect(luaD_checkstack(L, n)); |
743 | ra = RA(i); /* previous call may change the stack */ | 743 | ra = RA(i); /* previous call may change the stack */ |