diff options
| -rw-r--r-- | lparser.h | 29 |
1 files changed, 16 insertions, 13 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp roberto $ | 2 | ** $Id: lparser.h,v 1.75 2015/12/17 15:44:50 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 | */ |
| @@ -13,15 +13,18 @@ | |||
| 13 | 13 | ||
| 14 | 14 | ||
| 15 | /* | 15 | /* |
| 16 | ** Expression descriptor. | 16 | ** Expression and variable descriptor. |
| 17 | ** Code generation for expressions can be delayed to allow | 17 | ** Code generation for variables and expressions can be delayed to allow |
| 18 | ** optimizations; An 'expdesc' structure describes a | 18 | ** optimizations; An 'expdesc' structure describes a potentially-delayed |
| 19 | ** potentially-delayed expression. | 19 | ** variable/expression. It has a description of its "main" value plus a |
| 20 | ** list of conditional jumps that can also produce its value (generated | ||
| 21 | ** by short-circuit operators 'and'/'or'). | ||
| 20 | */ | 22 | */ |
| 21 | 23 | ||
| 22 | /* kinds of expressions */ | 24 | /* kinds of variables/expressions */ |
| 23 | typedef enum { | 25 | typedef enum { |
| 24 | VVOID, /* expression has no value */ | 26 | VVOID, /* when 'expdesc' describes the last expression a list, |
| 27 | this kind means an empty list (so, no expression) */ | ||
| 25 | VNIL, /* constant nil */ | 28 | VNIL, /* constant nil */ |
| 26 | VTRUE, /* constant true */ | 29 | VTRUE, /* constant true */ |
| 27 | VFALSE, /* constant false */ | 30 | VFALSE, /* constant false */ |
| @@ -31,11 +34,11 @@ typedef enum { | |||
| 31 | VNONRELOC, /* expression has its value in a fixed register; | 34 | VNONRELOC, /* expression has its value in a fixed register; |
| 32 | info = result register */ | 35 | info = result register */ |
| 33 | VLOCAL, /* local variable; info = local register */ | 36 | VLOCAL, /* local variable; info = local register */ |
| 34 | VUPVAL, /* upvalue; info = index of upvalue in 'upvalues' */ | 37 | VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ |
| 35 | VINDEXED, /* indexed expression; | 38 | VINDEXED, /* indexed variable; |
| 36 | ind.vt = whether 't' is register or upvalue; | 39 | ind.vt = whether 't' is register or upvalue; |
| 37 | ind.t = table register or upvalue; | 40 | ind.t = table register or upvalue; |
| 38 | ind.idx = index as R/K */ | 41 | ind.idx = key's R/K index */ |
| 39 | VJMP, /* expression is a test/comparison; | 42 | VJMP, /* expression is a test/comparison; |
| 40 | info = pc of corresponding jump instruction */ | 43 | info = pc of corresponding jump instruction */ |
| 41 | VRELOCABLE, /* expression can put result in any register; | 44 | VRELOCABLE, /* expression can put result in any register; |
| @@ -51,14 +54,14 @@ typedef enum { | |||
| 51 | typedef struct expdesc { | 54 | typedef struct expdesc { |
| 52 | expkind k; | 55 | expkind k; |
| 53 | union { | 56 | union { |
| 57 | lua_Integer ival; /* for VKINT */ | ||
| 58 | lua_Number nval; /* for VKFLT */ | ||
| 59 | int info; /* for generic use */ | ||
| 54 | struct { /* for indexed variables (VINDEXED) */ | 60 | struct { /* for indexed variables (VINDEXED) */ |
| 55 | short idx; /* index (R/K) */ | 61 | short idx; /* index (R/K) */ |
| 56 | lu_byte t; /* table (register or upvalue) */ | 62 | lu_byte t; /* table (register or upvalue) */ |
| 57 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ | 63 | lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ |
| 58 | } ind; | 64 | } ind; |
| 59 | int info; /* for generic use */ | ||
| 60 | lua_Number nval; /* for VKFLT */ | ||
| 61 | lua_Integer ival; /* for VKINT */ | ||
| 62 | } u; | 65 | } u; |
| 63 | int t; /* patch list of 'exit when true' */ | 66 | int t; /* patch list of 'exit when true' */ |
| 64 | int f; /* patch list of 'exit when false' */ | 67 | int f; /* patch list of 'exit when false' */ |
