aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs393
1 files changed, 0 insertions, 393 deletions
diff --git a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs b/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
deleted file mode 100644
index 11b567e..0000000
--- a/OpenSim/Grid/ScriptEngine/DotNetEngine/Compiler/LSO/LSL_BaseClass_OPCODES.cs
+++ /dev/null
@@ -1,393 +0,0 @@
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
28using System;
29
30namespace OpenSim.Grid.ScriptEngine.DotNetEngine.Compiler.LSO
31{
32 public partial class LSL_BaseClass
33 {
34 /*
35 * OPCODES
36 *
37 * These are internal "assembly" commands,
38 * basic operators like "ADD", "PUSH" and "POP"
39 *
40 * It also contains managed stack and keeps track of internal variables, etc.
41 *
42 */
43
44
45 public void StoreToLocal(UInt32 index)
46 {
47 // TODO: How to determine local?
48 Common.SendToDebug("::StoreToLocal " + index);
49 if (LocalVariables.ContainsKey(index))
50 LocalVariables.Remove(index);
51 LocalVariables.Add(index, LSLStack.Peek());
52 }
53
54 public void StoreToGlobal(UInt32 index)
55 {
56 Common.SendToDebug("::StoreToGlobal " + index);
57 if (GlobalVariables.ContainsKey(index))
58 GlobalVariables.Remove(index);
59 GlobalVariables.Add(index, LSLStack.Peek());
60 }
61
62 public void StoreToStatic(UInt32 index)
63 {
64 Common.SendToDebug("::StoreToStatic " + index);
65 //if (StaticVariables.ContainsKey(index))
66 // StaticVariables.Remove(index);
67 StaticVariables.Add(index, LSLStack.Peek());
68 }
69
70 public void GetFromLocal(UInt32 index)
71 {
72 // TODO: How to determine local?
73 Common.SendToDebug("::GetFromLocal " + index);
74 object ret;
75 LocalVariables.TryGetValue(index, out ret);
76 LSLStack.Push(ret);
77 //return ret;
78 }
79
80 public void GetFromGlobal(UInt32 index)
81 {
82 Common.SendToDebug("::GetFromGlobal " + index);
83 object ret;
84 GlobalVariables.TryGetValue(index, out ret);
85 LSLStack.Push(ret);
86 //return ret;
87 }
88
89 public void GetFromStatic(UInt32 index)
90 {
91 Common.SendToDebug("::GetFromStatic " + index);
92 object ret;
93 StaticVariables.TryGetValue(index, out ret);
94 Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString());
95 LSLStack.Push(ret);
96 //return ret;
97 }
98
99 public object POPToStack()
100 {
101 Common.SendToDebug("::POPToStack");
102 //return LSLStack.Pop();
103 object p = LSLStack.Pop();
104 if (p.GetType() == typeof (UInt32))
105 return (UInt32) p;
106 if (p.GetType() == typeof (string))
107 return (string) p;
108 if (p.GetType() == typeof (Int32))
109 return (Int32) p;
110 if (p.GetType() == typeof (UInt16))
111 return (UInt16) p;
112 if (p.GetType() == typeof (float))
113 return (float) p;
114 if (p.GetType() == typeof (LSO_Enums.Vector))
115 return (LSO_Enums.Vector) p;
116 if (p.GetType() == typeof (LSO_Enums.Rotation))
117 return (LSO_Enums.Rotation) p;
118 if (p.GetType() == typeof (LSO_Enums.Key))
119 return (LSO_Enums.Key) p;
120
121 return p;
122 }
123
124 //public object POPToStack(UInt32 count)
125 //{
126 // // POP NUMBER FROM TOP OF STACK
127 // //LSLStack.SetLength(LSLStack.Length - 4);
128 // Common.SendToDebug("::POPToStack " + count);
129 // if (count < 2)
130 // return LSLStack.Pop();
131
132 // Stack<object> s = new Stack<object>();
133 // for (int i = 0; i < count; i++)
134 // {
135 // s.Push(LSLStack.Pop);
136
137 // }
138
139 //}
140
141 public void POP()
142 {
143 // POP NUMBER FROM TOP OF STACK
144 //LSLStack.SetLength(LSLStack.Length - 4);
145 Common.SendToDebug("::POP");
146 if (LSLStack.Count < 1)
147 {
148 //TODO: Temporary fix
149 Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!");
150 }
151 else
152 {
153 LSLStack.Pop();
154 }
155 }
156
157 public void PUSH(object Param)
158 {
159 if (Param == null)
160 {
161 Common.SendToDebug("::PUSH: <null>");
162 }
163 else
164 {
165 //Common.SendToDebug("::PUSH: " + Param.GetType());
166 }
167
168 LSLStack.Push(Param);
169 }
170
171 public void ADD(UInt32 Param)
172 {
173 Common.SendToDebug("::ADD: " + Param);
174 object o2 = LSLStack.Pop();
175 object o1 = LSLStack.Pop();
176 Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() +
177 " (" + o2.ToString() + ")");
178 if (o2.GetType() == typeof (string))
179 {
180 LSLStack.Push((string) o1 + (string) o2);
181 return;
182 }
183 if (o2.GetType() == typeof (UInt32))
184 {
185 LSLStack.Push((UInt32) o1 + (UInt32) o2);
186 return;
187 }
188 }
189
190 public void SUB(UInt32 Param)
191 {
192 Common.SendToDebug("::SUB: " + Param);
193 UInt32 i2 = (UInt32) LSLStack.Pop();
194 UInt32 i1 = (UInt32) LSLStack.Pop();
195 LSLStack.Push((UInt32) (i1 - i2));
196 }
197
198 public void MUL(UInt32 Param)
199 {
200 Common.SendToDebug("::SUB: " + Param);
201 UInt32 i2 = (UInt32) LSLStack.Pop();
202 UInt32 i1 = (UInt32) LSLStack.Pop();
203 LSLStack.Push((UInt32) (i1*i2));
204 }
205
206 public void DIV(UInt32 Param)
207 {
208 Common.SendToDebug("::DIV: " + Param);
209 UInt32 i2 = (UInt32) LSLStack.Pop();
210 UInt32 i1 = (UInt32) LSLStack.Pop();
211 LSLStack.Push((UInt32) (i1/i2));
212 }
213
214
215 public void MOD(UInt32 Param)
216 {
217 Common.SendToDebug("::MOD: " + Param);
218 UInt32 i2 = (UInt32) LSLStack.Pop();
219 UInt32 i1 = (UInt32) LSLStack.Pop();
220 LSLStack.Push((UInt32) (i1%i2));
221 }
222
223 public void EQ(UInt32 Param)
224 {
225 Common.SendToDebug("::EQ: " + Param);
226 UInt32 i2 = (UInt32) LSLStack.Pop();
227 UInt32 i1 = (UInt32) LSLStack.Pop();
228 if (i1 == i2)
229 {
230 LSLStack.Push((UInt32) 1);
231 }
232 else
233 {
234 LSLStack.Push((UInt32) 0);
235 }
236 }
237
238 public void NEQ(UInt32 Param)
239 {
240 Common.SendToDebug("::NEQ: " + Param);
241 UInt32 i2 = (UInt32) LSLStack.Pop();
242 UInt32 i1 = (UInt32) LSLStack.Pop();
243 if (i1 != i2)
244 {
245 LSLStack.Push((UInt32) 1);
246 }
247 else
248 {
249 LSLStack.Push((UInt32) 0);
250 }
251 }
252
253 public void LEQ(UInt32 Param)
254 {
255 Common.SendToDebug("::LEQ: " + 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
268 public void GEQ(UInt32 Param)
269 {
270 Common.SendToDebug("::GEQ: " + Param);
271 UInt32 i2 = (UInt32) LSLStack.Pop();
272 UInt32 i1 = (UInt32) LSLStack.Pop();
273 if (i1 >= i2)
274 {
275 LSLStack.Push((UInt32) 1);
276 }
277 else
278 {
279 LSLStack.Push((UInt32) 0);
280 }
281 }
282
283 public void LESS(UInt32 Param)
284 {
285 Common.SendToDebug("::LESS: " + Param);
286 UInt32 i2 = (UInt32) LSLStack.Pop();
287 UInt32 i1 = (UInt32) LSLStack.Pop();
288 if (i1 < i2)
289 {
290 LSLStack.Push((UInt32) 1);
291 }
292 else
293 {
294 LSLStack.Push((UInt32) 0);
295 }
296 }
297
298 public void GREATER(UInt32 Param)
299 {
300 Common.SendToDebug("::GREATER: " + Param);
301 UInt32 i2 = (UInt32) LSLStack.Pop();
302 UInt32 i1 = (UInt32) LSLStack.Pop();
303 if (i1 > i2)
304 {
305 LSLStack.Push((UInt32) 1);
306 }
307 else
308 {
309 LSLStack.Push((UInt32) 0);
310 }
311 }
312
313
314 public void BITAND()
315 {
316 Common.SendToDebug("::BITAND");
317 UInt32 i2 = (UInt32) LSLStack.Pop();
318 UInt32 i1 = (UInt32) LSLStack.Pop();
319 LSLStack.Push((UInt32) (i1 & i2));
320 }
321
322 public void BITOR()
323 {
324 Common.SendToDebug("::BITOR");
325 UInt32 i2 = (UInt32) LSLStack.Pop();
326 UInt32 i1 = (UInt32) LSLStack.Pop();
327 LSLStack.Push((UInt32) (i1 | i2));
328 }
329
330 public void BITXOR()
331 {
332 Common.SendToDebug("::BITXOR");
333 UInt32 i2 = (UInt32) LSLStack.Pop();
334 UInt32 i1 = (UInt32) LSLStack.Pop();
335 LSLStack.Push((UInt32) (i1 ^ i2));
336 }
337
338 public void BOOLAND()
339 {
340 Common.SendToDebug("::BOOLAND");
341 bool b2 = bool.Parse((string) LSLStack.Pop());
342 bool b1 = bool.Parse((string) LSLStack.Pop());
343 if (b1 && b2)
344 {
345 LSLStack.Push((UInt32) 1);
346 }
347 else
348 {
349 LSLStack.Push((UInt32) 0);
350 }
351 }
352
353 public void BOOLOR()
354 {
355 Common.SendToDebug("::BOOLOR");
356 bool b2 = bool.Parse((string) LSLStack.Pop());
357 bool b1 = bool.Parse((string) LSLStack.Pop());
358
359 if (b1 || b2)
360 {
361 LSLStack.Push((UInt32) 1);
362 }
363 else
364 {
365 LSLStack.Push((UInt32) 0);
366 }
367 }
368
369 public void NEG(UInt32 Param)
370 {
371 Common.SendToDebug("::NEG: " + Param);
372 //UInt32 i2 = (UInt32)LSLStack.Pop();
373 UInt32 i1 = (UInt32) LSLStack.Pop();
374 LSLStack.Push((UInt32) (i1*-1));
375 }
376
377 public void BITNOT()
378 {
379 //Common.SendToDebug("::BITNOT");
380 //UInt32 i2 = (UInt32)LSLStack.Pop();
381 //UInt32 i1 = (UInt32)LSLStack.Pop();
382 //LSLStack.Push((UInt32)(i1 / i2));
383 }
384
385 public void BOOLNOT()
386 {
387 //Common.SendToDebug("::BOOLNOT");
388 ////UInt32 i2 = (UInt32)LSLStack.Pop();
389 //UInt32 i1 = (UInt32)LSLStack.Pop();
390 //LSLStack.Push((UInt32)(i1));
391 }
392 }
393}