LSL_BaseClass_OPCODES.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSim Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. namespace OpenSim.Region.ScriptEngine.LSOEngine.LSO
  28. {
  29. //public partial class LSL_BaseClass
  30. //{
  31. // /*
  32. // * OPCODES
  33. // *
  34. // * These are internal "assembly" commands,
  35. // * basic operators like "ADD", "PUSH" and "POP"
  36. // *
  37. // * It also contains managed stack and keeps track of internal variables, etc.
  38. // *
  39. // */
  40. // public void StoreToLocal(UInt32 index)
  41. // {
  42. // // TODO: How to determine local?
  43. // LSOEngine.LSO.Common.SendToDebug("::StoreToLocal " + index);
  44. // if (LocalVariables.ContainsKey(index))
  45. // LocalVariables.Remove(index);
  46. // LocalVariables.Add(index, LSLStack.Peek());
  47. // }
  48. // public void StoreToGlobal(UInt32 index)
  49. // {
  50. // LSOEngine.LSO.Common.SendToDebug("::StoreToGlobal " + index);
  51. // if (GlobalVariables.ContainsKey(index))
  52. // GlobalVariables.Remove(index);
  53. // GlobalVariables.Add(index, LSLStack.Peek());
  54. // }
  55. // public void StoreToStatic(UInt32 index)
  56. // {
  57. // LSOEngine.LSO.Common.SendToDebug("::StoreToStatic " + index);
  58. // //if (StaticVariables.ContainsKey(index))
  59. // // StaticVariables.Remove(index);
  60. // StaticVariables.Add(index, LSLStack.Peek());
  61. // }
  62. // public void GetFromLocal(UInt32 index)
  63. // {
  64. // // TODO: How to determine local?
  65. // LSOEngine.LSO.Common.SendToDebug("::GetFromLocal " + index);
  66. // object ret;
  67. // LocalVariables.TryGetValue(index, out ret);
  68. // LSLStack.Push(ret);
  69. // //return ret;
  70. // }
  71. // public void GetFromGlobal(UInt32 index)
  72. // {
  73. // LSOEngine.LSO.Common.SendToDebug("::GetFromGlobal " + index);
  74. // object ret;
  75. // GlobalVariables.TryGetValue(index, out ret);
  76. // LSLStack.Push(ret);
  77. // //return ret;
  78. // }
  79. // public void GetFromStatic(UInt32 index)
  80. // {
  81. // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic " + index);
  82. // object ret;
  83. // StaticVariables.TryGetValue(index, out ret);
  84. // LSOEngine.LSO.Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString());
  85. // LSLStack.Push(ret);
  86. // //return ret;
  87. // }
  88. // public object POPToStack()
  89. // {
  90. // LSOEngine.LSO.Common.SendToDebug("::POPToStack");
  91. // //return LSLStack.Pop();
  92. // object p = LSLStack.Pop();
  93. // if (p.GetType() == typeof (UInt32))
  94. // return (UInt32) p;
  95. // if (p.GetType() == typeof (string))
  96. // return (string) p;
  97. // if (p.GetType() == typeof (Int32))
  98. // return (Int32) p;
  99. // if (p.GetType() == typeof (UInt16))
  100. // return (UInt16) p;
  101. // if (p.GetType() == typeof (float))
  102. // return (float) p;
  103. // if (p.GetType() == typeof (LSO_Enums.Vector))
  104. // return (LSO_Enums.Vector) p;
  105. // if (p.GetType() == typeof (LSO_Enums.Rotation))
  106. // return (LSO_Enums.Rotation) p;
  107. // if (p.GetType() == typeof (LSO_Enums.Key))
  108. // return (LSO_Enums.Key) p;
  109. // return p;
  110. // }
  111. // //public object POPToStack(UInt32 count)
  112. // //{
  113. // // // POP NUMBER FROM TOP OF STACK
  114. // // //LSLStack.SetLength(LSLStack.Length - 4);
  115. // // Common.SendToDebug("::POPToStack " + count);
  116. // // if (count < 2)
  117. // // return LSLStack.Pop();
  118. // // Stack<object> s = new Stack<object>();
  119. // // for (int i = 0; i < count; i++)
  120. // // {
  121. // // s.Push(LSLStack.Pop);
  122. // // }
  123. // //}
  124. // public void POP()
  125. // {
  126. // // POP NUMBER FROM TOP OF STACK
  127. // //LSLStack.SetLength(LSLStack.Length - 4);
  128. // LSOEngine.LSO.Common.SendToDebug("::POP");
  129. // if (LSLStack.Count < 1)
  130. // {
  131. // //TODO: Temporary fix
  132. // LSOEngine.LSO.Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!");
  133. // }
  134. // else
  135. // {
  136. // LSLStack.Pop();
  137. // }
  138. // }
  139. // public void PUSH(object Param)
  140. // {
  141. // if (Param == null)
  142. // {
  143. // LSOEngine.LSO.Common.SendToDebug("::PUSH: <null>");
  144. // }
  145. // else
  146. // {
  147. // //Common.SendToDebug("::PUSH: " + Param.GetType());
  148. // }
  149. // LSLStack.Push(Param);
  150. // }
  151. // public void ADD(UInt32 Param)
  152. // {
  153. // LSOEngine.LSO.Common.SendToDebug("::ADD: " + Param);
  154. // object o2 = LSLStack.Pop();
  155. // object o1 = LSLStack.Pop();
  156. // LSOEngine.LSO.Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() +
  157. // " (" + o2.ToString() + ")");
  158. // if (o2.GetType() == typeof (string))
  159. // {
  160. // LSLStack.Push((string) o1 + (string) o2);
  161. // return;
  162. // }
  163. // if (o2.GetType() == typeof (UInt32))
  164. // {
  165. // LSLStack.Push((UInt32) o1 + (UInt32) o2);
  166. // return;
  167. // }
  168. // }
  169. // public void SUB(UInt32 Param)
  170. // {
  171. // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param);
  172. // UInt32 i2 = (UInt32) LSLStack.Pop();
  173. // UInt32 i1 = (UInt32) LSLStack.Pop();
  174. // LSLStack.Push((UInt32) (i1 - i2));
  175. // }
  176. // public void MUL(UInt32 Param)
  177. // {
  178. // LSOEngine.LSO.Common.SendToDebug("::SUB: " + Param);
  179. // UInt32 i2 = (UInt32) LSLStack.Pop();
  180. // UInt32 i1 = (UInt32) LSLStack.Pop();
  181. // LSLStack.Push((UInt32) (i1*i2));
  182. // }
  183. // public void DIV(UInt32 Param)
  184. // {
  185. // LSOEngine.LSO.Common.SendToDebug("::DIV: " + Param);
  186. // UInt32 i2 = (UInt32) LSLStack.Pop();
  187. // UInt32 i1 = (UInt32) LSLStack.Pop();
  188. // LSLStack.Push((UInt32) (i1/i2));
  189. // }
  190. // public void MOD(UInt32 Param)
  191. // {
  192. // LSOEngine.LSO.Common.SendToDebug("::MOD: " + Param);
  193. // UInt32 i2 = (UInt32) LSLStack.Pop();
  194. // UInt32 i1 = (UInt32) LSLStack.Pop();
  195. // LSLStack.Push((UInt32) (i1%i2));
  196. // }
  197. // public void EQ(UInt32 Param)
  198. // {
  199. // LSOEngine.LSO.Common.SendToDebug("::EQ: " + Param);
  200. // UInt32 i2 = (UInt32) LSLStack.Pop();
  201. // UInt32 i1 = (UInt32) LSLStack.Pop();
  202. // if (i1 == i2)
  203. // {
  204. // LSLStack.Push((UInt32) 1);
  205. // }
  206. // else
  207. // {
  208. // LSLStack.Push((UInt32) 0);
  209. // }
  210. // }
  211. // public void NEQ(UInt32 Param)
  212. // {
  213. // LSOEngine.LSO.Common.SendToDebug("::NEQ: " + Param);
  214. // UInt32 i2 = (UInt32) LSLStack.Pop();
  215. // UInt32 i1 = (UInt32) LSLStack.Pop();
  216. // if (i1 != i2)
  217. // {
  218. // LSLStack.Push((UInt32) 1);
  219. // }
  220. // else
  221. // {
  222. // LSLStack.Push((UInt32) 0);
  223. // }
  224. // }
  225. // public void LEQ(UInt32 Param)
  226. // {
  227. // LSOEngine.LSO.Common.SendToDebug("::LEQ: " + Param);
  228. // UInt32 i2 = (UInt32) LSLStack.Pop();
  229. // UInt32 i1 = (UInt32) LSLStack.Pop();
  230. // if (i1 <= i2)
  231. // {
  232. // LSLStack.Push((UInt32) 1);
  233. // }
  234. // else
  235. // {
  236. // LSLStack.Push((UInt32) 0);
  237. // }
  238. // }
  239. // public void GEQ(UInt32 Param)
  240. // {
  241. // LSOEngine.LSO.Common.SendToDebug("::GEQ: " + Param);
  242. // UInt32 i2 = (UInt32) LSLStack.Pop();
  243. // UInt32 i1 = (UInt32) LSLStack.Pop();
  244. // if (i1 >= i2)
  245. // {
  246. // LSLStack.Push((UInt32) 1);
  247. // }
  248. // else
  249. // {
  250. // LSLStack.Push((UInt32) 0);
  251. // }
  252. // }
  253. // public void LESS(UInt32 Param)
  254. // {
  255. // LSOEngine.LSO.Common.SendToDebug("::LESS: " + Param);
  256. // UInt32 i2 = (UInt32) LSLStack.Pop();
  257. // UInt32 i1 = (UInt32) LSLStack.Pop();
  258. // if (i1 < i2)
  259. // {
  260. // LSLStack.Push((UInt32) 1);
  261. // }
  262. // else
  263. // {
  264. // LSLStack.Push((UInt32) 0);
  265. // }
  266. // }
  267. // public void GREATER(UInt32 Param)
  268. // {
  269. // LSOEngine.LSO.Common.SendToDebug("::GREATER: " + Param);
  270. // UInt32 i2 = (UInt32) LSLStack.Pop();
  271. // UInt32 i1 = (UInt32) LSLStack.Pop();
  272. // if (i1 > i2)
  273. // {
  274. // LSLStack.Push((UInt32) 1);
  275. // }
  276. // else
  277. // {
  278. // LSLStack.Push((UInt32) 0);
  279. // }
  280. // }
  281. // public void BITAND()
  282. // {
  283. // LSOEngine.LSO.Common.SendToDebug("::BITAND");
  284. // UInt32 i2 = (UInt32) LSLStack.Pop();
  285. // UInt32 i1 = (UInt32) LSLStack.Pop();
  286. // LSLStack.Push((UInt32) (i1 & i2));
  287. // }
  288. // public void BITOR()
  289. // {
  290. // LSOEngine.LSO.Common.SendToDebug("::BITOR");
  291. // UInt32 i2 = (UInt32) LSLStack.Pop();
  292. // UInt32 i1 = (UInt32) LSLStack.Pop();
  293. // LSLStack.Push((UInt32) (i1 | i2));
  294. // }
  295. // public void BITXOR()
  296. // {
  297. // LSOEngine.LSO.Common.SendToDebug("::BITXOR");
  298. // UInt32 i2 = (UInt32) LSLStack.Pop();
  299. // UInt32 i1 = (UInt32) LSLStack.Pop();
  300. // LSLStack.Push((UInt32) (i1 ^ i2));
  301. // }
  302. // public void BOOLAND()
  303. // {
  304. // LSOEngine.LSO.Common.SendToDebug("::BOOLAND");
  305. // bool b2 = bool.Parse((string) LSLStack.Pop());
  306. // bool b1 = bool.Parse((string) LSLStack.Pop());
  307. // if (b1 && b2)
  308. // {
  309. // LSLStack.Push((UInt32) 1);
  310. // }
  311. // else
  312. // {
  313. // LSLStack.Push((UInt32) 0);
  314. // }
  315. // }
  316. // public void BOOLOR()
  317. // {
  318. // LSOEngine.LSO.Common.SendToDebug("::BOOLOR");
  319. // bool b2 = bool.Parse((string) LSLStack.Pop());
  320. // bool b1 = bool.Parse((string) LSLStack.Pop());
  321. // if (b1 || b2)
  322. // {
  323. // LSLStack.Push((UInt32) 1);
  324. // }
  325. // else
  326. // {
  327. // LSLStack.Push((UInt32) 0);
  328. // }
  329. // }
  330. // public void NEG(UInt32 Param)
  331. // {
  332. // LSOEngine.LSO.Common.SendToDebug("::NEG: " + Param);
  333. // //UInt32 i2 = (UInt32)LSLStack.Pop();
  334. // UInt32 i1 = (UInt32) LSLStack.Pop();
  335. // LSLStack.Push((UInt32) (i1*-1));
  336. // }
  337. // public void BITNOT()
  338. // {
  339. // //Common.SendToDebug("::BITNOT");
  340. // //UInt32 i2 = (UInt32)LSLStack.Pop();
  341. // //UInt32 i1 = (UInt32)LSLStack.Pop();
  342. // //LSLStack.Push((UInt32)(i1 / i2));
  343. // }
  344. // public void BOOLNOT()
  345. // {
  346. // //Common.SendToDebug("::BOOLNOT");
  347. // ////UInt32 i2 = (UInt32)LSLStack.Pop();
  348. // //UInt32 i1 = (UInt32)LSLStack.Pop();
  349. // //LSLStack.Push((UInt32)(i1));
  350. // }
  351. //}
  352. }