diff options
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 27 |
1 files changed, 17 insertions, 10 deletions
@@ -34,8 +34,9 @@ typedef enum { | |||
34 | VNONRELOC, /* expression has its value in a fixed register; | 34 | VNONRELOC, /* expression has its value in a fixed register; |
35 | info = result register */ | 35 | info = result register */ |
36 | VLOCAL, /* local variable; var.ridx = local register; | 36 | VLOCAL, /* local variable; var.ridx = local register; |
37 | var.vidx = index in 'actvar.arr' */ | 37 | var.vidx = relative index in 'actvar.arr' */ |
38 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ | 38 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ |
39 | VCONST, /* compile-time constant; info = absolute index in 'actvar.arr' */ | ||
39 | VINDEXED, /* indexed variable; | 40 | VINDEXED, /* indexed variable; |
40 | ind.t = table register; | 41 | ind.t = table register; |
41 | ind.idx = key's R index */ | 42 | ind.idx = key's R index */ |
@@ -81,19 +82,25 @@ typedef struct expdesc { | |||
81 | } expdesc; | 82 | } expdesc; |
82 | 83 | ||
83 | 84 | ||
85 | /* kinds of variables */ | ||
86 | #define VDKREG 0 /* regular */ | ||
87 | #define RDKCONST 1 /* constant */ | ||
88 | #define RDKTOCLOSE 2 /* to-be-closed */ | ||
89 | #define RDKCTC 3 /* compile-time constant */ | ||
90 | |||
84 | /* description of an active local variable */ | 91 | /* description of an active local variable */ |
85 | typedef struct Vardesc { | 92 | typedef union Vardesc { |
86 | TValuefields; /* constant value (if it is a compile-time constant) */ | 93 | struct { |
87 | lu_byte ro; /* true if variable is 'const' */ | 94 | TValuefields; /* constant value (if it is a compile-time constant) */ |
88 | lu_byte sidx; /* index of the variable in the stack */ | 95 | lu_byte kind; |
89 | short pidx; /* index of the variable in the Proto's 'locvars' array */ | 96 | lu_byte sidx; /* index of the variable in the stack */ |
90 | TString *name; /* variable name */ | 97 | short pidx; /* index of the variable in the Proto's 'locvars' array */ |
98 | TString *name; /* variable name */ | ||
99 | } vd; | ||
100 | TValue k; /* constant value (if any) */ | ||
91 | } Vardesc; | 101 | } Vardesc; |
92 | 102 | ||
93 | 103 | ||
94 | /* check whether Vardesc is in the stack (not a compile-time constant) */ | ||
95 | #define vdinstack(vd) (ttisnil(vd)) | ||
96 | |||
97 | 104 | ||
98 | /* description of pending goto statements and label statements */ | 105 | /* description of pending goto statements and label statements */ |
99 | typedef struct Labeldesc { | 106 | typedef struct Labeldesc { |