diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2001-06-05 15:17:01 -0300 |
| commit | 762d059a13d83eb367238a6115bbb4f5f13fcb49 (patch) | |
| tree | f35fdf0675b791865d0d4800522b172903b34803 /lcode.h | |
| parent | 572a69b6afbd368beab8844bc876b0f9690b5253 (diff) | |
| download | lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.gz lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.tar.bz2 lua-762d059a13d83eb367238a6115bbb4f5f13fcb49.zip | |
new implementation for the Virtual Machine
Diffstat (limited to 'lcode.h')
| -rw-r--r-- | lcode.h | 49 |
1 files changed, 21 insertions, 28 deletions
| @@ -1,5 +1,5 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** $Id: lcode.h,v 1.20 2001/02/20 18:15:33 roberto Exp roberto $ | 2 | ** $Id: lcode.h,v 1.21 2001/02/23 17:17:25 roberto Exp roberto $ |
| 3 | ** Code generator for Lua | 3 | ** Code generator for Lua |
| 4 | ** See Copyright Notice in lua.h | 4 | ** See Copyright Notice in lua.h |
| 5 | */ | 5 | */ |
| @@ -31,43 +31,36 @@ typedef enum BinOpr { | |||
| 31 | OPR_NOBINOPR | 31 | OPR_NOBINOPR |
| 32 | } BinOpr; | 32 | } BinOpr; |
| 33 | 33 | ||
| 34 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr; | 34 | #define binopistest(op) ((op) >= OPR_NE) |
| 35 | |||
| 36 | |||
| 37 | enum Mode {iO, iU, iS, iAB}; /* instruction format */ | ||
| 38 | 35 | ||
| 39 | #define VD 100 /* flag for variable delta */ | 36 | typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr; |
| 40 | |||
| 41 | typedef struct OpProperties { | ||
| 42 | lu_byte mode; | ||
| 43 | lu_byte push; | ||
| 44 | lu_byte pop; | ||
| 45 | } OpProperties; | ||
| 46 | 37 | ||
| 47 | extern const OpProperties luaK_opproperties[]; | ||
| 48 | 38 | ||
| 39 | #define luaK_codeAsBc(fs,o,A,sBc) luaK_codeABc(fs,o,A,(sBc)+MAXARG_sBc) | ||
| 49 | 40 | ||
| 50 | void luaK_error (LexState *ls, const l_char *msg); | 41 | void luaK_error (LexState *ls, const l_char *msg); |
| 51 | int luaK_code0 (FuncState *fs, OpCode o); | 42 | int luaK_codeABc (FuncState *fs, OpCode o, int A, int Bc); |
| 52 | int luaK_code1 (FuncState *fs, OpCode o, int arg1); | 43 | int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C); |
| 53 | int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2); | 44 | void luaK_nil (FuncState *fs, int from, int n); |
| 45 | void luaK_reserveregs (FuncState *fs, int n); | ||
| 46 | int luaK_stringk (FuncState *fs, TString *s); | ||
| 47 | int luaK_exp2anyreg (FuncState *fs, expdesc *e); | ||
| 48 | void luaK_exp2nextreg (FuncState *fs, expdesc *e); | ||
| 49 | void luaK_exp2val (FuncState *fs, expdesc *e); | ||
| 50 | int luaK_exp2RK (FuncState *fs, expdesc *e); | ||
| 51 | void luaK_self (FuncState *fs, expdesc *e, expdesc *key); | ||
| 52 | void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k); | ||
| 53 | void luaK_goiftrue (FuncState *fs, expdesc *e); | ||
| 54 | void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e); | ||
| 55 | void luaK_setcallreturns (FuncState *fs, expdesc *var, int nresults); | ||
| 54 | int luaK_jump (FuncState *fs); | 56 | int luaK_jump (FuncState *fs); |
| 55 | void luaK_patchlist (FuncState *fs, int list, int target); | 57 | void luaK_patchlist (FuncState *fs, int list, int target); |
| 56 | void luaK_fixfor (FuncState *fs, int pc, int dest); | 58 | void luaK_fixfor (FuncState *fs, int pc, int dest); |
| 57 | void luaK_concat (FuncState *fs, int *l1, int l2); | 59 | void luaK_concat (FuncState *fs, int *l1, int l2); |
| 58 | void luaK_goiftrue (FuncState *fs, expdesc *v, int keepvalue); | ||
| 59 | int luaK_getlabel (FuncState *fs); | 60 | int luaK_getlabel (FuncState *fs); |
| 60 | void luaK_deltastack (FuncState *fs, int delta); | 61 | void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v); |
| 61 | void luaK_kstr (LexState *ls, int c); | 62 | void luaK_infix (FuncState *fs, BinOpr op, expdesc *v); |
| 62 | void luaK_number (FuncState *fs, lua_Number f); | 63 | void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2); |
| 63 | void luaK_adjuststack (FuncState *fs, int n); | ||
| 64 | int luaK_lastisopen (FuncState *fs); | ||
| 65 | void luaK_setcallreturns (FuncState *fs, int nresults); | ||
| 66 | void luaK_tostack (LexState *ls, expdesc *v, int onlyone); | ||
| 67 | void luaK_storevar (LexState *ls, const expdesc *var); | ||
| 68 | void luaK_prefix (LexState *ls, UnOpr op, expdesc *v); | ||
| 69 | void luaK_infix (LexState *ls, BinOpr op, expdesc *v); | ||
| 70 | void luaK_posfix (LexState *ls, BinOpr op, expdesc *v1, expdesc *v2); | ||
| 71 | 64 | ||
| 72 | 65 | ||
| 73 | #endif | 66 | #endif |
