|
@ -1,5 +1,5 @@ |
|
|
/*
|
|
|
/*
|
|
|
** $Id: lparser.h,v 1.74 2014/10/25 11:50:46 roberto Exp roberto $ |
|
|
** $Id: lparser.h,v 1.75 2015/12/17 15:44:50 roberto Exp roberto $ |
|
|
** Lua Parser |
|
|
** Lua Parser |
|
|
** See Copyright Notice in lua.h |
|
|
** See Copyright Notice in lua.h |
|
|
*/ |
|
|
*/ |
|
@ -13,15 +13,18 @@ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
/*
|
|
|
** Expression descriptor. |
|
|
** Expression and variable descriptor. |
|
|
** Code generation for expressions can be delayed to allow |
|
|
** Code generation for variables and expressions can be delayed to allow |
|
|
** optimizations; An 'expdesc' structure describes a |
|
|
** optimizations; An 'expdesc' structure describes a potentially-delayed |
|
|
** potentially-delayed expression. |
|
|
** variable/expression. It has a description of its "main" value plus a |
|
|
|
|
|
** list of conditional jumps that can also produce its value (generated |
|
|
|
|
|
** by short-circuit operators 'and'/'or'). |
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
/* kinds of expressions */ |
|
|
/* kinds of variables/expressions */ |
|
|
typedef enum { |
|
|
typedef enum { |
|
|
VVOID, /* expression has no value */ |
|
|
VVOID, /* when 'expdesc' describes the last expression a list,
|
|
|
|
|
|
this kind means an empty list (so, no expression) */ |
|
|
VNIL, /* constant nil */ |
|
|
VNIL, /* constant nil */ |
|
|
VTRUE, /* constant true */ |
|
|
VTRUE, /* constant true */ |
|
|
VFALSE, /* constant false */ |
|
|
VFALSE, /* constant false */ |
|
@ -31,11 +34,11 @@ typedef enum { |
|
|
VNONRELOC, /* expression has its value in a fixed register;
|
|
|
VNONRELOC, /* expression has its value in a fixed register;
|
|
|
info = result register */ |
|
|
info = result register */ |
|
|
VLOCAL, /* local variable; info = local register */ |
|
|
VLOCAL, /* local variable; info = local register */ |
|
|
VUPVAL, /* upvalue; info = index of upvalue in 'upvalues' */ |
|
|
VUPVAL, /* upvalue variable; info = index of upvalue in 'upvalues' */ |
|
|
VINDEXED, /* indexed expression;
|
|
|
VINDEXED, /* indexed variable;
|
|
|
ind.vt = whether 't' is register or upvalue; |
|
|
ind.vt = whether 't' is register or upvalue; |
|
|
ind.t = table register or upvalue; |
|
|
ind.t = table register or upvalue; |
|
|
ind.idx = index as R/K */ |
|
|
ind.idx = key's R/K index */ |
|
|
VJMP, /* expression is a test/comparison;
|
|
|
VJMP, /* expression is a test/comparison;
|
|
|
info = pc of corresponding jump instruction */ |
|
|
info = pc of corresponding jump instruction */ |
|
|
VRELOCABLE, /* expression can put result in any register;
|
|
|
VRELOCABLE, /* expression can put result in any register;
|
|
@ -51,14 +54,14 @@ typedef enum { |
|
|
typedef struct expdesc { |
|
|
typedef struct expdesc { |
|
|
expkind k; |
|
|
expkind k; |
|
|
union { |
|
|
union { |
|
|
|
|
|
lua_Integer ival; /* for VKINT */ |
|
|
|
|
|
lua_Number nval; /* for VKFLT */ |
|
|
|
|
|
int info; /* for generic use */ |
|
|
struct { /* for indexed variables (VINDEXED) */ |
|
|
struct { /* for indexed variables (VINDEXED) */ |
|
|
short idx; /* index (R/K) */ |
|
|
short idx; /* index (R/K) */ |
|
|
lu_byte t; /* table (register or upvalue) */ |
|
|
lu_byte t; /* table (register or upvalue) */ |
|
|
lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ |
|
|
lu_byte vt; /* whether 't' is register (VLOCAL) or upvalue (VUPVAL) */ |
|
|
} ind; |
|
|
} ind; |
|
|
int info; /* for generic use */ |
|
|
|
|
|
lua_Number nval; /* for VKFLT */ |
|
|
|
|
|
lua_Integer ival; /* for VKINT */ |
|
|
|
|
|
} u; |
|
|
} u; |
|
|
int t; /* patch list of 'exit when true' */ |
|
|
int t; /* patch list of 'exit when true' */ |
|
|
int f; /* patch list of 'exit when false' */ |
|
|
int f; /* patch list of 'exit when false' */ |
|
|