Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-11-07 10:37:55

0001 /*
0002 ** $Id: lcode.h $
0003 ** Code generator for Lua
0004 ** See Copyright Notice in lua.h
0005 */
0006 
0007 #ifndef lcode_h
0008 #define lcode_h
0009 
0010 #include "llex.h"
0011 #include "lobject.h"
0012 #include "lopcodes.h"
0013 #include "lparser.h"
0014 
0015 
0016 /*
0017 ** Marks the end of a patch list. It is an invalid value both as an absolute
0018 ** address, and as a list link (would link an element to itself).
0019 */
0020 #define NO_JUMP (-1)
0021 
0022 
0023 /*
0024 ** grep "ORDER OPR" if you change these enums  (ORDER OP)
0025 */
0026 typedef enum BinOpr {
0027   /* arithmetic operators */
0028   OPR_ADD, OPR_SUB, OPR_MUL, OPR_MOD, OPR_POW,
0029   OPR_DIV, OPR_IDIV,
0030   /* bitwise operators */
0031   OPR_BAND, OPR_BOR, OPR_BXOR,
0032   OPR_SHL, OPR_SHR,
0033   /* string operator */
0034   OPR_CONCAT,
0035   /* comparison operators */
0036   OPR_EQ, OPR_LT, OPR_LE,
0037   OPR_NE, OPR_GT, OPR_GE,
0038   /* logical operators */
0039   OPR_AND, OPR_OR,
0040   OPR_NOBINOPR
0041 } BinOpr;
0042 
0043 
0044 /* true if operation is foldable (that is, it is arithmetic or bitwise) */
0045 #define foldbinop(op)   ((op) <= OPR_SHR)
0046 
0047 
0048 #define luaK_codeABC(fs,o,a,b,c)    luaK_codeABCk(fs,o,a,b,c,0)
0049 
0050 
0051 typedef enum UnOpr { OPR_MINUS, OPR_BNOT, OPR_NOT, OPR_LEN, OPR_NOUNOPR } UnOpr;
0052 
0053 
0054 /* get (pointer to) instruction of given 'expdesc' */
0055 #define getinstruction(fs,e)    ((fs)->f->code[(e)->u.info])
0056 
0057 
0058 #define luaK_setmultret(fs,e)   luaK_setreturns(fs, e, LUA_MULTRET)
0059 
0060 #define luaK_jumpto(fs,t)   luaK_patchlist(fs, luaK_jump(fs), t)
0061 
0062 LUAI_FUNC int luaK_code (FuncState *fs, Instruction i);
0063 LUAI_FUNC int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
0064 LUAI_FUNC int luaK_codeABCk (FuncState *fs, OpCode o, int A,
0065                                             int B, int C, int k);
0066 LUAI_FUNC int luaK_exp2const (FuncState *fs, const expdesc *e, TValue *v);
0067 LUAI_FUNC void luaK_fixline (FuncState *fs, int line);
0068 LUAI_FUNC void luaK_nil (FuncState *fs, int from, int n);
0069 LUAI_FUNC void luaK_reserveregs (FuncState *fs, int n);
0070 LUAI_FUNC void luaK_checkstack (FuncState *fs, int n);
0071 LUAI_FUNC void luaK_int (FuncState *fs, int reg, lua_Integer n);
0072 LUAI_FUNC void luaK_dischargevars (FuncState *fs, expdesc *e);
0073 LUAI_FUNC int luaK_exp2anyreg (FuncState *fs, expdesc *e);
0074 LUAI_FUNC void luaK_exp2anyregup (FuncState *fs, expdesc *e);
0075 LUAI_FUNC void luaK_exp2nextreg (FuncState *fs, expdesc *e);
0076 LUAI_FUNC void luaK_exp2val (FuncState *fs, expdesc *e);
0077 LUAI_FUNC void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
0078 LUAI_FUNC void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
0079 LUAI_FUNC void luaK_goiftrue (FuncState *fs, expdesc *e);
0080 LUAI_FUNC void luaK_goiffalse (FuncState *fs, expdesc *e);
0081 LUAI_FUNC void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
0082 LUAI_FUNC void luaK_setreturns (FuncState *fs, expdesc *e, int nresults);
0083 LUAI_FUNC void luaK_setoneret (FuncState *fs, expdesc *e);
0084 LUAI_FUNC int luaK_jump (FuncState *fs);
0085 LUAI_FUNC void luaK_ret (FuncState *fs, int first, int nret);
0086 LUAI_FUNC void luaK_patchlist (FuncState *fs, int list, int target);
0087 LUAI_FUNC void luaK_patchtohere (FuncState *fs, int list);
0088 LUAI_FUNC void luaK_concat (FuncState *fs, int *l1, int l2);
0089 LUAI_FUNC int luaK_getlabel (FuncState *fs);
0090 LUAI_FUNC void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v, int line);
0091 LUAI_FUNC void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
0092 LUAI_FUNC void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1,
0093                             expdesc *v2, int line);
0094 LUAI_FUNC void luaK_settablesize (FuncState *fs, int pc,
0095                                   int ra, int asize, int hsize);
0096 LUAI_FUNC void luaK_setlist (FuncState *fs, int base, int nelems, int tostore);
0097 LUAI_FUNC void luaK_finish (FuncState *fs);
0098 LUAI_FUNC l_noret luaK_semerror (LexState *ls, const char *msg);
0099 
0100 
0101 #endif