aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
diff options
context:
space:
mode:
authorMW2007-05-26 13:40:19 +0000
committerMW2007-05-26 13:40:19 +0000
commit3436961bb5c01d659d09be134368f4f69460cef9 (patch)
tree3753ba4d7818df2a6bce0bbe863ff033cdfd568a /OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
downloadopensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.zip
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.gz
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.bz2
opensim-SC_OLD-3436961bb5c01d659d09be134368f4f69460cef9.tar.xz
Start of rewrite 5279!
Diffstat (limited to 'OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs')
-rw-r--r--OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs108
1 files changed, 108 insertions, 0 deletions
diff --git a/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
new file mode 100644
index 0000000..b94248c
--- /dev/null
+++ b/OpenSim/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs
@@ -0,0 +1,108 @@
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 this._mThread.stack.StackFrames.Pop();
53 run = false;
54 }
55 handled = true;
56 }
57 if (currentOpCode == 174)
58 {
59 if (this._mThread.stack.StackFrames.Count > 1)
60 {
61 Console.WriteLine("returning float from function");
62 int retPC1 = this._mThread.currentFrame.ReturnPC;
63 BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
64 this._mThread.stack.StackFrames.Pop();
65 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
66 this._mThread.PC = retPC1;
67 if (bas1 is Float)
68 {
69 this._mThread.currentFrame.OpStack.Push((Float)bas1);
70 }
71 }
72 else
73 {
74 // Console.WriteLine("No parent function so ending program");
75 this._mThread.stack.StackFrames.Pop();
76 run = false;
77 }
78 handled = true;
79 }
80 if (currentOpCode == 177)
81 {
82 if (this._mThread.stack.StackFrames.Count > 1)
83 {
84 Console.WriteLine("returning from function");
85 int retPC = this._mThread.currentFrame.ReturnPC;
86 this._mThread.stack.StackFrames.Pop();
87 this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
88 this._mThread.PC = retPC;
89 }
90 else
91 {
92 // Console.WriteLine("No parent function so ending program");
93 this._mThread.stack.StackFrames.Pop();
94 run = false;
95 }
96 handled = true;
97 }
98 }
99 if (!handled)
100 {
101 Console.WriteLine("opcode " + currentOpCode + " not been handled ");
102 }
103 return run;
104
105 }
106 }
107 }
108}