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