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,
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,
20     CMP_L = 3,
21     CMP_LE = 4,
22     CMP_3W = 5
23 };
24 
25 enum NewObjectType {
26     NOT_TABLE = 0,
27     NOT_ARRAY = 1,
28     NOT_CLASS = 2
29 };
30 
31 enum AppendArrayType {
32     AAT_STACK = 0,
33     AAT_LITERAL = 1,
34     AAT_INT = 2,
35     AAT_FLOAT = 3,
36     AAT_BOOL = 4
37 };
38 
39 enum SQOpcode
40 {
41     _OP_LINE=               0x00,
42     _OP_LOAD=               0x01,
43     _OP_LOADINT=            0x02,
44     _OP_LOADFLOAT=          0x03,
45     _OP_DLOAD=              0x04,
46     _OP_TAILCALL=           0x05,
47     _OP_CALL=               0x06,
48     _OP_PREPCALL=           0x07,
49     _OP_PREPCALLK=          0x08,
50     _OP_GETK=               0x09,
51     _OP_MOVE=               0x0A,
52     _OP_NEWSLOT=            0x0B,
53     _OP_DELETE=             0x0C,
54     _OP_SET=                0x0D,
55     _OP_GET=                0x0E,
56     _OP_EQ=                 0x0F,
57     _OP_NE=                 0x10,
58     _OP_ADD=                0x11,
59     _OP_SUB=                0x12,
60     _OP_MUL=                0x13,
61     _OP_DIV=                0x14,
62     _OP_MOD=                0x15,
63     _OP_BITW=               0x16,
64     _OP_RETURN=             0x17,
65     _OP_LOADNULLS=          0x18,
66     _OP_LOADROOT=           0x19,
67     _OP_LOADBOOL=           0x1A,
68     _OP_DMOVE=              0x1B,
69     _OP_JMP=                0x1C,
70     //_OP_JNZ=              0x1D,
71     _OP_JCMP=               0x1D,
72     _OP_JZ=                 0x1E,
73     _OP_SETOUTER=           0x1F,
74     _OP_GETOUTER=           0x20,
75     _OP_NEWOBJ=             0x21,
76     _OP_APPENDARRAY=        0x22,
77     _OP_COMPARITH=          0x23,
78     _OP_INC=                0x24,
79     _OP_INCL=               0x25,
80     _OP_PINC=               0x26,
81     _OP_PINCL=              0x27,
82     _OP_CMP=                0x28,
83     _OP_EXISTS=             0x29,
84     _OP_INSTANCEOF=         0x2A,
85     _OP_AND=                0x2B,
86     _OP_OR=                 0x2C,
87     _OP_NEG=                0x2D,
88     _OP_NOT=                0x2E,
89     _OP_BWNOT=              0x2F,
90     _OP_CLOSURE=            0x30,
91     _OP_YIELD=              0x31,
92     _OP_RESUME=             0x32,
93     _OP_FOREACH=            0x33,
94     _OP_POSTFOREACH=        0x34,
95     _OP_CLONE=              0x35,
96     _OP_TYPEOF=             0x36,
97     _OP_PUSHTRAP=           0x37,
98     _OP_POPTRAP=            0x38,
99     _OP_THROW=              0x39,
100     _OP_NEWSLOTA=           0x3A,
101     _OP_GETBASE=            0x3B,
102     _OP_CLOSE=              0x3C
103 };
104 
105 struct SQInstructionDesc {
106     const SQChar *name;
107 };
108 
109 struct SQInstruction
110 {
SQInstructionSQInstruction111     SQInstruction(){};
112     SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
113     {   op = (unsigned char)_op;
114         _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
115         _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
116     }
117 
118 
119     SQInt32 _arg1;
120     unsigned char op;
121     unsigned char _arg0;
122     unsigned char _arg2;
123     unsigned char _arg3;
124 };
125 
126 #include "squtils.h"
127 typedef sqvector<SQInstruction> SQInstructionVec;
128 
129 #define NEW_SLOT_ATTRIBUTES_FLAG    0x01
130 #define NEW_SLOT_STATIC_FLAG        0x02
131 
132 #endif // _SQOPCODES_H_
133