Johan Wikman / SQUIRREL3

Dependents:   Squirrel

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers sqopcodes.h Source File

sqopcodes.h

00001 /*  see copyright notice in squirrel.h */
00002 #ifndef _SQOPCODES_H_
00003 #define _SQOPCODES_H_
00004 
00005 #define MAX_FUNC_STACKSIZE 0xFF
00006 #define MAX_LITERALS ((SQInteger)0x7FFFFFFF)
00007 
00008 enum BitWiseOP {
00009     BW_AND = 0,
00010     BW_OR = 2,  
00011     BW_XOR = 3,
00012     BW_SHIFTL = 4,
00013     BW_SHIFTR = 5,
00014     BW_USHIFTR = 6
00015 };
00016 
00017 enum CmpOP {
00018     CMP_G = 0,
00019     CMP_GE = 2, 
00020     CMP_L = 3,
00021     CMP_LE = 4,
00022     CMP_3W = 5
00023 };
00024 
00025 enum NewObjectType {
00026     NOT_TABLE = 0,
00027     NOT_ARRAY = 1,
00028     NOT_CLASS = 2
00029 };
00030 
00031 enum AppendArrayType {
00032     AAT_STACK = 0,
00033     AAT_LITERAL = 1,
00034     AAT_INT = 2,
00035     AAT_FLOAT = 3,
00036     AAT_BOOL = 4
00037 };
00038 
00039 enum SQOpcode
00040 {
00041     _OP_LINE=               0x00,   
00042     _OP_LOAD=               0x01,
00043     _OP_LOADINT=            0x02,
00044     _OP_LOADFLOAT=          0x03,
00045     _OP_DLOAD=              0x04,
00046     _OP_TAILCALL=           0x05,   
00047     _OP_CALL=               0x06,   
00048     _OP_PREPCALL=           0x07,   
00049     _OP_PREPCALLK=          0x08,   
00050     _OP_GETK=               0x09,   
00051     _OP_MOVE=               0x0A,   
00052     _OP_NEWSLOT=            0x0B,   
00053     _OP_DELETE=             0x0C,   
00054     _OP_SET=                0x0D,   
00055     _OP_GET=                0x0E,
00056     _OP_EQ=                 0x0F,
00057     _OP_NE=                 0x10,
00058     _OP_ADD=                0x11,
00059     _OP_SUB=                0x12,
00060     _OP_MUL=                0x13,
00061     _OP_DIV=                0x14,
00062     _OP_MOD=                0x15,
00063     _OP_BITW=               0x16,
00064     _OP_RETURN=             0x17,   
00065     _OP_LOADNULLS=          0x18,   
00066     _OP_LOADROOT=           0x19,
00067     _OP_LOADBOOL=           0x1A,
00068     _OP_DMOVE=              0x1B,   
00069     _OP_JMP=                0x1C,   
00070     //_OP_JNZ=              0x1D,
00071     _OP_JCMP=               0x1D,
00072     _OP_JZ=                 0x1E,   
00073     _OP_SETOUTER=           0x1F,   
00074     _OP_GETOUTER=           0x20,   
00075     _OP_NEWOBJ=             0x21,
00076     _OP_APPENDARRAY=        0x22,   
00077     _OP_COMPARITH=          0x23,   
00078     _OP_INC=                0x24,   
00079     _OP_INCL=               0x25,   
00080     _OP_PINC=               0x26,   
00081     _OP_PINCL=              0x27,   
00082     _OP_CMP=                0x28,
00083     _OP_EXISTS=             0x29,   
00084     _OP_INSTANCEOF=         0x2A,
00085     _OP_AND=                0x2B,
00086     _OP_OR=                 0x2C,
00087     _OP_NEG=                0x2D,
00088     _OP_NOT=                0x2E,
00089     _OP_BWNOT=              0x2F,   
00090     _OP_CLOSURE=            0x30,   
00091     _OP_YIELD=              0x31,   
00092     _OP_RESUME=             0x32,
00093     _OP_FOREACH=            0x33,
00094     _OP_POSTFOREACH=        0x34,
00095     _OP_CLONE=              0x35,
00096     _OP_TYPEOF=             0x36,
00097     _OP_PUSHTRAP=           0x37,
00098     _OP_POPTRAP=            0x38,
00099     _OP_THROW=              0x39,
00100     _OP_NEWSLOTA=           0x3A,
00101     _OP_GETBASE=            0x3B,
00102     _OP_CLOSE=              0x3C,
00103 };                            
00104 
00105 struct SQInstructionDesc {    
00106     const SQChar *name;       
00107 };                            
00108 
00109 struct SQInstruction 
00110 {
00111     SQInstruction(){};
00112     SQInstruction(SQOpcode _op,SQInteger a0=0,SQInteger a1=0,SQInteger a2=0,SQInteger a3=0)
00113     {   op = _op;
00114         _arg0 = (unsigned char)a0;_arg1 = (SQInt32)a1;
00115         _arg2 = (unsigned char)a2;_arg3 = (unsigned char)a3;
00116     }
00117     
00118     
00119     SQInt32 _arg1;
00120     unsigned char op;
00121     unsigned char _arg0;
00122     unsigned char _arg2;
00123     unsigned char _arg3;
00124 };
00125 
00126 #include "squtils.h"
00127 typedef sqvector<SQInstruction> SQInstructionVec;
00128 
00129 #define NEW_SLOT_ATTRIBUTES_FLAG    0x01
00130 #define NEW_SLOT_STATIC_FLAG        0x02
00131 
00132 #endif // _SQOPCODES_H_