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