diff options
Diffstat (limited to 'OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs')
-rw-r--r-- | OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs | 119 |
1 files changed, 119 insertions, 0 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs new file mode 100644 index 0000000..f944c52 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs | |||
@@ -0,0 +1,119 @@ | |||
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.ExtensionsScriptModule.JVMEngine.Types; | ||
32 | using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; | ||
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Framework.Interfaces; | ||
35 | using OpenSim.Region.Environment.Scenes; | ||
36 | using OpenSim.Region.ExtensionsScriptModule; | ||
37 | |||
38 | namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM | ||
39 | { | ||
40 | public partial class Thread | ||
41 | { | ||
42 | // Is this smart? | ||
43 | public static MainMemory GlobalMemory; | ||
44 | public static Scene World; | ||
45 | private int PC = 0; | ||
46 | private Stack stack; | ||
47 | private Interpreter m_Interpreter; | ||
48 | public ClassRecord currentClass; | ||
49 | public ClassInstance currentInstance; | ||
50 | private StackFrame m_currentFrame; | ||
51 | public int excutionCounter = 0; | ||
52 | public bool running = false; | ||
53 | |||
54 | public ScriptInfo scriptInfo; | ||
55 | |||
56 | public Thread() | ||
57 | { | ||
58 | this.m_Interpreter = new Interpreter(this); | ||
59 | this.stack = new Stack(); | ||
60 | } | ||
61 | |||
62 | public void SetPC(int methodpointer) | ||
63 | { | ||
64 | //Console.WriteLine("Thread PC has been set to " + methodpointer); | ||
65 | PC = methodpointer; | ||
66 | } | ||
67 | |||
68 | public void StartMethod(ClassRecord rec, string methName) | ||
69 | { | ||
70 | m_currentFrame = new StackFrame(); | ||
71 | this.stack.StackFrames.Push(m_currentFrame); | ||
72 | this.currentClass = rec; | ||
73 | currentClass.StartMethod(this, methName); | ||
74 | } | ||
75 | |||
76 | public void StartMethod( string methName) | ||
77 | { | ||
78 | m_currentFrame = new StackFrame(); | ||
79 | this.stack.StackFrames.Push(m_currentFrame); | ||
80 | currentClass.StartMethod(this, methName); | ||
81 | } | ||
82 | |||
83 | public void JumpToStaticVoidMethod(string methName, int returnPC) | ||
84 | { | ||
85 | m_currentFrame = new StackFrame(); | ||
86 | m_currentFrame.ReturnPC = returnPC; | ||
87 | this.stack.StackFrames.Push(m_currentFrame); | ||
88 | currentClass.StartMethod(this, methName); | ||
89 | } | ||
90 | |||
91 | public void JumpToStaticParamMethod(string methName, string param, int returnPC) | ||
92 | { | ||
93 | if (param == "I") | ||
94 | { | ||
95 | BaseType bs1 = m_currentFrame.OpStack.Pop(); | ||
96 | m_currentFrame = new StackFrame(); | ||
97 | m_currentFrame.ReturnPC = returnPC; | ||
98 | this.stack.StackFrames.Push(m_currentFrame); | ||
99 | m_currentFrame.LocalVariables[0] = ((Int)bs1); | ||
100 | currentClass.StartMethod(this, methName); | ||
101 | } | ||
102 | if (param == "F") | ||
103 | { | ||
104 | |||
105 | } | ||
106 | } | ||
107 | |||
108 | public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) | ||
109 | { | ||
110 | |||
111 | } | ||
112 | |||
113 | public bool Excute() | ||
114 | { | ||
115 | excutionCounter++; | ||
116 | return this.m_Interpreter.Excute(); | ||
117 | } | ||
118 | } | ||
119 | } | ||