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.
This commit is contained in:
Roberto Ierusalimschy
2018-10-29 14:26:48 -03:00
parent 6e9b719694
commit a006514ea1
8 changed files with 131 additions and 182 deletions

View File

@@ -88,6 +88,7 @@ typedef struct Labeldesc {
int pc; /* position in code */
int line; /* line where it appeared */
lu_byte nactvar; /* local level where it appears in current block */
lu_byte close; /* goto that escapes upvalues */
} Labeldesc;
@@ -128,6 +129,7 @@ typedef struct FuncState {
int np; /* number of elements in 'p' */
int nabslineinfo; /* number of elements in 'abslineinfo' */
int firstlocal; /* index of first local var (in Dyndata array) */
int firstlabel; /* index of first label (in 'dyd->label->arr') */
short nlocvars; /* number of elements in 'f->locvars' */
lu_byte nactvar; /* number of active local variables */
lu_byte nups; /* number of upvalues */