From 616438fe9ab5e3ae7d73e9ad838e9b7bdea1ea59 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Mon, 31 May 2004 15:51:50 -0300 Subject: new way to use `vararg' parameters (with `...') --- lopcodes.h | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'lopcodes.h') diff --git a/lopcodes.h b/lopcodes.h index be5bde30..8fdaf6b1 100644 --- a/lopcodes.h +++ b/lopcodes.h @@ -1,5 +1,5 @@ /* -** $Id: lopcodes.h,v 1.107 2004/04/30 20:13:38 roberto Exp roberto $ +** $Id: lopcodes.h,v 1.108 2004/05/17 12:34:00 roberto Exp roberto $ ** Opcodes for Lua virtual machine ** See Copyright Notice in lua.h */ @@ -79,7 +79,7 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */ #define GET_OPCODE(i) (cast(OpCode, (i)&MASK1(SIZE_OP,0))) #define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,0)) | cast(Instruction, o))) -#define GETARG_A(i) (cast(int, (i)>>POS_A) & MASK1(SIZE_A,0)) +#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0))) #define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ ((cast(Instruction, u)<=) R(A)*/ -OP_CLOSURE/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ +OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ + +OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */ } OpCode; -#define NUM_OPCODES (cast(int, OP_CLOSURE+1)) +#define NUM_OPCODES (cast(int, OP_VARARG+1)) /*=========================================================================== Notes: - (1) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, + (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, and can be 0: OP_CALL then sets `top' to last_result+1, so next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. - (2) In OP_RETURN, if (B == 0) then return up to `top' + (*) In OP_VARARG, if (B == 0) then use actual number of varargs and + set top (like in OP_CALL). + + (*) In OP_RETURN, if (B == 0) then return up to `top' - (3) For comparisons, B specifies what conditions the test should accept. + (*) For comparisons, B specifies what conditions the test should accept. - (4) All `skips' (pc++) assume that next instruction is a jump + (*) All `skips' (pc++) assume that next instruction is a jump ===========================================================================*/ -- cgit v1.2.3-55-g6feb