diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-05-02 15:17:59 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2018-05-02 15:17:59 -0300 |
commit | e64e20ac8136b6cf53601127fc5c69310d644eeb (patch) | |
tree | 614b2da18d9c41882f556266e921c50dcac35d75 /lvm.c | |
parent | deb807837c1ed327d6069fb6676e624784d01e22 (diff) | |
download | lua-e64e20ac8136b6cf53601127fc5c69310d644eeb.tar.gz lua-e64e20ac8136b6cf53601127fc5c69310d644eeb.tar.bz2 lua-e64e20ac8136b6cf53601127fc5c69310d644eeb.zip |
minimizing the code ran by 'vmfetch' + no more 'vra'
(the code is simpler without 'vra' and conversion is a no-op)
Diffstat (limited to 'lvm.c')
-rw-r--r-- | lvm.c | 222 |
1 files changed, 109 insertions, 113 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lvm.c,v 2.352 2018/04/02 17:52:07 roberto Exp roberto $ | 2 | ** $Id: lvm.c,v 2.353 2018/04/04 14:23:41 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 | */ |
@@ -489,7 +489,7 @@ int luaV_equalobj (lua_State *L, const TValue *t1, const TValue *t2) { | |||
489 | case LUA_TNIL: return 1; | 489 | case LUA_TNIL: return 1; |
490 | case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2)); | 490 | case LUA_TNUMINT: return (ivalue(t1) == ivalue(t2)); |
491 | case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); | 491 | case LUA_TNUMFLT: return luai_numeq(fltvalue(t1), fltvalue(t2)); |
492 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1 !! */ | 492 | case LUA_TBOOLEAN: return bvalue(t1) == bvalue(t2); /* true must be 1! */ |
493 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); | 493 | case LUA_TLIGHTUSERDATA: return pvalue(t1) == pvalue(t2); |
494 | case LUA_TLCF: return fvalue(t1) == fvalue(t2); | 494 | case LUA_TLCF: return fvalue(t1) == fvalue(t2); |
495 | case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); | 495 | case LUA_TSHRSTR: return eqshrstr(tsvalue(t1), tsvalue(t2)); |
@@ -867,15 +867,12 @@ void luaV_finishOp (lua_State *L) { | |||
867 | 867 | ||
868 | /* fetch an instruction and prepare its execution */ | 868 | /* fetch an instruction and prepare its execution */ |
869 | #define vmfetch() { \ | 869 | #define vmfetch() { \ |
870 | i = *(pc++); \ | 870 | if (trap) { /* stack reallocation or hooks? */ \ |
871 | if (trap) { \ | 871 | trap = luaG_traceexec(L, pc); /* handle hooks */ \ |
872 | if (!(L->hookmask & (LUA_MASKLINE | LUA_MASKCOUNT))) \ | 872 | updatebase(ci); /* correct stack */ \ |
873 | trap = ci->u.l.trap = 0; /* no need to stop again */ \ | ||
874 | else { savepc(L); luaG_traceexec(L); } \ | ||
875 | updatebase(ci); /* the trap may be just for that */ \ | ||
876 | } \ | 873 | } \ |
874 | i = *(pc++); \ | ||
877 | ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \ | 875 | ra = RA(i); /* WARNING: any stack reallocation invalidates 'ra' */ \ |
878 | vra = s2v(ra); \ | ||
879 | } | 876 | } |
880 | 877 | ||
881 | #define vmdispatch(o) switch(o) | 878 | #define vmdispatch(o) switch(o) |
@@ -899,7 +896,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
899 | pc = ci->u.l.savedpc; | 896 | pc = ci->u.l.savedpc; |
900 | if (trap) { | 897 | if (trap) { |
901 | if (cl->p->is_vararg) | 898 | if (cl->p->is_vararg) |
902 | trap = 0; /* hooks will start with PREPVARARG instruction */ | 899 | trap = 0; /* hooks will start after PREPVARARG instruction */ |
903 | else if (pc == cl->p->code) /* first instruction (not resuming)? */ | 900 | else if (pc == cl->p->code) /* first instruction (not resuming)? */ |
904 | luaD_hookcall(L, ci); | 901 | luaD_hookcall(L, ci); |
905 | ci->u.l.trap = 1; /* there may be other hooks */ | 902 | ci->u.l.trap = 1; /* there may be other hooks */ |
@@ -910,7 +907,6 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
910 | int cond; /* flag for conditional jumps */ | 907 | int cond; /* flag for conditional jumps */ |
911 | Instruction i; /* instruction being executed */ | 908 | Instruction i; /* instruction being executed */ |
912 | StkId ra; /* instruction's A register */ | 909 | StkId ra; /* instruction's A register */ |
913 | TValue *vra; /* corresponding value */ | ||
914 | vmfetch(); | 910 | vmfetch(); |
915 | lua_assert(base == ci->func + 1); | 911 | lua_assert(base == ci->func + 1); |
916 | lua_assert(base <= L->top && L->top < L->stack + L->stacksize); | 912 | lua_assert(base <= L->top && L->top < L->stack + L->stacksize); |
@@ -927,12 +923,12 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
927 | } | 923 | } |
928 | vmcase(OP_LOADI) { | 924 | vmcase(OP_LOADI) { |
929 | lua_Integer b = GETARG_sBx(i); | 925 | lua_Integer b = GETARG_sBx(i); |
930 | setivalue(vra, b); | 926 | setivalue(s2v(ra), b); |
931 | vmbreak; | 927 | vmbreak; |
932 | } | 928 | } |
933 | vmcase(OP_LOADF) { | 929 | vmcase(OP_LOADF) { |
934 | int b = GETARG_sBx(i); | 930 | int b = GETARG_sBx(i); |
935 | setfltvalue(vra, cast_num(b)); | 931 | setfltvalue(s2v(ra), cast_num(b)); |
936 | vmbreak; | 932 | vmbreak; |
937 | } | 933 | } |
938 | vmcase(OP_LOADKX) { | 934 | vmcase(OP_LOADKX) { |
@@ -942,7 +938,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
942 | vmbreak; | 938 | vmbreak; |
943 | } | 939 | } |
944 | vmcase(OP_LOADBOOL) { | 940 | vmcase(OP_LOADBOOL) { |
945 | setbvalue(vra, GETARG_B(i)); | 941 | setbvalue(s2v(ra), GETARG_B(i)); |
946 | if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ | 942 | if (GETARG_C(i)) pc++; /* skip next instruction (if C) */ |
947 | vmbreak; | 943 | vmbreak; |
948 | } | 944 | } |
@@ -960,8 +956,8 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
960 | } | 956 | } |
961 | vmcase(OP_SETUPVAL) { | 957 | vmcase(OP_SETUPVAL) { |
962 | UpVal *uv = cl->upvals[GETARG_B(i)]; | 958 | UpVal *uv = cl->upvals[GETARG_B(i)]; |
963 | setobj(L, uv->v, vra); | 959 | setobj(L, uv->v, s2v(ra)); |
964 | luaC_barrier(L, uv, vra); | 960 | luaC_barrier(L, uv, s2v(ra)); |
965 | vmbreak; | 961 | vmbreak; |
966 | } | 962 | } |
967 | vmcase(OP_GETTABUP) { | 963 | vmcase(OP_GETTABUP) { |
@@ -1035,25 +1031,25 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1035 | TValue *rc = RKC(i); /* value */ | 1031 | TValue *rc = RKC(i); /* value */ |
1036 | lua_Unsigned n; | 1032 | lua_Unsigned n; |
1037 | if (ttisinteger(rb) /* fast track for integers? */ | 1033 | if (ttisinteger(rb) /* fast track for integers? */ |
1038 | ? (n = ivalue(rb), luaV_fastgeti(L, vra, n, slot)) | 1034 | ? (n = ivalue(rb), luaV_fastgeti(L, s2v(ra), n, slot)) |
1039 | : luaV_fastget(L, vra, rb, slot, luaH_get)) { | 1035 | : luaV_fastget(L, s2v(ra), rb, slot, luaH_get)) { |
1040 | luaV_finishfastset(L, vra, slot, rc); | 1036 | luaV_finishfastset(L, s2v(ra), slot, rc); |
1041 | } | 1037 | } |
1042 | else | 1038 | else |
1043 | Protect(luaV_finishset(L, vra, rb, rc, slot)); | 1039 | Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); |
1044 | vmbreak; | 1040 | vmbreak; |
1045 | } | 1041 | } |
1046 | vmcase(OP_SETI) { | 1042 | vmcase(OP_SETI) { |
1047 | const TValue *slot; | 1043 | const TValue *slot; |
1048 | int c = GETARG_B(i); | 1044 | int c = GETARG_B(i); |
1049 | TValue *rc = RKC(i); | 1045 | TValue *rc = RKC(i); |
1050 | if (luaV_fastgeti(L, vra, c, slot)) { | 1046 | if (luaV_fastgeti(L, s2v(ra), c, slot)) { |
1051 | luaV_finishfastset(L, vra, slot, rc); | 1047 | luaV_finishfastset(L, s2v(ra), slot, rc); |
1052 | } | 1048 | } |
1053 | else { | 1049 | else { |
1054 | TValue key; | 1050 | TValue key; |
1055 | setivalue(&key, c); | 1051 | setivalue(&key, c); |
1056 | Protect(luaV_finishset(L, vra, &key, rc, slot)); | 1052 | Protect(luaV_finishset(L, s2v(ra), &key, rc, slot)); |
1057 | } | 1053 | } |
1058 | vmbreak; | 1054 | vmbreak; |
1059 | } | 1055 | } |
@@ -1062,11 +1058,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1062 | TValue *rb = KB(i); | 1058 | TValue *rb = KB(i); |
1063 | TValue *rc = RKC(i); | 1059 | TValue *rc = RKC(i); |
1064 | TString *key = tsvalue(rb); /* key must be a string */ | 1060 | TString *key = tsvalue(rb); /* key must be a string */ |
1065 | if (luaV_fastget(L, vra, key, slot, luaH_getshortstr)) { | 1061 | if (luaV_fastget(L, s2v(ra), key, slot, luaH_getshortstr)) { |
1066 | luaV_finishfastset(L, vra, slot, rc); | 1062 | luaV_finishfastset(L, s2v(ra), slot, rc); |
1067 | } | 1063 | } |
1068 | else | 1064 | else |
1069 | Protect(luaV_finishset(L, vra, rb, rc, slot)); | 1065 | Protect(luaV_finishset(L, s2v(ra), rb, rc, slot)); |
1070 | vmbreak; | 1066 | vmbreak; |
1071 | } | 1067 | } |
1072 | vmcase(OP_NEWTABLE) { | 1068 | vmcase(OP_NEWTABLE) { |
@@ -1099,10 +1095,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1099 | int ic = GETARG_sC(i); | 1095 | int ic = GETARG_sC(i); |
1100 | lua_Number nb; | 1096 | lua_Number nb; |
1101 | if (ttisinteger(rb)) { | 1097 | if (ttisinteger(rb)) { |
1102 | setivalue(vra, intop(+, ivalue(rb), ic)); | 1098 | setivalue(s2v(ra), intop(+, ivalue(rb), ic)); |
1103 | } | 1099 | } |
1104 | else if (tonumberns(rb, nb)) { | 1100 | else if (tonumberns(rb, nb)) { |
1105 | setfltvalue(vra, luai_numadd(L, nb, cast_num(ic))); | 1101 | setfltvalue(s2v(ra), luai_numadd(L, nb, cast_num(ic))); |
1106 | } | 1102 | } |
1107 | else | 1103 | else |
1108 | Protect(luaT_trybiniTM(L, rb, ic, GETARG_k(i), ra, TM_ADD)); | 1104 | Protect(luaT_trybiniTM(L, rb, ic, GETARG_k(i), ra, TM_ADD)); |
@@ -1113,10 +1109,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1113 | int ic = GETARG_sC(i); | 1109 | int ic = GETARG_sC(i); |
1114 | lua_Number nb; | 1110 | lua_Number nb; |
1115 | if (ttisinteger(rb)) { | 1111 | if (ttisinteger(rb)) { |
1116 | setivalue(vra, intop(-, ivalue(rb), ic)); | 1112 | setivalue(s2v(ra), intop(-, ivalue(rb), ic)); |
1117 | } | 1113 | } |
1118 | else if (tonumberns(rb, nb)) { | 1114 | else if (tonumberns(rb, nb)) { |
1119 | setfltvalue(vra, luai_numsub(L, nb, cast_num(ic))); | 1115 | setfltvalue(s2v(ra), luai_numsub(L, nb, cast_num(ic))); |
1120 | } | 1116 | } |
1121 | else | 1117 | else |
1122 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_SUB)); | 1118 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_SUB)); |
@@ -1127,10 +1123,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1127 | int ic = GETARG_sC(i); | 1123 | int ic = GETARG_sC(i); |
1128 | lua_Number nb; | 1124 | lua_Number nb; |
1129 | if (ttisinteger(rb)) { | 1125 | if (ttisinteger(rb)) { |
1130 | setivalue(vra, intop(*, ivalue(rb), ic)); | 1126 | setivalue(s2v(ra), intop(*, ivalue(rb), ic)); |
1131 | } | 1127 | } |
1132 | else if (tonumberns(rb, nb)) { | 1128 | else if (tonumberns(rb, nb)) { |
1133 | setfltvalue(vra, luai_nummul(L, nb, cast_num(ic))); | 1129 | setfltvalue(s2v(ra), luai_nummul(L, nb, cast_num(ic))); |
1134 | } | 1130 | } |
1135 | else | 1131 | else |
1136 | Protect(luaT_trybiniTM(L, rb, ic, GETARG_k(i), ra, TM_MUL)); | 1132 | Protect(luaT_trybiniTM(L, rb, ic, GETARG_k(i), ra, TM_MUL)); |
@@ -1141,13 +1137,13 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1141 | int ic = GETARG_sC(i); | 1137 | int ic = GETARG_sC(i); |
1142 | lua_Number nb; | 1138 | lua_Number nb; |
1143 | if (ttisinteger(rb)) { | 1139 | if (ttisinteger(rb)) { |
1144 | setivalue(vra, luaV_mod(L, ivalue(rb), ic)); | 1140 | setivalue(s2v(ra), luaV_mod(L, ivalue(rb), ic)); |
1145 | } | 1141 | } |
1146 | else if (tonumberns(rb, nb)) { | 1142 | else if (tonumberns(rb, nb)) { |
1147 | lua_Number m; | 1143 | lua_Number m; |
1148 | lua_Number nc = cast_num(ic); | 1144 | lua_Number nc = cast_num(ic); |
1149 | luai_nummod(L, nb, nc, m); | 1145 | luai_nummod(L, nb, nc, m); |
1150 | setfltvalue(vra, m); | 1146 | setfltvalue(s2v(ra), m); |
1151 | } | 1147 | } |
1152 | else | 1148 | else |
1153 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_MOD)); | 1149 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_MOD)); |
@@ -1159,7 +1155,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1159 | lua_Number nb; | 1155 | lua_Number nb; |
1160 | if (tonumberns(rb, nb)) { | 1156 | if (tonumberns(rb, nb)) { |
1161 | lua_Number nc = cast_num(ic); | 1157 | lua_Number nc = cast_num(ic); |
1162 | setfltvalue(vra, luai_numpow(L, nb, nc)); | 1158 | setfltvalue(s2v(ra), luai_numpow(L, nb, nc)); |
1163 | } | 1159 | } |
1164 | else | 1160 | else |
1165 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_POW)); | 1161 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_POW)); |
@@ -1171,7 +1167,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1171 | lua_Number nb; | 1167 | lua_Number nb; |
1172 | if (tonumberns(rb, nb)) { | 1168 | if (tonumberns(rb, nb)) { |
1173 | lua_Number nc = cast_num(ic); | 1169 | lua_Number nc = cast_num(ic); |
1174 | setfltvalue(vra, luai_numdiv(L, nb, nc)); | 1170 | setfltvalue(s2v(ra), luai_numdiv(L, nb, nc)); |
1175 | } | 1171 | } |
1176 | else | 1172 | else |
1177 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_DIV)); | 1173 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_DIV)); |
@@ -1182,11 +1178,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1182 | int ic = GETARG_sC(i); | 1178 | int ic = GETARG_sC(i); |
1183 | lua_Number nb; | 1179 | lua_Number nb; |
1184 | if (ttisinteger(rb)) { | 1180 | if (ttisinteger(rb)) { |
1185 | setivalue(vra, luaV_div(L, ivalue(rb), ic)); | 1181 | setivalue(s2v(ra), luaV_div(L, ivalue(rb), ic)); |
1186 | } | 1182 | } |
1187 | else if (tonumberns(rb, nb)) { | 1183 | else if (tonumberns(rb, nb)) { |
1188 | lua_Number nc = cast_num(ic); | 1184 | lua_Number nc = cast_num(ic); |
1189 | setfltvalue(vra, luai_numdiv(L, nb, nc)); | 1185 | setfltvalue(s2v(ra), luai_numdiv(L, nb, nc)); |
1190 | } | 1186 | } |
1191 | else | 1187 | else |
1192 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_IDIV)); | 1188 | Protect(luaT_trybiniTM(L, rb, ic, 0, ra, TM_IDIV)); |
@@ -1198,10 +1194,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1198 | lua_Number nb; lua_Number nc; | 1194 | lua_Number nb; lua_Number nc; |
1199 | if (ttisinteger(rb) && ttisinteger(rc)) { | 1195 | if (ttisinteger(rb) && ttisinteger(rc)) { |
1200 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); | 1196 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); |
1201 | setivalue(vra, intop(+, ib, ic)); | 1197 | setivalue(s2v(ra), intop(+, ib, ic)); |
1202 | } | 1198 | } |
1203 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1199 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1204 | setfltvalue(vra, luai_numadd(L, nb, nc)); | 1200 | setfltvalue(s2v(ra), luai_numadd(L, nb, nc)); |
1205 | } | 1201 | } |
1206 | else | 1202 | else |
1207 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); | 1203 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_ADD)); |
@@ -1213,10 +1209,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1213 | lua_Number nb; lua_Number nc; | 1209 | lua_Number nb; lua_Number nc; |
1214 | if (ttisinteger(rb) && ttisinteger(rc)) { | 1210 | if (ttisinteger(rb) && ttisinteger(rc)) { |
1215 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); | 1211 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); |
1216 | setivalue(vra, intop(-, ib, ic)); | 1212 | setivalue(s2v(ra), intop(-, ib, ic)); |
1217 | } | 1213 | } |
1218 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1214 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1219 | setfltvalue(vra, luai_numsub(L, nb, nc)); | 1215 | setfltvalue(s2v(ra), luai_numsub(L, nb, nc)); |
1220 | } | 1216 | } |
1221 | else | 1217 | else |
1222 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); | 1218 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SUB)); |
@@ -1228,10 +1224,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1228 | lua_Number nb; lua_Number nc; | 1224 | lua_Number nb; lua_Number nc; |
1229 | if (ttisinteger(rb) && ttisinteger(rc)) { | 1225 | if (ttisinteger(rb) && ttisinteger(rc)) { |
1230 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); | 1226 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); |
1231 | setivalue(vra, intop(*, ib, ic)); | 1227 | setivalue(s2v(ra), intop(*, ib, ic)); |
1232 | } | 1228 | } |
1233 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1229 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1234 | setfltvalue(vra, luai_nummul(L, nb, nc)); | 1230 | setfltvalue(s2v(ra), luai_nummul(L, nb, nc)); |
1235 | } | 1231 | } |
1236 | else | 1232 | else |
1237 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); | 1233 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_MUL)); |
@@ -1242,7 +1238,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1242 | TValue *rc = vRC(i); | 1238 | TValue *rc = vRC(i); |
1243 | lua_Number nb; lua_Number nc; | 1239 | lua_Number nb; lua_Number nc; |
1244 | if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1240 | if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1245 | setfltvalue(vra, luai_numdiv(L, nb, nc)); | 1241 | setfltvalue(s2v(ra), luai_numdiv(L, nb, nc)); |
1246 | } | 1242 | } |
1247 | else | 1243 | else |
1248 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); | 1244 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_DIV)); |
@@ -1253,7 +1249,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1253 | TValue *p2 = KC(i); | 1249 | TValue *p2 = KC(i); |
1254 | lua_Integer i1; | 1250 | lua_Integer i1; |
1255 | if (tointegerns(p1, &i1)) { | 1251 | if (tointegerns(p1, &i1)) { |
1256 | setivalue(vra, intop(&, i1, ivalue(p2))); | 1252 | setivalue(s2v(ra), intop(&, i1, ivalue(p2))); |
1257 | } | 1253 | } |
1258 | else | 1254 | else |
1259 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BAND)); | 1255 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BAND)); |
@@ -1264,7 +1260,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1264 | TValue *p2 = KC(i); | 1260 | TValue *p2 = KC(i); |
1265 | lua_Integer i1; | 1261 | lua_Integer i1; |
1266 | if (tointegerns(p1, &i1)) { | 1262 | if (tointegerns(p1, &i1)) { |
1267 | setivalue(vra, intop(|, i1, ivalue(p2))); | 1263 | setivalue(s2v(ra), intop(|, i1, ivalue(p2))); |
1268 | } | 1264 | } |
1269 | else | 1265 | else |
1270 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BOR)); | 1266 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BOR)); |
@@ -1275,7 +1271,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1275 | TValue *p2 = KC(i); | 1271 | TValue *p2 = KC(i); |
1276 | lua_Integer i1; | 1272 | lua_Integer i1; |
1277 | if (tointegerns(p1, &i1)) { | 1273 | if (tointegerns(p1, &i1)) { |
1278 | setivalue(vra, intop(^, i1, ivalue(p2))); | 1274 | setivalue(s2v(ra), intop(^, i1, ivalue(p2))); |
1279 | } | 1275 | } |
1280 | else | 1276 | else |
1281 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BXOR)); | 1277 | Protect(luaT_trybinassocTM(L, p1, p2, ra, TESTARG_k(i), TM_BXOR)); |
@@ -1286,7 +1282,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1286 | TValue *rc = vRC(i); | 1282 | TValue *rc = vRC(i); |
1287 | lua_Integer ib; lua_Integer ic; | 1283 | lua_Integer ib; lua_Integer ic; |
1288 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { | 1284 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { |
1289 | setivalue(vra, intop(&, ib, ic)); | 1285 | setivalue(s2v(ra), intop(&, ib, ic)); |
1290 | } | 1286 | } |
1291 | else | 1287 | else |
1292 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); | 1288 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BAND)); |
@@ -1297,7 +1293,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1297 | TValue *rc = vRC(i); | 1293 | TValue *rc = vRC(i); |
1298 | lua_Integer ib; lua_Integer ic; | 1294 | lua_Integer ib; lua_Integer ic; |
1299 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { | 1295 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { |
1300 | setivalue(vra, intop(|, ib, ic)); | 1296 | setivalue(s2v(ra), intop(|, ib, ic)); |
1301 | } | 1297 | } |
1302 | else | 1298 | else |
1303 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); | 1299 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BOR)); |
@@ -1308,7 +1304,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1308 | TValue *rc = vRC(i); | 1304 | TValue *rc = vRC(i); |
1309 | lua_Integer ib; lua_Integer ic; | 1305 | lua_Integer ib; lua_Integer ic; |
1310 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { | 1306 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { |
1311 | setivalue(vra, intop(^, ib, ic)); | 1307 | setivalue(s2v(ra), intop(^, ib, ic)); |
1312 | } | 1308 | } |
1313 | else | 1309 | else |
1314 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); | 1310 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_BXOR)); |
@@ -1319,7 +1315,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1319 | int ic = GETARG_sC(i); | 1315 | int ic = GETARG_sC(i); |
1320 | lua_Integer ib; | 1316 | lua_Integer ib; |
1321 | if (tointegerns(rb, &ib)) { | 1317 | if (tointegerns(rb, &ib)) { |
1322 | setivalue(vra, luaV_shiftl(ib, -ic)); | 1318 | setivalue(s2v(ra), luaV_shiftl(ib, -ic)); |
1323 | } | 1319 | } |
1324 | else { | 1320 | else { |
1325 | TMS ev = TM_SHR; | 1321 | TMS ev = TM_SHR; |
@@ -1335,7 +1331,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1335 | int ic = GETARG_sC(i); | 1331 | int ic = GETARG_sC(i); |
1336 | lua_Integer ib; | 1332 | lua_Integer ib; |
1337 | if (tointegerns(rb, &ib)) { | 1333 | if (tointegerns(rb, &ib)) { |
1338 | setivalue(vra, luaV_shiftl(ic, ib)); | 1334 | setivalue(s2v(ra), luaV_shiftl(ic, ib)); |
1339 | } | 1335 | } |
1340 | else | 1336 | else |
1341 | Protect(luaT_trybiniTM(L, rb, ic, 1, ra, TM_SHL)); | 1337 | Protect(luaT_trybiniTM(L, rb, ic, 1, ra, TM_SHL)); |
@@ -1346,7 +1342,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1346 | TValue *rc = vRC(i); | 1342 | TValue *rc = vRC(i); |
1347 | lua_Integer ib; lua_Integer ic; | 1343 | lua_Integer ib; lua_Integer ic; |
1348 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { | 1344 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { |
1349 | setivalue(vra, luaV_shiftl(ib, ic)); | 1345 | setivalue(s2v(ra), luaV_shiftl(ib, ic)); |
1350 | } | 1346 | } |
1351 | else | 1347 | else |
1352 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); | 1348 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHL)); |
@@ -1357,7 +1353,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1357 | TValue *rc = vRC(i); | 1353 | TValue *rc = vRC(i); |
1358 | lua_Integer ib; lua_Integer ic; | 1354 | lua_Integer ib; lua_Integer ic; |
1359 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { | 1355 | if (tointegerns(rb, &ib) && tointegerns(rc, &ic)) { |
1360 | setivalue(vra, luaV_shiftl(ib, -ic)); | 1356 | setivalue(s2v(ra), luaV_shiftl(ib, -ic)); |
1361 | } | 1357 | } |
1362 | else | 1358 | else |
1363 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); | 1359 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_SHR)); |
@@ -1369,12 +1365,12 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1369 | lua_Number nb; lua_Number nc; | 1365 | lua_Number nb; lua_Number nc; |
1370 | if (ttisinteger(rb) && ttisinteger(rc)) { | 1366 | if (ttisinteger(rb) && ttisinteger(rc)) { |
1371 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); | 1367 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); |
1372 | setivalue(vra, luaV_mod(L, ib, ic)); | 1368 | setivalue(s2v(ra), luaV_mod(L, ib, ic)); |
1373 | } | 1369 | } |
1374 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1370 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1375 | lua_Number m; | 1371 | lua_Number m; |
1376 | luai_nummod(L, nb, nc, m); | 1372 | luai_nummod(L, nb, nc, m); |
1377 | setfltvalue(vra, m); | 1373 | setfltvalue(s2v(ra), m); |
1378 | } | 1374 | } |
1379 | else | 1375 | else |
1380 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); | 1376 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_MOD)); |
@@ -1386,10 +1382,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1386 | lua_Number nb; lua_Number nc; | 1382 | lua_Number nb; lua_Number nc; |
1387 | if (ttisinteger(rb) && ttisinteger(rc)) { | 1383 | if (ttisinteger(rb) && ttisinteger(rc)) { |
1388 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); | 1384 | lua_Integer ib = ivalue(rb); lua_Integer ic = ivalue(rc); |
1389 | setivalue(vra, luaV_div(L, ib, ic)); | 1385 | setivalue(s2v(ra), luaV_div(L, ib, ic)); |
1390 | } | 1386 | } |
1391 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1387 | else if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1392 | setfltvalue(vra, luai_numidiv(L, nb, nc)); | 1388 | setfltvalue(s2v(ra), luai_numidiv(L, nb, nc)); |
1393 | } | 1389 | } |
1394 | else | 1390 | else |
1395 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); | 1391 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_IDIV)); |
@@ -1400,7 +1396,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1400 | TValue *rc = vRC(i); | 1396 | TValue *rc = vRC(i); |
1401 | lua_Number nb; lua_Number nc; | 1397 | lua_Number nb; lua_Number nc; |
1402 | if (tonumberns(rb, nb) && tonumberns(rc, nc)) { | 1398 | if (tonumberns(rb, nb) && tonumberns(rc, nc)) { |
1403 | setfltvalue(vra, luai_numpow(L, nb, nc)); | 1399 | setfltvalue(s2v(ra), luai_numpow(L, nb, nc)); |
1404 | } | 1400 | } |
1405 | else | 1401 | else |
1406 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); | 1402 | Protect(luaT_trybinTM(L, rb, rc, ra, TM_POW)); |
@@ -1411,10 +1407,10 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1411 | lua_Number nb; | 1407 | lua_Number nb; |
1412 | if (ttisinteger(rb)) { | 1408 | if (ttisinteger(rb)) { |
1413 | lua_Integer ib = ivalue(rb); | 1409 | lua_Integer ib = ivalue(rb); |
1414 | setivalue(vra, intop(-, 0, ib)); | 1410 | setivalue(s2v(ra), intop(-, 0, ib)); |
1415 | } | 1411 | } |
1416 | else if (tonumberns(rb, nb)) { | 1412 | else if (tonumberns(rb, nb)) { |
1417 | setfltvalue(vra, luai_numunm(L, nb)); | 1413 | setfltvalue(s2v(ra), luai_numunm(L, nb)); |
1418 | } | 1414 | } |
1419 | else | 1415 | else |
1420 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); | 1416 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_UNM)); |
@@ -1424,7 +1420,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1424 | TValue *rb = vRB(i); | 1420 | TValue *rb = vRB(i); |
1425 | lua_Integer ib; | 1421 | lua_Integer ib; |
1426 | if (tointegerns(rb, &ib)) { | 1422 | if (tointegerns(rb, &ib)) { |
1427 | setivalue(vra, intop(^, ~l_castS2U(0), ib)); | 1423 | setivalue(s2v(ra), intop(^, ~l_castS2U(0), ib)); |
1428 | } | 1424 | } |
1429 | else | 1425 | else |
1430 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); | 1426 | Protect(luaT_trybinTM(L, rb, rb, ra, TM_BNOT)); |
@@ -1433,7 +1429,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1433 | vmcase(OP_NOT) { | 1429 | vmcase(OP_NOT) { |
1434 | TValue *rb = vRB(i); | 1430 | TValue *rb = vRB(i); |
1435 | int nrb = l_isfalse(rb); /* next assignment may change this value */ | 1431 | int nrb = l_isfalse(rb); /* next assignment may change this value */ |
1436 | setbvalue(vra, nrb); | 1432 | setbvalue(s2v(ra), nrb); |
1437 | vmbreak; | 1433 | vmbreak; |
1438 | } | 1434 | } |
1439 | vmcase(OP_LEN) { | 1435 | vmcase(OP_LEN) { |
@@ -1457,45 +1453,45 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1457 | } | 1453 | } |
1458 | vmcase(OP_EQ) { | 1454 | vmcase(OP_EQ) { |
1459 | TValue *rb = vRB(i); | 1455 | TValue *rb = vRB(i); |
1460 | Protect(cond = luaV_equalobj(L, vra, rb)); | 1456 | Protect(cond = luaV_equalobj(L, s2v(ra), rb)); |
1461 | docondjump(); | 1457 | docondjump(); |
1462 | vmbreak; | 1458 | vmbreak; |
1463 | } | 1459 | } |
1464 | vmcase(OP_LT) { | 1460 | vmcase(OP_LT) { |
1465 | TValue *rb = vRB(i); | 1461 | TValue *rb = vRB(i); |
1466 | if (ttisinteger(vra) && ttisinteger(rb)) | 1462 | if (ttisinteger(s2v(ra)) && ttisinteger(rb)) |
1467 | cond = (ivalue(vra) < ivalue(rb)); | 1463 | cond = (ivalue(s2v(ra)) < ivalue(rb)); |
1468 | else if (ttisnumber(vra) && ttisnumber(rb)) | 1464 | else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) |
1469 | cond = LTnum(vra, rb); | 1465 | cond = LTnum(s2v(ra), rb); |
1470 | else | 1466 | else |
1471 | Protect(cond = lessthanothers(L, vra, rb)); | 1467 | Protect(cond = lessthanothers(L, s2v(ra), rb)); |
1472 | docondjump(); | 1468 | docondjump(); |
1473 | vmbreak; | 1469 | vmbreak; |
1474 | } | 1470 | } |
1475 | vmcase(OP_LE) { | 1471 | vmcase(OP_LE) { |
1476 | TValue *rb = vRB(i); | 1472 | TValue *rb = vRB(i); |
1477 | if (ttisinteger(vra) && ttisinteger(rb)) | 1473 | if (ttisinteger(s2v(ra)) && ttisinteger(rb)) |
1478 | cond = (ivalue(vra) <= ivalue(rb)); | 1474 | cond = (ivalue(s2v(ra)) <= ivalue(rb)); |
1479 | else if (ttisnumber(vra) && ttisnumber(rb)) | 1475 | else if (ttisnumber(s2v(ra)) && ttisnumber(rb)) |
1480 | cond = LEnum(vra, rb); | 1476 | cond = LEnum(s2v(ra), rb); |
1481 | else | 1477 | else |
1482 | Protect(cond = lessequalothers(L, vra, rb)); | 1478 | Protect(cond = lessequalothers(L, s2v(ra), rb)); |
1483 | docondjump(); | 1479 | docondjump(); |
1484 | vmbreak; | 1480 | vmbreak; |
1485 | } | 1481 | } |
1486 | vmcase(OP_EQK) { | 1482 | vmcase(OP_EQK) { |
1487 | TValue *rb = KB(i); | 1483 | TValue *rb = KB(i); |
1488 | /* basic types do not use '__eq'; we can use raw equality */ | 1484 | /* basic types do not use '__eq'; we can use raw equality */ |
1489 | cond = luaV_equalobj(NULL, vra, rb); | 1485 | cond = luaV_equalobj(NULL, s2v(ra), rb); |
1490 | docondjump(); | 1486 | docondjump(); |
1491 | vmbreak; | 1487 | vmbreak; |
1492 | } | 1488 | } |
1493 | vmcase(OP_EQI) { | 1489 | vmcase(OP_EQI) { |
1494 | int im = GETARG_sB(i); | 1490 | int im = GETARG_sB(i); |
1495 | if (ttisinteger(vra)) | 1491 | if (ttisinteger(s2v(ra))) |
1496 | cond = (ivalue(vra) == im); | 1492 | cond = (ivalue(s2v(ra)) == im); |
1497 | else if (ttisfloat(vra)) | 1493 | else if (ttisfloat(s2v(ra))) |
1498 | cond = luai_numeq(fltvalue(vra), cast_num(im)); | 1494 | cond = luai_numeq(fltvalue(s2v(ra)), cast_num(im)); |
1499 | else | 1495 | else |
1500 | cond = 0; /* other types cannot be equal to a number */ | 1496 | cond = 0; /* other types cannot be equal to a number */ |
1501 | docondjump(); | 1497 | docondjump(); |
@@ -1503,50 +1499,50 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1503 | } | 1499 | } |
1504 | vmcase(OP_LTI) { | 1500 | vmcase(OP_LTI) { |
1505 | int im = GETARG_sB(i); | 1501 | int im = GETARG_sB(i); |
1506 | if (ttisinteger(vra)) | 1502 | if (ttisinteger(s2v(ra))) |
1507 | cond = (ivalue(vra) < im); | 1503 | cond = (ivalue(s2v(ra)) < im); |
1508 | else if (ttisfloat(vra)) | 1504 | else if (ttisfloat(s2v(ra))) |
1509 | cond = luai_numlt(fltvalue(vra), cast_num(im)); | 1505 | cond = luai_numlt(fltvalue(s2v(ra)), cast_num(im)); |
1510 | else | 1506 | else |
1511 | Protect(cond = luaT_callorderiTM(L, vra, im, 0, TM_LT)); | 1507 | Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 0, TM_LT)); |
1512 | docondjump(); | 1508 | docondjump(); |
1513 | vmbreak; | 1509 | vmbreak; |
1514 | } | 1510 | } |
1515 | vmcase(OP_LEI) { | 1511 | vmcase(OP_LEI) { |
1516 | int im = GETARG_sB(i); | 1512 | int im = GETARG_sB(i); |
1517 | if (ttisinteger(vra)) | 1513 | if (ttisinteger(s2v(ra))) |
1518 | cond = (ivalue(vra) <= im); | 1514 | cond = (ivalue(s2v(ra)) <= im); |
1519 | else if (ttisfloat(vra)) | 1515 | else if (ttisfloat(s2v(ra))) |
1520 | cond = luai_numle(fltvalue(vra), cast_num(im)); | 1516 | cond = luai_numle(fltvalue(s2v(ra)), cast_num(im)); |
1521 | else | 1517 | else |
1522 | Protect(cond = luaT_callorderiTM(L, vra, im, 0, TM_LE)); | 1518 | Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 0, TM_LE)); |
1523 | docondjump(); | 1519 | docondjump(); |
1524 | vmbreak; | 1520 | vmbreak; |
1525 | } | 1521 | } |
1526 | vmcase(OP_GTI) { | 1522 | vmcase(OP_GTI) { |
1527 | int im = GETARG_sB(i); | 1523 | int im = GETARG_sB(i); |
1528 | if (ttisinteger(vra)) | 1524 | if (ttisinteger(s2v(ra))) |
1529 | cond = (im < ivalue(vra)); | 1525 | cond = (im < ivalue(s2v(ra))); |
1530 | else if (ttisfloat(vra)) | 1526 | else if (ttisfloat(s2v(ra))) |
1531 | cond = luai_numlt(cast_num(im), fltvalue(vra)); | 1527 | cond = luai_numlt(cast_num(im), fltvalue(s2v(ra))); |
1532 | else | 1528 | else |
1533 | Protect(cond = luaT_callorderiTM(L, vra, im, 1, TM_LT)); | 1529 | Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 1, TM_LT)); |
1534 | docondjump(); | 1530 | docondjump(); |
1535 | vmbreak; | 1531 | vmbreak; |
1536 | } | 1532 | } |
1537 | vmcase(OP_GEI) { | 1533 | vmcase(OP_GEI) { |
1538 | int im = GETARG_sB(i); | 1534 | int im = GETARG_sB(i); |
1539 | if (ttisinteger(vra)) | 1535 | if (ttisinteger(s2v(ra))) |
1540 | cond = (im <= ivalue(vra)); | 1536 | cond = (im <= ivalue(s2v(ra))); |
1541 | else if (ttisfloat(vra)) | 1537 | else if (ttisfloat(s2v(ra))) |
1542 | cond = luai_numle(cast_num(im), fltvalue(vra)); | 1538 | cond = luai_numle(cast_num(im), fltvalue(s2v(ra))); |
1543 | else | 1539 | else |
1544 | Protect(cond = luaT_callorderiTM(L, vra, im, 1, TM_LE)); | 1540 | Protect(cond = luaT_callorderiTM(L, s2v(ra), im, 1, TM_LE)); |
1545 | docondjump(); | 1541 | docondjump(); |
1546 | vmbreak; | 1542 | vmbreak; |
1547 | } | 1543 | } |
1548 | vmcase(OP_TEST) { | 1544 | vmcase(OP_TEST) { |
1549 | cond = !l_isfalse(vra); | 1545 | cond = !l_isfalse(s2v(ra)); |
1550 | docondjump(); | 1546 | docondjump(); |
1551 | vmbreak; | 1547 | vmbreak; |
1552 | } | 1548 | } |
@@ -1583,11 +1579,11 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1583 | delta = ci->u.l.nextraargs + nparams1; | 1579 | delta = ci->u.l.nextraargs + nparams1; |
1584 | luaF_close(L, base); /* close upvalues from current call */ | 1580 | luaF_close(L, base); /* close upvalues from current call */ |
1585 | } | 1581 | } |
1586 | if (!ttisfunction(vra)) { /* not a function? */ | 1582 | if (!ttisfunction(s2v(ra))) { /* not a function? */ |
1587 | luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ | 1583 | luaD_tryfuncTM(L, ra); /* try '__call' metamethod */ |
1588 | b++; /* there is now one extra argument */ | 1584 | b++; /* there is now one extra argument */ |
1589 | } | 1585 | } |
1590 | if (!ttisLclosure(vra)) { /* C function? */ | 1586 | if (!ttisLclosure(s2v(ra))) { /* C function? */ |
1591 | luaD_call(L, ra, LUA_MULTRET); /* call it */ | 1587 | luaD_call(L, ra, LUA_MULTRET); /* call it */ |
1592 | updatetrap(ci); | 1588 | updatetrap(ci); |
1593 | if (trap) { /* stack may have been relocated */ | 1589 | if (trap) { /* stack may have been relocated */ |
@@ -1647,18 +1643,18 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1647 | return; | 1643 | return; |
1648 | } | 1644 | } |
1649 | vmcase(OP_FORLOOP1) { | 1645 | vmcase(OP_FORLOOP1) { |
1650 | lua_Integer idx = intop(+, ivalue(vra), 1); /* increment index */ | 1646 | lua_Integer idx = intop(+, ivalue(s2v(ra)), 1); /* increment index */ |
1651 | lua_Integer limit = ivalue(s2v(ra + 1)); | 1647 | lua_Integer limit = ivalue(s2v(ra + 1)); |
1652 | if (idx <= limit) { | 1648 | if (idx <= limit) { |
1653 | pc -= GETARG_Bx(i); /* jump back */ | 1649 | pc -= GETARG_Bx(i); /* jump back */ |
1654 | chgivalue(vra, idx); /* update internal index... */ | 1650 | chgivalue(s2v(ra), idx); /* update internal index... */ |
1655 | setivalue(s2v(ra + 3), idx); /* ...and external index */ | 1651 | setivalue(s2v(ra + 3), idx); /* ...and external index */ |
1656 | } | 1652 | } |
1657 | updatetrap(ci); | 1653 | updatetrap(ci); |
1658 | vmbreak; | 1654 | vmbreak; |
1659 | } | 1655 | } |
1660 | vmcase(OP_FORPREP1) { | 1656 | vmcase(OP_FORPREP1) { |
1661 | TValue *init = vra; | 1657 | TValue *init = s2v(ra); |
1662 | TValue *plimit = s2v(ra + 1); | 1658 | TValue *plimit = s2v(ra + 1); |
1663 | lua_Integer ilimit, initv; | 1659 | lua_Integer ilimit, initv; |
1664 | int stopnow; | 1660 | int stopnow; |
@@ -1673,25 +1669,25 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1673 | vmbreak; | 1669 | vmbreak; |
1674 | } | 1670 | } |
1675 | vmcase(OP_FORLOOP) { | 1671 | vmcase(OP_FORLOOP) { |
1676 | if (ttisinteger(vra)) { /* integer loop? */ | 1672 | if (ttisinteger(s2v(ra))) { /* integer loop? */ |
1677 | lua_Integer step = ivalue(s2v(ra + 2)); | 1673 | lua_Integer step = ivalue(s2v(ra + 2)); |
1678 | lua_Integer idx = intop(+, ivalue(vra), step); /* increment index */ | 1674 | lua_Integer idx = intop(+, ivalue(s2v(ra)), step); /* new index */ |
1679 | lua_Integer limit = ivalue(s2v(ra + 1)); | 1675 | lua_Integer limit = ivalue(s2v(ra + 1)); |
1680 | if ((0 < step) ? (idx <= limit) : (limit <= idx)) { | 1676 | if ((0 < step) ? (idx <= limit) : (limit <= idx)) { |
1681 | pc -= GETARG_Bx(i); /* jump back */ | 1677 | pc -= GETARG_Bx(i); /* jump back */ |
1682 | chgivalue(vra, idx); /* update internal index... */ | 1678 | chgivalue(s2v(ra), idx); /* update internal index... */ |
1683 | setivalue(s2v(ra + 3), idx); /* ...and external index */ | 1679 | setivalue(s2v(ra + 3), idx); /* ...and external index */ |
1684 | } | 1680 | } |
1685 | } | 1681 | } |
1686 | else { /* floating loop */ | 1682 | else { /* floating loop */ |
1687 | lua_Number step = fltvalue(s2v(ra + 2)); | 1683 | lua_Number step = fltvalue(s2v(ra + 2)); |
1688 | lua_Number limit = fltvalue(s2v(ra + 1)); | 1684 | lua_Number limit = fltvalue(s2v(ra + 1)); |
1689 | lua_Number idx = fltvalue(vra); | 1685 | lua_Number idx = fltvalue(s2v(ra)); |
1690 | idx = luai_numadd(L, idx, step); /* inc. index */ | 1686 | idx = luai_numadd(L, idx, step); /* inc. index */ |
1691 | if (luai_numlt(0, step) ? luai_numle(idx, limit) | 1687 | if (luai_numlt(0, step) ? luai_numle(idx, limit) |
1692 | : luai_numle(limit, idx)) { | 1688 | : luai_numle(limit, idx)) { |
1693 | pc -= GETARG_Bx(i); /* jump back */ | 1689 | pc -= GETARG_Bx(i); /* jump back */ |
1694 | chgfltvalue(vra, idx); /* update internal index... */ | 1690 | chgfltvalue(s2v(ra), idx); /* update internal index... */ |
1695 | setfltvalue(s2v(ra + 3), idx); /* ...and external index */ | 1691 | setfltvalue(s2v(ra + 3), idx); /* ...and external index */ |
1696 | } | 1692 | } |
1697 | } | 1693 | } |
@@ -1699,7 +1695,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1699 | vmbreak; | 1695 | vmbreak; |
1700 | } | 1696 | } |
1701 | vmcase(OP_FORPREP) { | 1697 | vmcase(OP_FORPREP) { |
1702 | TValue *init = vra; | 1698 | TValue *init = s2v(ra); |
1703 | TValue *plimit = s2v(ra + 1); | 1699 | TValue *plimit = s2v(ra + 1); |
1704 | TValue *pstep = s2v(ra + 2); | 1700 | TValue *pstep = s2v(ra + 2); |
1705 | lua_Integer ilimit; | 1701 | lua_Integer ilimit; |
@@ -1761,7 +1757,7 @@ void luaV_execute (lua_State *L, CallInfo *ci) { | |||
1761 | if (c == 0) { | 1757 | if (c == 0) { |
1762 | c = GETARG_Ax(*pc); pc++; | 1758 | c = GETARG_Ax(*pc); pc++; |
1763 | } | 1759 | } |
1764 | h = hvalue(vra); | 1760 | h = hvalue(s2v(ra)); |
1765 | last = ((c-1)*LFIELDS_PER_FLUSH) + n; | 1761 | last = ((c-1)*LFIELDS_PER_FLUSH) + n; |
1766 | if (last > h->sizearray) /* needs more space? */ | 1762 | if (last > h->sizearray) /* needs more space? */ |
1767 | luaH_resizearray(L, h, last); /* preallocate it at once */ | 1763 | luaH_resizearray(L, h, last); /* preallocate it at once */ |