From c16aafee09bfcce12c3d667cd6ec382e29695490 Mon Sep 17 00:00:00 2001 From: MW Date: Tue, 28 Aug 2007 18:30:28 +0000 Subject: [PATCH] Taken the old scripting engine out of Region.Environment and moved it into a separate module: OpenSim.Region.ExtensionsScriptModule (named as such because the purpose of it is to script server extensions, rather than "user scripting" like Tedd's engine.) --- OpenSim/Region/Environment/ModuleLoader.cs | 3 + .../Region/Environment/Modules/ChatModule.cs | 2 +- .../Scenes/Scene.PacketHandlers.cs | 10 - OpenSim/Region/Environment/Scenes/Scene.cs | 9 - .../JVMEngine/Types/PrimitiveTypes/Byte.cs | 10 - .../JVMEngine/Types/PrimitiveTypes/Char.cs | 10 - .../Engines/CSharp}/CSharpScriptEngine.cs | 204 +-- .../CSharp}/Examples/ExportRegionToLSL.cs | 142 +- .../Engines/JScript}/JScriptEngine.cs | 204 +-- .../Engines/JVMEngine/JVM/ClassInstance.cs | 92 +- .../Engines/JVMEngine/JVM/ClassRecord.cs | 1278 ++++++++--------- .../Engines/JVMEngine/JVM/Heap.cs | 86 +- .../JVMEngine/JVM/Interpreter.Logic.cs | 1100 +++++++------- .../JVMEngine/JVM/Interpreter.Methods.cs | 192 +-- .../JVMEngine/JVM/Interpreter.Return.cs | 80 +- .../Engines/JVMEngine/JVM/Interpreter.cs | 270 ++-- .../Engines/JVMEngine/JVM/MainMemory.cs | 90 +- .../Engines/JVMEngine/JVM/MethodMemory.cs | 92 +- .../Engines/JVMEngine/JVM/Object.cs | 74 +- .../Engines/JVMEngine/JVM/OpCodes.cs | 112 +- .../Engines/JVMEngine/JVM/Stack.cs | 84 +- .../Engines/JVMEngine/JVM/StackFrame.cs | 98 +- .../Engines/JVMEngine/JVM/Thread.cs | 238 +-- .../Engines/JVMEngine/JavaEngine.cs | 57 +- .../Engines/JVMEngine/OpenSimJVM.cs | 341 ++--- .../Engines/JVMEngine/Types/ArrayReference.cs | 20 +- .../Engines/JVMEngine/Types/BaseType.cs | 20 +- .../JVMEngine/Types/ObjectReference.cs | 32 +- .../JVMEngine/Types/PrimitiveTypes/Byte.cs | 11 + .../JVMEngine/Types/PrimitiveTypes/Char.cs | 11 + .../JVMEngine/Types/PrimitiveTypes/Float.cs | 33 +- .../JVMEngine/Types/PrimitiveTypes/Int.cs | 33 +- ...penSim.Region.ExtensionScriptEngine.csproj | 213 +++ ...m.Region.ExtensionScriptEngine.csproj.user | 12 + ...Sim.Region.ExtensionScriptEngine.dll.build | 78 + ...enSim.Region.ExtensionsScriptModule.csproj | 207 +++ ....Region.ExtensionsScriptModule.csproj.user | 12 + ...im.Region.ExtensionsScriptModule.dll.build | 77 + .../Script.cs | 128 +- .../ScriptAPI.cs | 64 +- .../ScriptInfo.cs | 126 +- .../ScriptInterpretedAPI.cs | 534 +++---- .../ScriptInterpretedEvents.cs | 46 +- .../ScriptManager.cs | 245 ++-- prebuild.xml | 28 + 45 files changed, 3727 insertions(+), 3081 deletions(-) delete mode 100644 OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs delete mode 100644 OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs rename OpenSim/Region/{Environment/Scenes/Scripting/Engines/CSharpEngine => ExtensionsScriptModule/Engines/CSharp}/CSharpScriptEngine.cs (96%) rename OpenSim/Region/{Environment/Scenes/Scripting/Engines/CSharpEngine => ExtensionsScriptModule/Engines/CSharp}/Examples/ExportRegionToLSL.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting/Engines/JScriptEngine => ExtensionsScriptModule/Engines/JScript}/JScriptEngine.cs (96%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/ClassInstance.cs (91%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/ClassRecord.cs (96%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Heap.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Interpreter.Logic.cs (97%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Interpreter.Methods.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Interpreter.Return.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Interpreter.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/MainMemory.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/MethodMemory.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Object.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/OpCodes.cs (90%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Stack.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/StackFrame.cs (92%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JVM/Thread.cs (92%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/JavaEngine.cs (80%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/OpenSimJVM.cs (94%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/Types/ArrayReference.cs (63%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/Types/BaseType.cs (61%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/Types/ObjectReference.cs (72%) create mode 100644 OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs create mode 100644 OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs (55%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs (54%) create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj.user create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.dll.build create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj.user create mode 100644 OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.dll.build rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/Script.cs (95%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/ScriptAPI.cs (91%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/ScriptInfo.cs (95%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/ScriptInterpretedAPI.cs (96%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/ScriptInterpretedEvents.cs (87%) rename OpenSim/Region/{Environment/Scenes/Scripting => ExtensionsScriptModule}/ScriptManager.cs (67%) diff --git a/OpenSim/Region/Environment/ModuleLoader.cs b/OpenSim/Region/Environment/ModuleLoader.cs index 8e42d90835..dbe43d57f2 100644 --- a/OpenSim/Region/Environment/ModuleLoader.cs +++ b/OpenSim/Region/Environment/ModuleLoader.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Reflection; using System.Text; +using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Modules; @@ -37,6 +38,8 @@ namespace OpenSim.Region.Environment avatarProfiles.Initialise(scene); scene.AddModule(avatarProfiles.GetName(), avatarProfiles); + this.LoadModule("OpenSim.Region.ExtensionsScriptModule.dll", "ExtensionsScriptingModule", scene); + // Post Initialise Modules xferManager.PostInitialise(); // chatModule.PostInitialise(); //for now leave this disabled as it would start up a partially working irc bot diff --git a/OpenSim/Region/Environment/Modules/ChatModule.cs b/OpenSim/Region/Environment/Modules/ChatModule.cs index 703fe651aa..300269a351 100644 --- a/OpenSim/Region/Environment/Modules/ChatModule.cs +++ b/OpenSim/Region/Environment/Modules/ChatModule.cs @@ -21,7 +21,7 @@ namespace OpenSim.Region.Environment.Modules private int m_port = 6668; private string m_user = "USER OpenSimBot 8 * :I'm a OpenSim to irc bot"; - private string m_nick = "OpenSimBoT"; + private string m_nick = "OpenSimBot"; private string m_channel = "#opensim"; private NetworkStream m_stream; diff --git a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs index dcec289d91..568639fa97 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.PacketHandlers.cs @@ -155,16 +155,6 @@ namespace OpenSim.Region.Environment.Scenes }); } - - /// - /// - /// - /// - public void SendAvatarsToClient(IClientAPI remoteClient) - { - - } - /// /// /// diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index b2ddb7d652..cd5d2a260b 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -44,7 +44,6 @@ using OpenSim.Framework.Communications.Caches; using OpenSim.Region.Environment.LandManagement; using OpenSim.Region.Environment; using OpenSim.Region.Environment.Interfaces; -using OpenSim.Region.Scripting; using OpenSim.Region.Terrain; using OpenSim.Framework.Data; using Caps = OpenSim.Region.Capabilities.Caps; @@ -122,13 +121,6 @@ namespace OpenSim.Region.Environment.Scenes get { return m_estateManager; } } - private ScriptManager m_scriptManager; - - public ScriptManager ScriptManager - { - get { return m_scriptManager; } - } - private PermissionManager m_permissionManager; public PermissionManager PermissionsMngr @@ -174,7 +166,6 @@ namespace OpenSim.Region.Environment.Scenes m_LandManager = new LandManager(this, m_regInfo); m_estateManager = new EstateManager(this, m_regInfo); - m_scriptManager = new ScriptManager(this); m_eventManager = new EventManager(); m_permissionManager = new PermissionManager(this); 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 deleted file mode 100644 index 5a7b780880..0000000000 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.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 deleted file mode 100644 index c87ee8f005..0000000000 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Char : BaseType - { - } -} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs similarity index 96% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/CSharpScriptEngine.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index 8e1b23ebf3..7da3d55d69 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -1,102 +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.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.Environment.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.Name; - 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); - } - } -} +/* +* 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.ExtensionsScriptModule.CSharp +{ + 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.Environment.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.Name; + 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/CSharpEngine/Examples/ExportRegionToLSL.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs index 80d77f28a5..90d3438229 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/CSharpEngine/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -1,72 +1,72 @@ -using OpenSim.Framework.Console; -using OpenSim.Framework; -using OpenSim.Region.Environment; -using OpenSim.Region.Environment.Scenes; - -using System.Collections.Generic; -using libsecondlife; - -namespace OpenSim.Region.Scripting.Examples -{ - public class LSLExportScript : IScript - { - ScriptInfo script; - - public string Name - { - get { return "LSL Export Script 0.1"; } - } - - public void Initialise(ScriptInfo scriptInfo) - { - script = scriptInfo; - - script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); - } - - void ProcessConsoleMsg(string[] args) - { - /*if (args[0].ToLower() == "lslexport") - { - string sequence = ""; - - foreach (KeyValuePair obj in script.world.Objects) - { - SceneObject root = obj.Value; - - sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; - - string rootPrim = processPrimitiveToString(root.rootPrimitive); - - sequence += "ROOT:" + rootPrim; - - foreach (KeyValuePair prim in root.Children) - { - string child = processPrimitiveToString(prim.Value); - sequence += "CHILD:" + child; - } - } - - System.Console.WriteLine(sequence); - }*/ - } - - string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) - { - /*string desc = prim.Description; - string name = prim.Name; - LLVector3 pos = prim.Pos; - LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w); - LLVector3 scale = prim.Scale; - LLVector3 rootPos = prim.WorldPos; - - string setPrimParams = ""; - - setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; - - return setPrimParams; - */ - return ""; - } - } +using OpenSim.Framework.Console; +using OpenSim.Framework; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; + +using System.Collections.Generic; +using libsecondlife; + +namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples +{ + public class LSLExportScript : IScript + { + ScriptInfo script; + + public string Name + { + get { return "LSL Export Script 0.1"; } + } + + public void Initialise(ScriptInfo scriptInfo) + { + script = scriptInfo; + + script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg); + } + + void ProcessConsoleMsg(string[] args) + { + /*if (args[0].ToLower() == "lslexport") + { + string sequence = ""; + + foreach (KeyValuePair obj in script.world.Objects) + { + SceneObject root = obj.Value; + + sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n"; + + string rootPrim = processPrimitiveToString(root.rootPrimitive); + + sequence += "ROOT:" + rootPrim; + + foreach (KeyValuePair prim in root.Children) + { + string child = processPrimitiveToString(prim.Value); + sequence += "CHILD:" + child; + } + } + + System.Console.WriteLine(sequence); + }*/ + } + + string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) + { + /*string desc = prim.Description; + string name = prim.Name; + LLVector3 pos = prim.Pos; + LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w); + LLVector3 scale = prim.Scale; + LLVector3 rootPos = prim.WorldPos; + + string setPrimParams = ""; + + setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n"; + + return setPrimParams; + */ + return ""; + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JScriptEngine/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs similarity index 96% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JScriptEngine/JScriptEngine.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 554ffebb5e..8efbdc2963 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JScriptEngine/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -1,102 +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.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.Environment.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.Name; - 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); - } - } -} +/* +* 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.ExtensionsScriptModule.JScript +{ + 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.Environment.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.Name; + 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/JVM/ClassInstance.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs similarity index 91% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/ClassInstance.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs index 4b734a3187..bda4e3e780 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -1,46 +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; -using OpenSim.Region.Scripting.EmbeddedJVM.Types; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - public class ClassInstance : Object - { - public int Size; - public ClassRecord ClassRec; - public Dictionary Fields = new Dictionary(); - - public ClassInstance() - { - - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class ClassInstance : Object + { + public int Size; + public ClassRecord ClassRec; + public Dictionary Fields = new Dictionary(); + + public ClassInstance() + { + + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs similarity index 96% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/ClassRecord.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs index 4b2aec3d40..116d2bcdf9 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -1,640 +1,640 @@ -/* -* 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.Region.Scripting.EmbeddedJVM.Types; -using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - public class ClassRecord - { - private ushort m_majorVersion; - private ushort m_minorVersion; - private ushort m_constantPoolCount; - private ushort m_accessFlags; - private ushort m_thisClass; - private ushort m_supperClass; - private ushort m_interfaceCount; - private ushort m_fieldCount; - private ushort m_methodCount; - //private ushort _attributeCount; - //private string _name; - public Dictionary StaticFields = new Dictionary(); - public PoolClass MClass; - - public List m_constantsPool = new List(); - private List m_methodsList = new List(); - private List m_fieldList = new List(); - - public ClassRecord() - { - - } - - public ClassInstance CreateNewInstance() - { - ClassInstance classInst = new ClassInstance(); - classInst.ClassRec = this; - //TODO: set fields - - return classInst; - } - - 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; - m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); - m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); - Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); - for (int count = 0; count < (m_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.m_constantsPool.Add(utf8); - break; - case 3: //Int - break; - case 4: //Float - break; - case 7: //Class - PoolClass pClass = new PoolClass(this); - pClass.readValue(data, ref i); - this.m_constantsPool.Add(pClass); - break; - case 9: //FieldRef - PoolFieldRef pField = new PoolFieldRef(this); - pField.readValue(data, ref i); - this.m_constantsPool.Add(pField); - break; - case 10: //Method - PoolMethodRef pMeth = new PoolMethodRef(this); - pMeth.readValue(data, ref i); - this.m_constantsPool.Add(pMeth); - break; - case 12: //NamedType - PoolNamedType pNamed = new PoolNamedType(this); - pNamed.readValue(data, ref i); - this.m_constantsPool.Add(pNamed); - break; - } - } - - m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); - m_thisClass = (ushort)((data[i++] << 8) + data[i++]); - m_supperClass = (ushort)((data[i++] << 8) + data[i++]); - - if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) - { - this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); - } - - m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each interface - - m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each field - for (int count = 0; count < m_fieldCount; count++) - { - FieldInfo fieldInf = new FieldInfo(this); - fieldInf.ReadData(data, ref i); - this.m_fieldList.Add(fieldInf); - } - - m_methodCount = (ushort)((data[i++] << 8) + data[i++]); - for (int count = 0; count < m_methodCount; count++) - { - MethodInfo methInf = new MethodInfo(this); - methInf.ReadData(data, ref i); - this.m_methodsList.Add(methInf); - } - } - - public void AddMethodsToMemory(MethodMemory memory) - { - for (int count = 0; count < m_methodCount; count++) - { - this.m_methodsList[count].AddMethodCode(memory); - } - } - - public bool StartMethod(Thread thread, string methodName) - { - for (int count = 0; count < m_methodCount; count++) - { - if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) - { - if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) - { - //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); - thread.SetPC(this.m_methodsList[count].CodePointer); - return true; - } - } - } - return false; - } - - public void PrintToConsole() - { - Console.WriteLine("Class File:"); - Console.WriteLine("Major version: " + m_majorVersion); - Console.WriteLine("Minor version: " + m_minorVersion); - Console.WriteLine("Pool size: " + m_constantPoolCount); - - for (int i = 0; i < m_constantsPool.Count; i++) - { - this.m_constantsPool[i].Print(); - } - - Console.WriteLine("Access flags: " + m_accessFlags); - Console.WriteLine("This class: " + m_thisClass); - Console.WriteLine("Super class: " + m_supperClass); - - for (int count = 0; count < m_fieldCount; count++) - { - Console.WriteLine(); - this.m_fieldList[count].Print(); - } - - for (int count = 0; count < m_methodCount; count++) - { - Console.WriteLine(); - this.m_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.m_constantsPool[namePointer - 1]); - Console.Write("Class type: " + namePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); - - } - } - - public class PoolFieldRef : PoolItem - { - public ushort classPointer = 0; - public ushort nameTypePointer = 0; - public PoolNamedType mNameType; - public PoolClass mClass; - private ClassRecord parent; - - public PoolFieldRef(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.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); - Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); - } - } - - 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.m_constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent.m_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.m_constantsPool[namePointer - 1]); - Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); - Console.Write("Named type: " + namePointer + " , " + typePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_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.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_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.m_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.m_constantsPool[NameIndex - 1]).Value); - } - - } - } - - } - private class InterfaceInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - - public class FieldInfo - { - 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 FieldInfo(ClassRecord paren) - { - parent = paren; - } - - 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++) - { - FieldAttribute attri = new FieldAttribute(this.parent); - attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); - } - } - - public void Print() - { - Console.WriteLine("Field Info Struct: "); - Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); - Console.WriteLine("Attribute Count:" + AttributeCount); - //if static, add to static field list - // if (this.AccessFlags == 9) //public and static - if ((this.AccessFlags & 0x08) != 0) - { - switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) - { - case "I": - Int newin = new Int(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); - break; - case "F": - Float newfl = new Float(); - this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); - break; - } - - } - for (int i = 0; i < AttributeCount; i++) - { - this.Attributes[i].Print(); - } - } - - public class FieldAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - public byte[] Data; - private ClassRecord parent; - - public FieldAttribute(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("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); - } - } - } - - private class AttributeInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - #endregion - - } +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class ClassRecord + { + private ushort m_majorVersion; + private ushort m_minorVersion; + private ushort m_constantPoolCount; + private ushort m_accessFlags; + private ushort m_thisClass; + private ushort m_supperClass; + private ushort m_interfaceCount; + private ushort m_fieldCount; + private ushort m_methodCount; + //private ushort _attributeCount; + //private string _name; + public Dictionary StaticFields = new Dictionary(); + public PoolClass MClass; + + public List m_constantsPool = new List(); + private List m_methodsList = new List(); + private List m_fieldList = new List(); + + public ClassRecord() + { + + } + + public ClassInstance CreateNewInstance() + { + ClassInstance classInst = new ClassInstance(); + classInst.ClassRec = this; + //TODO: set fields + + return classInst; + } + + 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; + m_minorVersion = (ushort)((data[i++] << 8) + data[i++]); + m_majorVersion = (ushort)((data[i++] << 8) + data[i++]); + m_constantPoolCount = (ushort)((data[i++] << 8) + data[i++]); + Console.WriteLine("there should be " + m_constantPoolCount + " items in the pool"); + for (int count = 0; count < (m_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.m_constantsPool.Add(utf8); + break; + case 3: //Int + break; + case 4: //Float + break; + case 7: //Class + PoolClass pClass = new PoolClass(this); + pClass.readValue(data, ref i); + this.m_constantsPool.Add(pClass); + break; + case 9: //FieldRef + PoolFieldRef pField = new PoolFieldRef(this); + pField.readValue(data, ref i); + this.m_constantsPool.Add(pField); + break; + case 10: //Method + PoolMethodRef pMeth = new PoolMethodRef(this); + pMeth.readValue(data, ref i); + this.m_constantsPool.Add(pMeth); + break; + case 12: //NamedType + PoolNamedType pNamed = new PoolNamedType(this); + pNamed.readValue(data, ref i); + this.m_constantsPool.Add(pNamed); + break; + } + } + + m_accessFlags = (ushort)((data[i++] << 8) + data[i++]); + m_thisClass = (ushort)((data[i++] << 8) + data[i++]); + m_supperClass = (ushort)((data[i++] << 8) + data[i++]); + + if (this.m_constantsPool[this.m_thisClass - 1] is PoolClass) + { + this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); + } + + m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each interface + + m_fieldCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each field + for (int count = 0; count < m_fieldCount; count++) + { + FieldInfo fieldInf = new FieldInfo(this); + fieldInf.ReadData(data, ref i); + this.m_fieldList.Add(fieldInf); + } + + m_methodCount = (ushort)((data[i++] << 8) + data[i++]); + for (int count = 0; count < m_methodCount; count++) + { + MethodInfo methInf = new MethodInfo(this); + methInf.ReadData(data, ref i); + this.m_methodsList.Add(methInf); + } + } + + public void AddMethodsToMemory(MethodMemory memory) + { + for (int count = 0; count < m_methodCount; count++) + { + this.m_methodsList[count].AddMethodCode(memory); + } + } + + public bool StartMethod(Thread thread, string methodName) + { + for (int count = 0; count < m_methodCount; count++) + { + if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) + { + if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) + { + //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); + thread.SetPC(this.m_methodsList[count].CodePointer); + return true; + } + } + } + return false; + } + + public void PrintToConsole() + { + Console.WriteLine("Class File:"); + Console.WriteLine("Major version: " + m_majorVersion); + Console.WriteLine("Minor version: " + m_minorVersion); + Console.WriteLine("Pool size: " + m_constantPoolCount); + + for (int i = 0; i < m_constantsPool.Count; i++) + { + this.m_constantsPool[i].Print(); + } + + Console.WriteLine("Access flags: " + m_accessFlags); + Console.WriteLine("This class: " + m_thisClass); + Console.WriteLine("Super class: " + m_supperClass); + + for (int count = 0; count < m_fieldCount; count++) + { + Console.WriteLine(); + this.m_fieldList[count].Print(); + } + + for (int count = 0; count < m_methodCount; count++) + { + Console.WriteLine(); + this.m_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.m_constantsPool[namePointer - 1]); + Console.Write("Class type: " + namePointer); + Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); + + } + } + + public class PoolFieldRef : PoolItem + { + public ushort classPointer = 0; + public ushort nameTypePointer = 0; + public PoolNamedType mNameType; + public PoolClass mClass; + private ClassRecord parent; + + public PoolFieldRef(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.m_constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent.m_constantsPool[classPointer - 1]); + Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); + } + } + + 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.m_constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent.m_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.m_constantsPool[namePointer - 1]); + Type = ((PoolUtf8)this.parent.m_constantsPool[typePointer - 1]); + Console.Write("Named type: " + namePointer + " , " + typePointer); + Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_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.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_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.m_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.m_constantsPool[NameIndex - 1]).Value); + } + + } + } + + } + private class InterfaceInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + + public class FieldInfo + { + 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 FieldInfo(ClassRecord paren) + { + parent = paren; + } + + 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++) + { + FieldAttribute attri = new FieldAttribute(this.parent); + attri.ReadData(data, ref pointer); + this.Attributes.Add(attri); + } + } + + public void Print() + { + Console.WriteLine("Field Info Struct: "); + Console.WriteLine("AccessFlags: " + AccessFlags); + Console.WriteLine("NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value); + Console.WriteLine("Attribute Count:" + AttributeCount); + //if static, add to static field list + // if (this.AccessFlags == 9) //public and static + if ((this.AccessFlags & 0x08) != 0) + { + switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) + { + case "I": + Int newin = new Int(); + this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newin); + break; + case "F": + Float newfl = new Float(); + this.parent.StaticFields.Add(((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value, newfl); + break; + } + + } + for (int i = 0; i < AttributeCount; i++) + { + this.Attributes[i].Print(); + } + } + + public class FieldAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + public byte[] Data; + private ClassRecord parent; + + public FieldAttribute(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("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + } + } + } + + private class AttributeInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + #endregion + + } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Heap.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs index c6423fc76d..1b30956380 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -1,43 +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.Region.Scripting.EmbeddedJVM -{ - public class Heap - { - public List ClassObjects = new List(); - - public Heap() - { - - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Heap + { + public List ClassObjects = new List(); + + public Heap() + { + + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs similarity index 97% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs index ef6570dc49..1d5a0f66d2 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -1,551 +1,551 @@ -/* -* 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.Region.Scripting.EmbeddedJVM.Types; -using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - private bool IsLogicOpCode(byte opcode) - { - bool result = false; - switch (opcode) - { - case (byte)(byte)OpCode.iconst_m1: - Int m_int = new Int(); - m_int.mValue = -1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_0: - m_int = new Int(); - m_int.mValue = 0; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_1: - m_int = new Int(); - m_int.mValue = 1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_2: - m_int = new Int(); - m_int.mValue = 2; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)(byte)OpCode.iconst_3: - m_int = new Int(); - m_int.mValue = 3; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - break; - case (byte)(byte)OpCode.iconst_4: - m_int = new Int(); - m_int.mValue = 4; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)OpCode.iconst_5: - m_int = new Int(); - m_int.mValue = 5; - this.m_thread.m_currentFrame.OpStack.Push(m_int); - result = true; - break; - case (byte)OpCode.fconst_0: - Float m_float = new Float(); - m_float.mValue = 0.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.fconst_1: - m_float = new Float(); - m_float.mValue = 1.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.fconst_2: - m_float = new Float(); - m_float.mValue = 2.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); - result = true; - break; - case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? - int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; - Int pushInt = new Int(); - pushInt.mValue = pushvalue; - this.m_thread.m_currentFrame.OpStack.Push(pushInt); - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.sipush: - short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - Int pushInt2 = new Int(); - pushInt2.mValue = pushvalue2; - this.m_thread.m_currentFrame.OpStack.Push(pushInt2); - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.fload: - short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - Float fload = new Float(); - if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) - { - fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(fload); - } - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.iload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case (byte)OpCode.iload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case (byte)OpCode.fload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_2: - if (this.m_thread.m_currentFrame.LocalVariables[2] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.fload_3: - if (this.m_thread.m_currentFrame.LocalVariables[3] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case (byte)OpCode.istore: - short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); - if (istor is Int) - { - this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.fstore: - short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); - BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); - if (fstor is Float) - { - this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; - } - this.m_thread.PC++; - result = true; - break; - case (byte)OpCode.istore_0: - BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Int) - { - this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; - } - result = true; - break; - case (byte)OpCode.istore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Int) - { - this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; - } - result = true; - break; - case (byte)OpCode.fstore_0: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_2: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.fstore_3: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); - if (baset is Float) - { - this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; - } - result = true; - break; - case (byte)OpCode.pop: - this.m_thread.m_currentFrame.OpStack.Pop(); - result = true; - break; - case (byte)OpCode.fadd: - BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bf1 is Float && bf2 is Float) - { - Float nflt = new Float(); - nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nflt); - } - result = true; - break; - case (byte)OpCode.fsub: - BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bsf1 is Float && bsf2 is Float) - { - Float resf = new Float(); - resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(resf); - } - result = true; - break; - case (byte)OpCode.imul: //check the order of the two values off the stack is correct - BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (bs1 is Int && bs2 is Int) - { - Int nInt = new Int(); - nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; - this.m_thread.m_currentFrame.OpStack.Push(nInt); - } - result = true; - break; - case (byte)OpCode.iinc: - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) - { - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) - { - ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; - } - } - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.f2i: - BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (conv1 is Float) - { - Int newconv = new Int(); - newconv.mValue = (int)((Float)conv1).mValue; - this.m_thread.m_currentFrame.OpStack.Push(newconv); - } - result = true; - break; - case (byte)OpCode.fcmpl: - BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType flcom1 = this.m_thread.m_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.m_thread.m_currentFrame.OpStack.Push(compres); - } - result = true; - break; - case (byte)OpCode.fcmpg: - flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); - flcom1 = this.m_thread.m_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.m_thread.m_currentFrame.OpStack.Push(compres); - } - result = true; - break; - case (byte)OpCode.ifge: - short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (compe1 is Int) - { - if (((Int)compe1).mValue >= 0) - { - this.m_thread.PC += -1 + compareoffset2; - } - else - { - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.ifle: - short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); - if (comp1 is Int) - { - if (((Int)comp1).mValue <= 0) - { - this.m_thread.PC += -1 + compareoffset1; - } - else - { - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.if_icmpge: - short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bc1 = this.m_thread.m_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.m_thread.PC += -1 + compareoffset; - //Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode.if_icmple: - short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); - BaseType bcl1 = this.m_thread.m_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.m_thread.PC += -1 + compareloffset; - // Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - case (byte)OpCode._goto: - short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - this.m_thread.PC += -1 + offset; - result = true; - break; - case (byte)OpCode.getstatic: - short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) - { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - //from this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) - { - Float retFloat = new Float(); - retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; - this.m_thread.m_currentFrame.OpStack.Push(retFloat); - } - else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) - { - Int retInt = new Int(); - retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; - // Console.WriteLine("getting static field, " + retInt.mValue); - this.m_thread.m_currentFrame.OpStack.Push(retInt); - } - } - } - else - { - //get from a different class - } - } - this.m_thread.PC += 2; - result = true; - break; - case (byte)OpCode.putstatic: - fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); - BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); - if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) - { - if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - // this class - if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) - { - if (addstatic is Float) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) - { - Float newf = new Float(); - newf.mValue = ((Float)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; - } - } - else if (addstatic is Int) - { - if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) - { - //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); - Int newi = new Int(); - newi.mValue = ((Int)addstatic).mValue; - this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; - } - } - } - } - else - { - // a different class - } - } - this.m_thread.PC += 2; - result = true; - break; - - } - - return result; - } - } - } +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsLogicOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case (byte)(byte)OpCode.iconst_m1: + Int m_int = new Int(); + m_int.mValue = -1; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_0: + m_int = new Int(); + m_int.mValue = 0; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_1: + m_int = new Int(); + m_int.mValue = 1; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_2: + m_int = new Int(); + m_int.mValue = 2; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)(byte)OpCode.iconst_3: + m_int = new Int(); + m_int.mValue = 3; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + break; + case (byte)(byte)OpCode.iconst_4: + m_int = new Int(); + m_int.mValue = 4; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)OpCode.iconst_5: + m_int = new Int(); + m_int.mValue = 5; + this.m_thread.m_currentFrame.OpStack.Push(m_int); + result = true; + break; + case (byte)OpCode.fconst_0: + Float m_float = new Float(); + m_float.mValue = 0.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.fconst_1: + m_float = new Float(); + m_float.mValue = 1.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.fconst_2: + m_float = new Float(); + m_float.mValue = 2.0f; + this.m_thread.m_currentFrame.OpStack.Push(m_float); + result = true; + break; + case (byte)OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? + int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]; + Int pushInt = new Int(); + pushInt.mValue = pushvalue; + this.m_thread.m_currentFrame.OpStack.Push(pushInt); + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.sipush: + short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + Int pushInt2 = new Int(); + pushInt2.mValue = pushvalue2; + this.m_thread.m_currentFrame.OpStack.Push(pushInt2); + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.fload: + short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + Float fload = new Float(); + if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) + { + fload.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[findex1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(fload); + } + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.iload_0: + if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case (byte)OpCode.iload_1: + if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case (byte)OpCode.fload_0: + if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[0]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_1: + if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[1]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_2: + if (this.m_thread.m_currentFrame.LocalVariables[2] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[2]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.fload_3: + if (this.m_thread.m_currentFrame.LocalVariables[3] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this.m_thread.m_currentFrame.LocalVariables[3]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case (byte)OpCode.istore: + short findex3 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + BaseType istor = this.m_thread.m_currentFrame.OpStack.Pop(); + if (istor is Int) + { + this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.fstore: + short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + BaseType fstor = this.m_thread.m_currentFrame.OpStack.Pop(); + if (fstor is Float) + { + this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; + } + this.m_thread.PC++; + result = true; + break; + case (byte)OpCode.istore_0: + BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Int) + { + this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; + } + result = true; + break; + case (byte)OpCode.istore_1: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Int) + { + this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; + } + result = true; + break; + case (byte)OpCode.fstore_0: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_1: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_2: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.fstore_3: + baset = this.m_thread.m_currentFrame.OpStack.Pop(); + if (baset is Float) + { + this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; + } + result = true; + break; + case (byte)OpCode.pop: + this.m_thread.m_currentFrame.OpStack.Pop(); + result = true; + break; + case (byte)OpCode.fadd: + BaseType bf2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bf1 is Float && bf2 is Float) + { + Float nflt = new Float(); + nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(nflt); + } + result = true; + break; + case (byte)OpCode.fsub: + BaseType bsf2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bsf1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bsf1 is Float && bsf2 is Float) + { + Float resf = new Float(); + resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(resf); + } + result = true; + break; + case (byte)OpCode.imul: //check the order of the two values off the stack is correct + BaseType bs2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bs1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (bs1 is Int && bs2 is Int) + { + Int nInt = new Int(); + nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; + this.m_thread.m_currentFrame.OpStack.Push(nInt); + } + result = true; + break; + case (byte)OpCode.iinc: + if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] != null) + { + if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) + { + ((Int)this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]]).mValue += (sbyte)GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]; + } + } + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.f2i: + BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (conv1 is Float) + { + Int newconv = new Int(); + newconv.mValue = (int)((Float)conv1).mValue; + this.m_thread.m_currentFrame.OpStack.Push(newconv); + } + result = true; + break; + case (byte)OpCode.fcmpl: + BaseType flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType flcom1 = this.m_thread.m_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.m_thread.m_currentFrame.OpStack.Push(compres); + } + result = true; + break; + case (byte)OpCode.fcmpg: + flcom2 = this.m_thread.m_currentFrame.OpStack.Pop(); + flcom1 = this.m_thread.m_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.m_thread.m_currentFrame.OpStack.Push(compres); + } + result = true; + break; + case (byte)OpCode.ifge: + short compareoffset2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType compe1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (compe1 is Int) + { + if (((Int)compe1).mValue >= 0) + { + this.m_thread.PC += -1 + compareoffset2; + } + else + { + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.ifle: + short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType comp1 = this.m_thread.m_currentFrame.OpStack.Pop(); + if (comp1 is Int) + { + if (((Int)comp1).mValue <= 0) + { + this.m_thread.PC += -1 + compareoffset1; + } + else + { + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.if_icmpge: + short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType bc2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bc1 = this.m_thread.m_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.m_thread.PC += -1 + compareoffset; + //Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode.if_icmple: + short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType bcl2 = this.m_thread.m_currentFrame.OpStack.Pop(); + BaseType bcl1 = this.m_thread.m_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.m_thread.PC += -1 + compareloffset; + // Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this.m_thread.PC += 2; + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + case (byte)OpCode._goto: + short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + this.m_thread.PC += -1 + offset; + result = true; + break; + case (byte)OpCode.getstatic: + short fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + { + if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + //from this class + if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + { + Float retFloat = new Float(); + retFloat.mValue = ((Float)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; + this.m_thread.m_currentFrame.OpStack.Push(retFloat); + } + else if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + { + Int retInt = new Int(); + retInt.mValue = ((Int)this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value]).mValue; + // Console.WriteLine("getting static field, " + retInt.mValue); + this.m_thread.m_currentFrame.OpStack.Push(retInt); + } + } + } + else + { + //get from a different class + } + } + this.m_thread.PC += 2; + result = true; + break; + case (byte)OpCode.putstatic: + fieldrefIndex = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC + 1]); + BaseType addstatic = this.m_thread.m_currentFrame.OpStack.Pop(); + if (this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1] is ClassRecord.PoolFieldRef) + { + if (((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + // this class + if (this.m_thread.currentClass.StaticFields.ContainsKey(((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value)) + { + if (addstatic is Float) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Float) + { + Float newf = new Float(); + newf.mValue = ((Float)addstatic).mValue; + this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newf; + } + } + else if (addstatic is Int) + { + if (this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] is Int) + { + //Console.WriteLine("setting static field to " + ((Int)addstatic).mValue); + Int newi = new Int(); + newi.mValue = ((Int)addstatic).mValue; + this.m_thread.currentClass.StaticFields[((ClassRecord.PoolFieldRef)this.m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType.Name.Value] = newi; + } + } + } + } + else + { + // a different class + } + } + this.m_thread.PC += 2; + result = true; + break; + + } + + return result; + } + } + } } \ No newline at end of file diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index 42fd299881..9ccf749af4 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -1,96 +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.Region.Scripting.EmbeddedJVM.Types; -using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; -using OpenSim.Framework.Types; - -namespace OpenSim.Region.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.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); - if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) - { - string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_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.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) - { - //calling a method in this class - if (typeparam.Length == 0) - { - this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); - } - else - { - this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); - } - } - else - { - //calling a method of a different class - - // OpenSimAPI Class - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") - { - this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); - } - } - } - else - { - this.m_thread.PC += 2; - } - result = true; - break; - } - - return result; - } - } - } -} +/* +* 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.Framework.Interfaces; +using OpenSim.Framework; +using OpenSim.Framework.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + 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.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]); + if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) + { + string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_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.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value) + { + //calling a method in this class + if (typeparam.Length == 0) + { + this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2)); + } + else + { + this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2)); + } + } + else + { + //calling a method of a different class + + // OpenSimAPI Class + if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + { + this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null); + } + } + } + else + { + this.m_thread.PC += 2; + } + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs index 3c18a11761..f6fc226773 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -1,40 +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.Region.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs index e71832860f..efc8ac3af8 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -1,135 +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.Region.Scripting.EmbeddedJVM.Types; -using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - private Thread m_thread; - - public Interpreter(Thread parentThread) - { - m_thread = parentThread; - } - - public bool Excute() - { - bool run = true; - byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.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.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning int from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; - if (bas1 is Int) - { - this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 174) - { - if (this.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning float from function"); - int retPC1 = this.m_thread.m_currentFrame.ReturnPC; - BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC1; - if (bas1 is Float) - { - this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 177) - { - if (this.m_thread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning from function"); - int retPC = this.m_thread.m_currentFrame.ReturnPC; - this.m_thread.stack.StackFrames.Pop(); - this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); - this.m_thread.PC = retPC; - } - else - { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - } - if (!handled) - { - Console.WriteLine("opcode " + currentOpCode + " not been handled "); - } - return run; - - } - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + partial class Thread + { + private partial class Interpreter + { + private Thread m_thread; + + public Interpreter(Thread parentThread) + { + m_thread = parentThread; + } + + public bool Excute() + { + bool run = true; + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.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.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning int from function"); + int retPC1 = this.m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC1; + if (bas1 is Int) + { + this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 174) + { + if (this.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning float from function"); + int retPC1 = this.m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop(); + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC1; + if (bas1 is Float) + { + this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 177) + { + if (this.m_thread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning from function"); + int retPC = this.m_thread.m_currentFrame.ReturnPC; + this.m_thread.stack.StackFrames.Pop(); + this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek(); + this.m_thread.PC = retPC; + } + else + { + // Console.WriteLine("No parent function so ending program"); + this.m_thread.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/JVM/MainMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/MainMemory.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs index 7174975cd1..3599dba4b0 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -1,45 +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.Region.Scripting.EmbeddedJVM -{ - public class MainMemory - { - public Heap HeapArea; - public MethodMemory MethodArea; - - public MainMemory() - { - MethodArea = new MethodMemory(); - HeapArea = new Heap(); - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + 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/JVM/MethodMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/MethodMemory.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs index 5f29091ca9..e32be8f172 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -1,46 +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.Region.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]; - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + 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/JVM/Object.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Object.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs index 8acb2bd18f..3d43808551 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -1,37 +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.Region.Scripting.EmbeddedJVM -{ - public class Object - { - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Object + { + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/OpCodes.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs similarity index 90% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/OpCodes.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs index 22a9f12021..c6ac987efc 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/OpCodes.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs @@ -1,56 +1,56 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - public enum OpCode : byte - { - iconst_m1 = 2, - iconst_0 = 3, - iconst_1 = 4, - iconst_2 = 5, - iconst_3 = 6, - iconst_4 = 7, - iconst_5 = 8, - fconst_0 = 11, - fconst_1 = 12, - fconst_2 = 13, - bipush = 16, - sipush = 17, - fload = 23, - iload_0 = 26, - iload_1 = 27, - fload_0 = 34, - fload_1 = 35, - fload_2 = 36, - fload_3 = 37, - istore = 54, - fstore = 56, - istore_0 = 59, - istore_1 = 60, - istore_2 = 61, - istore_3 = 62, - fstore_0 = 67, - fstore_1 = 68, - fstore_2 = 69, - fstore_3 = 70, - pop = 87, - fadd = 98, - fsub = 102, - imul = 104, - iinc = 132, - f2i = 139, - fcmpl = 149, - fcmpg = 150, - ifge = 156, - ifgt = 157, - ifle = 158, - if_icmpge = 162, - if_icmpgt = 163, - if_icmple = 164, - _goto = 167, - getstatic = 178, - putstatic = 179 - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public enum OpCode : byte + { + iconst_m1 = 2, + iconst_0 = 3, + iconst_1 = 4, + iconst_2 = 5, + iconst_3 = 6, + iconst_4 = 7, + iconst_5 = 8, + fconst_0 = 11, + fconst_1 = 12, + fconst_2 = 13, + bipush = 16, + sipush = 17, + fload = 23, + iload_0 = 26, + iload_1 = 27, + fload_0 = 34, + fload_1 = 35, + fload_2 = 36, + fload_3 = 37, + istore = 54, + fstore = 56, + istore_0 = 59, + istore_1 = 60, + istore_2 = 61, + istore_3 = 62, + fstore_0 = 67, + fstore_1 = 68, + fstore_2 = 69, + fstore_3 = 70, + pop = 87, + fadd = 98, + fsub = 102, + imul = 104, + iinc = 132, + f2i = 139, + fcmpl = 149, + fcmpg = 150, + ifge = 156, + ifgt = 157, + ifle = 158, + if_icmpge = 162, + if_icmpgt = 163, + if_icmple = 164, + _goto = 167, + getstatic = 178, + putstatic = 179 + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Stack.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs index 7c12678ffc..f665743846 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -1,42 +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.Region.Scripting.EmbeddedJVM -{ - public class Stack - { - public Stack StackFrames = new Stack(); - - public Stack() - { - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public class Stack + { + public Stack StackFrames = new Stack(); + + public Stack() + { + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs similarity index 92% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/StackFrame.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs index 76257b88df..bbb3770e2d 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -1,49 +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.Region.Scripting.EmbeddedJVM.Types; - -namespace OpenSim.Region.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]; - } - - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + 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/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs similarity index 92% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Thread.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs index aad1f47179..f944c5282b 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -1,119 +1,119 @@ -/* -* 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.Region.Scripting.EmbeddedJVM.Types; -using OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Scripting; - -namespace OpenSim.Region.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 m_Interpreter; - public ClassRecord currentClass; - public ClassInstance currentInstance; - private StackFrame m_currentFrame; - public int excutionCounter = 0; - public bool running = false; - - public ScriptInfo scriptInfo; - - public Thread() - { - this.m_Interpreter = 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) - { - m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - this.currentClass = rec; - currentClass.StartMethod(this, methName); - } - - public void StartMethod( string methName) - { - m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticVoidMethod(string methName, int returnPC) - { - m_currentFrame = new StackFrame(); - m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticParamMethod(string methName, string param, int returnPC) - { - if (param == "I") - { - BaseType bs1 = m_currentFrame.OpStack.Pop(); - m_currentFrame = new StackFrame(); - m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); - m_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.m_Interpreter.Excute(); - } - } -} +/* +* 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.Region.ExtensionsScriptModule.JVMEngine.Types; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.ExtensionsScriptModule; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM +{ + public partial class Thread + { + // Is this smart? + public static MainMemory GlobalMemory; + public static Scene World; + private int PC = 0; + private Stack stack; + private Interpreter m_Interpreter; + public ClassRecord currentClass; + public ClassInstance currentInstance; + private StackFrame m_currentFrame; + public int excutionCounter = 0; + public bool running = false; + + public ScriptInfo scriptInfo; + + public Thread() + { + this.m_Interpreter = 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) + { + m_currentFrame = new StackFrame(); + this.stack.StackFrames.Push(m_currentFrame); + this.currentClass = rec; + currentClass.StartMethod(this, methName); + } + + public void StartMethod( string methName) + { + m_currentFrame = new StackFrame(); + this.stack.StackFrames.Push(m_currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticVoidMethod(string methName, int returnPC) + { + m_currentFrame = new StackFrame(); + m_currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(m_currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticParamMethod(string methName, string param, int returnPC) + { + if (param == "I") + { + BaseType bs1 = m_currentFrame.OpStack.Pop(); + m_currentFrame = new StackFrame(); + m_currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(m_currentFrame); + m_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.m_Interpreter.Excute(); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs similarity index 80% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JavaEngine.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs index 58cdf49732..28b9b33596 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/JavaEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs @@ -1,29 +1,28 @@ -using System; -using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.Scripting; -using OpenSim.Region.Scripting.EmbeddedJVM; - -namespace OpenSim.Region.Scripting -{ - public class JavaEngine : IScriptCompiler - { - public string FileExt() - { - return ".java"; - } - - public Dictionary compile(string filename) - { - JVMScript script = new JVMScript(); - Dictionary returns = new Dictionary(); - - script.LoadScript(filename); - - returns.Add(filename, script); - - return returns; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +using OpenSim.Region.ExtensionsScriptModule; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine +{ + public class JavaEngine : IScriptCompiler + { + public string FileExt() + { + return ".java"; + } + + public Dictionary compile(string filename) + { + JVMScript script = new JVMScript(); + Dictionary returns = new Dictionary(); + + script.LoadScript(filename); + + returns.Add(filename, script); + + return returns; + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs similarity index 94% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/OpenSimJVM.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs index 9fb76d4851..f60d555909 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -1,170 +1,171 @@ -/* -* 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.Scripting; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Scripting.EmbeddedJVM -{ - public class JVMScript : IScript - { - private List _threads = new List(); - private BlockingQueue CompileScripts = new BlockingQueue(); - private MainMemory _mainMemory; - - ScriptInfo scriptInfo; - - public void Initialise(ScriptInfo info) - { - scriptInfo = info; - - _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; - Thread.World = info.world; - CompileScript(); - - scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); - scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); - } - - void events_OnNewPresence(ScenePresence presence) - { - for (int i = 0; i < this._threads.Count; i++) - { - if (!this._threads[i].running) - { - this._threads[i].StartMethod("OnNewPresence"); - bool run = true; - while (run) - { - run = this._threads[i].Excute(); - } - } - } - } - - void events_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(); - } - } - } - } - - public string Name - { - get { return "JVM Scripting Engine"; } - } - - public void LoadScript(string script) - { - Console.WriteLine("OpenSimJVM - loading new script: " + script); - CompileInfo comp = new CompileInfo(); - comp.script = script; - comp.scriptName = script; - this.CompileScripts.Enqueue(comp); - } - - public void CompileScript() - { - CompileInfo comp = this.CompileScripts.Dequeue(); - string script = comp.script; - string scriptName = comp.scriptName; - 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.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); - } - } - - private class CompileInfo - { - public string script; - public string scriptName; - - public CompileInfo() - { - - } - } - } -} +/* +* 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.Scenes; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; +using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine +{ + public class JVMScript : IScript + { + private List _threads = new List(); + private BlockingQueue CompileScripts = new BlockingQueue(); + private MainMemory _mainMemory; + + ScriptInfo scriptInfo; + + public void Initialise(ScriptInfo info) + { + scriptInfo = info; + + _mainMemory = new MainMemory(); + Thread.GlobalMemory = this._mainMemory; + Thread.World = info.world; + CompileScript(); + + scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame); + scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); + } + + void events_OnNewPresence(ScenePresence presence) + { + for (int i = 0; i < this._threads.Count; i++) + { + if (!this._threads[i].running) + { + this._threads[i].StartMethod("OnNewPresence"); + bool run = true; + while (run) + { + run = this._threads[i].Excute(); + } + } + } + } + + void events_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(); + } + } + } + } + + public string Name + { + get { return "JVM Scripting Engine"; } + } + + public void LoadScript(string script) + { + Console.WriteLine("OpenSimJVM - loading new script: " + script); + CompileInfo comp = new CompileInfo(); + comp.script = script; + comp.scriptName = script; + this.CompileScripts.Enqueue(comp); + } + + public void CompileScript() + { + CompileInfo comp = this.CompileScripts.Dequeue(); + string script = comp.script; + string scriptName = comp.scriptName; + 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.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); + } + } + + private class CompileInfo + { + public string script; + public string scriptName; + + public CompileInfo() + { + + } + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs similarity index 63% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ArrayReference.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs index 0c4d6239b5..97753cfe0c 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ArrayReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types -{ - public class ArrayReference :BaseType - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class ArrayReference :BaseType + { + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/BaseType.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs similarity index 61% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/BaseType.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs index 7fc0a4f6fb..d1689dfbf3 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/BaseType.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/BaseType.cs @@ -1,10 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types -{ - public class BaseType : Object - { - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class BaseType : Object + { + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs similarity index 72% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ObjectReference.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs index 7718765586..8e1d4356d2 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/ObjectReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs @@ -1,16 +1,16 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types -{ - public class ObjectReference : BaseType - { - public ushort Reference; - - public ObjectReference() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types +{ + public class ObjectReference : BaseType + { + public ushort Reference; + + public ObjectReference() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs new file mode 100644 index 0000000000..cfbbd19751 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Byte : BaseType + { + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs new file mode 100644 index 0000000000..650e1ed1c4 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs @@ -0,0 +1,11 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Char : BaseType + { + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs similarity index 55% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs index 982e7484c7..b5bcc646b3 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs @@ -1,16 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Float : BaseType - { - public float mValue = 0; - - public Float() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.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/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs similarity index 54% rename from OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs rename to OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs index 073a9b35fa..df133afe4f 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs @@ -1,16 +1,17 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Region.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Int : BaseType - { - public int mValue = 0; - - public Int() - { - - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; + +namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes +{ + public class Int : BaseType + { + public int mValue = 0; + + public Int() + { + + } + } +} diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj new file mode 100644 index 0000000000..51ce2ad1d6 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj @@ -0,0 +1,213 @@ + + + Local + 8.0.50727 + 2.0 + {DD34045D-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + + OpenSim.Region.ExtensionScriptEngine + JScript + Grid + IE50 + false + Library + + + OpenSim.Region.ExtensionScriptEngine + + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + + True + 4096 + False + ..\..\..\bin\ + False + False + False + 4 + + + + + False + 285212672 + False + + + TRACE + + + False + 4096 + True + ..\..\..\bin\ + False + False + False + 4 + + + + + + ..\..\..\bin\libsecondlife.dll + False + + + Microsoft.JScript.dll + False + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Region.Environment + {DCBA491C-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + 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 + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj.user b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj.user new file mode 100644 index 0000000000..b3114ad033 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim11-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.dll.build b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.dll.build new file mode 100644 index 0000000000..ab3b7f4fb8 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionScriptEngine.dll.build @@ -0,0 +1,78 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj new file mode 100644 index 0000000000..3bc95bbc71 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj @@ -0,0 +1,207 @@ + + + Local + 8.0.50727 + 2.0 + {512D761A-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Region.ExtensionsScriptModule + JScript + Grid + IE50 + false + Library + + OpenSim.Region.ExtensionsScriptModule + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\..\bin\ + False + False + False + 4 + + + + + ..\..\..\bin\Axiom.MathLib.dll + False + + + ..\..\..\bin\libsecondlife.dll + False + + + Microsoft.JScript.dll + False + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Region.Environment + {DCBA491C-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + 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 + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj.user b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj.user new file mode 100644 index 0000000000..b3114ad033 --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim11-07\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.dll.build b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.dll.build new file mode 100644 index 0000000000..5714dcba9d --- /dev/null +++ b/OpenSim/Region/ExtensionsScriptModule/OpenSim.Region.ExtensionsScriptModule.dll.build @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim/Region/Environment/Scenes/Scripting/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs similarity index 95% rename from OpenSim/Region/Environment/Scenes/Scripting/Script.cs rename to OpenSim/Region/ExtensionsScriptModule/Script.cs index e1e1d87249..839d1a571c 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -1,64 +1,64 @@ -/* -* 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 OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Scripting -{ - public interface IScript - { - void Initialise(ScriptInfo scriptInfo); - string Name { get; } - } - - public class TestScript : IScript - { - ScriptInfo script; - - public string Name - { - get { return "TestScript 0.1"; } - } - - public void Initialise(ScriptInfo scriptInfo) - { - script = scriptInfo; - script.events.OnFrame += events_OnFrame; - script.events.OnNewPresence += events_OnNewPresence; - } - - void events_OnNewPresence(ScenePresence presence) - { - script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); - } - - void events_OnFrame() - { - //script.logger.Verbose("Hello World!"); - } - } -} +/* +* 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 OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + public interface IScript + { + void Initialise(ScriptInfo scriptInfo); + string Name { get; } + } + + public class TestScript : IScript + { + ScriptInfo script; + + public string Name + { + get { return "TestScript 0.1"; } + } + + public void Initialise(ScriptInfo scriptInfo) + { + script = scriptInfo; + script.events.OnFrame += events_OnFrame; + script.events.OnNewPresence += events_OnNewPresence; + } + + void events_OnNewPresence(ScenePresence presence) + { + script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); + } + + void events_OnFrame() + { + //script.logger.Verbose("Hello World!"); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs similarity index 91% rename from OpenSim/Region/Environment/Scenes/Scripting/ScriptAPI.cs rename to OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs index b3a804dd6d..d32de7c88b 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs @@ -1,32 +1,32 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Key = libsecondlife.LLUUID; -using Rotation = libsecondlife.LLQuaternion; -using Vector = libsecondlife.LLVector3; -using LSLList = System.Collections.Generic.List; - - -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.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; - ScriptInterpretedAPI interpretedAPI; - - public ScriptAPI(Scene world, Key taskID) - { - scene = world; - interpretedAPI = new ScriptInterpretedAPI(world, taskID); - } - - public Object CallMethod(String method, Object[] args) - { - return null; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Key = libsecondlife.LLUUID; +using Rotation = libsecondlife.LLQuaternion; +using Vector = libsecondlife.LLVector3; +using LSLList = System.Collections.Generic.List; + + +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + // 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; + ScriptInterpretedAPI interpretedAPI; + + public ScriptAPI(Scene world, Key taskID) + { + scene = world; + interpretedAPI = new ScriptInterpretedAPI(world, taskID); + } + + public Object CallMethod(String method, Object[] args) + { + return null; + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs similarity index 95% rename from OpenSim/Region/Environment/Scenes/Scripting/ScriptInfo.cs rename to OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index 35a6d9f67e..f8eef1fb1b 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -1,63 +1,63 @@ -/* -* 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 OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Scripting -{ - /// - /// Class which provides access to the world - /// - public class ScriptInfo - { - // Reference to world.eventsManager provided for convenience - public EventManager events; - - // The main world - public Scene world; - - // 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(world, libsecondlife.LLUUID.Zero); - } - - public void CreateTaskAPI(libsecondlife.LLUUID task) - { - api = new ScriptAPI(world, task); - } - } -} +/* +* 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 OpenSim.Framework.Console; +using OpenSim.Region.Environment.Scenes; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + /// + /// Class which provides access to the world + /// + public class ScriptInfo + { + // Reference to world.eventsManager provided for convenience + public EventManager events; + + // The main world + public Scene world; + + // 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(world, libsecondlife.LLUUID.Zero); + } + + public void CreateTaskAPI(libsecondlife.LLUUID task) + { + api = new ScriptAPI(world, task); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs similarity index 96% rename from OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs rename to OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs index 4617feb455..c880bce7e8 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs @@ -1,267 +1,267 @@ -using System; -using System.Collections.Generic; -using System.Text; -using Key = libsecondlife.LLUUID; -using Rotation = libsecondlife.LLQuaternion; -using Vector = libsecondlife.LLVector3; -using LSLList = System.Collections.Generic.List; - -using OpenSim.Region.Environment.Scenes; -using OpenSim.Region.Environment.LandManagement; -using libsecondlife; - -namespace OpenSim.Region.Scripting -{ - /// - /// A class inteded to act as an API for LSL-styled interpreted languages - /// - /// Avoid at all costs. This should ONLY be used for LSL. - class ScriptInterpretedAPI - { - protected LLUUID m_object; - protected Scene m_scene; - - /// - /// The scene in which this script is acting - /// - public Scene Scene - { - get { return m_scene; } - } - - /// - /// The id of the object our script is supposed to be acting in - /// - public Key ObjectID - { - get { return m_object; } - } - - /// - /// The object our script is supposed to be in - /// - public SceneObjectGroup Task - { - get { return Scene.Objects[ObjectID]; } - } - - /// - /// Creates a new ScriptInterpretedAPI for a specified object - /// - /// The scene the object is located in - /// The specific member being 'occupied' by the script - public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) - { - m_scene = world; - m_object = member; - } - - /// - /// Returns the absolute number of a integer value. - /// - /// Input - /// Absolute number of input - public int osAbs(int val) - { - return Math.Abs(val); - } - - public float osAcos(float val) - { - return (float)Math.Acos(val); - } - - [Obsolete("Unimplemented")] - public void osAddToLandPassList(Key avatar, float hours) - { - Vector myPosition = Task.AbsolutePosition; - Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); - - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); - return; - } - - [Obsolete("Unimplemented")] - public void osAdjustSoundVolume(float volume) - { - OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); - return; - } - - [Obsolete("Unimplemented")] - public void osAllowInventoryDrop(int add) - { - return; - } - - [Obsolete("Unimplemented")] - public float osAngleBetween(Rotation a, Rotation b) - { - Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); - Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); - - return 0; - } - - [Obsolete("Unimplemented")] - public void osApplyImpulse(Vector force, int local) - { - return; - } - - [Obsolete("Unimplemented")] - public void osApplyRotationalImpulse(Vector force, int local) - { - return; - } - - public float osAsin(float val) - { - return (float)Math.Asin(val); - } - - public float osAtan2(float x, float y) - { - return (float)Math.Atan2(x, y); - } - - [Obsolete("Unimplemented")] - public void osAttachToAvatar(Key avatar, int attachmentPoint) - { - return; - } - - [Obsolete("Unimplemented")] - public Key osAvatarOnSitTarget() - { - //TODO: Follow this as Children is chanced to be of type entity to support ScenePresences - /* - foreach (KeyValuePair Child in Task.Children) - { - if (Child.Value is ScenePresence) - { - return Child.Value.uuid; - } - } - */ - - return Key.Zero; - } - - public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) - { - Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); - Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); - Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); - Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); - - axQ.FromAxes(axFwd, axLeft, axUp); - - return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); - } - - public Rotation osAxisAngle2Rot(Vector axis, float angle) - { - Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); - - return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); - } - - public string osBase64ToString(string str) - { - Encoding enc = System.Text.Encoding.UTF8; - return enc.GetString(Convert.FromBase64String(str)); - } - - [Obsolete("Unimplemented")] - public void osBreakAllLinks() - { - return; - } - - [Obsolete("Unimplemented")] - public void osBreakLink() - { - return; - } - - public LSLList osCSV2List(string src) - { - LSLList retVal = new LSLList(); - retVal.AddRange(src.Split(',')); - - return retVal; - } - - public int osCeil(float val) - { - return (int)Math.Ceiling(val); - } - - [Obsolete("Unimplemented")] - public void osCloseRemoteDataChannel(Key channel) - { - return; - } - - [Obsolete("Unimplemented")] - public float osCloud(Vector offset) - { - return 0.0f; - } - - [Obsolete("Unimplemented")] - public void osCollisionFilter(string name, Key id, int accept) - { - return; - } - - [Obsolete("Unimplemented")] - public void osCollisionSprite(string impact_sprite) - { - return; - } - - public float osCos(float theta) - { - return (float)Math.Cos(theta); - } - - public void osCreateLink(Key target, int parent) - { - if(Scene.Entities[target] is SceneObjectGroup) - Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); - - return; - } - - [Obsolete("Partially Unimplemented")] - public LSLList osDeleteSubList(LSLList src, int start, int end) - { - if (start < 0 || end < 0) - { - throw new Exception("Unsupported at this time."); - } - - src.RemoveRange(start, start - end + 1); - return src; - } - - [Obsolete("Partially Unimplemented")] - public string osDeleteSubString(string src, int start, int end) - { - if (start < 0 || end < 0) - { - throw new Exception("Unsupported at this time."); - } - - return src.Remove(start, start - end + 1); - } - - [Obsolete("Unimplemented")] - public void osDetachFromAvatar(Key avatar) - { - return; - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using Key = libsecondlife.LLUUID; +using Rotation = libsecondlife.LLQuaternion; +using Vector = libsecondlife.LLVector3; +using LSLList = System.Collections.Generic.List; + +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.LandManagement; +using libsecondlife; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + /// + /// A class inteded to act as an API for LSL-styled interpreted languages + /// + /// Avoid at all costs. This should ONLY be used for LSL. + class ScriptInterpretedAPI + { + protected LLUUID m_object; + protected Scene m_scene; + + /// + /// The scene in which this script is acting + /// + public Scene Scene + { + get { return m_scene; } + } + + /// + /// The id of the object our script is supposed to be acting in + /// + public Key ObjectID + { + get { return m_object; } + } + + /// + /// The object our script is supposed to be in + /// + public SceneObjectGroup Task + { + get { return Scene.Objects[ObjectID]; } + } + + /// + /// Creates a new ScriptInterpretedAPI for a specified object + /// + /// The scene the object is located in + /// The specific member being 'occupied' by the script + public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) + { + m_scene = world; + m_object = member; + } + + /// + /// Returns the absolute number of a integer value. + /// + /// Input + /// Absolute number of input + public int osAbs(int val) + { + return Math.Abs(val); + } + + public float osAcos(float val) + { + return (float)Math.Acos(val); + } + + [Obsolete("Unimplemented")] + public void osAddToLandPassList(Key avatar, float hours) + { + Vector myPosition = Task.AbsolutePosition; + Land myParcel = Scene.LandManager.getLandObject(myPosition.X, myPosition.Y); + + OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAddToLandPassList(Key avatar, float hours)"); + return; + } + + [Obsolete("Unimplemented")] + public void osAdjustSoundVolume(float volume) + { + OpenSim.Framework.Console.MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); + return; + } + + [Obsolete("Unimplemented")] + public void osAllowInventoryDrop(int add) + { + return; + } + + [Obsolete("Unimplemented")] + public float osAngleBetween(Rotation a, Rotation b) + { + Axiom.Math.Quaternion axA = new Axiom.Math.Quaternion(a.W, a.X, a.Y, a.Z); + Axiom.Math.Quaternion axB = new Axiom.Math.Quaternion(b.W, b.X, b.Y, b.Z); + + return 0; + } + + [Obsolete("Unimplemented")] + public void osApplyImpulse(Vector force, int local) + { + return; + } + + [Obsolete("Unimplemented")] + public void osApplyRotationalImpulse(Vector force, int local) + { + return; + } + + public float osAsin(float val) + { + return (float)Math.Asin(val); + } + + public float osAtan2(float x, float y) + { + return (float)Math.Atan2(x, y); + } + + [Obsolete("Unimplemented")] + public void osAttachToAvatar(Key avatar, int attachmentPoint) + { + return; + } + + [Obsolete("Unimplemented")] + public Key osAvatarOnSitTarget() + { + //TODO: Follow this as Children is chanced to be of type entity to support ScenePresences + /* + foreach (KeyValuePair Child in Task.Children) + { + if (Child.Value is ScenePresence) + { + return Child.Value.uuid; + } + } + */ + + return Key.Zero; + } + + public Rotation osAxes2Rot(Vector fwd, Vector left, Vector up) + { + Axiom.Math.Quaternion axQ = new Axiom.Math.Quaternion(); + Axiom.Math.Vector3 axFwd = new Axiom.Math.Vector3(fwd.X, fwd.Y, fwd.Z); + Axiom.Math.Vector3 axLeft = new Axiom.Math.Vector3(left.X, left.Y, left.Z); + Axiom.Math.Vector3 axUp = new Axiom.Math.Vector3(up.X, up.Y, up.Z); + + axQ.FromAxes(axFwd, axLeft, axUp); + + return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); + } + + public Rotation osAxisAngle2Rot(Vector axis, float angle) + { + Axiom.Math.Quaternion axQ = Axiom.Math.Quaternion.FromAngleAxis(angle, new Axiom.Math.Vector3(axis.X, axis.Y, axis.Z)); + + return new Rotation(axQ.x, axQ.y, axQ.z, axQ.w); + } + + public string osBase64ToString(string str) + { + Encoding enc = System.Text.Encoding.UTF8; + return enc.GetString(Convert.FromBase64String(str)); + } + + [Obsolete("Unimplemented")] + public void osBreakAllLinks() + { + return; + } + + [Obsolete("Unimplemented")] + public void osBreakLink() + { + return; + } + + public LSLList osCSV2List(string src) + { + LSLList retVal = new LSLList(); + retVal.AddRange(src.Split(',')); + + return retVal; + } + + public int osCeil(float val) + { + return (int)Math.Ceiling(val); + } + + [Obsolete("Unimplemented")] + public void osCloseRemoteDataChannel(Key channel) + { + return; + } + + [Obsolete("Unimplemented")] + public float osCloud(Vector offset) + { + return 0.0f; + } + + [Obsolete("Unimplemented")] + public void osCollisionFilter(string name, Key id, int accept) + { + return; + } + + [Obsolete("Unimplemented")] + public void osCollisionSprite(string impact_sprite) + { + return; + } + + public float osCos(float theta) + { + return (float)Math.Cos(theta); + } + + public void osCreateLink(Key target, int parent) + { + if(Scene.Entities[target] is SceneObjectGroup) + Task.LinkToGroup((SceneObjectGroup)Scene.Entities[target]); + + return; + } + + [Obsolete("Partially Unimplemented")] + public LSLList osDeleteSubList(LSLList src, int start, int end) + { + if (start < 0 || end < 0) + { + throw new Exception("Unsupported at this time."); + } + + src.RemoveRange(start, start - end + 1); + return src; + } + + [Obsolete("Partially Unimplemented")] + public string osDeleteSubString(string src, int start, int end) + { + if (start < 0 || end < 0) + { + throw new Exception("Unsupported at this time."); + } + + return src.Remove(start, start - end + 1); + } + + [Obsolete("Unimplemented")] + public void osDetachFromAvatar(Key avatar) + { + return; + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedEvents.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs similarity index 87% rename from OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedEvents.cs rename to OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs index 41fe9c539f..92c67b7e5a 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptInterpretedEvents.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs @@ -1,23 +1,23 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Region.Environment.Scenes; -using libsecondlife; -using Key = libsecondlife.LLUUID; - -namespace OpenSim.Region.Scripting -{ - - public class ScriptInterpretedEvents - { - public delegate void OnTouchStartDelegate(Key user); - public event OnTouchStartDelegate OnTouchStart; - - - public void TriggerTouchStart(Key user) - { - if (OnTouchStart != null) - OnTouchStart(user); - } - } -} +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Region.Environment.Scenes; +using libsecondlife; +using Key = libsecondlife.LLUUID; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + + public class ScriptInterpretedEvents + { + public delegate void OnTouchStartDelegate(Key user); + public event OnTouchStartDelegate OnTouchStart; + + + public void TriggerTouchStart(Key user) + { + if (OnTouchStart != null) + OnTouchStart(user); + } + } +} diff --git a/OpenSim/Region/Environment/Scenes/Scripting/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs similarity index 67% rename from OpenSim/Region/Environment/Scenes/Scripting/ScriptManager.cs rename to OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 3bd395ed26..a97979f2dd 100644 --- a/OpenSim/Region/Environment/Scenes/Scripting/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -1,107 +1,138 @@ -/* -* 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.Collections.Generic; -using OpenSim.Framework.Console; -using OpenSim.Region.Environment.Scenes; - -namespace OpenSim.Region.Scripting -{ - public class ScriptManager - { - List scripts = new List(); - Scene scene; - Dictionary compilers = new Dictionary(); - - private void LoadFromCompiler(Dictionary compiledscripts) - { - foreach (KeyValuePair script in compiledscripts) - { - ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - MainLog.Instance.Verbose("Loading " + script.Key); - script.Value.Initialise(scriptInfo); - scripts.Add(script.Value); - } - MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); - } - - public ScriptManager(Scene world) - { - scene = world; - - // Default Engines - CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); - compilers.Add(csharpCompiler.FileExt(),csharpCompiler); - - JScriptEngine jscriptCompiler = new JScriptEngine(); - compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); - - JavaEngine javaCompiler = new JavaEngine(); - compilers.Add(javaCompiler.FileExt(), javaCompiler); - } - - public void Compile(string filename) - { - foreach (KeyValuePair compiler in compilers) - { - if (filename.EndsWith(compiler.Key)) - { - LoadFromCompiler(compiler.Value.compile(filename)); - break; - } - } - } - - public void RunScriptCmd(string[] args) - { - switch (args[0]) - { - case "load": - Compile(args[1]); - break; - - default: - MainLog.Instance.Error("Unknown script command"); - break; - } - } - - public void AddPreCompiledScript(IScript script) - { - MainLog.Instance.Verbose("Loading script " + script.Name); - ScriptInfo scriptInfo = new ScriptInfo(scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. - script.Initialise(scriptInfo); - scripts.Add(script); - } - } - - interface IScriptCompiler - { - Dictionary compile(string filename); - string FileExt(); - } -} +/* +* 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.Collections.Generic; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment; +using OpenSim.Region.Environment.Scenes; +using OpenSim.Region.Environment.Interfaces; +using OpenSim.Region.ExtensionsScriptModule.CSharp; +using OpenSim.Region.ExtensionsScriptModule.JScript; +using OpenSim.Region.ExtensionsScriptModule.JVMEngine; + +namespace OpenSim.Region.ExtensionsScriptModule +{ + public class ScriptManager : IRegionModule + { + List scripts = new List(); + Scene m_scene; + Dictionary compilers = new Dictionary(); + + private void LoadFromCompiler(Dictionary compiledscripts) + { + foreach (KeyValuePair script in compiledscripts) + { + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + MainLog.Instance.Verbose("Loading " + script.Key); + script.Value.Initialise(scriptInfo); + scripts.Add(script.Value); + } + MainLog.Instance.Verbose("Finished loading " + compiledscripts.Count.ToString() + " script(s)"); + } + + public ScriptManager() + { + // Default Engines + CSharpScriptEngine csharpCompiler = new CSharpScriptEngine(); + compilers.Add(csharpCompiler.FileExt(),csharpCompiler); + + JScriptEngine jscriptCompiler = new JScriptEngine(); + compilers.Add(jscriptCompiler.FileExt(), jscriptCompiler); + + JavaEngine javaCompiler = new JavaEngine(); + compilers.Add(javaCompiler.FileExt(), javaCompiler); + } + + public void Initialise(Scene scene) + { + System.Console.WriteLine("Initialising Extensions Scripting Module"); + m_scene = scene; + + m_scene.RegisterAPIMethod("API_CompileExtensionScript", new ModuleAPIMethod(Compile)); + m_scene.RegisterAPIMethod("API_AddExtensionScript", new ModuleAPIMethod(AddPreCompiledScript)); + } + + public void PostInitialise() + { + + } + + public void CloseDown() + { + + } + + public string GetName() + { + return "ExtensionsScriptingModule"; + } + + public bool Compile(string filename, int dummyParam) + { + foreach (KeyValuePair compiler in compilers) + { + if (filename.EndsWith(compiler.Key)) + { + LoadFromCompiler(compiler.Value.compile(filename)); + break; + } + } + + return true; + } + + public void RunScriptCmd(string[] args) + { + switch (args[0]) + { + case "load": + Compile(args[1], 0); + break; + + default: + MainLog.Instance.Error("Unknown script command"); + break; + } + } + + public bool AddPreCompiledScript(IScript script, int dummyParam) + { + MainLog.Instance.Verbose("Loading script " + script.Name); + ScriptInfo scriptInfo = new ScriptInfo(m_scene); // Since each script could potentially corrupt their access with a stray assignment, making a new one for each script. + script.Initialise(scriptInfo); + scripts.Add(script); + + return true; + } + } + + interface IScriptCompiler + { + Dictionary compile(string filename); + string FileExt(); + } +} diff --git a/prebuild.xml b/prebuild.xml index 0dcaabc5be..2d475c7326 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -595,6 +595,34 @@ + + + + ../../../bin/ + + + + + ../../../bin/ + + + + ../../../bin/ + + + + + + + + + + + + + + +