lua/lcode.h

74 lines
2.0 KiB
C
Raw Normal View History

2000-02-22 21:31:19 +08:00
/*
2001-02-24 01:17:25 +08:00
** $Id: lcode.h,v 1.20 2001/02/20 18:15:33 roberto Exp roberto $
2000-02-22 21:31:19 +08:00
** Code generator for Lua
** See Copyright Notice in lua.h
*/
#ifndef lcode_h
#define lcode_h
#include "llex.h"
#include "lobject.h"
#include "lopcodes.h"
#include "lparser.h"
2000-02-22 21:31:19 +08:00
2000-04-13 02:47:03 +08:00
/*
** Marks the end of a patch list. It is an invalid value both as an absolute
** address, and as a list link (would link an element to itself).
*/
#define NO_JUMP (-1)
2000-04-06 01:51:58 +08:00
2000-08-09 22:49:13 +08:00
/*
** 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 */
2000-06-29 04:21:06 +08:00
#define VD 100 /* flag for variable delta */
typedef struct OpProperties {
2001-02-21 02:15:33 +08:00
lu_byte mode;
lu_byte push;
lu_byte pop;
} OpProperties;
extern const OpProperties luaK_opproperties[];
2001-02-24 01:17:25 +08:00
void luaK_error (LexState *ls, const l_char *msg);
2000-04-08 03:35:20 +08:00
int luaK_code0 (FuncState *fs, OpCode o);
int luaK_code1 (FuncState *fs, OpCode o, int arg1);
int luaK_code2 (FuncState *fs, OpCode o, int arg1, int arg2);
2000-04-06 01:51:58 +08:00
int luaK_jump (FuncState *fs);
2000-03-14 04:37:16 +08:00
void luaK_patchlist (FuncState *fs, int list, int target);
2001-01-29 23:26:40 +08:00
void luaK_fixfor (FuncState *fs, int pc, int dest);
2000-04-06 01:51:58 +08:00
void luaK_concat (FuncState *fs, int *l1, int l2);
2000-03-14 04:37:16 +08:00
void luaK_goiftrue (FuncState *fs, expdesc *v, int keepvalue);
int luaK_getlabel (FuncState *fs);
void luaK_deltastack (FuncState *fs, int delta);
void luaK_kstr (LexState *ls, int c);
void luaK_number (FuncState *fs, lua_Number f);
2000-03-14 04:37:16 +08:00
void luaK_adjuststack (FuncState *fs, int n);
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);
2000-08-09 22:49:13 +08:00
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);
2000-02-22 21:31:19 +08:00
#endif