annotate src/lua/lparser.h @ 218:ca9d2897435b

moved hardcoded stuff into its own namespace.
author Robert McIntyre <rlm@mit.edu>
date Fri, 23 Mar 2012 20:18:03 -0500
parents 27763b933818
children
rev   line source
rlm@1 1 /*
rlm@1 2 ** $Id: lparser.h,v 1.57.1.1 2007/12/27 13:02:25 roberto Exp $
rlm@1 3 ** Lua Parser
rlm@1 4 ** See Copyright Notice in lua.h
rlm@1 5 */
rlm@1 6
rlm@1 7 #ifndef lparser_h
rlm@1 8 #define lparser_h
rlm@1 9
rlm@1 10 #include "llimits.h"
rlm@1 11 #include "lobject.h"
rlm@1 12 #include "lzio.h"
rlm@1 13
rlm@1 14
rlm@1 15 /*
rlm@1 16 ** Expression descriptor
rlm@1 17 */
rlm@1 18
rlm@1 19 typedef enum {
rlm@1 20 VVOID, /* no value */
rlm@1 21 VNIL,
rlm@1 22 VTRUE,
rlm@1 23 VFALSE,
rlm@1 24 VK, /* info = index of constant in `k' */
rlm@1 25 VKNUM, /* nval = numerical value */
rlm@1 26 VLOCAL, /* info = local register */
rlm@1 27 VUPVAL, /* info = index of upvalue in `upvalues' */
rlm@1 28 VGLOBAL, /* info = index of table; aux = index of global name in `k' */
rlm@1 29 VINDEXED, /* info = table register; aux = index register (or `k') */
rlm@1 30 VJMP, /* info = instruction pc */
rlm@1 31 VRELOCABLE, /* info = instruction pc */
rlm@1 32 VNONRELOC, /* info = result register */
rlm@1 33 VCALL, /* info = instruction pc */
rlm@1 34 VVARARG /* info = instruction pc */
rlm@1 35 } expkind;
rlm@1 36
rlm@1 37 typedef struct expdesc {
rlm@1 38 expkind k;
rlm@1 39 union {
rlm@1 40 struct { int info, aux; } s;
rlm@1 41 lua_Number nval;
rlm@1 42 } u;
rlm@1 43 int t; /* patch list of `exit when true' */
rlm@1 44 int f; /* patch list of `exit when false' */
rlm@1 45 } expdesc;
rlm@1 46
rlm@1 47
rlm@1 48 typedef struct upvaldesc {
rlm@1 49 lu_byte k;
rlm@1 50 lu_byte info;
rlm@1 51 } upvaldesc;
rlm@1 52
rlm@1 53
rlm@1 54 struct BlockCnt; /* defined in lparser.c */
rlm@1 55
rlm@1 56
rlm@1 57 /* state needed to generate code for a given function */
rlm@1 58 typedef struct FuncState {
rlm@1 59 Proto *f; /* current function header */
rlm@1 60 Table *h; /* table to find (and reuse) elements in `k' */
rlm@1 61 struct FuncState *prev; /* enclosing function */
rlm@1 62 struct LexState *ls; /* lexical state */
rlm@1 63 struct lua_State *L; /* copy of the Lua state */
rlm@1 64 struct BlockCnt *bl; /* chain of current blocks */
rlm@1 65 int pc; /* next position to code (equivalent to `ncode') */
rlm@1 66 int lasttarget; /* `pc' of last `jump target' */
rlm@1 67 int jpc; /* list of pending jumps to `pc' */
rlm@1 68 int freereg; /* first free register */
rlm@1 69 int nk; /* number of elements in `k' */
rlm@1 70 int np; /* number of elements in `p' */
rlm@1 71 short nlocvars; /* number of elements in `locvars' */
rlm@1 72 lu_byte nactvar; /* number of active local variables */
rlm@1 73 upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */
rlm@1 74 unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */
rlm@1 75 } FuncState;
rlm@1 76
rlm@1 77
rlm@1 78 LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff,
rlm@1 79 const char *name);
rlm@1 80
rlm@1 81
rlm@1 82 #endif