diff options
Diffstat (limited to 'lopcodes.h')
| -rw-r--r-- | lopcodes.h | 31 |
1 files changed, 17 insertions, 14 deletions
| @@ -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 | ||
| 231 | typedef enum { | 231 | typedef enum { |
| @@ -238,7 +238,7 @@ OP_LOADF,/* A sBx R[A] := (lua_Number)sBx */ | |||
| 238 | OP_LOADK,/* A Bx R[A] := K[Bx] */ | 238 | OP_LOADK,/* A Bx R[A] := K[Bx] */ |
| 239 | OP_LOADKX,/* A R[A] := K[extra arg] */ | 239 | OP_LOADKX,/* A R[A] := K[extra arg] */ |
| 240 | OP_LOADFALSE,/* A R[A] := false */ | 240 | OP_LOADFALSE,/* A R[A] := false */ |
| 241 | OP_LFALSESKIP,/*A R[A] := false; pc++ (*) */ | 241 | OP_LFALSESKIP,/*A R[A] := false; pc++ */ |
| 242 | OP_LOADTRUE,/* A R[A] := true */ | 242 | OP_LOADTRUE,/* A R[A] := true */ |
| 243 | OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ | 243 | OP_LOADNIL,/* A B R[A], R[A+1], ..., R[A+B] := nil */ |
| 244 | OP_GETUPVAL,/* A B R[A] := UpValue[B] */ | 244 | OP_GETUPVAL,/* A B R[A] := UpValue[B] */ |
| @@ -289,7 +289,7 @@ OP_BXOR,/* A B C R[A] := R[B] ~ R[C] */ | |||
| 289 | OP_SHL,/* A B C R[A] := R[B] << R[C] */ | 289 | OP_SHL,/* A B C R[A] := R[B] << R[C] */ |
| 290 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ | 290 | OP_SHR,/* A B C R[A] := R[B] >> R[C] */ |
| 291 | 291 | ||
| 292 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] (*) */ | 292 | OP_MMBIN,/* A B C call C metamethod over R[A] and R[B] */ |
| 293 | OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ | 293 | OP_MMBINI,/* A sB C k call C metamethod over R[A] and sB */ |
| 294 | OP_MMBINK,/* A B C k call C metamethod over R[A] and K[B] */ | 294 | OP_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++ */ | |||
| 315 | OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ | 315 | OP_GEI,/* A sB k if ((R[A] >= sB) ~= k) then pc++ */ |
| 316 | 316 | ||
| 317 | OP_TEST,/* A k if (not R[A] == k) then pc++ */ | 317 | OP_TEST,/* A k if (not R[A] == k) then pc++ */ |
| 318 | OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] (*) */ | 318 | OP_TESTSET,/* A B k if (not R[B] == k) then pc++ else R[A] := R[B] */ |
| 319 | 319 | ||
| 320 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ | 320 | OP_CALL,/* A B C R[A], ... ,R[A+C-2] := R[A](R[A+1], ... ,R[A+B-1]) */ |
| 321 | OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ | 321 | OP_TAILCALL,/* A B C k return R[A](R[A+1], ... ,R[A+B-1]) */ |
| 322 | 322 | ||
| 323 | OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] (see note) */ | 323 | OP_RETURN,/* A B C k return R[A], ... ,R[A+B-2] */ |
| 324 | OP_RETURN0,/* return */ | 324 | OP_RETURN0,/* return */ |
| 325 | OP_RETURN1,/* A return R[A] */ | 325 | OP_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 | ||
| 337 | OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ | 337 | OP_CLOSURE,/* A Bx R[A] := closure(KPROTO[Bx]) */ |
| 338 | 338 | ||
| 339 | OP_VARARG,/* A C R[A], ..., R[A+C-2] = vararg, R[B] is vararg param. */ | 339 | OP_VARARG,/* A B C k R[A], ..., R[A+C-2] = varargs */ |
| 340 | 340 | ||
| 341 | OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */ | 341 | OP_GETVARG, /* A B C R[A] := R[B][R[C]], R[B] is vararg parameter */ |
| 342 | 342 | ||
| 343 | OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx - 1] is global name)*/ | 343 | OP_ERRNNIL,/* A Bx raise error if R[A] ~= nil (K[Bx - 1] is global name)*/ |
| 344 | 344 | ||
| 345 | OP_VARARGPREP,/* (adjust vararg parameters) */ | 345 | OP_VARARGPREP,/* (adjust varargs) */ |
| 346 | 346 | ||
| 347 | OP_EXTRAARG/* Ax extra (larger) argument for previous opcode */ | 347 | OP_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 |
