aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h31
1 files changed, 17 insertions, 14 deletions
diff --git a/lopcodes.h b/lopcodes.h
index fac87da2..b6bd182e 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -224,8 +224,8 @@ enum OpMode {iABC, ivABC, iABx, iAsBx, iAx, isJ};
224 224
225 225
226/* 226/*
227** Grep "ORDER OP" if you change these enums. Opcodes marked with a (*) 227** Grep "ORDER OP" if you change this enum.
228** has extra descriptions in the notes after the enumeration. 228** See "Notes" below for more information about some instructions.
229*/ 229*/
230 230
231typedef enum { 231typedef enum {
@@ -238,7 +238,7 @@ OP_LOADF,/* A sBx R[A] := (lua_Number)sBx */
238OP_LOADK,/* A Bx R[A] := K[Bx] */ 238OP_LOADK,/* A Bx R[A] := K[Bx] */
239OP_LOADKX,/* A R[A] := K[extra arg] */ 239OP_LOADKX,/* A R[A] := K[extra arg] */
240OP_LOADFALSE,/* A R[A] := false */ 240OP_LOADFALSE,/* A R[A] := false */
241OP_LFALSESKIP,/*A R[A] := false; pc++ (*) */ 241OP_LFALSESKIP,/*A R[A] := false; pc++ */
242OP_LOADTRUE,/* A R[A] := true */ 242OP_LOADTRUE,/* A R[A] := true */
243OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ 243OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */
244OP_GETUPVAL,/* A B R[A] := UpValue[B] */ 244OP_GETUPVAL,/* A B R[A] := UpValue[B] */
@@ -289,7 +289,7 @@ OP_BXOR,/* A B C R[A] := R[B] ~ R[C] */
289OP_SHL,/* A B C R[A] := R[B] << R[C] */ 289OP_SHL,/* A B C R[A] := R[B] << R[C] */
290OP_SHR,/* A B C R[A] := R[B] >> R[C] */ 290OP_SHR,/* A B C R[A] := R[B] >> R[C] */
291 291
292OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] (*) */ 292OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */
293OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ 293OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */
294OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ 294OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */
295 295
@@ -315,12 +315,12 @@ OP_GTI,/* A sB k if ((R[A] > sB) ~= k) then pc++ */
315OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ 315OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */
316 316
317OP_TEST,/* A k if (not R[A] == k) then pc++ */ 317OP_TEST,/* A k if (not R[A] == k) then pc++ */
318OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] (*) */ 318OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] */
319 319
320OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ 320OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */
321OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ 321OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */
322 322
323OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] (see note) */ 323OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] */
324OP_RETURN0,/* return */ 324OP_RETURN0,/* return */
325OP_RETURN1,/* A return R[A] */ 325OP_RETURN1,/* A return R[A] */
326 326
@@ -336,13 +336,13 @@ OP_SETLIST,/* A vB vC k R[A][vC+i] := R[A+i], 1 <= i <= vB */
336 336
337OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ 337OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */
338 338
339OP_VARARG,/* A C R[A], ..., R[A+C-2] = vararg, R[B] is vararg param. */ 339OP_VARARG,/* A B C k R[A], ..., R[A+C-2] = varargs */
340 340
341OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */ 341OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */
342 342
343OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx - 1] is global name)*/ 343OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx - 1] is global name)*/
344 344
345OP_VARARGPREP,/* (adjust vararg parameters) */ 345OP_VARARGPREP,/* (adjust varargs) */
346 346
347OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ 347OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
348} OpCode; 348} OpCode;
@@ -371,7 +371,8 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
371 OP_RETURN*, OP_SETLIST) may use 'top'. 371 OP_RETURN*, OP_SETLIST) may use 'top'.
372 372
373 (*) In OP_VARARG, if (C == 0) then use actual number of varargs and 373 (*) In OP_VARARG, if (C == 0) then use actual number of varargs and
374 set top (like in OP_CALL with C == 0). 374 set top (like in OP_CALL with C == 0). 'k' means function has a
375 vararg table, which is in R[B].
375 376
376 (*) In OP_RETURN, if (B == 0) then return up to 'top'. 377 (*) In OP_RETURN, if (B == 0) then return up to 'top'.
377 378
@@ -387,20 +388,22 @@ OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */
387 is vC. Otherwise, the array size is EXTRAARG _ vC. 388 is vC. Otherwise, the array size is EXTRAARG _ vC.
388 389
389 (*) In OP_ERRNNIL, (Bx == 0) means index of global name doesn't 390 (*) In OP_ERRNNIL, (Bx == 0) means index of global name doesn't
390 fit in Bx. (So, that name is not available for the instruction.) 391 fit in Bx. (So, that name is not available for the error message.)
391 392
392 (*) For comparisons, k specifies what condition the test should accept 393 (*) For comparisons, k specifies what condition the test should accept
393 (true or false). 394 (true or false).
394 395
395 (*) In OP_MMBINI/OP_MMBINK, k means the arguments were flipped 396 (*) In OP_MMBINI/OP_MMBINK, k means the arguments were flipped
396 (the constant is the first operand). 397 (the constant is the first operand).
397 398
398 (*) All 'skips' (pc++) assume that next instruction is a jump. 399 (*) All comparison and test instructions assume that the instruction
400 being skipped (pc++) is a jump.
399 401
400 (*) In instructions OP_RETURN/OP_TAILCALL, 'k' specifies that the 402 (*) In instructions OP_RETURN/OP_TAILCALL, 'k' specifies that the
401 function builds upvalues, which may need to be closed. C > 0 means 403 function builds upvalues, which may need to be closed. C > 0 means
402 the function is vararg, so that its 'func' must be corrected before 404 the function has hidden vararg arguments, so that its 'func' must be
403 returning; in this case, (C - 1) is its number of fixed parameters. 405 corrected before returning; in this case, (C - 1) is its number of
406 fixed parameters.
404 407
405 (*) In comparisons with an immediate operand, C signals whether the 408 (*) In comparisons with an immediate operand, C signals whether the
406 original operand was a float. (It must be corrected in case of 409 original operand was a float. (It must be corrected in case of