diff options
author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-04-28 17:57:45 -0300 |
---|---|---|
committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2017-04-28 17:57:45 -0300 |
commit | 502a1d1108d4e3b97e012d2ed9a496fd003b08db (patch) | |
tree | 0d1daa63ebe8af89a35ec5ecbc48f7e055eb0374 /lparser.h | |
parent | 173e41b2ebed59a716d299470de25e50aee3b921 (diff) | |
download | lua-502a1d1108d4e3b97e012d2ed9a496fd003b08db.tar.gz lua-502a1d1108d4e3b97e012d2ed9a496fd003b08db.tar.bz2 lua-502a1d1108d4e3b97e012d2ed9a496fd003b08db.zip |
new opcodes for table access with constant keys (strings and integers)
Diffstat (limited to 'lparser.h')
-rw-r--r-- | lparser.h | 24 |
1 files changed, 16 insertions, 8 deletions
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | ** $Id: lparser.h,v 1.75 2015/12/17 15:44:50 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.76 2015/12/30 18:16:13 roberto Exp roberto $ |
3 | ** Lua Parser | 3 | ** Lua Parser |
4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
5 | */ | 5 | */ |
@@ -36,9 +36,17 @@ typedef enum { | |||
36 | VLOCAL, /* local variable; info = local register */ | 36 | VLOCAL, /* local variable; info = local register */ |
37 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ | 37 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ |
38 | VINDEXED, /* indexed variable; | 38 | VINDEXED, /* indexed variable; |
39 | ind.vt = whether 't' is register or upvalue; | 39 | ind.t = table register; |
40 | ind.t = table register or upvalue; | 40 | ind.idx = key's R index */ |
41 | ind.idx = key's R/K index */ | 41 | VINDEXUP, /* indexed upvalue; |
42 | ind.t = table upvalue; | ||
43 | ind.idx = key's K index */ | ||
44 | VINDEXI, /* indexed variable with constant integer; | ||
45 | ind.t = table register; | ||
46 | ind.idx = key's value */ | ||
47 | VINDEXSTR, /* indexed variable with literal string; | ||
48 | ind.t = table register; | ||
49 | ind.idx = key's K index */ | ||
42 | VJMP, /* expression is a test/comparison; | 50 | VJMP, /* expression is a test/comparison; |
43 | info = pc of corresponding jump instruction */ | 51 | info = pc of corresponding jump instruction */ |
44 | VRELOCABLE, /* expression can put result in any register; | 52 | VRELOCABLE, /* expression can put result in any register; |
@@ -48,7 +56,8 @@ typedef enum { | |||
48 | } expkind; | 56 | } expkind; |
49 | 57 | ||
50 | 58 | ||
51 | #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXED) | 59 | #define vkisvar(k) (VLOCAL <= (k) && (k) <= VINDEXSTR) |
60 | #define vkisindexed(k) (VINDEXED <= (k) && (k) <= VINDEXSTR) | ||
52 | #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) | 61 | #define vkisinreg(k) ((k) == VNONRELOC || (k) == VLOCAL) |
53 | 62 | ||
54 | typedef struct expdesc { | 63 | typedef struct expdesc { |
@@ -57,10 +66,9 @@ typedef struct expdesc { | |||
57 | lua_Integer ival; /* for VKINT */ | 66 | lua_Integer ival; /* for VKINT */ |
58 | lua_Number nval; /* for VKFLT */ | 67 | lua_Number nval; /* for VKFLT */ |
59 | int info; /* for generic use */ | 68 | int info; /* for generic use */ |
60 | struct { /* for indexed variables (VINDEXED) */ | 69 | struct { /* for indexed variables */ |
61 | short idx; /* index (R/K) */ | 70 | short idx; /* index (R or "long" K) */ |
62 | lu_byte t; /* table (register or upvalue) */ | 71 | lu_byte t; /* table (register or upvalue) */ |
63 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ | ||
64 | } ind; | 72 | } ind; |
65 | } u; | 73 | } u; |
66 | int t; /* patch list of 'exit when true' */ | 74 | int t; /* patch list of 'exit when true' */ |