The Squirrel interpreter. See http://www.squirrel-lang.org/

Dependents:   Squirrel

Committer:
jhnwkmn
Date:
Tue Dec 16 11:39:42 2014 +0000
Revision:
3:7268a3ceaffc
Parent:
0:97a4f8cc534c
Accepts \r as line terminator as well.

Who changed what in which revision?

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