aboutsummaryrefslogtreecommitdiff
path: root/ltests.c
diff options
context:
space:
mode:
Diffstat (limited to 'ltests.c')
-rw-r--r--ltests.c62
1 files changed, 31 insertions, 31 deletions
diff --git a/ltests.c b/ltests.c
index ad40801e..8a6b4065 100644
--- a/ltests.c
+++ b/ltests.c
@@ -217,7 +217,7 @@ void *debug_realloc (void *ud, void *b, size_t oldsize, size_t size) {
217 mc->memlimit = limit ? strtoul(limit, NULL, 10) : ULONG_MAX; 217 mc->memlimit = limit ? strtoul(limit, NULL, 10) : ULONG_MAX;
218 } 218 }
219 if (block == NULL) { 219 if (block == NULL) {
220 type = (oldsize < LUA_NUMTYPES) ? oldsize : 0; 220 type = (oldsize < LUA_NUMTYPES) ? cast_int(oldsize) : 0;
221 oldsize = 0; 221 oldsize = 0;
222 } 222 }
223 else { 223 else {
@@ -567,7 +567,7 @@ static l_obj checkgraylist (global_State *g, GCObject *o) {
567** Check objects in gray lists. 567** Check objects in gray lists.
568*/ 568*/
569static l_obj checkgrays (global_State *g) { 569static l_obj checkgrays (global_State *g) {
570 int total = 0; /* count number of elements in all lists */ 570 l_obj total = 0; /* count number of elements in all lists */
571 if (!keepinvariant(g)) return total; 571 if (!keepinvariant(g)) return total;
572 total += checkgraylist(g, g->gray); 572 total += checkgraylist(g, g->gray);
573 total += checkgraylist(g, g->grayagain); 573 total += checkgraylist(g, g->grayagain);
@@ -778,7 +778,7 @@ static int listk (lua_State *L) {
778 luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1), 778 luaL_argcheck(L, lua_isfunction(L, 1) && !lua_iscfunction(L, 1),
779 1, "Lua function expected"); 779 1, "Lua function expected");
780 p = getproto(obj_at(L, 1)); 780 p = getproto(obj_at(L, 1));
781 lua_createtable(L, p->sizek, 0); 781 lua_createtable(L, cast_uint(p->sizek), 0);
782 for (i=0; i<p->sizek; i++) { 782 for (i=0; i<p->sizek; i++) {
783 pushobject(L, p->k+i); 783 pushobject(L, p->k+i);
784 lua_rawseti(L, -2, i+1); 784 lua_rawseti(L, -2, i+1);
@@ -794,7 +794,7 @@ static int listabslineinfo (lua_State *L) {
794 1, "Lua function expected"); 794 1, "Lua function expected");
795 p = getproto(obj_at(L, 1)); 795 p = getproto(obj_at(L, 1));
796 luaL_argcheck(L, p->abslineinfo != NULL, 1, "function has no debug info"); 796 luaL_argcheck(L, p->abslineinfo != NULL, 1, "function has no debug info");
797 lua_createtable(L, 2 * p->sizeabslineinfo, 0); 797 lua_createtable(L, 2u * cast_uint(p->sizeabslineinfo), 0);
798 for (i=0; i < p->sizeabslineinfo; i++) { 798 for (i=0; i < p->sizeabslineinfo; i++) {
799 lua_pushinteger(L, p->abslineinfo[i].pc); 799 lua_pushinteger(L, p->abslineinfo[i].pc);
800 lua_rawseti(L, -2, 2 * i + 1); 800 lua_rawseti(L, -2, 2 * i + 1);
@@ -847,9 +847,9 @@ static int get_limits (lua_State *L) {
847 847
848static int mem_query (lua_State *L) { 848static int mem_query (lua_State *L) {
849 if (lua_isnone(L, 1)) { 849 if (lua_isnone(L, 1)) {
850 lua_pushinteger(L, l_memcontrol.total); 850 lua_pushinteger(L, cast(lua_Integer, l_memcontrol.total));
851 lua_pushinteger(L, l_memcontrol.numblocks); 851 lua_pushinteger(L, cast(lua_Integer, l_memcontrol.numblocks));
852 lua_pushinteger(L, l_memcontrol.maxmem); 852 lua_pushinteger(L, cast(lua_Integer, l_memcontrol.maxmem));
853 return 3; 853 return 3;
854 } 854 }
855 else if (lua_isnumber(L, 1)) { 855 else if (lua_isnumber(L, 1)) {
@@ -863,7 +863,7 @@ static int mem_query (lua_State *L) {
863 int i; 863 int i;
864 for (i = LUA_NUMTYPES - 1; i >= 0; i--) { 864 for (i = LUA_NUMTYPES - 1; i >= 0; i--) {
865 if (strcmp(t, ttypename(i)) == 0) { 865 if (strcmp(t, ttypename(i)) == 0) {
866 lua_pushinteger(L, l_memcontrol.objcount[i]); 866 lua_pushinteger(L, cast(lua_Integer, l_memcontrol.objcount[i]));
867 return 1; 867 return 1;
868 } 868 }
869 } 869 }
@@ -874,9 +874,9 @@ static int mem_query (lua_State *L) {
874 874
875static int alloc_count (lua_State *L) { 875static int alloc_count (lua_State *L) {
876 if (lua_isnone(L, 1)) 876 if (lua_isnone(L, 1))
877 l_memcontrol.countlimit = ~0L; 877 l_memcontrol.countlimit = cast(unsigned long, ~0L);
878 else 878 else
879 l_memcontrol.countlimit = luaL_checkinteger(L, 1); 879 l_memcontrol.countlimit = cast(unsigned long, luaL_checkinteger(L, 1));
880 return 0; 880 return 0;
881} 881}
882 882
@@ -975,26 +975,26 @@ static int gc_state (lua_State *L) {
975static int hash_query (lua_State *L) { 975static int hash_query (lua_State *L) {
976 if (lua_isnone(L, 2)) { 976 if (lua_isnone(L, 2)) {
977 luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected"); 977 luaL_argcheck(L, lua_type(L, 1) == LUA_TSTRING, 1, "string expected");
978 lua_pushinteger(L, tsvalue(obj_at(L, 1))->hash); 978 lua_pushinteger(L, cast_int(tsvalue(obj_at(L, 1))->hash));
979 } 979 }
980 else { 980 else {
981 TValue *o = obj_at(L, 1); 981 TValue *o = obj_at(L, 1);
982 Table *t; 982 Table *t;
983 luaL_checktype(L, 2, LUA_TTABLE); 983 luaL_checktype(L, 2, LUA_TTABLE);
984 t = hvalue(obj_at(L, 2)); 984 t = hvalue(obj_at(L, 2));
985 lua_pushinteger(L, luaH_mainposition(t, o) - t->node); 985 lua_pushinteger(L, cast(lua_Integer, luaH_mainposition(t, o) - t->node));
986 } 986 }
987 return 1; 987 return 1;
988} 988}
989 989
990 990
991static int stacklevel (lua_State *L) { 991static int stacklevel (lua_State *L) {
992 unsigned long a = 0; 992 int a = 0;
993 lua_pushinteger(L, (L->top.p - L->stack.p)); 993 lua_pushinteger(L, cast(lua_Integer, L->top.p - L->stack.p));
994 lua_pushinteger(L, stacksize(L)); 994 lua_pushinteger(L, stacksize(L));
995 lua_pushinteger(L, L->nCcalls); 995 lua_pushinteger(L, cast(lua_Integer, L->nCcalls));
996 lua_pushinteger(L, L->nci); 996 lua_pushinteger(L, L->nci);
997 lua_pushinteger(L, (unsigned long)&a); 997 lua_pushinteger(L, (lua_Integer)(size_t)&a);
998 return 5; 998 return 5;
999} 999}
1000 1000
@@ -1007,9 +1007,9 @@ static int table_query (lua_State *L) {
1007 t = hvalue(obj_at(L, 1)); 1007 t = hvalue(obj_at(L, 1));
1008 asize = luaH_realasize(t); 1008 asize = luaH_realasize(t);
1009 if (i == -1) { 1009 if (i == -1) {
1010 lua_pushinteger(L, asize); 1010 lua_pushinteger(L, cast(lua_Integer, asize));
1011 lua_pushinteger(L, allocsizenode(t)); 1011 lua_pushinteger(L, cast(lua_Integer, allocsizenode(t)));
1012 lua_pushinteger(L, t->alimit); 1012 lua_pushinteger(L, cast(lua_Integer, t->alimit));
1013 return 3; 1013 return 3;
1014 } 1014 }
1015 else if (cast_uint(i) < asize) { 1015 else if (cast_uint(i) < asize) {
@@ -1018,7 +1018,7 @@ static int table_query (lua_State *L) {
1018 api_incr_top(L); 1018 api_incr_top(L);
1019 lua_pushnil(L); 1019 lua_pushnil(L);
1020 } 1020 }
1021 else if ((i -= asize) < sizenode(t)) { 1021 else if (cast_uint(i -= cast_int(asize)) < sizenode(t)) {
1022 TValue k; 1022 TValue k;
1023 getnodekey(L, &k, gnode(t, i)); 1023 getnodekey(L, &k, gnode(t, i));
1024 if (!isempty(gval(gnode(t, i))) || 1024 if (!isempty(gval(gnode(t, i))) ||
@@ -1054,7 +1054,7 @@ static int query_GCparams (lua_State *L) {
1054 1054
1055static int test_codeparam (lua_State *L) { 1055static int test_codeparam (lua_State *L) {
1056 lua_Integer p = luaL_checkinteger(L, 1); 1056 lua_Integer p = luaL_checkinteger(L, 1);
1057 lua_pushinteger(L, luaO_codeparam(p)); 1057 lua_pushinteger(L, luaO_codeparam(cast_uint(p)));
1058 return 1; 1058 return 1;
1059} 1059}
1060 1060
@@ -1062,7 +1062,7 @@ static int test_codeparam (lua_State *L) {
1062static int test_applyparam (lua_State *L) { 1062static int test_applyparam (lua_State *L) {
1063 lua_Integer p = luaL_checkinteger(L, 1); 1063 lua_Integer p = luaL_checkinteger(L, 1);
1064 lua_Integer x = luaL_checkinteger(L, 2); 1064 lua_Integer x = luaL_checkinteger(L, 2);
1065 lua_pushinteger(L, luaO_applyparam(p, x)); 1065 lua_pushinteger(L, luaO_applyparam(cast_byte(p), x));
1066 return 1; 1066 return 1;
1067} 1067}
1068 1068
@@ -1147,7 +1147,7 @@ static int upvalue (lua_State *L) {
1147 1147
1148static int newuserdata (lua_State *L) { 1148static int newuserdata (lua_State *L) {
1149 size_t size = cast_sizet(luaL_optinteger(L, 1, 0)); 1149 size_t size = cast_sizet(luaL_optinteger(L, 1, 0));
1150 int nuv = luaL_optinteger(L, 2, 0); 1150 int nuv = cast_int(luaL_optinteger(L, 2, 0));
1151 char *p = cast_charp(lua_newuserdatauv(L, size, nuv)); 1151 char *p = cast_charp(lua_newuserdatauv(L, size, nuv));
1152 while (size--) *p++ = '\0'; 1152 while (size--) *p++ = '\0';
1153 return 1; 1153 return 1;
@@ -1227,8 +1227,8 @@ static lua_State *getstate (lua_State *L) {
1227 1227
1228static int loadlib (lua_State *L) { 1228static int loadlib (lua_State *L) {
1229 lua_State *L1 = getstate(L); 1229 lua_State *L1 = getstate(L);
1230 int load = luaL_checkinteger(L, 2); 1230 int load = cast_int(luaL_checkinteger(L, 2));
1231 int preload = luaL_checkinteger(L, 3); 1231 int preload = cast_int(luaL_checkinteger(L, 3));
1232 luaL_openselectedlibs(L1, load, preload); 1232 luaL_openselectedlibs(L1, load, preload);
1233 luaL_requiref(L1, "T", luaB_opentests, 0); 1233 luaL_requiref(L1, "T", luaB_opentests, 0);
1234 lua_assert(lua_type(L1, -1) == LUA_TTABLE); 1234 lua_assert(lua_type(L1, -1) == LUA_TTABLE);
@@ -1490,13 +1490,13 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1490 } 1490 }
1491 else if EQ("append") { 1491 else if EQ("append") {
1492 int t = getindex; 1492 int t = getindex;
1493 int i = lua_rawlen(L1, t); 1493 int i = cast_int(lua_rawlen(L1, t));
1494 lua_rawseti(L1, t, i + 1); 1494 lua_rawseti(L1, t, i + 1);
1495 } 1495 }
1496 else if EQ("arith") { 1496 else if EQ("arith") {
1497 int op; 1497 int op;
1498 skip(&pc); 1498 skip(&pc);
1499 op = strchr(ops, *pc++) - ops; 1499 op = cast_int(strchr(ops, *pc++) - ops);
1500 lua_arith(L1, op); 1500 lua_arith(L1, op);
1501 } 1501 }
1502 else if EQ("call") { 1502 else if EQ("call") {
@@ -1538,7 +1538,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1538 } 1538 }
1539 else if EQ("func2num") { 1539 else if EQ("func2num") {
1540 lua_CFunction func = lua_tocfunction(L1, getindex); 1540 lua_CFunction func = lua_tocfunction(L1, getindex);
1541 lua_pushnumber(L1, cast_sizet(func)); 1541 lua_pushinteger(L1, cast(lua_Integer, func));
1542 } 1542 }
1543 else if EQ("getfield") { 1543 else if EQ("getfield") {
1544 int t = getindex; 1544 int t = getindex;
@@ -1624,13 +1624,13 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) {
1624 lua_pushinteger(L1, lua_resetthread(L1)); /* deprecated */ 1624 lua_pushinteger(L1, lua_resetthread(L1)); /* deprecated */
1625 } 1625 }
1626 else if EQ("newuserdata") { 1626 else if EQ("newuserdata") {
1627 lua_newuserdata(L1, getnum); 1627 lua_newuserdata(L1, cast_sizet(getnum));
1628 } 1628 }
1629 else if EQ("next") { 1629 else if EQ("next") {
1630 lua_next(L1, -2); 1630 lua_next(L1, -2);
1631 } 1631 }
1632 else if EQ("objsize") { 1632 else if EQ("objsize") {
1633 lua_pushinteger(L1, lua_rawlen(L1, getindex)); 1633 lua_pushinteger(L1, l_castU2S(lua_rawlen(L1, getindex)));
1634 } 1634 }
1635 else if EQ("pcall") { 1635 else if EQ("pcall") {
1636 int narg = getnum; 1636 int narg = getnum;
@@ -1903,7 +1903,7 @@ static int Cfunck (lua_State *L, int status, lua_KContext ctx) {
1903 lua_setglobal(L, "status"); 1903 lua_setglobal(L, "status");
1904 lua_pushinteger(L, ctx); 1904 lua_pushinteger(L, ctx);
1905 lua_setglobal(L, "ctx"); 1905 lua_setglobal(L, "ctx");
1906 return runC(L, L, lua_tostring(L, ctx)); 1906 return runC(L, L, lua_tostring(L, cast_int(ctx)));
1907} 1907}
1908 1908
1909 1909