lsl.cs 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. namespace libLSL
  5. {
  6. enum lslVarType : byte
  7. {
  8. VARTYPE_VOID = 0,
  9. VARTYPE_INTEGER = 1,
  10. VARTYPE_FLOAT = 2,
  11. VARTYPE_STRING = 3,
  12. VARTYPE_KEY = 4,
  13. VARTYPE_VECTOR = 5,
  14. VARTYPE_ROTATION = 6,
  15. VARTYPE_LIST = 7
  16. }
  17. enum lslEventType : byte
  18. {
  19. EVENT_STATE_ENTRY = 0,
  20. EVENT_STATE_EXIT = 1,
  21. EVENT_TOUCH_START = 2,
  22. EVENT_TOUCH = 3,
  23. EVENT_TOUCH_END = 4,
  24. EVENT_COLLISION_START = 5,
  25. EVENT_COLLISION = 6,
  26. EVENT_COLLISION_END = 7,
  27. EVENT_LAND_COLLISION_START = 8,
  28. EVENT_LAND_COLLISION = 9,
  29. EVENT_LAND_COLLISION_END = 10,
  30. EVENT_TIMER = 11,
  31. EVENT_LISTEN = 12,
  32. EVENT_ON_REZ = 13,
  33. EVENT_SENSOR = 14,
  34. EVENT_NO_SENSOR = 15,
  35. EVENT_CONTROL = 16,
  36. EVENT_MONEY = 17,
  37. EVENT_EMAIL = 18,
  38. EVENT_AT_TARGET = 19,
  39. EVENT_NOT_AT_TARGET = 20,
  40. EVENT_AT_ROT_TARGET = 21,
  41. EVENT_NOT_AT_ROT_TARGET = 22,
  42. EVENT_RUN_TIME_PERMISSIONS = 23,
  43. EVENT_CHANGED = 24,
  44. EVENT_ATTACH = 25,
  45. EVENT_DATASERVER = 26,
  46. EVENT_LINK_MESSAGE = 27,
  47. EVENT_MOVING_START = 28,
  48. EVENT_MOVING_END = 29,
  49. EVENT_OBJECT_REZ = 30,
  50. EVENT_REMOTE_DATA = 31,
  51. EVENT_HTTP_RESPONSE = 32
  52. }
  53. enum lslOpcodes : byte
  54. {
  55. // No Operation
  56. OP_NOOP = 0x00,
  57. // Pops
  58. OP_POP = 0x01,
  59. OP_POPS = 0x02,
  60. OP_POPL = 0x03,
  61. OP_POPV = 0x04,
  62. OP_POPQ = 0x05,
  63. OP_POPARG = 0x06,
  64. OP_POPIP = 0x07,
  65. OP_POPBP = 0x08,
  66. OP_POPSP = 0x09,
  67. OP_POPSLR = 0x0A,
  68. // Dupes
  69. OP_DUP = 0x20,
  70. OP_DUPS = 0x21,
  71. OP_DUPL = 0x22,
  72. OP_DUPV = 0x23,
  73. OP_DUPQ = 0x24,
  74. // Stores
  75. OP_STORE = 0x30,
  76. OP_STORES = 0x31,
  77. OP_STOREL = 0x32,
  78. OP_STOREV = 0x33,
  79. OP_STOREQ = 0x34,
  80. OP_STOREG = 0x35,
  81. OP_STOREGS = 0x36,
  82. OP_STOREGL = 0x37,
  83. OP_STOREGV = 0x38,
  84. OP_STOREGQ = 0x39,
  85. // Loads
  86. OP_LOADP = 0x3A,
  87. OP_LOADSP = 0x3B,
  88. OP_LOADLP = 0x3C,
  89. OP_LOADVP = 0x3D,
  90. OP_LOADQP = 0x3E,
  91. OP_LOADGP = 0x3F,
  92. OP_LOADGSP = 0x40,
  93. OP_LOADGLP = 0x41,
  94. OP_LOADGVP = 0x42,
  95. OP_LOADGQP = 0x43,
  96. // Pushes
  97. OP_PUSH = 0x50,
  98. OP_PUSHS = 0x51,
  99. OP_PUSHL = 0x52,
  100. OP_PUSHV = 0x53,
  101. OP_PUSHQ = 0x54,
  102. OP_PUSHG = 0x55,
  103. OP_PUSHGS = 0x56,
  104. OP_PUSHGL = 0x57,
  105. OP_PUSHGV = 0x58,
  106. OP_PUSHGQ = 0x59,
  107. OP_PUSHIP = 0x5A,
  108. OP_PUSHBP = 0x5B,
  109. OP_PUSHSP = 0x5C,
  110. OP_PUSHARGB = 0x5D,
  111. OP_PUSHARGI = 0x5E,
  112. OP_PUSHARGF = 0x5F,
  113. OP_PUSHARGS = 0x60,
  114. OP_PUSHARGV = 0x61,
  115. OP_PUSHARGQ = 0x62,
  116. OP_PUSHE = 0x63,
  117. OP_PUSHEV = 0x64,
  118. OP_PUSHEQ = 0x65,
  119. OP_PUSHARGE = 0x66,
  120. // Numerics
  121. OP_ADD = 0x70,
  122. OP_SUB = 0x71,
  123. OP_MUL = 0x72,
  124. OP_DIV = 0x73,
  125. OP_MOD = 0x74,
  126. OP_EQ = 0x75,
  127. OP_NEQ = 0x76,
  128. OP_LEQ = 0x77,
  129. OP_GEQ = 0x78,
  130. OP_LESS = 0x79,
  131. OP_GREATER = 0x7A,
  132. OP_BITAND = 0x7B,
  133. OP_BITOR = 0x7C,
  134. OP_BITXOR = 0x7D,
  135. OP_BOOLAND = 0x7E,
  136. OP_BOOLOR = 0x7F,
  137. OP_NEG = 0x80,
  138. OP_BITNOT = 0x81,
  139. OP_BOOLNOT = 0x82,
  140. // Sequence
  141. OP_JUMP = 0x90,
  142. OP_JUMPIF = 0x91,
  143. OP_JUMPNIF = 0x92,
  144. OP_STATE = 0x93,
  145. OP_CALL = 0x94,
  146. OP_RETURN = 0x95,
  147. // Cast
  148. OP_CAST = 0xA0,
  149. // Stack
  150. OP_STACKTOS = 0xB0,
  151. OP_STACKTOL = 0xB1,
  152. // Debug
  153. OP_PRINT = 0xC0,
  154. // Library
  155. OP_CALLLIB = 0xD0,
  156. OP_CALLLIB_TWO_BYTE = 0xD1,
  157. // More Numerics
  158. OP_SHL = 0xE0,
  159. OP_SHR = 0xE1
  160. }
  161. class lslHeader
  162. {
  163. int TM; // Top of memory
  164. int IP; // Instruction pointer
  165. int VN; // Version Number (0x00000200)
  166. int BP; // Base Pointer
  167. int SP; // Stack Pointer
  168. int HR; // Heap Register
  169. int HP; // Heap Pointer
  170. int CS; // Current State
  171. int NS; // Next State
  172. int CE; // Current Events (Which events need running still?)
  173. int IE; // In Event
  174. int ER; // Event Register
  175. int FR; // Fault Register
  176. int SLR; // Sleep Register
  177. int GVR; // Global Variable Register (Pointer)
  178. int GFR; // Global Function Register (Pointer)
  179. int PR; // Parameter Register - OnRez Int?
  180. int ESR; // Energy Supply Register
  181. int SR; // State Register
  182. long NCE; // Extended Current Events
  183. long NIE; // Extended In Event
  184. long NER; // Extended Event Register
  185. public void readFromBytes(byte[] data)
  186. {
  187. }
  188. }
  189. class lslStaticBlock
  190. {
  191. int length; // Length (bytes)
  192. lslVarType varType;// Variable Type
  193. byte unknown; // Unknown
  194. Object varObject; // Variable Object
  195. public void readFromBytes(byte[] data)
  196. {
  197. }
  198. }
  199. class lslHeapBlock
  200. {
  201. int length;
  202. lslVarType varType;
  203. short referenceCount;
  204. Object varObject;
  205. public void readFromBytes(byte[] data)
  206. {
  207. }
  208. }
  209. class lslStatePointer
  210. {
  211. int location;
  212. long eventMask;
  213. public void readFromBytes(byte[] data)
  214. {
  215. }
  216. }
  217. class lslStateFrameBlock
  218. {
  219. int number;
  220. lslStatePointer[] pointers;
  221. public void readFromBytes(byte[] data)
  222. {
  223. }
  224. }
  225. class lslStateBlockElement
  226. {
  227. int pointerToCode;
  228. int callFrameSize;
  229. public void readFromBytes(byte[] data)
  230. {
  231. }
  232. }
  233. class lslStateBlock
  234. {
  235. int length;
  236. byte unknown;
  237. lslStateBlockElement[] handlers; // ?
  238. public void readFromBytes(byte[] data)
  239. {
  240. }
  241. }
  242. class lslFunctioBlock
  243. {
  244. int number;
  245. int[] pointers; // Relative to this -> codechunk
  246. public void readFromBytes(byte[] data)
  247. {
  248. }
  249. }
  250. class lslCodeArgument
  251. {
  252. lslVarType type;
  253. byte empty;
  254. public void readFromBytes(byte[] data)
  255. {
  256. }
  257. }
  258. class lslCodeChunkHeader
  259. {
  260. int length;
  261. string comment;
  262. lslVarType returnType;
  263. lslCodeArgument[] arguments;
  264. byte empty;
  265. public void readFromBytes(byte[] data)
  266. {
  267. }
  268. }
  269. class lslCodeChunk
  270. {
  271. lslCodeChunkHeader header;
  272. lslByteCode bytecode;
  273. public void readFromBytes(byte[] data)
  274. {
  275. }
  276. }
  277. }