diff options
author | Adam Frisby | 2008-05-08 05:09:35 +0000 |
---|---|---|
committer | Adam Frisby | 2008-05-08 05:09:35 +0000 |
commit | 8a48516bcfcce1a49499d33db0e8eab2f59f7c1a (patch) | |
tree | ead8b2684a00546180dc5ccbcedbce48427faeb5 /OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs | |
parent | * Fixes Prim ExtraParams (diff) | |
download | opensim-SC-8a48516bcfcce1a49499d33db0e8eab2f59f7c1a.zip opensim-SC-8a48516bcfcce1a49499d33db0e8eab2f59f7c1a.tar.gz opensim-SC-8a48516bcfcce1a49499d33db0e8eab2f59f7c1a.tar.bz2 opensim-SC-8a48516bcfcce1a49499d33db0e8eab2f59f7c1a.tar.xz |
* Spring cleaning, round 3029
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs | 619 |
1 files changed, 0 insertions, 619 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs deleted file mode 100644 index f5ffc6f..0000000 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ /dev/null | |||
@@ -1,619 +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 | |||
28 | using OpenSim.Region.ExtensionsScriptModule.Engines.JVMEngine.Types; | ||
29 | using OpenSim.Region.ExtensionsScriptModule.Engines.JVMEngine.Types.PrimitiveTypes; | ||
30 | |||
31 | namespace OpenSim.Region.ExtensionsScriptModule.Engines.JVMEngine.JVM | ||
32 | { | ||
33 | partial class Thread | ||
34 | { | ||
35 | private partial class Interpreter | ||
36 | { | ||
37 | private bool IsLogicOpCode(byte opcode) | ||
38 | { | ||
39 | bool result = false; | ||
40 | switch (opcode) | ||
41 | { | ||
42 | case (byte) (byte) OpCode.iconst_m1: | ||
43 | Int m_int = new Int(); | ||
44 | m_int.mValue = -1; | ||
45 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
46 | result = true; | ||
47 | break; | ||
48 | case (byte) (byte) OpCode.iconst_0: | ||
49 | m_int = new Int(); | ||
50 | m_int.mValue = 0; | ||
51 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
52 | result = true; | ||
53 | break; | ||
54 | case (byte) (byte) OpCode.iconst_1: | ||
55 | m_int = new Int(); | ||
56 | m_int.mValue = 1; | ||
57 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
58 | result = true; | ||
59 | break; | ||
60 | case (byte) (byte) OpCode.iconst_2: | ||
61 | m_int = new Int(); | ||
62 | m_int.mValue = 2; | ||
63 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
64 | result = true; | ||
65 | break; | ||
66 | case (byte) (byte) OpCode.iconst_3: | ||
67 | m_int = new Int(); | ||
68 | m_int.mValue = 3; | ||
69 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
70 | break; | ||
71 | case (byte) (byte) OpCode.iconst_4: | ||
72 | m_int = new Int(); | ||
73 | m_int.mValue = 4; | ||
74 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
75 | result = true; | ||
76 | break; | ||
77 | case (byte) OpCode.iconst_5: | ||
78 | m_int = new Int(); | ||
79 | m_int.mValue = 5; | ||
80 | m_thread.m_currentFrame.OpStack.Push(m_int); | ||
81 | result = true; | ||
82 | break; | ||
83 | case (byte) OpCode.fconst_0: | ||
84 | Float m_float = new Float(); | ||
85 | m_float.mValue = 0.0f; | ||
86 | m_thread.m_currentFrame.OpStack.Push(m_float); | ||
87 | result = true; | ||
88 | break; | ||
89 | case (byte) OpCode.fconst_1: | ||
90 | m_float = new Float(); | ||
91 | m_float.mValue = 1.0f; | ||
92 | m_thread.m_currentFrame.OpStack.Push(m_float); | ||
93 | result = true; | ||
94 | break; | ||
95 | case (byte) OpCode.fconst_2: | ||
96 | m_float = new Float(); | ||
97 | m_float.mValue = 2.0f; | ||
98 | m_thread.m_currentFrame.OpStack.Push(m_float); | ||
99 | result = true; | ||
100 | break; | ||
101 | case (byte) OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? | ||
102 | int pushvalue = (int) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]; | ||
103 | Int pushInt = new Int(); | ||
104 | pushInt.mValue = pushvalue; | ||
105 | m_thread.m_currentFrame.OpStack.Push(pushInt); | ||
106 | m_thread.PC++; | ||
107 | result = true; | ||
108 | break; | ||
109 | case (byte) OpCode.sipush: | ||
110 | short pushvalue2 = | ||
111 | (short) | ||
112 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
113 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
114 | Int pushInt2 = new Int(); | ||
115 | pushInt2.mValue = pushvalue2; | ||
116 | m_thread.m_currentFrame.OpStack.Push(pushInt2); | ||
117 | m_thread.PC += 2; | ||
118 | result = true; | ||
119 | break; | ||
120 | case (byte) OpCode.fload: | ||
121 | short findex1 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); | ||
122 | Float fload = new Float(); | ||
123 | if (m_thread.m_currentFrame.LocalVariables[findex1] != null) | ||
124 | { | ||
125 | if (m_thread.m_currentFrame.LocalVariables[findex1] is Float) | ||
126 | { | ||
127 | fload.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[findex1]).mValue; | ||
128 | m_thread.m_currentFrame.OpStack.Push(fload); | ||
129 | } | ||
130 | } | ||
131 | m_thread.PC++; | ||
132 | result = true; | ||
133 | break; | ||
134 | case (byte) OpCode.iload_0: | ||
135 | if (m_thread.m_currentFrame.LocalVariables[0] != null) | ||
136 | { | ||
137 | if (m_thread.m_currentFrame.LocalVariables[0] is Int) | ||
138 | { | ||
139 | Int newInt = new Int(); | ||
140 | newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[0]).mValue; | ||
141 | m_thread.m_currentFrame.OpStack.Push(newInt); | ||
142 | } | ||
143 | } | ||
144 | result = true; | ||
145 | break; | ||
146 | case (byte) OpCode.iload_1: | ||
147 | if (m_thread.m_currentFrame.LocalVariables[1] != null) | ||
148 | { | ||
149 | if (m_thread.m_currentFrame.LocalVariables[1] is Int) | ||
150 | { | ||
151 | Int newInt = new Int(); | ||
152 | newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[1]).mValue; | ||
153 | m_thread.m_currentFrame.OpStack.Push(newInt); | ||
154 | } | ||
155 | } | ||
156 | result = true; | ||
157 | break; | ||
158 | case (byte) OpCode.fload_0: | ||
159 | if (m_thread.m_currentFrame.LocalVariables[0] != null) | ||
160 | { | ||
161 | if (m_thread.m_currentFrame.LocalVariables[0] is Float) | ||
162 | { | ||
163 | Float newfloat = new Float(); | ||
164 | newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[0]).mValue; | ||
165 | m_thread.m_currentFrame.OpStack.Push(newfloat); | ||
166 | } | ||
167 | } | ||
168 | result = true; | ||
169 | break; | ||
170 | case (byte) OpCode.fload_1: | ||
171 | if (m_thread.m_currentFrame.LocalVariables[1] != null) | ||
172 | { | ||
173 | if (m_thread.m_currentFrame.LocalVariables[1] is Float) | ||
174 | { | ||
175 | Float newfloat = new Float(); | ||
176 | newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[1]).mValue; | ||
177 | m_thread.m_currentFrame.OpStack.Push(newfloat); | ||
178 | } | ||
179 | } | ||
180 | result = true; | ||
181 | break; | ||
182 | case (byte) OpCode.fload_2: | ||
183 | if (m_thread.m_currentFrame.LocalVariables[2] != null) | ||
184 | { | ||
185 | if (m_thread.m_currentFrame.LocalVariables[2] is Float) | ||
186 | { | ||
187 | Float newfloat = new Float(); | ||
188 | newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[2]).mValue; | ||
189 | m_thread.m_currentFrame.OpStack.Push(newfloat); | ||
190 | } | ||
191 | } | ||
192 | result = true; | ||
193 | break; | ||
194 | case (byte) OpCode.fload_3: | ||
195 | if (m_thread.m_currentFrame.LocalVariables[3] != null) | ||
196 | { | ||
197 | if (m_thread.m_currentFrame.LocalVariables[3] is Float) | ||
198 | { | ||
199 | Float newfloat = new Float(); | ||
200 | newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[3]).mValue; | ||
201 | m_thread.m_currentFrame.OpStack.Push(newfloat); | ||
202 | } | ||
203 | } | ||
204 | result = true; | ||
205 | break; | ||
206 | case (byte) OpCode.istore: | ||
207 | short findex3 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); | ||
208 | BaseType istor = m_thread.m_currentFrame.OpStack.Pop(); | ||
209 | if (istor is Int) | ||
210 | { | ||
211 | m_thread.m_currentFrame.LocalVariables[findex3] = (Int) istor; | ||
212 | } | ||
213 | m_thread.PC++; | ||
214 | result = true; | ||
215 | break; | ||
216 | case (byte) OpCode.fstore: | ||
217 | short findex = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); | ||
218 | BaseType fstor = m_thread.m_currentFrame.OpStack.Pop(); | ||
219 | if (fstor is Float) | ||
220 | { | ||
221 | m_thread.m_currentFrame.LocalVariables[findex] = (Float) fstor; | ||
222 | } | ||
223 | m_thread.PC++; | ||
224 | result = true; | ||
225 | break; | ||
226 | case (byte) OpCode.istore_0: | ||
227 | BaseType baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
228 | if (baset is Int) | ||
229 | { | ||
230 | m_thread.m_currentFrame.LocalVariables[0] = (Int) baset; | ||
231 | } | ||
232 | result = true; | ||
233 | break; | ||
234 | case (byte) OpCode.istore_1: | ||
235 | baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
236 | if (baset is Int) | ||
237 | { | ||
238 | m_thread.m_currentFrame.LocalVariables[1] = (Int) baset; | ||
239 | } | ||
240 | result = true; | ||
241 | break; | ||
242 | case (byte) OpCode.fstore_0: | ||
243 | baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
244 | if (baset is Float) | ||
245 | { | ||
246 | m_thread.m_currentFrame.LocalVariables[0] = (Float) baset; | ||
247 | } | ||
248 | result = true; | ||
249 | break; | ||
250 | case (byte) OpCode.fstore_1: | ||
251 | baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
252 | if (baset is Float) | ||
253 | { | ||
254 | m_thread.m_currentFrame.LocalVariables[1] = (Float) baset; | ||
255 | } | ||
256 | result = true; | ||
257 | break; | ||
258 | case (byte) OpCode.fstore_2: | ||
259 | baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
260 | if (baset is Float) | ||
261 | { | ||
262 | m_thread.m_currentFrame.LocalVariables[2] = (Float) baset; | ||
263 | } | ||
264 | result = true; | ||
265 | break; | ||
266 | case (byte) OpCode.fstore_3: | ||
267 | baset = m_thread.m_currentFrame.OpStack.Pop(); | ||
268 | if (baset is Float) | ||
269 | { | ||
270 | m_thread.m_currentFrame.LocalVariables[3] = (Float) baset; | ||
271 | } | ||
272 | result = true; | ||
273 | break; | ||
274 | case (byte) OpCode.pop: | ||
275 | m_thread.m_currentFrame.OpStack.Pop(); | ||
276 | result = true; | ||
277 | break; | ||
278 | case (byte) OpCode.fadd: | ||
279 | BaseType bf2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
280 | BaseType bf1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
281 | if (bf1 is Float && bf2 is Float) | ||
282 | { | ||
283 | Float nflt = new Float(); | ||
284 | nflt.mValue = ((Float) bf1).mValue + ((Float) bf2).mValue; | ||
285 | m_thread.m_currentFrame.OpStack.Push(nflt); | ||
286 | } | ||
287 | result = true; | ||
288 | break; | ||
289 | case (byte) OpCode.fsub: | ||
290 | BaseType bsf2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
291 | BaseType bsf1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
292 | if (bsf1 is Float && bsf2 is Float) | ||
293 | { | ||
294 | Float resf = new Float(); | ||
295 | resf.mValue = ((Float) bsf1).mValue - ((Float) bsf2).mValue; | ||
296 | m_thread.m_currentFrame.OpStack.Push(resf); | ||
297 | } | ||
298 | result = true; | ||
299 | break; | ||
300 | case (byte) OpCode.imul: //check the order of the two values off the stack is correct | ||
301 | BaseType bs2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
302 | BaseType bs1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
303 | if (bs1 is Int && bs2 is Int) | ||
304 | { | ||
305 | Int nInt = new Int(); | ||
306 | nInt.mValue = ((Int) bs1).mValue*((Int) bs2).mValue; | ||
307 | m_thread.m_currentFrame.OpStack.Push(nInt); | ||
308 | } | ||
309 | result = true; | ||
310 | break; | ||
311 | case (byte) OpCode.iinc: | ||
312 | if (m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]] != | ||
313 | null) | ||
314 | { | ||
315 | if ( | ||
316 | m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] | ||
317 | ] is Int) | ||
318 | { | ||
319 | ((Int) | ||
320 | m_thread.m_currentFrame.LocalVariables[ | ||
321 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]]).mValue += | ||
322 | (sbyte) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]; | ||
323 | } | ||
324 | } | ||
325 | m_thread.PC += 2; | ||
326 | result = true; | ||
327 | break; | ||
328 | case (byte) OpCode.f2i: | ||
329 | BaseType conv1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
330 | if (conv1 is Float) | ||
331 | { | ||
332 | Int newconv = new Int(); | ||
333 | newconv.mValue = (int) ((Float) conv1).mValue; | ||
334 | m_thread.m_currentFrame.OpStack.Push(newconv); | ||
335 | } | ||
336 | result = true; | ||
337 | break; | ||
338 | case (byte) OpCode.fcmpl: | ||
339 | BaseType flcom2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
340 | BaseType flcom1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
341 | if (flcom1 is Float && flcom2 is Float) | ||
342 | { | ||
343 | Int compres = new Int(); | ||
344 | if (((Float) flcom1).mValue < ((Float) flcom2).mValue) | ||
345 | { | ||
346 | compres.mValue = -1; | ||
347 | } | ||
348 | else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) | ||
349 | { | ||
350 | compres.mValue = 1; | ||
351 | } | ||
352 | else | ||
353 | { | ||
354 | compres.mValue = 0; | ||
355 | } | ||
356 | m_thread.m_currentFrame.OpStack.Push(compres); | ||
357 | } | ||
358 | result = true; | ||
359 | break; | ||
360 | case (byte) OpCode.fcmpg: | ||
361 | flcom2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
362 | flcom1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
363 | if (flcom1 is Float && flcom2 is Float) | ||
364 | { | ||
365 | Int compres = new Int(); | ||
366 | if (((Float) flcom1).mValue < ((Float) flcom2).mValue) | ||
367 | { | ||
368 | compres.mValue = -1; | ||
369 | } | ||
370 | else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) | ||
371 | { | ||
372 | compres.mValue = 1; | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | compres.mValue = 0; | ||
377 | } | ||
378 | m_thread.m_currentFrame.OpStack.Push(compres); | ||
379 | } | ||
380 | result = true; | ||
381 | break; | ||
382 | case (byte) OpCode.ifge: | ||
383 | short compareoffset2 = | ||
384 | (short) | ||
385 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
386 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
387 | BaseType compe1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
388 | if (compe1 is Int) | ||
389 | { | ||
390 | if (((Int) compe1).mValue >= 0) | ||
391 | { | ||
392 | m_thread.PC += -1 + compareoffset2; | ||
393 | } | ||
394 | else | ||
395 | { | ||
396 | m_thread.PC += 2; | ||
397 | } | ||
398 | } | ||
399 | else | ||
400 | { | ||
401 | m_thread.PC += 2; | ||
402 | } | ||
403 | result = true; | ||
404 | break; | ||
405 | case (byte) OpCode.ifle: | ||
406 | short compareoffset1 = | ||
407 | (short) | ||
408 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
409 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
410 | BaseType comp1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
411 | if (comp1 is Int) | ||
412 | { | ||
413 | if (((Int) comp1).mValue <= 0) | ||
414 | { | ||
415 | m_thread.PC += -1 + compareoffset1; | ||
416 | } | ||
417 | else | ||
418 | { | ||
419 | m_thread.PC += 2; | ||
420 | } | ||
421 | } | ||
422 | else | ||
423 | { | ||
424 | m_thread.PC += 2; | ||
425 | } | ||
426 | result = true; | ||
427 | break; | ||
428 | case (byte) OpCode.if_icmpge: | ||
429 | short compareoffset = | ||
430 | (short) | ||
431 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
432 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
433 | BaseType bc2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
434 | BaseType bc1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
435 | if (bc1 is Int && bc2 is Int) | ||
436 | { | ||
437 | //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); | ||
438 | if (((Int) bc1).mValue >= ((Int) bc2).mValue) | ||
439 | { | ||
440 | // Console.WriteLine("branch compare true , offset is " +compareoffset); | ||
441 | // Console.WriteLine("current PC is " + this._mThread.PC); | ||
442 | m_thread.PC += -1 + compareoffset; | ||
443 | //Console.WriteLine("new PC is " + this._mThread.PC); | ||
444 | } | ||
445 | else | ||
446 | { | ||
447 | //Console.WriteLine("branch compare false"); | ||
448 | m_thread.PC += 2; | ||
449 | } | ||
450 | } | ||
451 | else | ||
452 | { | ||
453 | m_thread.PC += 2; | ||
454 | } | ||
455 | result = true; | ||
456 | break; | ||
457 | case (byte) OpCode.if_icmple: | ||
458 | short compareloffset = | ||
459 | (short) | ||
460 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
461 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
462 | BaseType bcl2 = m_thread.m_currentFrame.OpStack.Pop(); | ||
463 | BaseType bcl1 = m_thread.m_currentFrame.OpStack.Pop(); | ||
464 | if (bcl1 is Int && bcl2 is Int) | ||
465 | { | ||
466 | //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); | ||
467 | if (((Int) bcl1).mValue <= ((Int) bcl2).mValue) | ||
468 | { | ||
469 | // Console.WriteLine("branch compare true , offset is " + compareloffset); | ||
470 | // Console.WriteLine("current PC is " + this._mThread.PC); | ||
471 | m_thread.PC += -1 + compareloffset; | ||
472 | // Console.WriteLine("new PC is " + this._mThread.PC); | ||
473 | } | ||
474 | else | ||
475 | { | ||
476 | //Console.WriteLine("branch compare false"); | ||
477 | m_thread.PC += 2; | ||
478 | } | ||
479 | } | ||
480 | else | ||
481 | { | ||
482 | m_thread.PC += 2; | ||
483 | } | ||
484 | result = true; | ||
485 | break; | ||
486 | case (byte) OpCode._goto: | ||
487 | short offset = | ||
488 | (short) | ||
489 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
490 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
491 | m_thread.PC += -1 + offset; | ||
492 | result = true; | ||
493 | break; | ||
494 | case (byte) OpCode.getstatic: | ||
495 | short fieldrefIndex = | ||
496 | (short) | ||
497 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
498 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
499 | if (m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) | ||
500 | { | ||
501 | if ( | ||
502 | ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). | ||
503 | mClass.Name.Value == m_thread.currentClass.MClass.Name.Value) | ||
504 | { | ||
505 | //from this class | ||
506 | if ( | ||
507 | m_thread.currentClass.StaticFields.ContainsKey( | ||
508 | ((ClassRecord.PoolFieldRef) | ||
509 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) | ||
510 | { | ||
511 | if ( | ||
512 | m_thread.currentClass.StaticFields[ | ||
513 | ((ClassRecord.PoolFieldRef) | ||
514 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name. | ||
515 | Value] is Float) | ||
516 | { | ||
517 | Float retFloat = new Float(); | ||
518 | retFloat.mValue = | ||
519 | ((Float) | ||
520 | m_thread.currentClass.StaticFields[ | ||
521 | ((ClassRecord.PoolFieldRef) | ||
522 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
523 | Name.Value]).mValue; | ||
524 | m_thread.m_currentFrame.OpStack.Push(retFloat); | ||
525 | } | ||
526 | else if ( | ||
527 | m_thread.currentClass.StaticFields[ | ||
528 | ((ClassRecord.PoolFieldRef) | ||
529 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
530 | Name.Value] is Int) | ||
531 | { | ||
532 | Int retInt = new Int(); | ||
533 | retInt.mValue = | ||
534 | ((Int) | ||
535 | m_thread.currentClass.StaticFields[ | ||
536 | ((ClassRecord.PoolFieldRef) | ||
537 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). | ||
538 | mNameType.Name.Value]).mValue; | ||
539 | // Console.WriteLine("getting static field, " + retInt.mValue); | ||
540 | m_thread.m_currentFrame.OpStack.Push(retInt); | ||
541 | } | ||
542 | } | ||
543 | } | ||
544 | else | ||
545 | { | ||
546 | //get from a different class | ||
547 | } | ||
548 | } | ||
549 | m_thread.PC += 2; | ||
550 | result = true; | ||
551 | break; | ||
552 | case (byte) OpCode.putstatic: | ||
553 | fieldrefIndex = | ||
554 | (short) | ||
555 | ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + | ||
556 | GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); | ||
557 | BaseType addstatic = m_thread.m_currentFrame.OpStack.Pop(); | ||
558 | if (m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) | ||
559 | { | ||
560 | if ( | ||
561 | ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). | ||
562 | mClass.Name.Value == m_thread.currentClass.MClass.Name.Value) | ||
563 | { | ||
564 | // this class | ||
565 | if ( | ||
566 | m_thread.currentClass.StaticFields.ContainsKey( | ||
567 | ((ClassRecord.PoolFieldRef) | ||
568 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) | ||
569 | { | ||
570 | if (addstatic is Float) | ||
571 | { | ||
572 | if ( | ||
573 | m_thread.currentClass.StaticFields[ | ||
574 | ((ClassRecord.PoolFieldRef) | ||
575 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
576 | Name.Value] is Float) | ||
577 | { | ||
578 | Float newf = new Float(); | ||
579 | newf.mValue = ((Float) addstatic).mValue; | ||
580 | m_thread.currentClass.StaticFields[ | ||
581 | ((ClassRecord.PoolFieldRef) | ||
582 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
583 | Name.Value] = newf; | ||
584 | } | ||
585 | } | ||
586 | else if (addstatic is Int) | ||
587 | { | ||
588 | if ( | ||
589 | m_thread.currentClass.StaticFields[ | ||
590 | ((ClassRecord.PoolFieldRef) | ||
591 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
592 | Name.Value] is Int) | ||
593 | { | ||
594 | //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); | ||
595 | Int newi = new Int(); | ||
596 | newi.mValue = ((Int) addstatic).mValue; | ||
597 | m_thread.currentClass.StaticFields[ | ||
598 | ((ClassRecord.PoolFieldRef) | ||
599 | m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. | ||
600 | Name.Value] = newi; | ||
601 | } | ||
602 | } | ||
603 | } | ||
604 | } | ||
605 | else | ||
606 | { | ||
607 | // a different class | ||
608 | } | ||
609 | } | ||
610 | m_thread.PC += 2; | ||
611 | result = true; | ||
612 | break; | ||
613 | } | ||
614 | |||
615 | return result; | ||
616 | } | ||
617 | } | ||
618 | } | ||
619 | } \ No newline at end of file | ||