diff options
-rw-r--r-- | lcode.c | 8 | ||||
-rw-r--r-- | ldump.c | 2 | ||||
-rw-r--r-- | llimits.h | 3 | ||||
-rw-r--r-- | lobject.c | 2 | ||||
-rw-r--r-- | lopcodes.h | 40 | ||||
-rw-r--r-- | lparser.c | 4 | ||||
-rw-r--r-- | ltests.c | 30 | ||||
-rw-r--r-- | lundump.c | 2 |
8 files changed, 47 insertions, 44 deletions
@@ -1317,22 +1317,22 @@ void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k) { | |||
1317 | lu_byte temp = cast_byte(t->u.info); /* upvalue index */ | 1317 | lu_byte temp = cast_byte(t->u.info); /* upvalue index */ |
1318 | t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ | 1318 | t->u.ind.t = temp; /* (can't do a direct assignment; values overlap) */ |
1319 | lua_assert(isKstr(fs, k)); | 1319 | lua_assert(isKstr(fs, k)); |
1320 | t->u.ind.idx = cast(short, k->u.info); /* literal short string */ | 1320 | t->u.ind.idx = cast_short(k->u.info); /* literal short string */ |
1321 | t->k = VINDEXUP; | 1321 | t->k = VINDEXUP; |
1322 | } | 1322 | } |
1323 | else { | 1323 | else { |
1324 | /* register index of the table */ | 1324 | /* register index of the table */ |
1325 | t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info); | 1325 | t->u.ind.t = cast_byte((t->k == VLOCAL) ? t->u.var.ridx: t->u.info); |
1326 | if (isKstr(fs, k)) { | 1326 | if (isKstr(fs, k)) { |
1327 | t->u.ind.idx = cast(short, k->u.info); /* literal short string */ | 1327 | t->u.ind.idx = cast_short(k->u.info); /* literal short string */ |
1328 | t->k = VINDEXSTR; | 1328 | t->k = VINDEXSTR; |
1329 | } | 1329 | } |
1330 | else if (isCint(k)) { /* int. constant in proper range? */ | 1330 | else if (isCint(k)) { /* int. constant in proper range? */ |
1331 | t->u.ind.idx = cast(short, k->u.ival); | 1331 | t->u.ind.idx = cast_short(k->u.ival); |
1332 | t->k = VINDEXI; | 1332 | t->k = VINDEXI; |
1333 | } | 1333 | } |
1334 | else { | 1334 | else { |
1335 | t->u.ind.idx = cast(short, luaK_exp2anyreg(fs, k)); /* register */ | 1335 | t->u.ind.idx = cast_short(luaK_exp2anyreg(fs, k)); /* register */ |
1336 | t->k = VINDEXED; | 1336 | t->k = VINDEXED; |
1337 | } | 1337 | } |
1338 | } | 1338 | } |
@@ -108,7 +108,7 @@ static void dumpSize (DumpState *D, size_t sz) { | |||
108 | 108 | ||
109 | static void dumpInt (DumpState *D, int x) { | 109 | static void dumpInt (DumpState *D, int x) { |
110 | lua_assert(x >= 0); | 110 | lua_assert(x >= 0); |
111 | dumpVarint(D, cast(size_t, x)); | 111 | dumpVarint(D, cast_sizet(x)); |
112 | } | 112 | } |
113 | 113 | ||
114 | 114 | ||
@@ -137,12 +137,15 @@ typedef LUAI_UACINT l_uacInt; | |||
137 | #define cast_voidp(i) cast(void *, (i)) | 137 | #define cast_voidp(i) cast(void *, (i)) |
138 | #define cast_num(i) cast(lua_Number, (i)) | 138 | #define cast_num(i) cast(lua_Number, (i)) |
139 | #define cast_int(i) cast(int, (i)) | 139 | #define cast_int(i) cast(int, (i)) |
140 | #define cast_short(i) cast(short, (i)) | ||
140 | #define cast_uint(i) cast(unsigned int, (i)) | 141 | #define cast_uint(i) cast(unsigned int, (i)) |
141 | #define cast_byte(i) cast(lu_byte, (i)) | 142 | #define cast_byte(i) cast(lu_byte, (i)) |
142 | #define cast_uchar(i) cast(unsigned char, (i)) | 143 | #define cast_uchar(i) cast(unsigned char, (i)) |
143 | #define cast_char(i) cast(char, (i)) | 144 | #define cast_char(i) cast(char, (i)) |
144 | #define cast_charp(i) cast(char *, (i)) | 145 | #define cast_charp(i) cast(char *, (i)) |
145 | #define cast_sizet(i) cast(size_t, (i)) | 146 | #define cast_sizet(i) cast(size_t, (i)) |
147 | #define cast_Integer(i) cast(lua_Integer, (i)) | ||
148 | #define cast_Inst(i) cast(Instruction, (i)) | ||
146 | 149 | ||
147 | 150 | ||
148 | /* cast a signed lua_Integer to lua_Unsigned */ | 151 | /* cast a signed lua_Integer to lua_Unsigned */ |
@@ -618,7 +618,7 @@ const char *luaO_pushvfstring (lua_State *L, const char *fmt, va_list argp) { | |||
618 | } | 618 | } |
619 | case 'I': { /* a 'lua_Integer' */ | 619 | case 'I': { /* a 'lua_Integer' */ |
620 | TValue num; | 620 | TValue num; |
621 | setivalue(&num, cast(lua_Integer, va_arg(argp, l_uacInt))); | 621 | setivalue(&num, cast_Integer(va_arg(argp, l_uacInt))); |
622 | addnum2buff(&buff, &num); | 622 | addnum2buff(&buff, &num); |
623 | break; | 623 | break; |
624 | } | 624 | } |
@@ -126,14 +126,14 @@ enum OpMode {iABC, ivABC, iABx, iAsBx, iAx, isJ}; | |||
126 | 126 | ||
127 | #define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0))) | 127 | #define GET_OPCODE(i) (cast(OpCode, ((i)>>POS_OP) & MASK1(SIZE_OP,0))) |
128 | #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ | 128 | #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,POS_OP)) | \ |
129 | ((cast(Instruction, o)<<POS_OP)&MASK1(SIZE_OP,POS_OP)))) | 129 | ((cast_Inst(o)<<POS_OP)&MASK1(SIZE_OP,POS_OP)))) |
130 | 130 | ||
131 | #define checkopm(i,m) (getOpMode(GET_OPCODE(i)) == m) | 131 | #define checkopm(i,m) (getOpMode(GET_OPCODE(i)) == m) |
132 | 132 | ||
133 | 133 | ||
134 | #define getarg(i,pos,size) (cast_int(((i)>>(pos)) & MASK1(size,0))) | 134 | #define getarg(i,pos,size) (cast_int(((i)>>(pos)) & MASK1(size,0))) |
135 | #define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ | 135 | #define setarg(i,v,pos,size) ((i) = (((i)&MASK0(size,pos)) | \ |
136 | ((cast(Instruction, v)<<pos)&MASK1(size,pos)))) | 136 | ((cast_Inst(v)<<pos)&MASK1(size,pos)))) |
137 | 137 | ||
138 | #define GETARG_A(i) getarg(i, POS_A, SIZE_A) | 138 | #define GETARG_A(i) getarg(i, POS_A, SIZE_A) |
139 | #define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A) | 139 | #define SETARG_A(i,v) setarg(i, v, POS_A, SIZE_A) |
@@ -174,28 +174,28 @@ enum OpMode {iABC, ivABC, iABx, iAsBx, iAx, isJ}; | |||
174 | setarg(i, cast_uint((j)+OFFSET_sJ), POS_sJ, SIZE_sJ) | 174 | setarg(i, cast_uint((j)+OFFSET_sJ), POS_sJ, SIZE_sJ) |
175 | 175 | ||
176 | 176 | ||
177 | #define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \ | 177 | #define CREATE_ABCk(o,a,b,c,k) ((cast_Inst(o)<<POS_OP) \ |
178 | | (cast(Instruction, a)<<POS_A) \ | 178 | | (cast_Inst(a)<<POS_A) \ |
179 | | (cast(Instruction, b)<<POS_B) \ | 179 | | (cast_Inst(b)<<POS_B) \ |
180 | | (cast(Instruction, c)<<POS_C) \ | 180 | | (cast_Inst(c)<<POS_C) \ |
181 | | (cast(Instruction, k)<<POS_k)) | 181 | | (cast_Inst(k)<<POS_k)) |
182 | 182 | ||
183 | #define CREATE_vABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \ | 183 | #define CREATE_vABCk(o,a,b,c,k) ((cast_Inst(o)<<POS_OP) \ |
184 | | (cast(Instruction, a)<<POS_A) \ | 184 | | (cast_Inst(a)<<POS_A) \ |
185 | | (cast(Instruction, b)<<POS_vB) \ | 185 | | (cast_Inst(b)<<POS_vB) \ |
186 | | (cast(Instruction, c)<<POS_vC) \ | 186 | | (cast_Inst(c)<<POS_vC) \ |
187 | | (cast(Instruction, k)<<POS_k)) | 187 | | (cast_Inst(k)<<POS_k)) |
188 | 188 | ||
189 | #define CREATE_ABx(o,a,bc) ((cast(Instruction, o)<<POS_OP) \ | 189 | #define CREATE_ABx(o,a,bc) ((cast_Inst(o)<<POS_OP) \ |
190 | | (cast(Instruction, a)<<POS_A) \ | 190 | | (cast_Inst(a)<<POS_A) \ |
191 | | (cast(Instruction, bc)<<POS_Bx)) | 191 | | (cast_Inst(bc)<<POS_Bx)) |
192 | 192 | ||
193 | #define CREATE_Ax(o,a) ((cast(Instruction, o)<<POS_OP) \ | 193 | #define CREATE_Ax(o,a) ((cast_Inst(o)<<POS_OP) \ |
194 | | (cast(Instruction, a)<<POS_Ax)) | 194 | | (cast_Inst(a)<<POS_Ax)) |
195 | 195 | ||
196 | #define CREATE_sJ(o,j,k) ((cast(Instruction, o) << POS_OP) \ | 196 | #define CREATE_sJ(o,j,k) ((cast_Inst(o) << POS_OP) \ |
197 | | (cast(Instruction, j) << POS_sJ) \ | 197 | | (cast_Inst(j) << POS_sJ) \ |
198 | | (cast(Instruction, k) << POS_k)) | 198 | | (cast_Inst(k) << POS_k)) |
199 | 199 | ||
200 | 200 | ||
201 | #if !defined(MAXINDEXRK) /* (for debugging only) */ | 201 | #if !defined(MAXINDEXRK) /* (for debugging only) */ |
@@ -276,7 +276,7 @@ static LocVar *localdebuginfo (FuncState *fs, int vidx) { | |||
276 | static void init_var (FuncState *fs, expdesc *e, int vidx) { | 276 | static void init_var (FuncState *fs, expdesc *e, int vidx) { |
277 | e->f = e->t = NO_JUMP; | 277 | e->f = e->t = NO_JUMP; |
278 | e->k = VLOCAL; | 278 | e->k = VLOCAL; |
279 | e->u.var.vidx = cast(short, vidx); | 279 | e->u.var.vidx = cast_short(vidx); |
280 | e->u.var.ridx = getlocalvardesc(fs, vidx)->vd.ridx; | 280 | e->u.var.ridx = getlocalvardesc(fs, vidx)->vd.ridx; |
281 | } | 281 | } |
282 | 282 | ||
@@ -495,7 +495,7 @@ static void buildvar (LexState *ls, TString *varname, expdesc *var) { | |||
495 | luaK_exp2anyregup(fs, var); /* but could be a constant */ | 495 | luaK_exp2anyregup(fs, var); /* but could be a constant */ |
496 | codestring(&key, varname); /* key is variable name */ | 496 | codestring(&key, varname); /* key is variable name */ |
497 | luaK_indexed(fs, var, &key); /* env[varname] */ | 497 | luaK_indexed(fs, var, &key); /* env[varname] */ |
498 | var->u.ind.vidx = cast(short, info); /* mark it as a declared global */ | 498 | var->u.ind.vidx = cast_short(info); /* mark it as a declared global */ |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
@@ -910,9 +910,9 @@ static int get_limits (lua_State *L) { | |||
910 | 910 | ||
911 | static int mem_query (lua_State *L) { | 911 | static int mem_query (lua_State *L) { |
912 | if (lua_isnone(L, 1)) { | 912 | if (lua_isnone(L, 1)) { |
913 | lua_pushinteger(L, cast(lua_Integer, l_memcontrol.total)); | 913 | lua_pushinteger(L, cast_Integer(l_memcontrol.total)); |
914 | lua_pushinteger(L, cast(lua_Integer, l_memcontrol.numblocks)); | 914 | lua_pushinteger(L, cast_Integer(l_memcontrol.numblocks)); |
915 | lua_pushinteger(L, cast(lua_Integer, l_memcontrol.maxmem)); | 915 | lua_pushinteger(L, cast_Integer(l_memcontrol.maxmem)); |
916 | return 3; | 916 | return 3; |
917 | } | 917 | } |
918 | else if (lua_isnumber(L, 1)) { | 918 | else if (lua_isnumber(L, 1)) { |
@@ -926,7 +926,7 @@ static int mem_query (lua_State *L) { | |||
926 | int i; | 926 | int i; |
927 | for (i = LUA_NUMTYPES - 1; i >= 0; i--) { | 927 | for (i = LUA_NUMTYPES - 1; i >= 0; i--) { |
928 | if (strcmp(t, ttypename(i)) == 0) { | 928 | if (strcmp(t, ttypename(i)) == 0) { |
929 | lua_pushinteger(L, cast(lua_Integer, l_memcontrol.objcount[i])); | 929 | lua_pushinteger(L, cast_Integer(l_memcontrol.objcount[i])); |
930 | return 1; | 930 | return 1; |
931 | } | 931 | } |
932 | } | 932 | } |
@@ -1074,7 +1074,7 @@ static int hash_query (lua_State *L) { | |||
1074 | Table *t; | 1074 | Table *t; |
1075 | luaL_checktype(L, 2, LUA_TTABLE); | 1075 | luaL_checktype(L, 2, LUA_TTABLE); |
1076 | t = hvalue(obj_at(L, 2)); | 1076 | t = hvalue(obj_at(L, 2)); |
1077 | lua_pushinteger(L, cast(lua_Integer, luaH_mainposition(t, o) - t->node)); | 1077 | lua_pushinteger(L, cast_Integer(luaH_mainposition(t, o) - t->node)); |
1078 | } | 1078 | } |
1079 | return 1; | 1079 | return 1; |
1080 | } | 1080 | } |
@@ -1082,9 +1082,9 @@ static int hash_query (lua_State *L) { | |||
1082 | 1082 | ||
1083 | static int stacklevel (lua_State *L) { | 1083 | static int stacklevel (lua_State *L) { |
1084 | int a = 0; | 1084 | int a = 0; |
1085 | lua_pushinteger(L, cast(lua_Integer, L->top.p - L->stack.p)); | 1085 | lua_pushinteger(L, cast_Integer(L->top.p - L->stack.p)); |
1086 | lua_pushinteger(L, stacksize(L)); | 1086 | lua_pushinteger(L, stacksize(L)); |
1087 | lua_pushinteger(L, cast(lua_Integer, L->nCcalls)); | 1087 | lua_pushinteger(L, cast_Integer(L->nCcalls)); |
1088 | lua_pushinteger(L, L->nci); | 1088 | lua_pushinteger(L, L->nci); |
1089 | lua_pushinteger(L, (lua_Integer)(size_t)&a); | 1089 | lua_pushinteger(L, (lua_Integer)(size_t)&a); |
1090 | return 5; | 1090 | return 5; |
@@ -1099,9 +1099,9 @@ static int table_query (lua_State *L) { | |||
1099 | t = hvalue(obj_at(L, 1)); | 1099 | t = hvalue(obj_at(L, 1)); |
1100 | asize = t->asize; | 1100 | asize = t->asize; |
1101 | if (i == -1) { | 1101 | if (i == -1) { |
1102 | lua_pushinteger(L, cast(lua_Integer, asize)); | 1102 | lua_pushinteger(L, cast_Integer(asize)); |
1103 | lua_pushinteger(L, cast(lua_Integer, allocsizenode(t))); | 1103 | lua_pushinteger(L, cast_Integer(allocsizenode(t))); |
1104 | lua_pushinteger(L, cast(lua_Integer, asize > 0 ? *lenhint(t) : 0)); | 1104 | lua_pushinteger(L, cast_Integer(asize > 0 ? *lenhint(t) : 0)); |
1105 | return 3; | 1105 | return 3; |
1106 | } | 1106 | } |
1107 | else if (cast_uint(i) < asize) { | 1107 | else if (cast_uint(i) < asize) { |
@@ -1157,7 +1157,7 @@ static int test_codeparam (lua_State *L) { | |||
1157 | static int test_applyparam (lua_State *L) { | 1157 | static int test_applyparam (lua_State *L) { |
1158 | lua_Integer p = luaL_checkinteger(L, 1); | 1158 | lua_Integer p = luaL_checkinteger(L, 1); |
1159 | lua_Integer x = luaL_checkinteger(L, 2); | 1159 | lua_Integer x = luaL_checkinteger(L, 2); |
1160 | lua_pushinteger(L, cast(lua_Integer, luaO_applyparam(cast_byte(p), x))); | 1160 | lua_pushinteger(L, cast_Integer(luaO_applyparam(cast_byte(p), x))); |
1161 | return 1; | 1161 | return 1; |
1162 | } | 1162 | } |
1163 | 1163 | ||
@@ -1257,7 +1257,7 @@ static int pushuserdata (lua_State *L) { | |||
1257 | 1257 | ||
1258 | 1258 | ||
1259 | static int udataval (lua_State *L) { | 1259 | static int udataval (lua_State *L) { |
1260 | lua_pushinteger(L, cast(lua_Integer, cast(size_t, lua_touserdata(L, 1)))); | 1260 | lua_pushinteger(L, cast_st2S(cast_sizet(lua_touserdata(L, 1)))); |
1261 | return 1; | 1261 | return 1; |
1262 | } | 1262 | } |
1263 | 1263 | ||
@@ -1294,7 +1294,7 @@ static int num2int (lua_State *L) { | |||
1294 | 1294 | ||
1295 | 1295 | ||
1296 | static int makeseed (lua_State *L) { | 1296 | static int makeseed (lua_State *L) { |
1297 | lua_pushinteger(L, cast(lua_Integer, luaL_makeseed(L))); | 1297 | lua_pushinteger(L, cast_Integer(luaL_makeseed(L))); |
1298 | return 1; | 1298 | return 1; |
1299 | } | 1299 | } |
1300 | 1300 | ||
@@ -1638,7 +1638,7 @@ static int runC (lua_State *L, lua_State *L1, const char *pc) { | |||
1638 | } | 1638 | } |
1639 | else if EQ("func2num") { | 1639 | else if EQ("func2num") { |
1640 | lua_CFunction func = lua_tocfunction(L1, getindex); | 1640 | lua_CFunction func = lua_tocfunction(L1, getindex); |
1641 | lua_pushinteger(L1, cast(lua_Integer, cast(size_t, func))); | 1641 | lua_pushinteger(L1, cast_st2S(cast_sizet(func))); |
1642 | } | 1642 | } |
1643 | else if EQ("getfield") { | 1643 | else if EQ("getfield") { |
1644 | int t = getindex; | 1644 | int t = getindex; |
@@ -2011,7 +2011,7 @@ static int Cfunc (lua_State *L) { | |||
2011 | static int Cfunck (lua_State *L, int status, lua_KContext ctx) { | 2011 | static int Cfunck (lua_State *L, int status, lua_KContext ctx) { |
2012 | lua_pushstring(L, statcodes[status]); | 2012 | lua_pushstring(L, statcodes[status]); |
2013 | lua_setglobal(L, "status"); | 2013 | lua_setglobal(L, "status"); |
2014 | lua_pushinteger(L, cast(lua_Integer, ctx)); | 2014 | lua_pushinteger(L, cast_Integer(ctx)); |
2015 | lua_setglobal(L, "ctx"); | 2015 | lua_setglobal(L, "ctx"); |
2016 | return runC(L, L, lua_tostring(L, cast_int(ctx))); | 2016 | return runC(L, L, lua_tostring(L, cast_int(ctx))); |
2017 | } | 2017 | } |
@@ -149,7 +149,7 @@ static void loadString (LoadState *S, Proto *p, TString **sl) { | |||
149 | return; | 149 | return; |
150 | } | 150 | } |
151 | else if (size == 1) { /* previously saved string? */ | 151 | else if (size == 1) { /* previously saved string? */ |
152 | lua_Integer idx = cast(lua_Integer, loadSize(S)); /* get its index */ | 152 | lua_Integer idx = cast_st2S(loadSize(S)); /* get its index */ |
153 | TValue stv; | 153 | TValue stv; |
154 | luaH_getint(S->h, idx, &stv); /* get its value */ | 154 | luaH_getint(S->h, idx, &stv); /* get its value */ |
155 | *sl = ts = tsvalue(&stv); | 155 | *sl = ts = tsvalue(&stv); |