aboutsummaryrefslogtreecommitdiff
path: root/lparser.h
diff options
context:
space:
mode:
authorRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-12-30 16:16:13 -0200
committerRoberto Ierusalimschy <roberto@inf.puc-rio.br>2015-12-30 16:16:13 -0200
commit07cf8415e3197b9a8e0f46743f7f9adc8fe8a256 (patch)
tree76730224aa9f53e42f20b0cb6069a3c98240df95 /lparser.h
parentc0836dda740f735c3f6a01b0090870b6c806d479 (diff)
downloadlua-07cf8415e3197b9a8e0f46743f7f9adc8fe8a256.tar.gz
lua-07cf8415e3197b9a8e0f46743f7f9adc8fe8a256.tar.bz2
lua-07cf8415e3197b9a8e0f46743f7f9adc8fe8a256.zip
more comments + reordeing of union inside 'expdesc' to allow
static initialization of a VKINT value
Diffstat (limited to 'lparser.h')
-rw-r--r--lparser.h29
1 files changed, 16 insertions, 13 deletions
diff --git a/lparser.h b/lparser.h
index 1e15a92b..13e613ac 100644
--- a/lparser.h
+++ b/lparser.h
@@ -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 */
23typedef enum { 25typedef 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 {
51typedef struct expdesc { 54typedef 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' */