fix cr/lfs and remove trailing whitespaces...
[supertux.git] / src / squirrel / squirrel / sqopcodes.h
1 /*      see copyright notice in squirrel.h */
2 #ifndef _SQOPCODES_H_
3 #define _SQOPCODES_H_
4
5 #define MAX_FUNC_STACKSIZE 0xFF
6 #define MAX_LITERALS ((SQInteger)0x7FFFFFFF)
7
8 enum BitWiseOP {
9         BW_AND = 0,
10         BW_OR = 2,      //like ADD
11         BW_XOR = 3,
12         BW_SHIFTL = 4,
13         BW_SHIFTR = 5,
14         BW_USHIFTR = 6
15 };
16
17 enum CmpOP {
18         CMP_G = 0,
19         CMP_GE = 2,     //like ADD
20         CMP_L = 3,
21         CMP_LE = 4
22 };
23 enum SQOpcode
24 {
25         _OP_LINE=                               0x00,
26         _OP_LOAD=                               0x01,
27         _OP_LOADINT=                    0x02,
28         _OP_DLOAD=                              0x03,
29         _OP_TAILCALL=                   0x04,
30         _OP_CALL=                               0x05,
31         _OP_PREPCALL=                   0x06,
32         _OP_PREPCALLK=                  0x07,
33         _OP_GETK=                               0x08,
34         _OP_MOVE=                               0x09,
35         _OP_NEWSLOT=                    0x0A,
36         _OP_DELETE=                             0x0B,
37         _OP_SET=                                0x0C,
38         _OP_GET=                                0x0D,
39         _OP_EQ=                                 0x0E,
40         _OP_NE=                                 0x0F,
41         _OP_ARITH=                              0x10,
42         _OP_BITW=                               0x11,
43         _OP_RETURN=                             0x12,
44         _OP_LOADNULLS=                  0x13,
45         _OP_LOADROOTTABLE=              0x14,
46         _OP_LOADBOOL=                   0x15,
47         _OP_DMOVE=                              0x16,
48         _OP_JMP=                                0x17,
49         _OP_JNZ=                                0x18,
50         _OP_JZ=                                 0x19,
51         _OP_LOADFREEVAR=                0x1A,
52         _OP_VARGC=                              0x1B,
53         _OP_GETVARGV=                   0x1C,
54         _OP_NEWTABLE=                   0x1D,
55         _OP_NEWARRAY=                   0x1E,
56         _OP_APPENDARRAY=                0x1F,
57         _OP_GETPARENT=                  0x20,
58         _OP_COMPARITH=                  0x21,
59         _OP_COMPARITHL=                 0x22,
60         _OP_INC=                                0x23,
61         _OP_INCL=                               0x24,
62         _OP_PINC=                               0x25,
63         _OP_PINCL=                              0x26,
64         _OP_CMP=                                0x27,
65         _OP_EXISTS=                             0x28,
66         _OP_INSTANCEOF=                 0x29,
67         _OP_AND=                                0x2A,
68         _OP_OR=                                 0x2B,
69         _OP_NEG=                                0x2C,
70         _OP_NOT=                                0x2D,
71         _OP_BWNOT=                              0x2E,
72         _OP_CLOSURE=                    0x2F,
73         _OP_YIELD=                              0x30,
74         _OP_RESUME=                             0x31,
75         _OP_FOREACH=                    0x32,
76         _OP_DELEGATE=                   0x33,
77         _OP_CLONE=                              0x34,
78         _OP_TYPEOF=                             0x35,
79         _OP_PUSHTRAP=                   0x36,
80         _OP_POPTRAP=                    0x37,
81         _OP_THROW=                              0x38,
82         _OP_CLASS=                              0x39,
83         _OP_NEWSLOTA=                   0x3A
84 };
85
86 struct SQInstructionDesc {
87         const SQChar *name;
88 };
89
90 struct SQInstruction
91 {
92         SQInstruction(){};
93         SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
94         {       op = _op;
95                 _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
96                 _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
97         }
98
99
100         SQInt32 _arg1;
101         unsigned char op;
102         unsigned char _arg0;
103         unsigned char _arg2;
104         unsigned char _arg3;
105 };
106
107 #include "squtils.h"
108 typedef sqvector<SQInstruction> SQInstructionVec;
109
110 #define NEW_SLOT_ATTRIBUTES_FLAG        0x01
111 #define NEW_SLOT_STATIC_FLAG            0x02
112
113 #endif // _SQOPCODES_H_