aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h21
1 files changed, 13 insertions, 8 deletions
diff --git a/lopcodes.h b/lopcodes.h
index be5bde30..8fdaf6b1 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -1,5 +1,5 @@
1/* 1/*
2** $Id: lopcodes.h,v 1.107 2004/04/30 20:13:38 roberto Exp roberto $ 2** $Id: lopcodes.h,v 1.108 2004/05/17 12:34:00 roberto Exp roberto $
3** Opcodes for Lua virtual machine 3** Opcodes for Lua virtual machine
4** See Copyright Notice in lua.h 4** See Copyright Notice in lua.h
5*/ 5*/
@@ -79,7 +79,7 @@ enum OpMode {iABC, iABx, iAsBx}; /* basic instruction format */
79#define GET_OPCODE(i) (cast(OpCode, (i)&MASK1(SIZE_OP,0))) 79#define GET_OPCODE(i) (cast(OpCode, (i)&MASK1(SIZE_OP,0)))
80#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,0)) | cast(Instruction, o))) 80#define SET_OPCODE(i,o) ((i) = (((i)&MASK0(SIZE_OP,0)) | cast(Instruction, o)))
81 81
82#define GETARG_A(i) (cast(int, (i)>>POS_A) & MASK1(SIZE_A,0)) 82#define GETARG_A(i) (cast(int, ((i)>>POS_A) & MASK1(SIZE_A,0)))
83#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \ 83#define SETARG_A(i,u) ((i) = (((i)&MASK0(SIZE_A,POS_A)) | \
84 ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A)))) 84 ((cast(Instruction, u)<<POS_A)&MASK1(SIZE_A,POS_A))))
85 85
@@ -183,25 +183,30 @@ OP_SETLIST,/* A Bx R(A)[Bx-Bx%FPF+i] := R(A+i), 1 <= i <= Bx%FPF+1 */
183OP_SETLISTO,/* A Bx */ 183OP_SETLISTO,/* A Bx */
184 184
185OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/ 185OP_CLOSE,/* A close all variables in the stack up to (>=) R(A)*/
186OP_CLOSURE/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */ 186OP_CLOSURE,/* A Bx R(A) := closure(KPROTO[Bx], R(A), ... ,R(A+n)) */
187
188OP_VARARG/* A B R(A), R(A+1), ..., R(A+B-1) = vararg */
187} OpCode; 189} OpCode;
188 190
189 191
190#define NUM_OPCODES (cast(int, OP_CLOSURE+1)) 192#define NUM_OPCODES (cast(int, OP_VARARG+1))
191 193
192 194
193 195
194/*=========================================================================== 196/*===========================================================================
195 Notes: 197 Notes:
196 (1) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1, 198 (*) In OP_CALL, if (B == 0) then B = top. C is the number of returns - 1,
197 and can be 0: OP_CALL then sets `top' to last_result+1, so 199 and can be 0: OP_CALL then sets `top' to last_result+1, so
198 next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'. 200 next open instruction (OP_CALL, OP_RETURN, OP_SETLIST) may use `top'.
199 201
200 (2) In OP_RETURN, if (B == 0) then return up to `top' 202 (*) In OP_VARARG, if (B == 0) then use actual number of varargs and
203 set top (like in OP_CALL).
204
205 (*) In OP_RETURN, if (B == 0) then return up to `top'
201 206
202 (3) For comparisons, B specifies what conditions the test should accept. 207 (*) For comparisons, B specifies what conditions the test should accept.
203 208
204 (4) All `skips' (pc++) assume that next instruction is a jump 209 (*) All `skips' (pc++) assume that next instruction is a jump
205===========================================================================*/ 210===========================================================================*/
206 211
207 212