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