From cf71a5ddc742692fad813f89f1c9ef53e1ffde0f Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 13 Mar 2019 13:16:53 -0300 Subject: Details Several small improvements (code style, warnings, comments, more tests), in particular: - 'lua_topointer' extended to handle strings - raises an error in 'string.format("%10q")' ('%q' with modifiers) - in the manual for 'string.format', the term "option" replaced by "conversion specifier" (the term used by the C standard) --- lopcodes.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'lopcodes.h') diff --git a/lopcodes.h b/lopcodes.h index d7403caf..3e100259 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -90,7 +90,6 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */ #define MAXARG_B ((1<> 1) -#define MAXARG_Cx ((1<<(SIZE_C + 1))-1) /* creates a mask with 'n' 1 bits at position 'p' */ @@ -233,8 +232,8 @@ OP_BANDK,/* A B C R(A) := R(B) & K(C):integer */ OP_BORK,/* A B C R(A) := R(B) | K(C):integer */ OP_BXORK,/* A B C R(A) := R(B) ~ K(C):integer */ -OP_SHRI,/* A B C R(A) := R(B) >> C */ -OP_SHLI,/* A B C R(A) := C << R(B) */ +OP_SHRI,/* A B sC R(A) := R(B) >> C */ +OP_SHLI,/* A B sC R(A) := C << R(B) */ OP_ADD,/* A B C R(A) := R(B) + R(C) */ OP_SUB,/* A B C R(A) := R(B) - R(C) */ @@ -272,7 +271,7 @@ OP_GTI,/* A sB if ((R(A) > sB) ~= k) then pc++ */ OP_GEI,/* A sB if ((R(A) >= sB) ~= k) then pc++ */ OP_TEST,/* A if (not R(A) == k) then pc++ */ -OP_TESTSET,/* A B if (not R(B) == k) then R(A) := R(B) else pc++ */ +OP_TESTSET,/* A B if (not R(B) == k) then pc++ else R(A) := R(B) */ OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ @@ -305,15 +304,15 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ } OpCode; -#define NUM_OPCODES (cast_int(OP_EXTRAARG) + 1) +#define NUM_OPCODES ((int)(OP_EXTRAARG) + 1) /*=========================================================================== Notes: - (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then 'top' is - set to last_result+1, so next open instruction (OP_CALL, OP_RETURN*, - OP_SETLIST) may use 'top'. + (*) In OP_CALL, if (B == 0) then B = top - A. If (C == 0), then + 'top' is set to last_result+1, so next open instruction (OP_CALL, + OP_RETURN*, OP_SETLIST) may use 'top'. (*) In OP_VARARG, if (C == 0) then use actual number of varargs and set top (like in OP_CALL with C == 0). -- cgit v1.2.3-55-g6feb