aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs
diff options
context:
space:
mode:
authorTedd Hansen2007-08-08 14:05:13 +0000
committerTedd Hansen2007-08-08 14:05:13 +0000
commit2a0e157985d790e6cbd83d61690da2709dfab9dd (patch)
treee9c38c11773796111fb4ff222429605bdd76fd5e /OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs
parent* Got SimpleApp working again (diff)
downloadopensim-SC_OLD-2a0e157985d790e6cbd83d61690da2709dfab9dd.zip
opensim-SC_OLD-2a0e157985d790e6cbd83d61690da2709dfab9dd.tar.gz
opensim-SC_OLD-2a0e157985d790e6cbd83d61690da2709dfab9dd.tar.bz2
opensim-SC_OLD-2a0e157985d790e6cbd83d61690da2709dfab9dd.tar.xz
Added ScriptEngine.DotNetEngine
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs342
1 files changed, 342 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs b/OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs
new file mode 100644
index 0000000..b771678
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine.Compiler.LSL/LSL_BaseClass_OPCODES.cs
@@ -0,0 +1,342 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4
5namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
6{
7 public partial class LSL_BaseClass
8 {
9
10
11
12 public void StoreToLocal(UInt32 index)
13 {
14 // TODO: How to determine local?
15 Common.SendToDebug("::StoreToLocal " + index);
16 if (LocalVariables.ContainsKey(index))
17 LocalVariables.Remove(index);
18 LocalVariables.Add(index, LSLStack.Peek());
19 }
20 public void StoreToGlobal(UInt32 index)
21 {
22 Common.SendToDebug("::StoreToGlobal " + index);
23 if (GlobalVariables.ContainsKey(index))
24 GlobalVariables.Remove(index);
25 GlobalVariables.Add(index, LSLStack.Peek());
26 }
27 public void StoreToStatic(UInt32 index)
28 {
29 Common.SendToDebug("::StoreToStatic " + index);
30 //if (StaticVariables.ContainsKey(index))
31 // StaticVariables.Remove(index);
32 StaticVariables.Add(index, LSLStack.Peek());
33 }
34 public void GetFromLocal(UInt32 index)
35 {
36 // TODO: How to determine local?
37 Common.SendToDebug("::GetFromLocal " + index);
38 object ret;
39 LocalVariables.TryGetValue(index, out ret);
40 LSLStack.Push(ret);
41 //return ret;
42 }
43 public void GetFromGlobal(UInt32 index)
44 {
45 Common.SendToDebug("::GetFromGlobal " + index);
46 object ret;
47 GlobalVariables.TryGetValue(index, out ret);
48 LSLStack.Push(ret);
49 //return ret;
50 }
51 public void GetFromStatic(UInt32 index)
52 {
53 Common.SendToDebug("::GetFromStatic " + index);
54 object ret;
55 StaticVariables.TryGetValue(index, out ret);
56 Common.SendToDebug("::GetFromStatic - ObjectType: " + ret.GetType().ToString());
57 LSLStack.Push(ret);
58 //return ret;
59 }
60
61 public object POPToStack()
62 {
63 Common.SendToDebug("::POPToStack");
64 //return LSLStack.Pop();
65 object p = LSLStack.Pop();
66 if (p.GetType() == typeof(UInt32))
67 return (UInt32)p;
68 if (p.GetType() == typeof(string))
69 return (string)p;
70 if (p.GetType() == typeof(Int32))
71 return (Int32)p;
72 if (p.GetType() == typeof(UInt16))
73 return (UInt16)p;
74 if (p.GetType() == typeof(float))
75 return (float)p;
76 if (p.GetType() == typeof(LSO_Enums.Vector))
77 return (LSO_Enums.Vector)p;
78 if (p.GetType() == typeof(LSO_Enums.Rotation))
79 return (LSO_Enums.Rotation)p;
80 if (p.GetType() == typeof(LSO_Enums.Key))
81 return (LSO_Enums.Key)p;
82
83 return p;
84 }
85
86 //public object POPToStack(UInt32 count)
87 //{
88 // // POP NUMBER FROM TOP OF STACK
89 // //LSLStack.SetLength(LSLStack.Length - 4);
90 // Common.SendToDebug("::POPToStack " + count);
91 // if (count < 2)
92 // return LSLStack.Pop();
93
94 // Stack<object> s = new Stack<object>();
95 // for (int i = 0; i < count; i++)
96 // {
97 // s.Push(LSLStack.Pop);
98
99 // }
100
101 //}
102
103 public void POP()
104 {
105 // POP NUMBER FROM TOP OF STACK
106 //LSLStack.SetLength(LSLStack.Length - 4);
107 Common.SendToDebug("::POP");
108 if (LSLStack.Count < 1)
109 {
110 //TODO: Temporary fix
111 Common.SendToDebug("ERROR: TRYING TO POP EMPTY STACK!");
112 }
113 else
114 {
115 LSLStack.Pop();
116 }
117 }
118 public void PUSH(object Param)
119 {
120 if (Param == null)
121 {
122 Common.SendToDebug("::PUSH: <null>");
123 }
124 else
125 {
126
127 //Common.SendToDebug("::PUSH: " + Param.GetType());
128 }
129
130 LSLStack.Push(Param);
131 }
132 public void ADD(UInt32 Param)
133 {
134 Common.SendToDebug("::ADD: " + Param);
135 object o2 = LSLStack.Pop();
136 object o1 = LSLStack.Pop();
137 Common.SendToDebug("::ADD: Debug: o1: " + o1.GetType() + " (" + o1.ToString() + "), o2: " + o2.GetType() + " (" + o2.ToString() + ")");
138 if (o2.GetType() == typeof(string))
139 {
140 LSLStack.Push((string)o1 + (string)o2);
141 return;
142 }
143 if (o2.GetType() == typeof(UInt32))
144 {
145 LSLStack.Push((UInt32)o1 + (UInt32)o2);
146 return;
147 }
148
149 }
150 public void SUB(UInt32 Param)
151 {
152 Common.SendToDebug("::SUB: " + Param);
153 UInt32 i2 = (UInt32)LSLStack.Pop();
154 UInt32 i1 = (UInt32)LSLStack.Pop();
155 LSLStack.Push((UInt32)(i1 - i2));
156 }
157 public void MUL(UInt32 Param)
158 {
159 Common.SendToDebug("::SUB: " + Param);
160 UInt32 i2 = (UInt32)LSLStack.Pop();
161 UInt32 i1 = (UInt32)LSLStack.Pop();
162 LSLStack.Push((UInt32)(i1 * i2));
163 }
164 public void DIV(UInt32 Param)
165 {
166 Common.SendToDebug("::DIV: " + Param);
167 UInt32 i2 = (UInt32)LSLStack.Pop();
168 UInt32 i1 = (UInt32)LSLStack.Pop();
169 LSLStack.Push((UInt32)(i1 / i2));
170 }
171
172
173 public void MOD(UInt32 Param)
174 {
175 Common.SendToDebug("::MOD: " + Param);
176 UInt32 i2 = (UInt32)LSLStack.Pop();
177 UInt32 i1 = (UInt32)LSLStack.Pop();
178 LSLStack.Push((UInt32)(i1 % i2));
179 }
180 public void EQ(UInt32 Param)
181 {
182 Common.SendToDebug("::EQ: " + Param);
183 UInt32 i2 = (UInt32)LSLStack.Pop();
184 UInt32 i1 = (UInt32)LSLStack.Pop();
185 if (i1 == i2)
186 {
187 LSLStack.Push((UInt32)1);
188 }
189 else
190 {
191 LSLStack.Push((UInt32)0);
192 }
193 }
194 public void NEQ(UInt32 Param)
195 {
196 Common.SendToDebug("::NEQ: " + Param);
197 UInt32 i2 = (UInt32)LSLStack.Pop();
198 UInt32 i1 = (UInt32)LSLStack.Pop();
199 if (i1 != i2)
200 {
201 LSLStack.Push((UInt32)1);
202 }
203 else
204 {
205 LSLStack.Push((UInt32)0);
206 }
207 }
208 public void LEQ(UInt32 Param)
209 {
210 Common.SendToDebug("::LEQ: " + Param);
211 UInt32 i2 = (UInt32)LSLStack.Pop();
212 UInt32 i1 = (UInt32)LSLStack.Pop();
213 if (i1 <= i2)
214 {
215 LSLStack.Push((UInt32)1);
216 }
217 else
218 {
219 LSLStack.Push((UInt32)0);
220 }
221 }
222 public void GEQ(UInt32 Param)
223 {
224 Common.SendToDebug("::GEQ: " + Param);
225 UInt32 i2 = (UInt32)LSLStack.Pop();
226 UInt32 i1 = (UInt32)LSLStack.Pop();
227 if (i1 >= i2)
228 {
229 LSLStack.Push((UInt32)1);
230 }
231 else
232 {
233 LSLStack.Push((UInt32)0);
234 }
235 }
236 public void LESS(UInt32 Param)
237 {
238 Common.SendToDebug("::LESS: " + Param);
239 UInt32 i2 = (UInt32)LSLStack.Pop();
240 UInt32 i1 = (UInt32)LSLStack.Pop();
241 if (i1 < i2)
242 {
243 LSLStack.Push((UInt32)1);
244 }
245 else
246 {
247 LSLStack.Push((UInt32)0);
248 }
249 }
250 public void GREATER(UInt32 Param)
251 {
252 Common.SendToDebug("::GREATER: " + Param);
253 UInt32 i2 = (UInt32)LSLStack.Pop();
254 UInt32 i1 = (UInt32)LSLStack.Pop();
255 if (i1 > i2)
256 {
257 LSLStack.Push((UInt32)1);
258 }
259 else
260 {
261 LSLStack.Push((UInt32)0);
262 }
263 }
264
265
266
267 public void BITAND()
268 {
269 Common.SendToDebug("::BITAND");
270 UInt32 i2 = (UInt32)LSLStack.Pop();
271 UInt32 i1 = (UInt32)LSLStack.Pop();
272 LSLStack.Push((UInt32)(i1 & i2));
273 }
274 public void BITOR()
275 {
276 Common.SendToDebug("::BITOR");
277 UInt32 i2 = (UInt32)LSLStack.Pop();
278 UInt32 i1 = (UInt32)LSLStack.Pop();
279 LSLStack.Push((UInt32)(i1 | i2));
280 }
281 public void BITXOR()
282 {
283 Common.SendToDebug("::BITXOR");
284 UInt32 i2 = (UInt32)LSLStack.Pop();
285 UInt32 i1 = (UInt32)LSLStack.Pop();
286 LSLStack.Push((UInt32)(i1 ^ i2));
287 }
288 public void BOOLAND()
289 {
290 Common.SendToDebug("::BOOLAND");
291 bool b2 = bool.Parse((string)LSLStack.Pop());
292 bool b1 = bool.Parse((string)LSLStack.Pop());
293 if (b1 && b2)
294 {
295 LSLStack.Push((UInt32)1);
296 }
297 else
298 {
299 LSLStack.Push((UInt32)0);
300 }
301 }
302 public void BOOLOR()
303 {
304 Common.SendToDebug("::BOOLOR");
305 bool b2 = bool.Parse((string)LSLStack.Pop());
306 bool b1 = bool.Parse((string)LSLStack.Pop());
307
308 if (b1 || b2)
309 {
310 LSLStack.Push((UInt32)1);
311 }
312 else
313 {
314 LSLStack.Push((UInt32)0);
315 }
316
317 }
318 public void NEG(UInt32 Param)
319 {
320 Common.SendToDebug("::NEG: " + Param);
321 //UInt32 i2 = (UInt32)LSLStack.Pop();
322 UInt32 i1 = (UInt32)LSLStack.Pop();
323 LSLStack.Push((UInt32)(i1 * -1));
324 }
325 public void BITNOT()
326 {
327 //Common.SendToDebug("::BITNOT");
328 //UInt32 i2 = (UInt32)LSLStack.Pop();
329 //UInt32 i1 = (UInt32)LSLStack.Pop();
330 //LSLStack.Push((UInt32)(i1 / i2));
331 }
332 public void BOOLNOT()
333 {
334 //Common.SendToDebug("::BOOLNOT");
335 ////UInt32 i2 = (UInt32)LSLStack.Pop();
336 //UInt32 i1 = (UInt32)LSLStack.Pop();
337 //LSLStack.Push((UInt32)(i1));
338 }
339
340
341 }
342}