aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-13 13:16:53 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2019-03-13 13:16:53 -0300
commitcf71a5ddc742692fad813f89f1c9ef53e1ffde0f (patch)
treedf02305ff3cf05908f21829384e3a7f8699d2331 /lopcodes.h
parent2c32bff60987d38a60a58d4f0123f3783da60a63 (diff)
downloadlua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.tar.gz
lua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.tar.bz2
lua-cf71a5ddc742692fad813f89f1c9ef53e1ffde0f.zip
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)
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h15
1 files changed, 7 insertions, 8 deletions
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 */
90#define MAXARG_B ((1<<SIZE_B)-1) 90#define MAXARG_B ((1<<SIZE_B)-1)
91#define MAXARG_C ((1<<SIZE_C)-1) 91#define MAXARG_C ((1<<SIZE_C)-1)
92#define OFFSET_sC (MAXARG_C >> 1) 92#define OFFSET_sC (MAXARG_C >> 1)
93#define MAXARG_Cx ((1<<(SIZE_C + 1))-1)
94 93
95 94
96/* creates a mask with 'n' 1 bits at position 'p' */ 95/* 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 */
233OP_BORK,/* A B C R(A) := R(B) | K(C):integer */ 232OP_BORK,/* A B C R(A) := R(B) | K(C):integer */
234OP_BXORK,/* A B C R(A) := R(B) ~ K(C):integer */ 233OP_BXORK,/* A B C R(A) := R(B) ~ K(C):integer */
235 234
236OP_SHRI,/* A B C R(A) := R(B) >> C */ 235OP_SHRI,/* A B sC R(A) := R(B) >> C */
237OP_SHLI,/* A B C R(A) := C << R(B) */ 236OP_SHLI,/* A B sC R(A) := C << R(B) */
238 237
239OP_ADD,/* A B C R(A) := R(B) + R(C) */ 238OP_ADD,/* A B C R(A) := R(B) + R(C) */
240OP_SUB,/* A B C R(A) := R(B) - R(C) */ 239OP_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++ */
272OP_GEI,/* A sB if ((R(A) >= sB) ~= k) then pc++ */ 271OP_GEI,/* A sB if ((R(A) >= sB) ~= k) then pc++ */
273 272
274OP_TEST,/* A if (not R(A) == k) then pc++ */ 273OP_TEST,/* A if (not R(A) == k) then pc++ */
275OP_TESTSET,/* A B if (not R(B) == k) then R(A) := R(B) else pc++ */ 274OP_TESTSET,/* A B if (not R(B) == k) then pc++ else R(A) := R(B) */
276 275
277OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ 276OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */
278OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ 277OP_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 */
305} OpCode; 304} OpCode;
306 305
307 306
308#define NUM_OPCODES (cast_int(OP_EXTRAARG) + 1) 307#define NUM_OPCODES ((int)(OP_EXTRAARG) + 1)
309 308
310 309
311 310
312/*=========================================================================== 311/*===========================================================================
313 Notes: 312 Notes:
314 (*) In OP_CALL, if (B == 0) then B = top. If (C == 0), then 'top' is 313 (*) In OP_CALL, if (B == 0) then B = top - A. If (C == 0), then
315 set to last_result+1, so next open instruction (OP_CALL, OP_RETURN*, 314 'top' is set to last_result+1, so next open instruction (OP_CALL,
316 OP_SETLIST) may use 'top'. 315 OP_RETURN*, OP_SETLIST) may use 'top'.
317 316
318 (*) In OP_VARARG, if (C == 0) then use actual number of varargs and 317 (*) In OP_VARARG, if (C == 0) then use actual number of varargs and
319 set top (like in OP_CALL with C == 0). 318 set top (like in OP_CALL with C == 0).