sqopcodes.h 3.3 KB

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