aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs55
1 files changed, 25 insertions, 30 deletions
diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
index b1258f6..274932a 100644
--- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
+++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs
@@ -27,15 +27,11 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Text; 30using System.Diagnostics;
31using System.IO; 31using System.IO;
32using System.Threading;
33using OpenSim.Framework;
34using OpenSim.Framework.Interfaces;
35using OpenSim.Framework; 32using OpenSim.Framework;
36using OpenSim.Region.Environment.Scenes; 33using OpenSim.Region.Environment.Scenes;
37using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; 34using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM;
38using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread;
39 35
40namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine 36namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
41{ 37{
@@ -45,14 +41,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
45 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>(); 41 private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
46 private MainMemory _mainMemory; 42 private MainMemory _mainMemory;
47 43
48 ScriptInfo scriptInfo; 44 private ScriptInfo scriptInfo;
49 45
50 public void Initialise(ScriptInfo info) 46 public void Initialise(ScriptInfo info)
51 { 47 {
52 scriptInfo = info; 48 scriptInfo = info;
53 49
54 _mainMemory = new MainMemory(); 50 _mainMemory = new MainMemory();
55 Thread.GlobalMemory = this._mainMemory; 51 Thread.GlobalMemory = _mainMemory;
56 Thread.World = info.world; 52 Thread.World = info.world;
57 CompileScript(); 53 CompileScript();
58 54
@@ -60,33 +56,33 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
60 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); 56 scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
61 } 57 }
62 58
63 void events_OnNewPresence(ScenePresence presence) 59 private void events_OnNewPresence(ScenePresence presence)
64 { 60 {
65 for (int i = 0; i < this._threads.Count; i++) 61 for (int i = 0; i < _threads.Count; i++)
66 { 62 {
67 if (!this._threads[i].running) 63 if (!_threads[i].running)
68 { 64 {
69 this._threads[i].StartMethod("OnNewPresence"); 65 _threads[i].StartMethod("OnNewPresence");
70 bool run = true; 66 bool run = true;
71 while (run) 67 while (run)
72 { 68 {
73 run = this._threads[i].Excute(); 69 run = _threads[i].Excute();
74 } 70 }
75 } 71 }
76 } 72 }
77 } 73 }
78 74
79 void events_OnFrame() 75 private void events_OnFrame()
80 { 76 {
81 for (int i = 0; i < this._threads.Count; i++) 77 for (int i = 0; i < _threads.Count; i++)
82 { 78 {
83 if (!this._threads[i].running) 79 if (!_threads[i].running)
84 { 80 {
85 this._threads[i].StartMethod("OnFrame"); 81 _threads[i].StartMethod("OnFrame");
86 bool run = true; 82 bool run = true;
87 while (run) 83 while (run)
88 { 84 {
89 run = this._threads[i].Excute(); 85 run = _threads[i].Excute();
90 } 86 }
91 } 87 }
92 } 88 }
@@ -103,12 +99,12 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
103 CompileInfo comp = new CompileInfo(); 99 CompileInfo comp = new CompileInfo();
104 comp.script = script; 100 comp.script = script;
105 comp.scriptName = script; 101 comp.scriptName = script;
106 this.CompileScripts.Enqueue(comp); 102 CompileScripts.Enqueue(comp);
107 } 103 }
108 104
109 public void CompileScript() 105 public void CompileScript()
110 { 106 {
111 CompileInfo comp = this.CompileScripts.Dequeue(); 107 CompileInfo comp = CompileScripts.Dequeue();
112 string script = comp.script; 108 string script = comp.script;
113 string scriptName = comp.scriptName; 109 string scriptName = comp.scriptName;
114 try 110 try
@@ -121,13 +117,13 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
121 tw.Close(); 117 tw.Close();
122 118
123 //now compile 119 //now compile
124 System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); 120 ProcessStartInfo psi = new ProcessStartInfo("javac.exe", "*.java");
125 // psi.RedirectStandardOutput = true; 121 // psi.RedirectStandardOutput = true;
126 psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; 122 psi.WindowStyle = ProcessWindowStyle.Hidden;
127 psi.UseShellExecute = false; 123 psi.UseShellExecute = false;
128 124
129 System.Diagnostics.Process javacomp; 125 Process javacomp;
130 javacomp = System.Diagnostics.Process.Start(psi); 126 javacomp = Process.Start(psi);
131 javacomp.WaitForExit(); 127 javacomp.WaitForExit();
132 128
133 129
@@ -136,17 +132,17 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
136 class1.LoadClassFromFile(scriptName + ".class"); 132 class1.LoadClassFromFile(scriptName + ".class");
137 class1.PrintToConsole(); 133 class1.PrintToConsole();
138 //Console.WriteLine(); 134 //Console.WriteLine();
139 this._mainMemory.MethodArea.Classes.Add(class1); 135 _mainMemory.MethodArea.Classes.Add(class1);
140 class1.AddMethodsToMemory(this._mainMemory.MethodArea); 136 class1.AddMethodsToMemory(_mainMemory.MethodArea);
141 137
142 Thread newThread = new Thread(); 138 Thread newThread = new Thread();
143 this._threads.Add(newThread); 139 _threads.Add(newThread);
144 newThread.currentClass = class1; 140 newThread.currentClass = class1;
145 newThread.scriptInfo = scriptInfo; 141 newThread.scriptInfo = scriptInfo;
146 142
147 //now delete the created files 143 //now delete the created files
148 System.IO.File.Delete(scriptName + ".java"); 144 File.Delete(scriptName + ".java");
149 System.IO.File.Delete(scriptName + ".class"); 145 File.Delete(scriptName + ".class");
150 //this.OnFrame(); 146 //this.OnFrame();
151 } 147 }
152 catch (Exception e) 148 catch (Exception e)
@@ -164,8 +160,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
164 160
165 public CompileInfo() 161 public CompileInfo()
166 { 162 {
167
168 } 163 }
169 } 164 }
170 } 165 }
171} 166} \ No newline at end of file