better code for unary/binary operators

This commit is contained in:
Roberto Ierusalimschy
2000-08-09 11:49:13 -03:00
parent a7c1390ffa
commit 5f22f8961c
3 changed files with 117 additions and 74 deletions

22
lcode.h
View File

@@ -1,5 +1,5 @@
/*
** $Id: lcode.h,v 1.14 2000/06/16 17:51:40 roberto Exp roberto $
** $Id: lcode.h,v 1.15 2000/06/28 20:20:36 roberto Exp roberto $
** Code generator for Lua
** See Copyright Notice in lua.h
*/
@@ -20,6 +20,20 @@
#define NO_JUMP (-1)
/*
** grep "ORDER OPR" if you change these enums
*/
typedef enum BinOpr {
OPR_ADD, OPR_SUB, OPR_MULT, OPR_DIV, OPR_POW,
OPR_CONCAT,
OPR_NE, OPR_EQ, OPR_LT, OPR_LE, OPR_GT, OPR_GE,
OPR_AND, OPR_OR,
OPR_NOBINOPR
} BinOpr;
typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr;
enum Mode {iO, iU, iS, iAB}; /* instruction format */
#define VD 100 /* flag for variable delta */
@@ -48,9 +62,9 @@ int luaK_lastisopen (FuncState *fs);
void luaK_setcallreturns (FuncState *fs, int nresults);
void luaK_tostack (LexState *ls, expdesc *v, int onlyone);
void luaK_storevar (LexState *ls, const expdesc *var);
void luaK_prefix (LexState *ls, int op, expdesc *v);
void luaK_infix (LexState *ls, int op, expdesc *v);
void luaK_posfix (LexState *ls, int op, expdesc *v1, expdesc *v2);
void luaK_prefix (LexState *ls, UnOpr op, expdesc *v);
void luaK_infix (LexState *ls, BinOpr op, expdesc *v);
void luaK_posfix (LexState *ls, BinOpr op, expdesc *v1, expdesc *v2);
#endif