1993-07-28 17:18:00 +04:00
|
|
|
/*
|
|
|
|
** TeCGraf - PUC-Rio
|
1996-03-15 16:13:13 +03:00
|
|
|
** $Id: opcode.h,v 3.19 1996/03/06 13:11:23 roberto Exp $
|
1993-07-28 17:18:00 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef opcode_h
|
|
|
|
#define opcode_h
|
|
|
|
|
1994-11-02 23:30:53 +03:00
|
|
|
#include "lua.h"
|
1994-12-21 00:20:36 +03:00
|
|
|
#include "types.h"
|
1994-11-23 17:32:00 +03:00
|
|
|
#include "tree.h"
|
1995-10-04 20:13:02 +03:00
|
|
|
#include "func.h"
|
1994-11-02 23:30:53 +03:00
|
|
|
|
1993-07-28 17:18:00 +04:00
|
|
|
|
1994-02-13 23:35:53 +03:00
|
|
|
#define FIELDS_PER_FLUSH 40
|
|
|
|
|
1994-08-05 23:31:09 +04:00
|
|
|
|
1993-07-28 17:18:00 +04:00
|
|
|
typedef enum
|
|
|
|
{
|
|
|
|
PUSHNIL,
|
|
|
|
PUSH0, PUSH1, PUSH2,
|
|
|
|
PUSHBYTE,
|
|
|
|
PUSHWORD,
|
|
|
|
PUSHFLOAT,
|
|
|
|
PUSHSTRING,
|
1994-08-05 23:31:09 +04:00
|
|
|
PUSHFUNCTION,
|
1993-07-28 17:18:00 +04:00
|
|
|
PUSHLOCAL0, PUSHLOCAL1, PUSHLOCAL2, PUSHLOCAL3, PUSHLOCAL4,
|
|
|
|
PUSHLOCAL5, PUSHLOCAL6, PUSHLOCAL7, PUSHLOCAL8, PUSHLOCAL9,
|
|
|
|
PUSHLOCAL,
|
|
|
|
PUSHGLOBAL,
|
|
|
|
PUSHINDEXED,
|
1994-11-02 23:30:53 +03:00
|
|
|
PUSHSELF,
|
1993-07-28 17:18:00 +04:00
|
|
|
STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4,
|
|
|
|
STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9,
|
|
|
|
STORELOCAL,
|
|
|
|
STOREGLOBAL,
|
|
|
|
STOREINDEXED0,
|
|
|
|
STOREINDEXED,
|
1994-02-13 23:35:53 +03:00
|
|
|
STORELIST0,
|
|
|
|
STORELIST,
|
|
|
|
STORERECORD,
|
1994-11-02 23:30:53 +03:00
|
|
|
ADJUST0,
|
1993-07-28 17:18:00 +04:00
|
|
|
ADJUST,
|
|
|
|
CREATEARRAY,
|
|
|
|
EQOP,
|
|
|
|
LTOP,
|
|
|
|
LEOP,
|
1994-11-06 18:35:04 +03:00
|
|
|
GTOP,
|
|
|
|
GEOP,
|
1993-07-28 17:18:00 +04:00
|
|
|
ADDOP,
|
|
|
|
SUBOP,
|
|
|
|
MULTOP,
|
|
|
|
DIVOP,
|
1994-10-17 22:00:40 +03:00
|
|
|
POWOP,
|
1993-07-28 17:18:00 +04:00
|
|
|
CONCOP,
|
|
|
|
MINUSOP,
|
|
|
|
NOTOP,
|
|
|
|
ONTJMP,
|
|
|
|
ONFJMP,
|
|
|
|
JMP,
|
|
|
|
UPJMP,
|
|
|
|
IFFJMP,
|
|
|
|
IFFUPJMP,
|
|
|
|
POP,
|
|
|
|
CALLFUNC,
|
1994-11-02 23:30:53 +03:00
|
|
|
RETCODE0,
|
1993-07-28 17:18:00 +04:00
|
|
|
RETCODE,
|
1995-10-25 16:05:51 +03:00
|
|
|
SETLINE
|
1993-07-28 17:18:00 +04:00
|
|
|
} OpCode;
|
|
|
|
|
1994-11-02 23:30:53 +03:00
|
|
|
#define MULT_RET 255
|
|
|
|
|
1993-07-28 17:18:00 +04:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
1996-02-13 20:30:39 +03:00
|
|
|
lua_CFunction f;
|
1994-11-02 23:30:53 +03:00
|
|
|
real n;
|
1994-11-23 17:32:00 +03:00
|
|
|
TaggedString *ts;
|
1995-10-04 20:13:02 +03:00
|
|
|
TFunc *tf;
|
1993-07-28 17:18:00 +04:00
|
|
|
struct Hash *a;
|
|
|
|
void *u;
|
1995-10-25 16:05:51 +03:00
|
|
|
int i;
|
1993-07-28 17:18:00 +04:00
|
|
|
} Value;
|
|
|
|
|
|
|
|
typedef struct Object
|
|
|
|
{
|
1994-11-07 18:20:56 +03:00
|
|
|
lua_Type tag;
|
1993-07-28 17:18:00 +04:00
|
|
|
Value value;
|
|
|
|
} Object;
|
|
|
|
|
|
|
|
|
|
|
|
/* Macros to access structure members */
|
|
|
|
#define tag(o) ((o)->tag)
|
|
|
|
#define nvalue(o) ((o)->value.n)
|
1994-11-23 17:32:00 +03:00
|
|
|
#define svalue(o) ((o)->value.ts->str)
|
|
|
|
#define tsvalue(o) ((o)->value.ts)
|
1993-07-28 17:18:00 +04:00
|
|
|
#define avalue(o) ((o)->value.a)
|
|
|
|
#define fvalue(o) ((o)->value.f)
|
|
|
|
#define uvalue(o) ((o)->value.u)
|
|
|
|
|
|
|
|
/* Macros to access symbol table */
|
|
|
|
#define s_object(i) (lua_table[i].object)
|
|
|
|
#define s_tag(i) (tag(&s_object(i)))
|
|
|
|
#define s_nvalue(i) (nvalue(&s_object(i)))
|
|
|
|
#define s_svalue(i) (svalue(&s_object(i)))
|
|
|
|
#define s_avalue(i) (avalue(&s_object(i)))
|
|
|
|
#define s_fvalue(i) (fvalue(&s_object(i)))
|
|
|
|
#define s_uvalue(i) (uvalue(&s_object(i)))
|
|
|
|
|
1994-12-21 00:20:36 +03:00
|
|
|
typedef union
|
|
|
|
{
|
1996-03-01 19:54:00 +03:00
|
|
|
struct {Byte c1; Byte c2;} m;
|
1994-12-21 00:20:36 +03:00
|
|
|
Word w;
|
|
|
|
} CodeWord;
|
1994-04-14 01:37:20 +04:00
|
|
|
#define get_word(code,pc) {code.m.c1 = *pc++; code.m.c2 = *pc++;}
|
1994-12-21 00:20:36 +03:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
1996-03-01 19:54:00 +03:00
|
|
|
struct {Byte c1; Byte c2; Byte c3; Byte c4;} m;
|
1994-12-21 00:20:36 +03:00
|
|
|
float f;
|
|
|
|
} CodeFloat;
|
1994-04-14 01:37:20 +04:00
|
|
|
#define get_float(code,pc) {code.m.c1 = *pc++; code.m.c2 = *pc++;\
|
|
|
|
code.m.c3 = *pc++; code.m.c4 = *pc++;}
|
1994-12-21 00:20:36 +03:00
|
|
|
|
|
|
|
typedef union
|
|
|
|
{
|
1996-03-01 19:54:00 +03:00
|
|
|
struct {Byte c1; Byte c2; Byte c3; Byte c4;} m;
|
1995-10-04 20:13:02 +03:00
|
|
|
TFunc *tf;
|
1994-12-21 00:20:36 +03:00
|
|
|
} CodeCode;
|
1994-08-05 23:31:09 +04:00
|
|
|
#define get_code(code,pc) {code.m.c1 = *pc++; code.m.c2 = *pc++;\
|
|
|
|
code.m.c3 = *pc++; code.m.c4 = *pc++;}
|
1994-12-21 00:20:36 +03:00
|
|
|
|
1994-04-14 01:37:20 +04:00
|
|
|
|
1993-07-28 17:18:00 +04:00
|
|
|
/* Exported functions */
|
1995-10-04 20:13:02 +03:00
|
|
|
void lua_parse (TFunc *tf); /* from "lua.stx" module */
|
1995-10-25 16:05:51 +03:00
|
|
|
void luaI_codedebugline (int line); /* from "lua.stx" module */
|
1995-10-17 14:58:41 +03:00
|
|
|
void lua_travstack (int (*fn)(Object *));
|
1994-11-07 19:34:44 +03:00
|
|
|
Object *luaI_Address (lua_Object o);
|
|
|
|
void luaI_pushobject (Object *o);
|
1994-11-10 20:36:54 +03:00
|
|
|
void luaI_gcFB (Object *o);
|
1996-03-15 16:13:13 +03:00
|
|
|
int luaI_dorun (TFunc *tf);
|
1993-07-28 17:18:00 +04:00
|
|
|
|
|
|
|
#endif
|