aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs427
1 files changed, 0 insertions, 427 deletions
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs
deleted file mode 100644
index 2a11afd..0000000
--- a/OpenSim/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs
+++ /dev/null
@@ -1,427 +0,0 @@
1/*
2* Copyright (c) Contributors, http://www.openmetaverse.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;
29using System.Collections.Generic;
30using System.Text;
31using OpenSim.Scripting.EmbeddedJVM.Types;
32using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
33
34namespace OpenSim.Scripting.EmbeddedJVM
35{
36 partial class Thread
37 {
38 private partial class Interpreter
39 {
40 private bool IsLogicOpCode(byte opcode)
41 {
42 bool result = false;
43 switch (opcode)
44 {
45 case 2:
46 Int m_int= new Int();
47 m_int.mValue = -1;
48 this._mThread.currentFrame.OpStack.Push(m_int);
49 result = true;
50 break;
51 case 3:
52 m_int= new Int();
53 m_int.mValue = 0;
54 this._mThread.currentFrame.OpStack.Push(m_int);
55 result = true;
56 break;
57 case 4:
58 m_int = new Int();
59 m_int.mValue = 1;
60 this._mThread.currentFrame.OpStack.Push(m_int);
61 result = true;
62 break;
63 case 5:
64 m_int = new Int();
65 m_int.mValue = 2;
66 this._mThread.currentFrame.OpStack.Push(m_int);
67 result = true;
68 break;
69 case 6:
70 m_int = new Int();
71 m_int.mValue = 3;
72 this._mThread.currentFrame.OpStack.Push(m_int);
73 break;
74 case 7:
75 m_int = new Int();
76 m_int.mValue = 4;
77 this._mThread.currentFrame.OpStack.Push(m_int);
78 result = true;
79 break;
80 case 8:
81 m_int = new Int();
82 m_int.mValue = 5;
83 this._mThread.currentFrame.OpStack.Push(m_int);
84 result = true;
85 break;
86 case 11:
87 Float m_float = new Float();
88 m_float.mValue = 0.0f;
89 this._mThread.currentFrame.OpStack.Push(m_float);
90 result = true;
91 break;
92 case 12:
93 m_float = new Float();
94 m_float.mValue = 1.0f;
95 this._mThread.currentFrame.OpStack.Push(m_float);
96 result = true;
97 break;
98 case 13:
99 m_float = new Float();
100 m_float.mValue = 2.0f;
101 this._mThread.currentFrame.OpStack.Push(m_float);
102 result = true;
103 break;
104 case 16:
105 int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
106 Int pushInt = new Int();
107 pushInt.mValue = pushvalue;
108 this._mThread.currentFrame.OpStack.Push(pushInt);
109 this._mThread.PC++;
110 result = true;
111 break;
112 case 17:
113 short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
114 Int pushInt2 = new Int();
115 pushInt2.mValue = pushvalue2;
116 this._mThread.currentFrame.OpStack.Push(pushInt2);
117 this._mThread.PC += 2;
118 result = true;
119 break;
120 case 23:
121 short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
122 Float fload = new Float();
123 if (this._mThread.currentFrame.LocalVariables[findex1] != null)
124 {
125 if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
126 {
127 fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
128 this._mThread.currentFrame.OpStack.Push(fload);
129 }
130 }
131 this._mThread.PC++;
132 result = true;
133 break;
134 case 26:
135 if (this._mThread.currentFrame.LocalVariables[0] != null)
136 {
137 if (this._mThread.currentFrame.LocalVariables[0] is Int)
138 {
139 Int newInt = new Int();
140 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
141 this._mThread.currentFrame.OpStack.Push(newInt);
142 }
143 }
144 result = true;
145 break;
146 case 27:
147 if (this._mThread.currentFrame.LocalVariables[1] != null)
148 {
149 if (this._mThread.currentFrame.LocalVariables[1] is Int)
150 {
151 Int newInt = new Int();
152 newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
153 this._mThread.currentFrame.OpStack.Push(newInt);
154 }
155 }
156 result = true;
157 break;
158 case 34:
159 if (this._mThread.currentFrame.LocalVariables[0] != null)
160 {
161 if (this._mThread.currentFrame.LocalVariables[0] is Float)
162 {
163 Float newfloat = new Float();
164 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
165 this._mThread.currentFrame.OpStack.Push(newfloat);
166 }
167 }
168 result = true;
169 break;
170 case 35:
171 if (this._mThread.currentFrame.LocalVariables[1] != null)
172 {
173 if (this._mThread.currentFrame.LocalVariables[1] is Float)
174 {
175 Float newfloat = new Float();
176 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
177 this._mThread.currentFrame.OpStack.Push(newfloat);
178 }
179 }
180 result = true;
181 break;
182 case 36:
183 if (this._mThread.currentFrame.LocalVariables[2] != null)
184 {
185 if (this._mThread.currentFrame.LocalVariables[2] is Float)
186 {
187 Float newfloat = new Float();
188 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
189 this._mThread.currentFrame.OpStack.Push(newfloat);
190 }
191 }
192 result = true;
193 break;
194 case 37:
195 if (this._mThread.currentFrame.LocalVariables[3] != null)
196 {
197 if (this._mThread.currentFrame.LocalVariables[3] is Float)
198 {
199 Float newfloat = new Float();
200 newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
201 this._mThread.currentFrame.OpStack.Push(newfloat);
202 }
203 }
204 result = true;
205 break;
206 case 56:
207 short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
208 BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
209 if (fstor is Float)
210 {
211 this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
212 }
213 this._mThread.PC++;
214 result = true;
215 break;
216 case 59:
217 BaseType baset = this._mThread.currentFrame.OpStack.Pop();
218 if (baset is Int)
219 {
220 this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
221 }
222 result = true;
223 break;
224 case 60:
225 baset = this._mThread.currentFrame.OpStack.Pop();
226 if (baset is Int)
227 {
228 this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
229 }
230 result = true;
231 break;
232 case 67:
233 baset = this._mThread.currentFrame.OpStack.Pop();
234 if (baset is Float)
235 {
236 this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
237 }
238 result = true;
239 break;
240 case 68:
241 baset = this._mThread.currentFrame.OpStack.Pop();
242 if (baset is Float)
243 {
244 this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
245 }
246 result = true;
247 break;
248 case 69:
249 baset = this._mThread.currentFrame.OpStack.Pop();
250 if (baset is Float)
251 {
252 this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
253 }
254 result = true;
255 break;
256 case 70:
257 baset = this._mThread.currentFrame.OpStack.Pop();
258 if (baset is Float)
259 {
260 this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
261 }
262 result = true;
263 break;
264 case 87:
265 this._mThread.currentFrame.OpStack.Pop();
266 result = true;
267 break;
268 case 98:
269 BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
270 BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
271 if (bf1 is Float && bf2 is Float)
272 {
273 Float nflt = new Float();
274 nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
275 this._mThread.currentFrame.OpStack.Push(nflt);
276 }
277 result = true;
278 break;
279 case 102:
280 BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
281 BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
282 if (bsf1 is Float && bsf2 is Float)
283 {
284 Float resf = new Float();
285 resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
286 this._mThread.currentFrame.OpStack.Push(resf);
287 }
288 result = true;
289 break;
290 case 104: //check the order of the two values off the stack is correct
291 BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
292 BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
293 if (bs1 is Int && bs2 is Int)
294 {
295 Int nInt = new Int();
296 nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
297 this._mThread.currentFrame.OpStack.Push(nInt);
298 }
299 result = true;
300 break;
301 case 132:
302 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
303 {
304 if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
305 {
306 ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
307 }
308 }
309 this._mThread.PC += 2;
310 result = true;
311 break;
312 case 139:
313 BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
314 if (conv1 is Float)
315 {
316 Int newconv = new Int();
317 newconv.mValue = (int)((Float)conv1).mValue;
318 this._mThread.currentFrame.OpStack.Push(newconv);
319 }
320 result = true;
321 break;
322 case 149:
323 BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
324 BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
325 if (flcom1 is Float && flcom2 is Float)
326 {
327 Int compres = new Int();
328 if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
329 {
330 compres.mValue = -1;
331 }
332 else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
333 {
334 compres.mValue = 1;
335 }
336 else
337 {
338 compres.mValue = 0;
339 }
340 this._mThread.currentFrame.OpStack.Push(compres);
341 }
342 result = true;
343 break;
344 case 158:
345 short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
346 BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
347 if (comp1 is Int)
348 {
349 if (((Int)comp1).mValue <= 0)
350 {
351 this._mThread.PC += -1 + compareoffset1;
352 }
353 else
354 {
355 this._mThread.PC += 2;
356 }
357 }
358 else
359 {
360 this._mThread.PC += 2;
361 }
362 result = true;
363 break;
364 case 162:
365 short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
366 BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
367 BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
368 if (bc1 is Int && bc2 is Int)
369 {
370 //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
371 if (((Int)bc1).mValue >= ((Int)bc2).mValue)
372 {
373 // Console.WriteLine("branch compare true , offset is " +compareoffset);
374 // Console.WriteLine("current PC is " + this._mThread.PC);
375 this._mThread.PC += -1 + compareoffset;
376 //Console.WriteLine("new PC is " + this._mThread.PC);
377 }
378 else
379 {
380 //Console.WriteLine("branch compare false");
381 this._mThread.PC += 2;
382 }
383 }
384 else
385 {
386 this._mThread.PC += 2;
387 }
388 result = true;
389 break;
390 case 164:
391 short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
392 BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
393 BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
394 if (bcl1 is Int && bcl2 is Int)
395 {
396 //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
397 if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
398 {
399 // Console.WriteLine("branch compare true , offset is " + compareloffset);
400 // Console.WriteLine("current PC is " + this._mThread.PC);
401 this._mThread.PC += -1 + compareloffset;
402 // Console.WriteLine("new PC is " + this._mThread.PC);
403 }
404 else
405 {
406 //Console.WriteLine("branch compare false");
407 this._mThread.PC += 2;
408 }
409 }
410 else
411 {
412 this._mThread.PC += 2;
413 }
414 result = true;
415 break;
416 case 167:
417 short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
418 this._mThread.PC += -1 + offset;
419 result = true;
420 break;
421 }
422
423 return result;
424 }
425 }
426 }
427}