aboutsummaryrefslogtreecommitdiff
path: root/opcode.h
diff options
context:
space:
mode:
authorThe Lua team <lua@tecgraf.puc-rio.br>1993-07-28 10:18:00 -0300
committerThe Lua team <lua@tecgraf.puc-rio.br>1993-07-28 10:18:00 -0300
commitcd05d9c5cb69020c069f037ba7f243f705d0a48a (patch)
treecb7f08c0684c10970a528984741047fb3babadd3 /opcode.h
downloadlua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.tar.gz
lua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.tar.bz2
lua-cd05d9c5cb69020c069f037ba7f243f705d0a48a.zip
oldest known commit
Diffstat (limited to 'opcode.h')
-rw-r--r--opcode.h144
1 files changed, 144 insertions, 0 deletions
diff --git a/opcode.h b/opcode.h
new file mode 100644
index 00000000..b32969d5
--- /dev/null
+++ b/opcode.h
@@ -0,0 +1,144 @@
1/*
2** opcode.h
3** TeCGraf - PUC-Rio
4** 16 Apr 92
5*/
6
7#ifndef opcode_h
8#define opcode_h
9
10#ifndef STACKGAP
11#define STACKGAP 128
12#endif
13
14#ifndef real
15#define real float
16#endif
17
18typedef unsigned char Byte;
19
20typedef unsigned short Word;
21
22typedef enum
23{
24 NOP,
25 PUSHNIL,
26 PUSH0, PUSH1, PUSH2,
27 PUSHBYTE,
28 PUSHWORD,
29 PUSHFLOAT,
30 PUSHSTRING,
31 PUSHLOCAL0, PUSHLOCAL1, PUSHLOCAL2, PUSHLOCAL3, PUSHLOCAL4,
32 PUSHLOCAL5, PUSHLOCAL6, PUSHLOCAL7, PUSHLOCAL8, PUSHLOCAL9,
33 PUSHLOCAL,
34 PUSHGLOBAL,
35 PUSHINDEXED,
36 PUSHMARK,
37 PUSHOBJECT,
38 STORELOCAL0, STORELOCAL1, STORELOCAL2, STORELOCAL3, STORELOCAL4,
39 STORELOCAL5, STORELOCAL6, STORELOCAL7, STORELOCAL8, STORELOCAL9,
40 STORELOCAL,
41 STOREGLOBAL,
42 STOREINDEXED0,
43 STOREINDEXED,
44 STOREFIELD,
45 ADJUST,
46 CREATEARRAY,
47 EQOP,
48 LTOP,
49 LEOP,
50 ADDOP,
51 SUBOP,
52 MULTOP,
53 DIVOP,
54 CONCOP,
55 MINUSOP,
56 NOTOP,
57 ONTJMP,
58 ONFJMP,
59 JMP,
60 UPJMP,
61 IFFJMP,
62 IFFUPJMP,
63 POP,
64 CALLFUNC,
65 RETCODE,
66 HALT,
67 SETFUNCTION,
68 SETLINE,
69 RESET
70} OpCode;
71
72typedef enum
73{
74 T_MARK,
75 T_NIL,
76 T_NUMBER,
77 T_STRING,
78 T_ARRAY,
79 T_FUNCTION,
80 T_CFUNCTION,
81 T_USERDATA
82} Type;
83
84typedef void (*Cfunction) (void);
85typedef int (*Input) (void);
86typedef void (*Unput) (int );
87
88typedef union
89{
90 Cfunction f;
91 real n;
92 char *s;
93 Byte *b;
94 struct Hash *a;
95 void *u;
96} Value;
97
98typedef struct Object
99{
100 Type tag;
101 Value value;
102} Object;
103
104typedef struct
105{
106 char *name;
107 Object object;
108} Symbol;
109
110/* Macros to access structure members */
111#define tag(o) ((o)->tag)
112#define nvalue(o) ((o)->value.n)
113#define svalue(o) ((o)->value.s)
114#define bvalue(o) ((o)->value.b)
115#define avalue(o) ((o)->value.a)
116#define fvalue(o) ((o)->value.f)
117#define uvalue(o) ((o)->value.u)
118
119/* Macros to access symbol table */
120#define s_name(i) (lua_table[i].name)
121#define s_object(i) (lua_table[i].object)
122#define s_tag(i) (tag(&s_object(i)))
123#define s_nvalue(i) (nvalue(&s_object(i)))
124#define s_svalue(i) (svalue(&s_object(i)))
125#define s_bvalue(i) (bvalue(&s_object(i)))
126#define s_avalue(i) (avalue(&s_object(i)))
127#define s_fvalue(i) (fvalue(&s_object(i)))
128#define s_uvalue(i) (uvalue(&s_object(i)))
129
130
131/* Exported functions */
132int lua_execute (Byte *pc);
133void lua_markstack (void);
134char *lua_strdup (char *l);
135
136void lua_setinput (Input fn); /* from "lua.lex" module */
137void lua_setunput (Unput fn); /* from "lua.lex" module */
138char *lua_lasttext (void); /* from "lua.lex" module */
139int lua_parse (void); /* from "lua.stx" module */
140void lua_type (void);
141void lua_obj2number (void);
142void lua_print (void);
143
144#endif