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