diff options
| author | chai <chaifix@163.com> | 2020-09-27 20:31:53 +0800 |
|---|---|---|
| committer | chai <chaifix@163.com> | 2020-09-27 20:31:53 +0800 |
| commit | 63cb4fbbb961da133c68865845eaf22d9b876700 (patch) | |
| tree | 42be163db598df2cf1c11d329c3e5843db4faa0c /src/lua51/lparser.h | |
| parent | 2dfa15a926f06137f2ba6afcce2e3c1d23300100 (diff) | |
*misc
Diffstat (limited to 'src/lua51/lparser.h')
| -rw-r--r-- | src/lua51/lparser.h | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/lua51/lparser.h b/src/lua51/lparser.h index 18836af..dbd7405 100644 --- a/src/lua51/lparser.h +++ b/src/lua51/lparser.h @@ -34,8 +34,9 @@ typedef enum { VVARARG /* info = instruction pc */ } expkind; +//c 存放表达式信息 typedef struct expdesc { - expkind k; + expkind k; // 表达式类型 union { struct { int info, aux; } s; lua_Number nval; @@ -54,27 +55,32 @@ typedef struct upvaldesc { struct BlockCnt; /* defined in lparser.c */ +//c 编译过程(词法分析、语法分析、代码生成阶段)的临时数据结构 +//c 用来辅助生成字节码 /* state needed to generate code for a given function */ typedef struct FuncState { + //c 函数字节码 Proto *f; /* current function header */ Table *h; /* table to find (and reuse) elements in `k' */ - struct FuncState *prev; /* enclosing function */ + //c 指向父函数的指针 + struct FuncState *prev; /* enclosing function */ struct LexState *ls; /* lexical state */ struct lua_State *L; /* copy of the Lua state */ struct BlockCnt *bl; /* chain of current blocks */ int pc; /* next position to code (equivalent to `ncode') */ int lasttarget; /* `pc' of last `jump target' */ int jpc; /* list of pending jumps to `pc' */ - int freereg; /* first free register */ + int freereg; /* first free register */ // 用来指示局部变量的栈位置 int nk; /* number of elements in `k' */ int np; /* number of elements in `p' */ short nlocvars; /* number of elements in `locvars' */ lu_byte nactvar; /* number of active local variables */ upvaldesc upvalues[LUAI_MAXUPVALUES]; /* upvalues */ - unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ + unsigned short actvar[LUAI_MAXVARS]; /* declared-variable stack */ // 在函数原型f->locvars的序号 } FuncState; +//c 编译的唯一入口,包含词法、语法、代码生成 LUAI_FUNC Proto *luaY_parser (lua_State *L, ZIO *z, Mbuffer *buff, const char *name); |
