diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-13 13:16:53 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2019-03-13 13:16:53 -0300 |
commit | cf71a5ddc742692fad813f89f1c9ef53e1ffde0f (patch) | |
tree | df02305ff3cf05908f21829384e3a7f8699d2331 /lopcodes.h | |
parent | 2c32bff60987d38a60a58d4f0123f3783da60a63 (diff) | |
download | lua-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.h | 15 |
1 files changed, 7 insertions, 8 deletions
@@ -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 */ | |||
233 | OP_BORK,/* A B C R(A) := R(B) | K(C):integer */ | 232 | OP_BORK,/* A B C R(A) := R(B) | K(C):integer */ |
234 | OP_BXORK,/* A B C R(A) := R(B) ~ K(C):integer */ | 233 | OP_BXORK,/* A B C R(A) := R(B) ~ K(C):integer */ |
235 | 234 | ||
236 | OP_SHRI,/* A B C R(A) := R(B) >> C */ | 235 | OP_SHRI,/* A B sC R(A) := R(B) >> C */ |
237 | OP_SHLI,/* A B C R(A) := C << R(B) */ | 236 | OP_SHLI,/* A B sC R(A) := C << R(B) */ |
238 | 237 | ||
239 | OP_ADD,/* A B C R(A) := R(B) + R(C) */ | 238 | OP_ADD,/* A B C R(A) := R(B) + R(C) */ |
240 | OP_SUB,/* A B C R(A) := R(B) - R(C) */ | 239 | 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++ */ | |||
272 | OP_GEI,/* A sB if ((R(A) >= sB) ~= k) then pc++ */ | 271 | OP_GEI,/* A sB if ((R(A) >= sB) ~= k) then pc++ */ |
273 | 272 | ||
274 | OP_TEST,/* A if (not R(A) == k) then pc++ */ | 273 | OP_TEST,/* A if (not R(A) == k) then pc++ */ |
275 | OP_TESTSET,/* A B if (not R(B) == k) then R(A) := R(B) else pc++ */ | 274 | OP_TESTSET,/* A B if (not R(B) == k) then pc++ else R(A) := R(B) */ |
276 | 275 | ||
277 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ | 276 | OP_CALL,/* A B C R(A), ... ,R(A+C-2) := R(A)(R(A+1), ... ,R(A+B-1)) */ |
278 | OP_TAILCALL,/* A B C return R(A)(R(A+1), ... ,R(A+B-1)) */ | 277 | 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 */ | |||
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). |