aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:30:46 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2021-02-24 11:30:46 -0300
commit31925e4cc20018b2cf46664febd6347ce4a4b766 (patch)
tree159667853fbe827acdce92923fa34d401b1a89ec
parent59c88f846d1dcd901a4420651aedf27816618923 (diff)
downloadlua-31925e4cc20018b2cf46664febd6347ce4a4b766.tar.gz
lua-31925e4cc20018b2cf46664febd6347ce4a4b766.tar.bz2
lua-31925e4cc20018b2cf46664febd6347ce4a4b766.zip
Details
Added documentation and asserts that constants for arithmetic opcodes must be numbers.
-rw-r--r--lopcodes.h14
-rw-r--r--lvm.c4
2 files changed, 9 insertions, 9 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 120cdd94..d6a47e5a 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -225,13 +225,13 @@ OP_SELF,/* A B C R[A+1] := R[B]; R[A] := R[B][RK(C):string] */
225 225
226OP_ADDI,/* A B sC R[A] := R[B] + sC */ 226OP_ADDI,/* A B sC R[A] := R[B] + sC */
227 227
228OP_ADDK,/* A B C R[A] := R[B] + K[C] */ 228OP_ADDK,/* A B C R[A] := R[B] + K[C]:number */
229OP_SUBK,/* A B C R[A] := R[B] - K[C] */ 229OP_SUBK,/* A B C R[A] := R[B] - K[C]:number */
230OP_MULK,/* A B C R[A] := R[B] * K[C] */ 230OP_MULK,/* A B C R[A] := R[B] * K[C]:number */
231OP_MODK,/* A B C R[A] := R[B] % K[C] */ 231OP_MODK,/* A B C R[A] := R[B] % K[C]:number */
232OP_POWK,/* A B C R[A] := R[B] ^ K[C] */ 232OP_POWK,/* A B C R[A] := R[B] ^ K[C]:number */
233OP_DIVK,/* A B C R[A] := R[B] / K[C] */ 233OP_DIVK,/* A B C R[A] := R[B] / K[C]:number */
234OP_IDIVK,/* A B C R[A] := R[B] // K[C] */ 234OP_IDIVK,/* A B C R[A] := R[B] // K[C]:number */
235 235
236OP_BANDK,/* A B C R[A] := R[B] & K[C]:integer */ 236OP_BANDK,/* A B C R[A] := R[B] & K[C]:integer */
237OP_BORK,/* A B C R[A] := R[B] | K[C]:integer */ 237OP_BORK,/* A B C R[A] := R[B] | K[C]:integer */
diff --git a/lvm.c b/lvm.c
index 728acd46..c0a10d6c 100644
--- a/lvm.c
+++ b/lvm.c
@@ -921,7 +921,7 @@ void luaV_finishOp (lua_State *L) {
921*/ 921*/
922#define op_arithfK(L,fop) { \ 922#define op_arithfK(L,fop) { \
923 TValue *v1 = vRB(i); \ 923 TValue *v1 = vRB(i); \
924 TValue *v2 = KC(i); \ 924 TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \
925 op_arithf_aux(L, v1, v2, fop); } 925 op_arithf_aux(L, v1, v2, fop); }
926 926
927 927
@@ -950,7 +950,7 @@ void luaV_finishOp (lua_State *L) {
950*/ 950*/
951#define op_arithK(L,iop,fop) { \ 951#define op_arithK(L,iop,fop) { \
952 TValue *v1 = vRB(i); \ 952 TValue *v1 = vRB(i); \
953 TValue *v2 = KC(i); \ 953 TValue *v2 = KC(i); lua_assert(ttisnumber(v2)); \
954 op_arith_aux(L, v1, v2, iop, fop); } 954 op_arith_aux(L, v1, v2, iop, fop); }
955 955
956 956