summaryrefslogtreecommitdiff
path: root/src/lparser.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/lparser.h')
-rw-r--r--src/lparser.h55
1 files changed, 33 insertions, 22 deletions
diff --git a/src/lparser.h b/src/lparser.h
index 445acea6..d6aaaf0e 100644
--- a/src/lparser.h
+++ b/src/lparser.h
@@ -1,13 +1,15 @@
/*
-** $Id: lparser.h,v 1.26 2000/10/09 13:47:46 roberto Exp $
-** LL(1) Parser and code generator for Lua
+** $Id: lparser.h,v 1.47 2003/02/11 10:46:24 roberto Exp $
+** Lua Parser
** See Copyright Notice in lua.h
*/
#ifndef lparser_h
#define lparser_h
+#include "llimits.h"
#include "lobject.h"
+#include "ltable.h"
#include "lzio.h"
@@ -16,45 +18,54 @@
*/
typedef enum {
- VGLOBAL,
- VLOCAL,
- VINDEXED,
- VEXP
+ VVOID, /* no value */
+ VNIL,
+ VTRUE,
+ VFALSE,
+ VK, /* info = index of constant in `k' */
+ VLOCAL, /* info = local register */
+ VUPVAL, /* info = index of upvalue in `upvalues' */
+ VGLOBAL, /* info = index of table; aux = index of global name in `k' */
+ VINDEXED, /* info = table register; aux = index register (or `k') */
+ VJMP, /* info = instruction pc */
+ VRELOCABLE, /* info = instruction pc */
+ VNONRELOC, /* info = result register */
+ VCALL /* info = result register */
} expkind;
typedef struct expdesc {
expkind k;
- union {
- int index; /* VGLOBAL: `kstr' index of global name; VLOCAL: stack index */
- struct {
- int t; /* patch list of `exit when true' */
- int f; /* patch list of `exit when false' */
- } l;
- } u;
+ int info, aux;
+ int t; /* patch list of `exit when true' */
+ int f; /* patch list of `exit when false' */
} expdesc;
+struct BlockCnt; /* defined in lparser.c */
+
/* state needed to generate code for a given function */
typedef struct FuncState {
Proto *f; /* current function header */
+ Table *h; /* table to find (and reuse) elements in `k' */
struct FuncState *prev; /* enclosing function */
struct LexState *ls; /* lexical state */
struct lua_State *L; /* copy of the Lua state */
- int pc; /* next position to code */
+ struct BlockCnt *bl; /* chain of current blocks */
+ int pc; /* next position to code (equivalent to `ncode') */
int lasttarget; /* `pc' of last `jump target' */
- int jlt; /* list of jumps to `lasttarget' */
- short stacklevel; /* number of values on activation register */
- short nactloc; /* number of active local variables */
- short nupvalues; /* number of upvalues */
- int lastline; /* line where last `lineinfo' was generated */
- struct Breaklabel *bl; /* chain of breakable blocks */
+ int jpc; /* list of pending jumps to `pc' */
+ int freereg; /* first free register */
+ int nk; /* number of elements in `k' */
+ int np; /* number of elements in `p' */
+ int nlocvars; /* number of elements in `locvars' */
+ int nactvar; /* number of active local variables */
expdesc upvalues[MAXUPVALUES]; /* upvalues */
- int actloc[MAXLOCALS]; /* local-variable stack (indices to locvars) */
+ int actvar[MAXVARS]; /* declared-variable stack */
} FuncState;
-Proto *luaY_parser (lua_State *L, ZIO *z);
+Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff);
#endif