aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim.Scripting.EmbeddedJVM/Interpreter.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/Interpreter.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 'OpenSim.Scripting.EmbeddedJVM/Interpreter.cs')
-rw-r--r--OpenSim.Scripting.EmbeddedJVM/Interpreter.cs105
1 files changed, 105 insertions, 0 deletions
diff --git a/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs b/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs
new file mode 100644
index 0000000..aeeee0a
--- /dev/null
+++ b/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs
@@ -0,0 +1,105 @@
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 Thread _mThread;
14
15 public Interpreter(Thread parentThread)
16 {
17 _mThread = parentThread;
18 }
19
20 public bool Excute()
21 {
22 bool run = true;
23 byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
24 // Console.WriteLine("opCode is: " + currentOpCode);
25 bool handled = false;
26
27 handled = this.IsLogicOpCode(currentOpCode);
28 if (!handled)
29 {
30 handled = this.IsMethodOpCode(currentOpCode);
31 }
32 if (!handled)
33 {
34 if (currentOpCode == 172)
35 {
36 if (this._mThread.stack.StackFrames.Count > 1)
37 {
38 Console.WriteLine("returning int from function");
39 int retPC1 = this._mThread.currentFrame.ReturnPC;
40 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
41 this._mThread.stack.StackFrames.Pop();
42 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
43 this._mThread.PC = retPC1;
44 if (bas1 is Int)
45 {
46 this._mThread.currentFrame.OpStack.Push((Int)bas1);
47 }
48 }
49 else
50 {
51 // Console.WriteLine("No parent function so ending program");
52 run = false;
53 }
54 handled = true;
55 }
56 if (currentOpCode == 174)
57 {
58 if (this._mThread.stack.StackFrames.Count > 1)
59 {
60 Console.WriteLine("returning float from function");
61 int retPC1 = this._mThread.currentFrame.ReturnPC;
62 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
63 this._mThread.stack.StackFrames.Pop();
64 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
65 this._mThread.PC = retPC1;
66 if (bas1 is Float)
67 {
68 this._mThread.currentFrame.OpStack.Push((Float)bas1);
69 }
70 }
71 else
72 {
73 // Console.WriteLine("No parent function so ending program");
74 run = false;
75 }
76 handled = true;
77 }
78 if (currentOpCode == 177)
79 {
80 if (this._mThread.stack.StackFrames.Count > 1)
81 {
82 Console.WriteLine("returning from function");
83 int retPC = this._mThread.currentFrame.ReturnPC;
84 this._mThread.stack.StackFrames.Pop();
85 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
86 this._mThread.PC = retPC;
87 }
88 else
89 {
90 // Console.WriteLine("No parent function so ending program");
91 run = false;
92 }
93 handled = true;
94 }
95 }
96 if (!handled)
97 {
98 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
99 }
100 return run;
101
102 }
103 }
104 }
105}