aboutsummaryrefslogtreecommitdiff
path: root/lopcodes.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-29 14:26:48 -0300
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2018-10-29 14:26:48 -0300
commita006514ea138a29b6031058d9002b48a572b5dd6 (patch)
treeb289a8af0c0497f2555784a0cf666659ceab0236 /lopcodes.h
parent6e9b719694bffb8de711f182d405ec37d32ae0b1 (diff)
downloadlua-a006514ea138a29b6031058d9002b48a572b5dd6.tar.gz
lua-a006514ea138a29b6031058d9002b48a572b5dd6.tar.bz2
lua-a006514ea138a29b6031058d9002b48a572b5dd6.zip
Big revamp in the implmentation of labels/gotos
Added restriction that, when a label is created, there cannot be another label with the same name visible. That allows backward goto's to be resolved when they are read. Backward goto's get a close if they jump out of the scope of some variable; labels get a close only if previous goto to it jumps out of the scope of some upvalue.
Diffstat (limited to 'lopcodes.h')
-rw-r--r--lopcodes.h9
1 files changed, 3 insertions, 6 deletions
diff --git a/lopcodes.h b/lopcodes.h
index 4797d7c3..5a38f767 100644
--- a/lopcodes.h
+++ b/lopcodes.h
@@ -21,7 +21,7 @@ iABC C(8) | B(8) |k| A(8) | Op(7) |
21iABx Bx(17) | A(8) | Op(7) | 21iABx Bx(17) | A(8) | Op(7) |
22iAsB sBx (signed)(17) | A(8) | Op(7) | 22iAsB sBx (signed)(17) | A(8) | Op(7) |
23iAx Ax(25) | Op(7) | 23iAx Ax(25) | Op(7) |
24isJ sJ(24) |m| Op(7) | 24isJ sJ(25) | Op(7) |
25 25
26 A signed argument is represented in excess K: the represented value is 26 A signed argument is represented in excess K: the represented value is
27 the written unsigned value minus K, where K is half the maximum for the 27 the written unsigned value minus K, where K is half the maximum for the
@@ -40,7 +40,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
40#define SIZE_Bx (SIZE_C + SIZE_B + 1) 40#define SIZE_Bx (SIZE_C + SIZE_B + 1)
41#define SIZE_A 8 41#define SIZE_A 8
42#define SIZE_Ax (SIZE_Bx + SIZE_A) 42#define SIZE_Ax (SIZE_Bx + SIZE_A)
43#define SIZE_sJ (SIZE_Bx + SIZE_A - 1) 43#define SIZE_sJ (SIZE_Bx + SIZE_A)
44 44
45#define SIZE_OP 7 45#define SIZE_OP 7
46 46
@@ -55,8 +55,7 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
55 55
56#define POS_Ax POS_A 56#define POS_Ax POS_A
57 57
58#define POS_m POS_A 58#define POS_sJ POS_A
59#define POS_sJ (POS_A + 1)
60 59
61/* 60/*
62** limits for opcode arguments. 61** limits for opcode arguments.
@@ -144,8 +143,6 @@ enum OpMode {iABC, iABx, iAsBx, iAx, isJ}; /* basic instruction formats */
144 check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ) 143 check_exp(checkopm(i, isJ), getarg(i, POS_sJ, SIZE_sJ) - OFFSET_sJ)
145#define SETARG_sJ(i,j) \ 144#define SETARG_sJ(i,j) \
146 setarg(i, cast_uint((j)+OFFSET_sJ), POS_sJ, SIZE_sJ) 145 setarg(i, cast_uint((j)+OFFSET_sJ), POS_sJ, SIZE_sJ)
147#define GETARG_m(i) check_exp(checkopm(i, isJ), getarg(i, POS_m, 1))
148#define SETARG_m(i,m) setarg(i, m, POS_m, 1)
149 146
150 147
151#define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \ 148#define CREATE_ABCk(o,a,b,c,k) ((cast(Instruction, o)<<POS_OP) \