From 3c46e5b170991e41e8c82e25bae65cf46152b924 Mon Sep 17 00:00:00 2001
From: Adam Frisby
Date: Thu, 5 Jul 2007 00:09:45 +0000
Subject: * Added Java support back into Sugilite (although it still needs a
calling host to be added).
---
.../Environment/OpenSim.Region.Environment.csproj | 128 ++++--
.../OpenSim.Region.Environment.dll.build | 26 +-
OpenSim/Region/Environment/Scenes/Scene.cs | 2 +-
.../Engines/CSharpEngine/CSharpScriptEngine.cs | 102 +++++
.../Scenes/scripting/Engines/CSharpScriptEngine.cs | 102 -----
.../Scenes/scripting/Engines/JScriptEngine.cs | 102 -----
.../Engines/JScriptEngine/JScriptEngine.cs | 102 +++++
.../scripting/Engines/JVMEngine/ClassInstance.cs | 45 ++
.../scripting/Engines/JVMEngine/ClassRecord.cs | 503 +++++++++++++++++++++
.../Scenes/scripting/Engines/JVMEngine/Heap.cs | 43 ++
.../scripting/Engines/JVMEngine/Interpreter.cs | 135 ++++++
.../Engines/JVMEngine/InterpreterLogic.cs | 427 +++++++++++++++++
.../Engines/JVMEngine/InterpreterMethods.cs | 96 ++++
.../Engines/JVMEngine/InterpreterReturn.cs | 40 ++
.../scripting/Engines/JVMEngine/MainMemory.cs | 45 ++
.../scripting/Engines/JVMEngine/MethodMemory.cs | 46 ++
.../Scenes/scripting/Engines/JVMEngine/Object.cs | 37 ++
.../scripting/Engines/JVMEngine/OpenSimJVM.cs | 176 +++++++
.../Scenes/scripting/Engines/JVMEngine/Stack.cs | 42 ++
.../scripting/Engines/JVMEngine/StackFrame.cs | 49 ++
.../Scenes/scripting/Engines/JVMEngine/Thread.cs | 120 +++++
.../Engines/JVMEngine/Types/ArrayReference.cs | 10 +
.../scripting/Engines/JVMEngine/Types/BaseType.cs | 10 +
.../Engines/JVMEngine/Types/ObjectReference.cs | 16 +
.../Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs | 10 +
.../Engines/JVMEngine/Types/PrimitiveTypes/Char.cs | 10 +
.../JVMEngine/Types/PrimitiveTypes/Float.cs | 16 +
.../Engines/JVMEngine/Types/PrimitiveTypes/Int.cs | 16 +
.../Region/Environment/Scenes/scripting/Script.cs | 2 +-
.../Environment/Scenes/scripting/ScriptAPI.cs | 25 +
.../Environment/Scenes/scripting/ScriptInfo.cs | 6 +-
.../Environment/Scenes/scripting/ScriptManager.cs | 2 +-
32 files changed, 2246 insertions(+), 245 deletions(-)
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
delete mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs
delete mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
create mode 100644 OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
(limited to 'OpenSim')
diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj
index f5724dd..365c7ff 100644
--- a/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj
+++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.csproj
@@ -1,4 +1,4 @@
-
+
Local
8.0.50727
@@ -6,8 +6,7 @@
{DCBA491C-0000-0000-0000-000000000000}
Debug
AnyCPU
-
-
+
OpenSim.Region.Environment
@@ -16,11 +15,9 @@
IE50
false
Library
-
-
+
OpenSim.Region.Environment
-
-
+
@@ -31,8 +28,7 @@
TRACE;DEBUG
-
-
+
True
4096
False
@@ -41,8 +37,7 @@
False
False
4
-
-
+
False
@@ -51,8 +46,7 @@
TRACE
-
-
+
False
4096
True
@@ -61,36 +55,34 @@
False
False
4
-
-
+
-
+
..\..\..\bin\Axiom.MathLib.dll
False
-
+
..\..\..\bin\Db4objects.Db4o.dll
False
-
+
..\..\..\bin\libsecondlife.dll
False
-
+
Microsoft.JScript.dll
False
-
+
System.dll
False
-
-
+
System.Xml.dll
False
-
+
..\..\..\bin\XMLRPC.dll
False
@@ -100,55 +92,55 @@
OpenSim.Framework
{8ACA2445-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Communications
{CB52B7E7-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Console
{A7CD0630-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.GenericConfig.Xml
{C74E4A30-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Framework.Servers
{2CC71860-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Region.Caches
{61FCCDB3-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Region.Capabilities
{39038E85-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Region.Physics.Manager
{F4FF31EB-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
OpenSim.Region.Terrain.BasicTerrain
{C9E0F891-0000-0000-0000-000000000000}
{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
- False
+ False
@@ -203,16 +195,82 @@
Code
+
+ Code
+
Code
Code
-
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
+ Code
+
+
Code
-
+
Code
@@ -223,4 +281,4 @@
-
\ No newline at end of file
+
diff --git a/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build
index d4b163e..52d9a26 100644
--- a/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build
+++ b/OpenSim/Region/Environment/OpenSim.Region.Environment.dll.build
@@ -28,10 +28,32 @@
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 0797566..1f370c4 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -39,7 +39,7 @@ using OpenSim.Framework.Servers;
using OpenSim.Framework.Types;
using OpenSim.Physics.Manager;
using OpenSim.Region.Caches;
-using OpenSim.Region.Enviorment.Scripting;
+using OpenSim.Region.Environment.Scripting;
using OpenSim.Region.Terrain;
using Caps=OpenSim.Region.Capabilities.Caps;
using Timer=System.Timers.Timer;
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
new file mode 100644
index 0000000..9cb881a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpEngine/CSharpScriptEngine.cs
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using Microsoft.CSharp;
+using OpenSim.Framework.Console;
+
+namespace OpenSim.Region.Environment.Scripting
+{
+ public class CSharpScriptEngine : IScriptCompiler
+ {
+ public string FileExt()
+ {
+ return ".cs";
+ }
+
+ private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename)
+ {
+ CompilerParameters compilerParams = new CompilerParameters();
+ CompilerResults compilerResults;
+ compilerParams.GenerateExecutable = false;
+ compilerParams.GenerateInMemory = true;
+ compilerParams.IncludeDebugInformation = false;
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
+ compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
+ compilerParams.ReferencedAssemblies.Add("System.dll");
+
+ compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
+
+ if (compilerResults.Errors.Count > 0)
+ {
+ MainLog.Instance.Error("Compile errors");
+ foreach (CompilerError error in compilerResults.Errors)
+ {
+ MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
+ }
+ }
+ else
+ {
+ Dictionary scripts = new Dictionary();
+
+ foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
+ {
+ Type testInterface = pluginType.GetInterface("IScript", true);
+
+ if (testInterface != null)
+ {
+ IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
+
+ string scriptName = "C#/" + script.getName();
+ Console.WriteLine("Script: " + scriptName + " loaded.");
+
+ if (!scripts.ContainsKey(scriptName))
+ {
+ scripts.Add(scriptName, script);
+ }
+ else
+ {
+ scripts[scriptName] = script;
+ }
+ }
+ }
+ return scripts;
+ }
+ return null;
+ }
+
+ public Dictionary compile(string filename)
+ {
+ CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
+ return LoadDotNetScript(csharpProvider, filename);
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs
deleted file mode 100644
index 7928088..0000000
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/CSharpScriptEngine.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using Microsoft.CSharp;
-using OpenSim.Framework.Console;
-
-namespace OpenSim.Region.Enviorment.Scripting
-{
- public class CSharpScriptEngine : IScriptCompiler
- {
- public string FileExt()
- {
- return ".cs";
- }
-
- private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename)
- {
- CompilerParameters compilerParams = new CompilerParameters();
- CompilerResults compilerResults;
- compilerParams.GenerateExecutable = false;
- compilerParams.GenerateInMemory = true;
- compilerParams.IncludeDebugInformation = false;
- compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
- compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
- compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
- compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
- compilerParams.ReferencedAssemblies.Add("System.dll");
-
- compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
-
- if (compilerResults.Errors.Count > 0)
- {
- MainLog.Instance.Error("Compile errors");
- foreach (CompilerError error in compilerResults.Errors)
- {
- MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
- }
- }
- else
- {
- Dictionary scripts = new Dictionary();
-
- foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
- {
- Type testInterface = pluginType.GetInterface("IScript", true);
-
- if (testInterface != null)
- {
- IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
-
- string scriptName = "C#/" + script.getName();
- Console.WriteLine("Script: " + scriptName + " loaded.");
-
- if (!scripts.ContainsKey(scriptName))
- {
- scripts.Add(scriptName, script);
- }
- else
- {
- scripts[scriptName] = script;
- }
- }
- }
- return scripts;
- }
- return null;
- }
-
- public Dictionary compile(string filename)
- {
- CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
- return LoadDotNetScript(csharpProvider, filename);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs
deleted file mode 100644
index d9d6f7e..0000000
--- a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine.cs
+++ /dev/null
@@ -1,102 +0,0 @@
-/*
-* Copyright (c) Contributors, http://www.openmetaverse.org/
-* See CONTRIBUTORS.TXT for a full list of copyright holders.
-*
-* Redistribution and use in source and binary forms, with or without
-* modification, are permitted provided that the following conditions are met:
-* * Redistributions of source code must retain the above copyright
-* notice, this list of conditions and the following disclaimer.
-* * Redistributions in binary form must reproduce the above copyright
-* notice, this list of conditions and the following disclaimer in the
-* documentation and/or other materials provided with the distribution.
-* * Neither the name of the OpenSim Project nor the
-* names of its contributors may be used to endorse or promote products
-* derived from this software without specific prior written permission.
-*
-* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
-* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
-* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
-* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
-* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
-* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*
-*/
-using System;
-using System.CodeDom.Compiler;
-using System.Collections.Generic;
-using Microsoft.JScript;
-using OpenSim.Framework.Console;
-
-namespace OpenSim.Region.Enviorment.Scripting
-{
- public class JScriptEngine : IScriptCompiler
- {
- public string FileExt()
- {
- return ".js";
- }
-
- private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename)
- {
- CompilerParameters compilerParams = new CompilerParameters();
- CompilerResults compilerResults;
- compilerParams.GenerateExecutable = false;
- compilerParams.GenerateInMemory = true;
- compilerParams.IncludeDebugInformation = false;
- compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
- compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
- compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
- compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
- compilerParams.ReferencedAssemblies.Add("System.dll");
-
- compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
-
- if (compilerResults.Errors.Count > 0)
- {
- MainLog.Instance.Error("Compile errors");
- foreach (CompilerError error in compilerResults.Errors)
- {
- MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
- }
- }
- else
- {
- Dictionary scripts = new Dictionary();
-
- foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
- {
- Type testInterface = pluginType.GetInterface("IScript", true);
-
- if (testInterface != null)
- {
- IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
-
- string scriptName = "JS.NET/" + script.getName();
- Console.WriteLine("Script: " + scriptName + " loaded.");
-
- if (!scripts.ContainsKey(scriptName))
- {
- scripts.Add(scriptName, script);
- }
- else
- {
- scripts[scriptName] = script;
- }
- }
- }
- return scripts;
- }
- return null;
- }
-
- public Dictionary compile(string filename)
- {
- JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
- return LoadDotNetScript(jscriptProvider, filename);
- }
- }
-}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
new file mode 100644
index 0000000..be1fe56
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JScriptEngine/JScriptEngine.cs
@@ -0,0 +1,102 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.CodeDom.Compiler;
+using System.Collections.Generic;
+using Microsoft.JScript;
+using OpenSim.Framework.Console;
+
+namespace OpenSim.Region.Environment.Scripting
+{
+ public class JScriptEngine : IScriptCompiler
+ {
+ public string FileExt()
+ {
+ return ".js";
+ }
+
+ private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename)
+ {
+ CompilerParameters compilerParams = new CompilerParameters();
+ CompilerResults compilerResults;
+ compilerParams.GenerateExecutable = false;
+ compilerParams.GenerateInMemory = true;
+ compilerParams.IncludeDebugInformation = false;
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Region.dll");
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Enviroment.dll");
+ compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
+ compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
+ compilerParams.ReferencedAssemblies.Add("System.dll");
+
+ compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
+
+ if (compilerResults.Errors.Count > 0)
+ {
+ MainLog.Instance.Error("Compile errors");
+ foreach (CompilerError error in compilerResults.Errors)
+ {
+ MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
+ }
+ }
+ else
+ {
+ Dictionary scripts = new Dictionary();
+
+ foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
+ {
+ Type testInterface = pluginType.GetInterface("IScript", true);
+
+ if (testInterface != null)
+ {
+ IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
+
+ string scriptName = "JS.NET/" + script.getName();
+ Console.WriteLine("Script: " + scriptName + " loaded.");
+
+ if (!scripts.ContainsKey(scriptName))
+ {
+ scripts.Add(scriptName, script);
+ }
+ else
+ {
+ scripts[scriptName] = script;
+ }
+ }
+ }
+ return scripts;
+ }
+ return null;
+ }
+
+ public Dictionary compile(string filename)
+ {
+ JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
+ return LoadDotNetScript(jscriptProvider, filename);
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs
new file mode 100644
index 0000000..1d93197
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassInstance.cs
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class ClassInstance : Object
+ {
+ public int size;
+ public Dictionary Fields = new Dictionary();
+
+ public ClassInstance()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs
new file mode 100644
index 0000000..f4ab1a2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/ClassRecord.cs
@@ -0,0 +1,503 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.IO;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class ClassRecord
+ {
+ private ushort _majorVersion;
+ private ushort _minorVersion;
+ private ushort _constantPoolCount;
+ private ushort _accessFlags;
+ private ushort _thisClass;
+ private ushort _supperClass;
+ private ushort _interfaceCount;
+ private ushort _fieldCount;
+ private ushort _methodCount;
+ //private ushort _attributeCount;
+ //private string _name;
+ public Dictionary StaticFields = new Dictionary();
+ public PoolClass mClass;
+
+ public List _constantsPool = new List();
+ private List _methodsList = new List();
+ private List _fieldList = new List();
+
+ public ClassRecord()
+ {
+
+ }
+
+ public ClassInstance CreateNewInstance()
+ {
+ return new ClassInstance();
+ }
+
+ public void LoadClassFromFile(string fileName)
+ {
+ Console.WriteLine("loading script " + fileName);
+ FileStream fs = File.OpenRead(fileName);
+ this.LoadClassFromBytes(ReadFully(fs));
+ fs.Close();
+ }
+
+ public void LoadClassFromBytes(byte[] data)
+ {
+ int i = 0;
+ i += 4;
+ _minorVersion = (ushort)((data[i++] << 8) + data[i++] );
+ _majorVersion = (ushort)((data[i++] << 8) + data[i++] );
+ _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] );
+ // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool");
+ for (int count = 0; count < _constantPoolCount -1 ; count++)
+ {
+ //read in the constant pool
+ byte pooltype = data[i++];
+ //Console.WriteLine("#" +count +": new constant type = " +pooltype);
+ //Console.WriteLine("start position is: " + i);
+ switch (pooltype)
+ {
+ case 1: //Utf8
+ ushort uLength = (ushort)((data[i++] << 8) + data[i++] );
+
+ // Console.WriteLine("new utf8 type, length is " + uLength);
+ PoolUtf8 utf8 = new PoolUtf8();
+ utf8.readValue(data, ref i, uLength);
+ this._constantsPool.Add(utf8);
+ break;
+ case 3: //Int
+ break;
+ case 7: //Class
+ PoolClass pClass = new PoolClass(this);
+ pClass.readValue(data, ref i);
+ this._constantsPool.Add(pClass);
+ break;
+ case 10: //Method
+ PoolMethodRef pMeth = new PoolMethodRef(this);
+ pMeth.readValue(data, ref i);
+ this._constantsPool.Add(pMeth);
+ break;
+ case 12: //NamedType
+ PoolNamedType pNamed = new PoolNamedType(this);
+ pNamed.readValue(data, ref i);
+ this._constantsPool.Add(pNamed);
+ break;
+ }
+ }
+
+ _accessFlags = (ushort)((data[i++] << 8) + data[i++] );
+ _thisClass = (ushort)((data[i++] << 8) + data[i++] );
+ _supperClass = (ushort)((data[i++] << 8) + data[i++] );
+
+ if (this._constantsPool[this._thisClass - 1] is PoolClass)
+ {
+ this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]);
+ }
+
+ _interfaceCount = (ushort)((data[i++] << 8) + data[i++]);
+ //should now read in the info for each interface
+ _fieldCount = (ushort)((data[i++] << 8) + data[i++]);
+ //should now read in the info for each field
+ _methodCount = (ushort)((data[i++] << 8) + data[i++]);
+ for (int count = 0; count < _methodCount; count++)
+ {
+ MethodInfo methInf = new MethodInfo(this);
+ methInf.ReadData(data, ref i);
+ this._methodsList.Add(methInf);
+ }
+ }
+
+ public void AddMethodsToMemory(MethodMemory memory)
+ {
+ for (int count = 0; count < _methodCount; count++)
+ {
+ this._methodsList[count].AddMethodCode(memory);
+ }
+ }
+
+ public bool StartMethod(Thread thread, string methodName)
+ {
+ for (int count = 0; count < _methodCount; count++)
+ {
+ if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8)
+ {
+ if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName)
+ {
+ //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value);
+ thread.SetPC(this._methodsList[count].CodePointer);
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ public void PrintToConsole()
+ {
+ Console.WriteLine("Class File:");
+ Console.WriteLine("Major version: " + _majorVersion);
+ Console.WriteLine("Minor version: " + _minorVersion);
+ Console.WriteLine("Pool size: " + _constantPoolCount);
+
+ for (int i = 0; i < _constantsPool.Count; i++)
+ {
+ this._constantsPool[i].Print();
+ }
+
+ Console.WriteLine("Access flags: " + _accessFlags);
+ Console.WriteLine("This class: " + _thisClass );
+ Console.WriteLine("Super class: " + _supperClass);
+
+ for (int count = 0; count < _methodCount; count++)
+ {
+ Console.WriteLine();
+ this._methodsList[count].Print();
+ }
+
+ Console.WriteLine("class name is " + this.mClass.Name.Value);
+ }
+
+ public static byte[] ReadFully(Stream stream)
+ {
+ byte[] buffer = new byte[1024];
+ using (MemoryStream ms = new MemoryStream())
+ {
+ while (true)
+ {
+ int read = stream.Read(buffer, 0, buffer.Length);
+ if (read <= 0)
+ return ms.ToArray();
+ ms.Write(buffer, 0, read);
+ }
+ }
+ }
+
+ #region nested classes
+ public class PoolItem
+ {
+ public virtual void Print()
+ {
+
+ }
+ }
+
+ public class PoolUtf8 : PoolItem
+ {
+ public string Value = "";
+
+ public void readValue(byte[] data,ref int pointer , int length)
+ {
+ for (int i = 0; i < length; i++)
+ {
+ int a =(int) data[pointer++];
+ if ((a & 0x80) == 0)
+ {
+ Value = Value + (char)a;
+ }
+ else if ((a & 0x20) == 0)
+ {
+ int b = (int) data[pointer++];
+ Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f));
+ }
+ else
+ {
+ int b = (int)data[pointer++];
+ int c = (int)data[pointer++];
+ Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f));
+ }
+ }
+ }
+
+ public override void Print()
+ {
+ Console.WriteLine("Utf8 type: " + Value);
+ }
+ }
+
+ private class PoolInt : PoolItem
+ {
+
+ }
+
+ public class PoolClass : PoolItem
+ {
+ //public string name = "";
+ public ushort namePointer = 0;
+ private ClassRecord parent;
+ public PoolUtf8 Name;
+
+ public PoolClass(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void readValue(byte[] data, ref int pointer)
+ {
+ namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
+ }
+
+ public override void Print()
+ {
+ this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]);
+ Console.Write("Class type: " + namePointer);
+ Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value);
+
+ }
+ }
+
+ public class PoolMethodRef : PoolItem
+ {
+ public ushort classPointer = 0;
+ public ushort nameTypePointer = 0;
+ public PoolNamedType mNameType;
+ public PoolClass mClass;
+ private ClassRecord parent;
+
+ public PoolMethodRef(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void readValue(byte[] data, ref int pointer)
+ {
+ classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ }
+
+ public override void Print()
+ {
+ this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]);
+ this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]);
+ Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer);
+ }
+ }
+
+ public class PoolNamedType : PoolItem
+ {
+ public ushort namePointer = 0;
+ public ushort typePointer = 0;
+ private ClassRecord parent;
+ public PoolUtf8 Name;
+ public PoolUtf8 Type;
+
+ public PoolNamedType(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void readValue(byte[] data, ref int pointer)
+ {
+ namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
+ typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] );
+ }
+
+ public override void Print()
+ {
+ Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]);
+ Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]);
+ Console.Write("Named type: " + namePointer + " , " + typePointer );
+ Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value);
+ }
+ }
+
+ //***********************
+ public class MethodInfo
+ {
+ public ushort AccessFlags = 0;
+ public ushort NameIndex = 0;
+ public string Name = "";
+ public ushort DescriptorIndex = 0;
+ public ushort AttributeCount = 0;
+ public List Attributes = new List();
+ private ClassRecord parent;
+ public int CodePointer = 0;
+
+ public MethodInfo(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void AddMethodCode(MethodMemory memory)
+ {
+ Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length);
+ memory.Methodcount++;
+ this.CodePointer = memory.NextMethodPC;
+ memory.NextMethodPC += this.Attributes[0].Code.Length;
+ }
+
+ public void ReadData(byte[] data, ref int pointer)
+ {
+ AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ for(int i =0; i< AttributeCount; i++)
+ {
+ MethodAttribute attri = new MethodAttribute(this.parent);
+ attri.ReadData(data, ref pointer);
+ this.Attributes.Add(attri);
+ }
+ }
+
+ public void Print()
+ {
+ Console.WriteLine("Method Info Struct: ");
+ Console.WriteLine("AccessFlags: " + AccessFlags);
+ Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
+ Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value);
+ Console.WriteLine("Attribute Count:" + AttributeCount);
+ for (int i = 0; i < AttributeCount; i++)
+ {
+ this.Attributes[i].Print();
+ }
+ }
+
+ public class MethodAttribute
+ {
+ public ushort NameIndex = 0;
+ public string Name = "";
+ public Int32 Length = 0;
+ //for now only support code attribute
+ public ushort MaxStack = 0;
+ public ushort MaxLocals = 0;
+ public Int32 CodeLength = 0;
+ public byte[] Code;
+ public ushort ExceptionTableLength = 0;
+ public ushort SubAttributeCount = 0;
+ public List SubAttributes = new List();
+ private ClassRecord parent;
+
+ public MethodAttribute(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void ReadData(byte[] data, ref int pointer)
+ {
+ NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
+ MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
+ Code = new byte[CodeLength];
+ for (int i = 0; i < CodeLength; i++)
+ {
+ Code[i] = data[pointer++];
+ }
+ ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ for (int i = 0; i < SubAttributeCount; i++)
+ {
+ SubAttribute subAttri = new SubAttribute(this.parent);
+ subAttri.ReadData(data, ref pointer);
+ this.SubAttributes.Add(subAttri);
+ }
+ }
+
+ public void Print()
+ {
+ Console.WriteLine("Method Attribute: ");
+ Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value);
+ Console.WriteLine("Length: " + Length);
+ Console.WriteLine("MaxStack: " + MaxStack);
+ Console.WriteLine("MaxLocals: " + MaxLocals);
+ Console.WriteLine("CodeLength: " + CodeLength);
+ for (int i = 0; i < Code.Length; i++)
+ {
+ Console.WriteLine("OpCode #" + i + " is: " + Code[i]);
+ }
+ Console.WriteLine("SubAttributes: " + SubAttributeCount);
+ for (int i = 0; i < SubAttributeCount; i++)
+ {
+ this.SubAttributes[i].Print();
+ }
+ }
+
+ public class SubAttribute
+ {
+ public ushort NameIndex = 0;
+ public string Name = "";
+ public Int32 Length = 0;
+ public byte[] Data;
+ private ClassRecord parent;
+
+ public SubAttribute(ClassRecord paren)
+ {
+ parent = paren;
+ }
+
+ public void ReadData(byte[] data, ref int pointer)
+ {
+ NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]);
+ Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]);
+ Data = new byte[Length];
+ for (int i = 0; i < Length; i++)
+ {
+ Data[i] = data[pointer++];
+ }
+ }
+
+ public void Print()
+ {
+ Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value);
+ }
+
+ }
+ }
+
+ }
+ private class InterfaceInfo
+ {
+ public void ReadData(byte[] data, ref int i)
+ {
+
+ }
+ }
+ private class FieldInfo
+ {
+ public void ReadData(byte[] data, ref int i)
+ {
+
+ }
+ }
+ private class AttributeInfo
+ {
+ public void ReadData(byte[] data, ref int i)
+ {
+
+ }
+ }
+ #endregion
+
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs
new file mode 100644
index 0000000..f213c36
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Heap.cs
@@ -0,0 +1,43 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class Heap
+ {
+ public List ClassObjects = new List();
+
+ public Heap()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs
new file mode 100644
index 0000000..c5995b2
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Interpreter.cs
@@ -0,0 +1,135 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ partial class Thread
+ {
+ private partial class Interpreter
+ {
+ private Thread _mThread;
+
+ public Interpreter(Thread parentThread)
+ {
+ _mThread = parentThread;
+ }
+
+ public bool Excute()
+ {
+ bool run = true;
+ byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++];
+ // Console.WriteLine("opCode is: " + currentOpCode);
+ bool handled = false;
+
+ handled = this.IsLogicOpCode(currentOpCode);
+ if (!handled)
+ {
+ handled = this.IsMethodOpCode(currentOpCode);
+ }
+ if (!handled)
+ {
+ if (currentOpCode == 172)
+ {
+ if (this._mThread.stack.StackFrames.Count > 1)
+ {
+ Console.WriteLine("returning int from function");
+ int retPC1 = this._mThread.currentFrame.ReturnPC;
+ BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
+ this._mThread.stack.StackFrames.Pop();
+ this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
+ this._mThread.PC = retPC1;
+ if (bas1 is Int)
+ {
+ this._mThread.currentFrame.OpStack.Push((Int)bas1);
+ }
+ }
+ else
+ {
+ // Console.WriteLine("No parent function so ending program");
+ this._mThread.stack.StackFrames.Pop();
+ run = false;
+ }
+ handled = true;
+ }
+ if (currentOpCode == 174)
+ {
+ if (this._mThread.stack.StackFrames.Count > 1)
+ {
+ Console.WriteLine("returning float from function");
+ int retPC1 = this._mThread.currentFrame.ReturnPC;
+ BaseType bas1 = this._mThread.currentFrame.OpStack.Pop();
+ this._mThread.stack.StackFrames.Pop();
+ this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
+ this._mThread.PC = retPC1;
+ if (bas1 is Float)
+ {
+ this._mThread.currentFrame.OpStack.Push((Float)bas1);
+ }
+ }
+ else
+ {
+ // Console.WriteLine("No parent function so ending program");
+ this._mThread.stack.StackFrames.Pop();
+ run = false;
+ }
+ handled = true;
+ }
+ if (currentOpCode == 177)
+ {
+ if (this._mThread.stack.StackFrames.Count > 1)
+ {
+ Console.WriteLine("returning from function");
+ int retPC = this._mThread.currentFrame.ReturnPC;
+ this._mThread.stack.StackFrames.Pop();
+ this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek();
+ this._mThread.PC = retPC;
+ }
+ else
+ {
+ // Console.WriteLine("No parent function so ending program");
+ this._mThread.stack.StackFrames.Pop();
+ run = false;
+ }
+ handled = true;
+ }
+ }
+ if (!handled)
+ {
+ Console.WriteLine("opcode " + currentOpCode + " not been handled ");
+ }
+ return run;
+
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs
new file mode 100644
index 0000000..2a11afd
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterLogic.cs
@@ -0,0 +1,427 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ partial class Thread
+ {
+ private partial class Interpreter
+ {
+ private bool IsLogicOpCode(byte opcode)
+ {
+ bool result = false;
+ switch (opcode)
+ {
+ case 2:
+ Int m_int= new Int();
+ m_int.mValue = -1;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 3:
+ m_int= new Int();
+ m_int.mValue = 0;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 4:
+ m_int = new Int();
+ m_int.mValue = 1;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 5:
+ m_int = new Int();
+ m_int.mValue = 2;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 6:
+ m_int = new Int();
+ m_int.mValue = 3;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ break;
+ case 7:
+ m_int = new Int();
+ m_int.mValue = 4;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 8:
+ m_int = new Int();
+ m_int.mValue = 5;
+ this._mThread.currentFrame.OpStack.Push(m_int);
+ result = true;
+ break;
+ case 11:
+ Float m_float = new Float();
+ m_float.mValue = 0.0f;
+ this._mThread.currentFrame.OpStack.Push(m_float);
+ result = true;
+ break;
+ case 12:
+ m_float = new Float();
+ m_float.mValue = 1.0f;
+ this._mThread.currentFrame.OpStack.Push(m_float);
+ result = true;
+ break;
+ case 13:
+ m_float = new Float();
+ m_float.mValue = 2.0f;
+ this._mThread.currentFrame.OpStack.Push(m_float);
+ result = true;
+ break;
+ case 16:
+ int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC];
+ Int pushInt = new Int();
+ pushInt.mValue = pushvalue;
+ this._mThread.currentFrame.OpStack.Push(pushInt);
+ this._mThread.PC++;
+ result = true;
+ break;
+ case 17:
+ short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
+ Int pushInt2 = new Int();
+ pushInt2.mValue = pushvalue2;
+ this._mThread.currentFrame.OpStack.Push(pushInt2);
+ this._mThread.PC += 2;
+ result = true;
+ break;
+ case 23:
+ short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]));
+ Float fload = new Float();
+ if (this._mThread.currentFrame.LocalVariables[findex1] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[findex1] is Float)
+ {
+ fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue;
+ this._mThread.currentFrame.OpStack.Push(fload);
+ }
+ }
+ this._mThread.PC++;
+ result = true;
+ break;
+ case 26:
+ if (this._mThread.currentFrame.LocalVariables[0] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[0] is Int)
+ {
+ Int newInt = new Int();
+ newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newInt);
+ }
+ }
+ result = true;
+ break;
+ case 27:
+ if (this._mThread.currentFrame.LocalVariables[1] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[1] is Int)
+ {
+ Int newInt = new Int();
+ newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newInt);
+ }
+ }
+ result = true;
+ break;
+ case 34:
+ if (this._mThread.currentFrame.LocalVariables[0] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[0] is Float)
+ {
+ Float newfloat = new Float();
+ newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newfloat);
+ }
+ }
+ result = true;
+ break;
+ case 35:
+ if (this._mThread.currentFrame.LocalVariables[1] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[1] is Float)
+ {
+ Float newfloat = new Float();
+ newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newfloat);
+ }
+ }
+ result = true;
+ break;
+ case 36:
+ if (this._mThread.currentFrame.LocalVariables[2] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[2] is Float)
+ {
+ Float newfloat = new Float();
+ newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newfloat);
+ }
+ }
+ result = true;
+ break;
+ case 37:
+ if (this._mThread.currentFrame.LocalVariables[3] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[3] is Float)
+ {
+ Float newfloat = new Float();
+ newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue;
+ this._mThread.currentFrame.OpStack.Push(newfloat);
+ }
+ }
+ result = true;
+ break;
+ case 56:
+ short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] ));
+ BaseType fstor = this._mThread.currentFrame.OpStack.Pop();
+ if (fstor is Float)
+ {
+ this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor;
+ }
+ this._mThread.PC++;
+ result = true;
+ break;
+ case 59:
+ BaseType baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Int)
+ {
+ this._mThread.currentFrame.LocalVariables[0] = (Int)baset;
+ }
+ result = true;
+ break;
+ case 60:
+ baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Int)
+ {
+ this._mThread.currentFrame.LocalVariables[1] = (Int)baset;
+ }
+ result = true;
+ break;
+ case 67:
+ baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Float)
+ {
+ this._mThread.currentFrame.LocalVariables[0] = (Float)baset;
+ }
+ result = true;
+ break;
+ case 68:
+ baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Float)
+ {
+ this._mThread.currentFrame.LocalVariables[1] = (Float)baset;
+ }
+ result = true;
+ break;
+ case 69:
+ baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Float)
+ {
+ this._mThread.currentFrame.LocalVariables[2] = (Float)baset;
+ }
+ result = true;
+ break;
+ case 70:
+ baset = this._mThread.currentFrame.OpStack.Pop();
+ if (baset is Float)
+ {
+ this._mThread.currentFrame.LocalVariables[3] = (Float)baset;
+ }
+ result = true;
+ break;
+ case 87:
+ this._mThread.currentFrame.OpStack.Pop();
+ result = true;
+ break;
+ case 98:
+ BaseType bf2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType bf1 = this._mThread.currentFrame.OpStack.Pop();
+ if (bf1 is Float && bf2 is Float)
+ {
+ Float nflt = new Float();
+ nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue;
+ this._mThread.currentFrame.OpStack.Push(nflt);
+ }
+ result = true;
+ break;
+ case 102:
+ BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop();
+ if (bsf1 is Float && bsf2 is Float)
+ {
+ Float resf = new Float();
+ resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue;
+ this._mThread.currentFrame.OpStack.Push(resf);
+ }
+ result = true;
+ break;
+ case 104: //check the order of the two values off the stack is correct
+ BaseType bs2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType bs1 = this._mThread.currentFrame.OpStack.Pop();
+ if (bs1 is Int && bs2 is Int)
+ {
+ Int nInt = new Int();
+ nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue;
+ this._mThread.currentFrame.OpStack.Push(nInt);
+ }
+ result = true;
+ break;
+ case 132:
+ if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null)
+ {
+ if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int)
+ {
+ ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1];
+ }
+ }
+ this._mThread.PC += 2;
+ result = true;
+ break;
+ case 139:
+ BaseType conv1 = this._mThread.currentFrame.OpStack.Pop();
+ if (conv1 is Float)
+ {
+ Int newconv = new Int();
+ newconv.mValue = (int)((Float)conv1).mValue;
+ this._mThread.currentFrame.OpStack.Push(newconv);
+ }
+ result = true;
+ break;
+ case 149:
+ BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop();
+ if (flcom1 is Float && flcom2 is Float)
+ {
+ Int compres = new Int();
+ if (((Float)flcom1).mValue < ((Float)flcom2).mValue)
+ {
+ compres.mValue = -1;
+ }
+ else if (((Float)flcom1).mValue > ((Float)flcom2).mValue)
+ {
+ compres.mValue = 1;
+ }
+ else
+ {
+ compres.mValue = 0;
+ }
+ this._mThread.currentFrame.OpStack.Push(compres);
+ }
+ result = true;
+ break;
+ case 158:
+ short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
+ BaseType comp1 = this._mThread.currentFrame.OpStack.Pop();
+ if (comp1 is Int)
+ {
+ if (((Int)comp1).mValue <= 0)
+ {
+ this._mThread.PC += -1 + compareoffset1;
+ }
+ else
+ {
+ this._mThread.PC += 2;
+ }
+ }
+ else
+ {
+ this._mThread.PC += 2;
+ }
+ result = true;
+ break;
+ case 162:
+ short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
+ BaseType bc2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType bc1 = this._mThread.currentFrame.OpStack.Pop();
+ if (bc1 is Int && bc2 is Int)
+ {
+ //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue);
+ if (((Int)bc1).mValue >= ((Int)bc2).mValue)
+ {
+ // Console.WriteLine("branch compare true , offset is " +compareoffset);
+ // Console.WriteLine("current PC is " + this._mThread.PC);
+ this._mThread.PC += -1 + compareoffset;
+ //Console.WriteLine("new PC is " + this._mThread.PC);
+ }
+ else
+ {
+ //Console.WriteLine("branch compare false");
+ this._mThread.PC += 2;
+ }
+ }
+ else
+ {
+ this._mThread.PC += 2;
+ }
+ result = true;
+ break;
+ case 164:
+ short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]);
+ BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop();
+ BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop();
+ if (bcl1 is Int && bcl2 is Int)
+ {
+ //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue);
+ if (((Int)bcl1).mValue <= ((Int)bcl2).mValue)
+ {
+ // Console.WriteLine("branch compare true , offset is " + compareloffset);
+ // Console.WriteLine("current PC is " + this._mThread.PC);
+ this._mThread.PC += -1 + compareloffset;
+ // Console.WriteLine("new PC is " + this._mThread.PC);
+ }
+ else
+ {
+ //Console.WriteLine("branch compare false");
+ this._mThread.PC += 2;
+ }
+ }
+ else
+ {
+ this._mThread.PC += 2;
+ }
+ result = true;
+ break;
+ case 167:
+ short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
+ this._mThread.PC += -1 + offset;
+ result = true;
+ break;
+ }
+
+ return result;
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs
new file mode 100644
index 0000000..4d60559
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterMethods.cs
@@ -0,0 +1,96 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework;
+using OpenSim.Framework.Types;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ partial class Thread
+ {
+ private partial class Interpreter
+ {
+ private bool IsMethodOpCode(byte opcode)
+ {
+ bool result = false;
+ switch (opcode)
+ {
+ case 184:
+ short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]);
+ if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
+ {
+ string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value;
+ string typeparam = "";
+ string typereturn = "";
+ int firstbrak = 0;
+ int secondbrak = 0;
+ firstbrak = typ.LastIndexOf('(');
+ secondbrak = typ.LastIndexOf(')');
+ typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
+ typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
+ if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value)
+ {
+ //calling a method in this class
+ if (typeparam.Length == 0)
+ {
+ this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2));
+ }
+ else
+ {
+ this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2));
+ }
+ }
+ else
+ {
+ //calling a method of a different class
+
+ // OpenSimAPI Class
+ if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
+ {
+ this._mThread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, null);
+ }
+ }
+ }
+ else
+ {
+ this._mThread.PC += 2;
+ }
+ result = true;
+ break;
+ }
+
+ return result;
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs
new file mode 100644
index 0000000..cbedb71
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/InterpreterReturn.cs
@@ -0,0 +1,40 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ partial class Thread
+ {
+ private partial class Interpreter
+ {
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs
new file mode 100644
index 0000000..97d9fb6
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MainMemory.cs
@@ -0,0 +1,45 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class MainMemory
+ {
+ public Heap HeapArea;
+ public MethodMemory MethodArea;
+
+ public MainMemory()
+ {
+ MethodArea = new MethodMemory();
+ HeapArea = new Heap();
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs
new file mode 100644
index 0000000..7e938b4
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/MethodMemory.cs
@@ -0,0 +1,46 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class MethodMemory
+ {
+ public byte[] MethodBuffer;
+ public List Classes = new List();
+ public int NextMethodPC = 0;
+ public int Methodcount = 0;
+
+ public MethodMemory()
+ {
+ MethodBuffer = new byte[20000];
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs
new file mode 100644
index 0000000..2c3bedd
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Object.cs
@@ -0,0 +1,37 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class Object
+ {
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
new file mode 100644
index 0000000..7ed734b
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/OpenSimJVM.cs
@@ -0,0 +1,176 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using System.IO;
+using System.Threading;
+using OpenSim.Framework;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Framework.Utilities;
+using OpenSim.Region.Environment.Scripting;
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class OpenSimJVM : IScript
+ {
+ private List _threads = new List();
+ private BlockingQueue CompileScripts = new BlockingQueue();
+ private MainMemory _mainMemory;
+ private System.Threading.Thread compileThread;
+
+ ScriptInfo scriptInfo;
+
+ public OpenSimJVM()
+ {
+
+ }
+
+ public void Initialise(ScriptInfo info)
+ {
+ scriptInfo = info;
+ }
+
+ public string getName()
+ {
+ return "JVM Scripting Engine";
+ }
+
+ public bool Init(Scene world)
+ {
+ Console.WriteLine("Creating OpenSim JVM scripting engine");
+ _mainMemory = new MainMemory();
+ Thread.GlobalMemory = this._mainMemory;
+ Thread.World = world;
+ compileThread = new System.Threading.Thread(new ThreadStart(CompileScript));
+ compileThread.IsBackground = true;
+ compileThread.Start();
+ return true;
+ }
+
+ public string GetName()
+ {
+ return "OpenSimJVM";
+ }
+
+ public void LoadScript(string script, string scriptName, uint entityID)
+ {
+ Console.WriteLine("OpenSimJVM - loading new script: " + scriptName);
+ CompileInfo comp = new CompileInfo();
+ comp.entityId = entityID;
+ comp.script = script;
+ comp.scriptName = scriptName;
+ this.CompileScripts.Enqueue(comp);
+ }
+
+ public void CompileScript()
+ {
+ while (true)
+ {
+ CompileInfo comp = this.CompileScripts.Dequeue();
+ string script = comp.script;
+ string scriptName = comp.scriptName;
+ uint entityID = comp.entityId;
+ try
+ {
+ //need to compile the script into a java class file
+
+ //first save it to a java source file
+ TextWriter tw = new StreamWriter(scriptName + ".java");
+ tw.WriteLine(script);
+ tw.Close();
+
+ //now compile
+ System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
+ // psi.RedirectStandardOutput = true;
+ psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
+ psi.UseShellExecute = false;
+
+ System.Diagnostics.Process javacomp;
+ javacomp = System.Diagnostics.Process.Start(psi);
+ javacomp.WaitForExit();
+
+
+ //now load in class file
+ ClassRecord class1 = new ClassRecord();
+ class1.LoadClassFromFile(scriptName + ".class");
+ class1.PrintToConsole();
+ //Console.WriteLine();
+ this._mainMemory.MethodArea.Classes.Add(class1);
+ class1.AddMethodsToMemory(this._mainMemory.MethodArea);
+
+ Thread newThread = new Thread();
+ this._threads.Add(newThread);
+ newThread.EntityId = entityID;
+ newThread.currentClass = class1;
+ newThread.scriptInfo = scriptInfo;
+
+ //now delete the created files
+ System.IO.File.Delete(scriptName + ".java");
+ System.IO.File.Delete(scriptName + ".class");
+ //this.OnFrame();
+ }
+ catch (Exception e)
+ {
+ Console.WriteLine("exception");
+ Console.WriteLine(e.StackTrace);
+ Console.WriteLine(e.Message);
+ }
+ }
+ }
+
+ public void OnFrame()
+ {
+ for (int i = 0; i < this._threads.Count; i++)
+ {
+ if (!this._threads[i].running)
+ {
+ this._threads[i].StartMethod("OnFrame");
+ bool run = true;
+ while (run)
+ {
+ run = this._threads[i].Excute();
+ }
+ }
+ }
+ }
+
+ private class CompileInfo
+ {
+ public string script;
+ public string scriptName;
+ public uint entityId;
+
+ public CompileInfo()
+ {
+
+ }
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs
new file mode 100644
index 0000000..69a274c
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Stack.cs
@@ -0,0 +1,42 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class Stack
+ {
+ public Stack StackFrames = new Stack();
+
+ public Stack()
+ {
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs
new file mode 100644
index 0000000..3a2b58a
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/StackFrame.cs
@@ -0,0 +1,49 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public class StackFrame
+ {
+ public BaseType[] LocalVariables;
+ public Stack OpStack = new Stack();
+
+ public int ReturnPC = 0;
+ public ClassRecord CallingClass = null;
+
+ public StackFrame()
+ {
+ LocalVariables = new BaseType[20];
+ }
+
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs
new file mode 100644
index 0000000..806f833
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Thread.cs
@@ -0,0 +1,120 @@
+/*
+* Copyright (c) Contributors, http://www.openmetaverse.org/
+* See CONTRIBUTORS.TXT for a full list of copyright holders.
+*
+* Redistribution and use in source and binary forms, with or without
+* modification, are permitted provided that the following conditions are met:
+* * Redistributions of source code must retain the above copyright
+* notice, this list of conditions and the following disclaimer.
+* * Redistributions in binary form must reproduce the above copyright
+* notice, this list of conditions and the following disclaimer in the
+* documentation and/or other materials provided with the distribution.
+* * Neither the name of the OpenSim Project nor the
+* names of its contributors may be used to endorse or promote products
+* derived from this software without specific prior written permission.
+*
+* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
+* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+*
+*/
+using System;
+using System.Collections.Generic;
+using System.Text;
+using OpenSim.Scripting.EmbeddedJVM.Types;
+using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes;
+using OpenSim.Framework;
+using OpenSim.Framework.Interfaces;
+using OpenSim.Region.Environment.Scenes;
+using OpenSim.Region.Environment.Scripting;
+
+namespace OpenSim.Scripting.EmbeddedJVM
+{
+ public partial class Thread
+ {
+ // Is this smart?
+ public static MainMemory GlobalMemory;
+ public static Scene World;
+ private int PC = 0;
+ private Stack stack;
+ private Interpreter mInterpreter;
+ public ClassRecord currentClass;
+ public ClassInstance currentInstance;
+ private StackFrame currentFrame;
+ public int excutionCounter = 0;
+ public bool running = false;
+ public uint EntityId = 0;
+
+ public ScriptInfo scriptInfo;
+
+ public Thread()
+ {
+ this.mInterpreter = new Interpreter(this);
+ this.stack = new Stack();
+ }
+
+ public void SetPC(int methodpointer)
+ {
+ //Console.WriteLine("Thread PC has been set to " + methodpointer);
+ PC = methodpointer;
+ }
+
+ public void StartMethod(ClassRecord rec, string methName)
+ {
+ currentFrame = new StackFrame();
+ this.stack.StackFrames.Push(currentFrame);
+ this.currentClass = rec;
+ currentClass.StartMethod(this, methName);
+ }
+
+ public void StartMethod( string methName)
+ {
+ currentFrame = new StackFrame();
+ this.stack.StackFrames.Push(currentFrame);
+ currentClass.StartMethod(this, methName);
+ }
+
+ public void JumpToStaticVoidMethod(string methName, int returnPC)
+ {
+ currentFrame = new StackFrame();
+ currentFrame.ReturnPC = returnPC;
+ this.stack.StackFrames.Push(currentFrame);
+ currentClass.StartMethod(this, methName);
+ }
+
+ public void JumpToStaticParamMethod(string methName, string param, int returnPC)
+ {
+ if (param == "I")
+ {
+ BaseType bs1 = currentFrame.OpStack.Pop();
+ currentFrame = new StackFrame();
+ currentFrame.ReturnPC = returnPC;
+ this.stack.StackFrames.Push(currentFrame);
+ currentFrame.LocalVariables[0] = ((Int)bs1);
+ currentClass.StartMethod(this, methName);
+ }
+ if (param == "F")
+ {
+
+ }
+ }
+
+ public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
+ {
+
+ }
+
+ public bool Excute()
+ {
+ excutionCounter++;
+ return this.mInterpreter.Excute();
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
new file mode 100644
index 0000000..2854eab
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ArrayReference.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types
+{
+ public class ArrayReference :BaseType
+ {
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
new file mode 100644
index 0000000..270aa7b
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/BaseType.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types
+{
+ public class BaseType : Object
+ {
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
new file mode 100644
index 0000000..da28eaa
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/ObjectReference.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types
+{
+ public class ObjectReference : BaseType
+ {
+ public ushort Reference;
+
+ public ObjectReference()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
new file mode 100644
index 0000000..1a3ecff
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
+{
+ public class Byte : BaseType
+ {
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
new file mode 100644
index 0000000..19002d4
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
+{
+ public class Char : BaseType
+ {
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
new file mode 100644
index 0000000..91f1679
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
+{
+ public class Float : BaseType
+ {
+ public float mValue = 0;
+
+ public Float()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
new file mode 100644
index 0000000..4ecd325
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs
@@ -0,0 +1,16 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes
+{
+ public class Int : BaseType
+ {
+ public int mValue = 0;
+
+ public Int()
+ {
+
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/Script.cs b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
index 8029883..139bdf1 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/Script.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/Script.cs
@@ -27,7 +27,7 @@
*/
using OpenSim.Region.Environment.Scenes;
-namespace OpenSim.Region.Enviorment.Scripting
+namespace OpenSim.Region.Environment.Scripting
{
public interface IScript
{
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
new file mode 100644
index 0000000..fd601cb
--- /dev/null
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptAPI.cs
@@ -0,0 +1,25 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+using OpenSim.Region.Environment.Scenes;
+
+namespace OpenSim.Region.Environment.Scripting
+{
+ // This class is to be used for engines which may not be able to access the Scene directly.
+ // Scene access is preffered, but obviously not possible on some non-.NET languages.
+ public class ScriptAPI
+ {
+ Scene scene;
+
+ public ScriptAPI(Scene world)
+ {
+ scene = world;
+ }
+
+ public Object CallMethod(String method, Object[] args)
+ {
+ return null;
+ }
+ }
+}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
index d984d60..ed6f033 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptInfo.cs
@@ -28,7 +28,7 @@
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
-namespace OpenSim.Region.Enviorment.Scripting
+namespace OpenSim.Region.Environment.Scripting
{
///
/// Class which provides access to the world
@@ -44,11 +44,15 @@ namespace OpenSim.Region.Enviorment.Scripting
// The console
public LogBase logger;
+ // API Access
+ public ScriptAPI api;
+
public ScriptInfo(Scene scene)
{
world = scene;
events = world.eventManager;
logger = MainLog.Instance;
+ api = new ScriptAPI(scene);
}
}
}
diff --git a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
index 1d47c24..250a4f0 100644
--- a/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
+++ b/OpenSim/Region/Environment/Scenes/scripting/ScriptManager.cs
@@ -29,7 +29,7 @@ using System.Collections.Generic;
using OpenSim.Framework.Console;
using OpenSim.Region.Environment.Scenes;
-namespace OpenSim.Region.Enviorment.Scripting
+namespace OpenSim.Region.Environment.Scripting
{
public class ScriptManager
{
--
cgit v1.1