From 5f22f8961c80ce36297f086ae31d87bbb6897c97 Mon Sep 17 00:00:00 2001 From: Roberto Ierusalimschy Date: Wed, 9 Aug 2000 11:49:13 -0300 Subject: better code for unary/binary operators --- lcode.h | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'lcode.h') diff --git a/lcode.h b/lcode.h index f7cf5e2c..c0f3392a 100644 --- a/lcode.h +++ b/lcode.h @@ -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 -- cgit v1.2.3-55-g6feb