From 67e12b95ea7b68f4904a7484d77ecfd787d16d0c Mon Sep 17 00:00:00 2001 From: lbsa71 Date: Tue, 30 Oct 2007 09:05:31 +0000 Subject: * Optimized usings * Shortened type references * Removed redundant 'this' qualifier --- .../Engines/CSharp/CSharpScriptEngine.cs | 13 +- .../Engines/CSharp/Examples/ExportRegionToLSL.cs | 16 +- .../Engines/JScript/JScriptEngine.cs | 5 +- .../Engines/JVMEngine/JVM/ClassInstance.cs | 5 +- .../Engines/JVMEngine/JVM/ClassRecord.cs | 222 +++++----- .../Engines/JVMEngine/JVM/Heap.cs | 5 +- .../Engines/JVMEngine/JVM/Interpreter.Logic.cs | 454 ++++++++++++--------- .../Engines/JVMEngine/JVM/Interpreter.Methods.cs | 44 +- .../Engines/JVMEngine/JVM/Interpreter.Return.cs | 6 +- .../Engines/JVMEngine/JVM/Interpreter.cs | 63 ++- .../Engines/JVMEngine/JVM/MainMemory.cs | 8 +- .../Engines/JVMEngine/JVM/MethodMemory.cs | 4 +- .../Engines/JVMEngine/JVM/Object.cs | 6 +- .../Engines/JVMEngine/JVM/OpCodes.cs | 6 +- .../Engines/JVMEngine/JVM/Stack.cs | 4 +- .../Engines/JVMEngine/JVM/StackFrame.cs | 5 +- .../Engines/JVMEngine/JVM/Thread.cs | 32 +- .../Engines/JVMEngine/JavaEngine.cs | 6 +- .../Engines/JVMEngine/OpenSimJVM.cs | 55 ++- .../Engines/JVMEngine/Types/ArrayReference.cs | 8 +- .../Engines/JVMEngine/Types/ObjectReference.cs | 7 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs | 7 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Char.cs | 7 +- .../JVMEngine/Types/PrimitiveTypes/Float.cs | 8 +- .../Engines/JVMEngine/Types/PrimitiveTypes/Int.cs | 8 +- OpenSim/Region/ExtensionsScriptModule/Script.cs | 8 +- OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs | 11 +- .../Region/ExtensionsScriptModule/ScriptInfo.cs | 7 +- .../ExtensionsScriptModule/ScriptInterpretedAPI.cs | 52 +-- .../ScriptInterpretedEvents.cs | 9 +- .../Region/ExtensionsScriptModule/ScriptManager.cs | 26 +- 31 files changed, 554 insertions(+), 563 deletions(-) (limited to 'OpenSim/Region/ExtensionsScriptModule') diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs index d4b27fc..176fc7b 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/CSharpScriptEngine.cs @@ -40,7 +40,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return ".cs"; } - private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) + private Dictionary LoadDotNetScript(CodeDomProvider compiler, string filename) { CompilerParameters compilerParams = new CompilerParameters(); CompilerResults compilerResults; @@ -66,15 +66,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp } else { - Dictionary scripts = new Dictionary(); - + 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()); + IScript script = + (IScript) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); string scriptName = "C#/" + script.Name; Console.WriteLine("Script: " + scriptName + " loaded."); @@ -94,10 +95,10 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp return null; } - public Dictionary compile(string filename) + public Dictionary compile(string filename) { CSharpCodeProvider csharpProvider = new CSharpCodeProvider(); return LoadDotNetScript(csharpProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs index 7ae4658..2d684d1 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/CSharp/Examples/ExportRegionToLSL.cs @@ -26,19 +26,13 @@ * */ -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; + private ScriptInfo script; public string Name { @@ -48,11 +42,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples public void Initialise(ScriptInfo scriptInfo) { script = scriptInfo; - + script.events.OnPluginConsole += new EventManager.OnPluginConsoleDelegate(ProcessConsoleMsg); } - void ProcessConsoleMsg(string[] args) + private void ProcessConsoleMsg(string[] args) { /*if (args[0].ToLower() == "lslexport") { @@ -79,7 +73,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples }*/ } - string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim) + private string processPrimitiveToString(SceneObjectPart prim) { /*string desc = prim.Description; string name = prim.Name; @@ -97,4 +91,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples return ""; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs index 4bde721..ea0e92a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JScript/JScriptEngine.cs @@ -74,7 +74,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript if (testInterface != null) { - IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); + IScript script = + (IScript) compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString()); string scriptName = "JS.NET/" + script.Name; Console.WriteLine("Script: " + scriptName + " loaded."); @@ -100,4 +101,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JScript return LoadDotNetScript(jscriptProvider, filename); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs index 6100c67..3f09099 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassInstance.cs @@ -25,9 +25,7 @@ * 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 @@ -40,7 +38,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public ClassInstance() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs index 5c3629c..3bcc824 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/ClassRecord.cs @@ -26,9 +26,8 @@ * */ using System; -using System.IO; using System.Collections.Generic; -using System.Text; +using System.IO; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; @@ -56,7 +55,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public ClassRecord() { - } public ClassInstance CreateNewInstance() @@ -72,7 +70,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { Console.WriteLine("loading script " + fileName); FileStream fs = File.OpenRead(fileName); - this.LoadClassFromBytes(ReadFully(fs)); + LoadClassFromBytes(ReadFully(fs)); fs.Close(); } @@ -80,9 +78,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { 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++]); + 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++) { @@ -92,13 +90,13 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //Console.WriteLine("start position is: " + i); switch (pooltype) { - case 1: //Utf8 - ushort uLength = (ushort)((data[i++] << 8) + data[i++]); + 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); + m_constantsPool.Add(utf8); break; case 3: //Int break; @@ -107,53 +105,53 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM case 7: //Class PoolClass pClass = new PoolClass(this); pClass.readValue(data, ref i); - this.m_constantsPool.Add(pClass); + m_constantsPool.Add(pClass); break; case 9: //FieldRef PoolFieldRef pField = new PoolFieldRef(this); pField.readValue(data, ref i); - this.m_constantsPool.Add(pField); + m_constantsPool.Add(pField); break; case 10: //Method PoolMethodRef pMeth = new PoolMethodRef(this); pMeth.readValue(data, ref i); - this.m_constantsPool.Add(pMeth); + m_constantsPool.Add(pMeth); break; - case 12: //NamedType + case 12: //NamedType PoolNamedType pNamed = new PoolNamedType(this); pNamed.readValue(data, ref i); - this.m_constantsPool.Add(pNamed); + 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++]); + 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) + if (m_constantsPool[m_thisClass - 1] is PoolClass) { - this.MClass = ((PoolClass)this.m_constantsPool[this.m_thisClass - 1]); + MClass = ((PoolClass) m_constantsPool[m_thisClass - 1]); } - m_interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + 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++]); + 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_fieldList.Add(fieldInf); } - m_methodCount = (ushort)((data[i++] << 8) + data[i++]); + 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); + m_methodsList.Add(methInf); } } @@ -161,7 +159,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int count = 0; count < m_methodCount; count++) { - this.m_methodsList[count].AddMethodCode(memory); + m_methodsList[count].AddMethodCode(memory); } } @@ -169,12 +167,12 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int count = 0; count < m_methodCount; count++) { - if (this.m_constantsPool[this.m_methodsList[count].NameIndex - 1] is PoolUtf8) + if (m_constantsPool[m_methodsList[count].NameIndex - 1] is PoolUtf8) { - if (((PoolUtf8)this.m_constantsPool[this.m_methodsList[count].NameIndex - 1]).Value == methodName) + if (((PoolUtf8) m_constantsPool[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); + thread.SetPC(m_methodsList[count].CodePointer); return true; } } @@ -191,7 +189,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM for (int i = 0; i < m_constantsPool.Count; i++) { - this.m_constantsPool[i].Print(); + m_constantsPool[i].Print(); } Console.WriteLine("Access flags: " + m_accessFlags); @@ -201,16 +199,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM for (int count = 0; count < m_fieldCount; count++) { Console.WriteLine(); - this.m_fieldList[count].Print(); + m_fieldList[count].Print(); } for (int count = 0; count < m_methodCount; count++) { Console.WriteLine(); - this.m_methodsList[count].Print(); + m_methodsList[count].Print(); } - Console.WriteLine("class name is " + this.MClass.Name.Value); + Console.WriteLine("class name is " + MClass.Name.Value); } public static byte[] ReadFully(Stream stream) @@ -229,11 +227,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } #region nested classes + public class PoolItem { public virtual void Print() { - } } @@ -245,21 +243,21 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { for (int i = 0; i < length; i++) { - int a = (int)data[pointer++]; + int a = (int) data[pointer++]; if ((a & 0x80) == 0) { - Value = Value + (char)a; + Value = Value + (char) a; } else if ((a & 0x20) == 0) { - int b = (int)data[pointer++]; - Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); + 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)); + int b = (int) data[pointer++]; + int c = (int) data[pointer++]; + Value = Value + (char) (((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); } } } @@ -272,7 +270,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM private class PoolInt : PoolItem { - } public class PoolClass : PoolItem @@ -289,15 +286,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + namePointer = (ushort) ((data[pointer++] << 8) + data[pointer++]); } public override void Print() { - this.Name = ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]); + Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]); Console.Write("Class type: " + namePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); - + Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value); } } @@ -316,14 +312,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[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]); + mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]); + mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]); Console.WriteLine("FieldRef type: " + classPointer + " , " + nameTypePointer); } } @@ -343,14 +339,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[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]); + mNameType = ((PoolNamedType) parent.m_constantsPool[nameTypePointer - 1]); + mClass = ((PoolClass) parent.m_constantsPool[classPointer - 1]); Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); } } @@ -370,16 +366,16 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void readValue(byte[] data, ref int pointer) { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - typePointer = (ushort)((data[pointer++] << 8) + data[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]); + Name = ((PoolUtf8) parent.m_constantsPool[namePointer - 1]); + Type = ((PoolUtf8) parent.m_constantsPool[typePointer - 1]); Console.Write("Named type: " + namePointer + " , " + typePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent.m_constantsPool[namePointer - 1]).Value); + Console.WriteLine(" // " + ((PoolUtf8) parent.m_constantsPool[namePointer - 1]).Value); } } @@ -402,23 +398,23 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void AddMethodCode(MethodMemory memory) { - Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); + Array.Copy(Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, Attributes[0].Code.Length); memory.Methodcount++; - this.CodePointer = memory.NextMethodPC; - memory.NextMethodPC += this.Attributes[0].Code.Length; + CodePointer = memory.NextMethodPC; + memory.NextMethodPC += 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++]); + 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); + MethodAttribute attri = new MethodAttribute(parent); attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); + Attributes.Add(attri); } } @@ -426,12 +422,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { 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("NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[DescriptorIndex - 1]).Value); Console.WriteLine("Attribute Count:" + AttributeCount); for (int i = 0; i < AttributeCount; i++) { - this.Attributes[i].Print(); + Attributes[i].Print(); } } @@ -457,30 +455,35 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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++]); + 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++]); + 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); + SubAttribute subAttri = new SubAttribute(parent); subAttri.ReadData(data, ref pointer); - this.SubAttributes.Add(subAttri); + 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("Name Index: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); Console.WriteLine("Length: " + Length); Console.WriteLine("MaxStack: " + MaxStack); Console.WriteLine("MaxLocals: " + MaxLocals); @@ -492,7 +495,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM Console.WriteLine("SubAttributes: " + SubAttributeCount); for (int i = 0; i < SubAttributeCount; i++) { - this.SubAttributes[i].Print(); + SubAttributes[i].Print(); } } @@ -511,8 +514,11 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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++]); + 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++) { @@ -522,18 +528,17 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void Print() { - Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); } - } } - } + private class InterfaceInfo { public void ReadData(byte[] data, ref int i) { - } } @@ -554,15 +559,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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++]); + 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); + FieldAttribute attri = new FieldAttribute(parent); attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); + Attributes.Add(attri); } } @@ -570,29 +575,30 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { 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("NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // " + + ((PoolUtf8) 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) + if ((AccessFlags & 0x08) != 0) { - switch (((PoolUtf8)this.parent.m_constantsPool[DescriptorIndex - 1]).Value) + switch (((PoolUtf8) 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); + parent.StaticFields.Add(((PoolUtf8) 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); + parent.StaticFields.Add(((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value, newfl); break; } - } for (int i = 0; i < AttributeCount; i++) { - this.Attributes[i].Print(); + Attributes[i].Print(); } } @@ -611,8 +617,10 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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++]); + 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++) { @@ -622,7 +630,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void Print() { - Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent.m_constantsPool[NameIndex - 1]).Value); + Console.WriteLine("FieldAttribute: NameIndex: " + NameIndex + " // " + + ((PoolUtf8) parent.m_constantsPool[NameIndex - 1]).Value); } } } @@ -631,10 +640,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public void ReadData(byte[] data, ref int i) { - } } - #endregion + #endregion } } \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs index c76767a..9876caa 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Heap.cs @@ -25,9 +25,7 @@ * 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 { @@ -37,7 +35,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public Heap() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs index 6b8930e..b172562 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Logic.cs @@ -25,9 +25,6 @@ * 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; @@ -42,304 +39,313 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM bool result = false; switch (opcode) { - case (byte)(byte)OpCode.iconst_m1: + case (byte) (byte) OpCode.iconst_m1: Int m_int = new Int(); m_int.mValue = -1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_0: + case (byte) (byte) OpCode.iconst_0: m_int = new Int(); m_int.mValue = 0; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_1: + case (byte) (byte) OpCode.iconst_1: m_int = new Int(); m_int.mValue = 1; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_2: + case (byte) (byte) OpCode.iconst_2: m_int = new Int(); m_int.mValue = 2; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)(byte)OpCode.iconst_3: + case (byte) (byte) OpCode.iconst_3: m_int = new Int(); m_int.mValue = 3; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); break; - case (byte)(byte)OpCode.iconst_4: + case (byte) (byte) OpCode.iconst_4: m_int = new Int(); m_int.mValue = 4; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)OpCode.iconst_5: + case (byte) OpCode.iconst_5: m_int = new Int(); m_int.mValue = 5; - this.m_thread.m_currentFrame.OpStack.Push(m_int); + m_thread.m_currentFrame.OpStack.Push(m_int); result = true; break; - case (byte)OpCode.fconst_0: + case (byte) OpCode.fconst_0: Float m_float = new Float(); m_float.mValue = 0.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + m_thread.m_currentFrame.OpStack.Push(m_float); result = true; break; - case (byte)OpCode.fconst_1: + case (byte) OpCode.fconst_1: m_float = new Float(); m_float.mValue = 1.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + m_thread.m_currentFrame.OpStack.Push(m_float); result = true; break; - case (byte)OpCode.fconst_2: + case (byte) OpCode.fconst_2: m_float = new Float(); m_float.mValue = 2.0f; - this.m_thread.m_currentFrame.OpStack.Push(m_float); + 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]; + case (byte) OpCode.bipush: //is this right? this should be pushing a byte onto stack not int? + int pushvalue = (int) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]; Int pushInt = new Int(); pushInt.mValue = pushvalue; - this.m_thread.m_currentFrame.OpStack.Push(pushInt); - this.m_thread.PC++; + m_thread.m_currentFrame.OpStack.Push(pushInt); + 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]); + case (byte) OpCode.sipush: + short pushvalue2 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); Int pushInt2 = new Int(); pushInt2.mValue = pushvalue2; - this.m_thread.m_currentFrame.OpStack.Push(pushInt2); - this.m_thread.PC += 2; + m_thread.m_currentFrame.OpStack.Push(pushInt2); + m_thread.PC += 2; result = true; break; - case (byte)OpCode.fload: - short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC])); + case (byte) OpCode.fload: + short findex1 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); Float fload = new Float(); - if (this.m_thread.m_currentFrame.LocalVariables[findex1] != null) + if (m_thread.m_currentFrame.LocalVariables[findex1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[findex1] is Float) + if (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); + fload.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[findex1]).mValue; + m_thread.m_currentFrame.OpStack.Push(fload); } } - this.m_thread.PC++; + m_thread.PC++; result = true; break; - case (byte)OpCode.iload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + case (byte) OpCode.iload_0: + if (m_thread.m_currentFrame.LocalVariables[0] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Int) + if (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); + newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[0]).mValue; + m_thread.m_currentFrame.OpStack.Push(newInt); } } result = true; break; - case (byte)OpCode.iload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + case (byte) OpCode.iload_1: + if (m_thread.m_currentFrame.LocalVariables[1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Int) + if (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); + newInt.mValue = ((Int) m_thread.m_currentFrame.LocalVariables[1]).mValue; + m_thread.m_currentFrame.OpStack.Push(newInt); } } result = true; break; - case (byte)OpCode.fload_0: - if (this.m_thread.m_currentFrame.LocalVariables[0] != null) + case (byte) OpCode.fload_0: + if (m_thread.m_currentFrame.LocalVariables[0] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[0] is Float) + if (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); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[0]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_1: - if (this.m_thread.m_currentFrame.LocalVariables[1] != null) + case (byte) OpCode.fload_1: + if (m_thread.m_currentFrame.LocalVariables[1] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[1] is Float) + if (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); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[1]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_2: - if (this.m_thread.m_currentFrame.LocalVariables[2] != null) + case (byte) OpCode.fload_2: + if (m_thread.m_currentFrame.LocalVariables[2] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[2] is Float) + if (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); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[2]).mValue; + m_thread.m_currentFrame.OpStack.Push(newfloat); } } result = true; break; - case (byte)OpCode.fload_3: - if (this.m_thread.m_currentFrame.LocalVariables[3] != null) + case (byte) OpCode.fload_3: + if (m_thread.m_currentFrame.LocalVariables[3] != null) { - if (this.m_thread.m_currentFrame.LocalVariables[3] is Float) + if (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); + newfloat.mValue = ((Float) m_thread.m_currentFrame.LocalVariables[3]).mValue; + 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(); + case (byte) OpCode.istore: + short findex3 = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); + BaseType istor = m_thread.m_currentFrame.OpStack.Pop(); if (istor is Int) { - this.m_thread.m_currentFrame.LocalVariables[findex3] = (Int)istor; + m_thread.m_currentFrame.LocalVariables[findex3] = (Int) istor; } - this.m_thread.PC++; + 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(); + case (byte) OpCode.fstore: + short findex = (short) ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC])); + BaseType fstor = m_thread.m_currentFrame.OpStack.Pop(); if (fstor is Float) { - this.m_thread.m_currentFrame.LocalVariables[findex] = (Float)fstor; + m_thread.m_currentFrame.LocalVariables[findex] = (Float) fstor; } - this.m_thread.PC++; + m_thread.PC++; result = true; break; - case (byte)OpCode.istore_0: - BaseType baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.istore_0: + BaseType baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Int) { - this.m_thread.m_currentFrame.LocalVariables[0] = (Int)baset; + m_thread.m_currentFrame.LocalVariables[0] = (Int) baset; } result = true; break; - case (byte)OpCode.istore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.istore_1: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Int) { - this.m_thread.m_currentFrame.LocalVariables[1] = (Int)baset; + m_thread.m_currentFrame.LocalVariables[1] = (Int) baset; } result = true; break; - case (byte)OpCode.fstore_0: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_0: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[0] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[0] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_1: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_1: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[1] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[1] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_2: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_2: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[2] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[2] = (Float) baset; } result = true; break; - case (byte)OpCode.fstore_3: - baset = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.fstore_3: + baset = m_thread.m_currentFrame.OpStack.Pop(); if (baset is Float) { - this.m_thread.m_currentFrame.LocalVariables[3] = (Float)baset; + m_thread.m_currentFrame.LocalVariables[3] = (Float) baset; } result = true; break; - case (byte)OpCode.pop: - this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.pop: + 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(); + case (byte) OpCode.fadd: + BaseType bf2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bf1 = 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); + nflt.mValue = ((Float) bf1).mValue + ((Float) bf2).mValue; + 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(); + case (byte) OpCode.fsub: + BaseType bsf2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bsf1 = 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); + resf.mValue = ((Float) bsf1).mValue - ((Float) bsf2).mValue; + 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(); + case (byte) OpCode.imul: //check the order of the two values off the stack is correct + BaseType bs2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bs1 = 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); + nInt.mValue = ((Int) bs1).mValue*((Int) bs2).mValue; + 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) + case (byte) OpCode.iinc: + if (m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]] != + null) { - if (this.m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC]] is Int) + if ( + m_thread.m_currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[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]; + ((Int) + m_thread.m_currentFrame.LocalVariables[ + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC]]).mValue += + (sbyte) GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]; } } - this.m_thread.PC += 2; + m_thread.PC += 2; result = true; break; - case (byte)OpCode.f2i: - BaseType conv1 = this.m_thread.m_currentFrame.OpStack.Pop(); + case (byte) OpCode.f2i: + BaseType conv1 = 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); + newconv.mValue = (int) ((Float) conv1).mValue; + 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(); + case (byte) OpCode.fcmpl: + BaseType flcom2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType flcom1 = m_thread.m_currentFrame.OpStack.Pop(); if (flcom1 is Float && flcom2 is Float) { Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + if (((Float) flcom1).mValue < ((Float) flcom2).mValue) { compres.mValue = -1; } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) { compres.mValue = 1; } @@ -347,21 +353,21 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { compres.mValue = 0; } - this.m_thread.m_currentFrame.OpStack.Push(compres); + 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(); + case (byte) OpCode.fcmpg: + flcom2 = m_thread.m_currentFrame.OpStack.Pop(); + flcom1 = m_thread.m_currentFrame.OpStack.Pop(); if (flcom1 is Float && flcom2 is Float) { Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + if (((Float) flcom1).mValue < ((Float) flcom2).mValue) { compres.mValue = -1; } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + else if (((Float) flcom1).mValue > ((Float) flcom2).mValue) { compres.mValue = 1; } @@ -369,128 +375,169 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { compres.mValue = 0; } - this.m_thread.m_currentFrame.OpStack.Push(compres); + 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(); + case (byte) OpCode.ifge: + short compareoffset2 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType compe1 = m_thread.m_currentFrame.OpStack.Pop(); if (compe1 is Int) { - if (((Int)compe1).mValue >= 0) + if (((Int) compe1).mValue >= 0) { - this.m_thread.PC += -1 + compareoffset2; + m_thread.PC += -1 + compareoffset2; } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + 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(); + case (byte) OpCode.ifle: + short compareoffset1 = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType comp1 = m_thread.m_currentFrame.OpStack.Pop(); if (comp1 is Int) { - if (((Int)comp1).mValue <= 0) + if (((Int) comp1).mValue <= 0) { - this.m_thread.PC += -1 + compareoffset1; + m_thread.PC += -1 + compareoffset1; } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + 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(); + case (byte) OpCode.if_icmpge: + short compareoffset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType bc2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bc1 = 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) + 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; + m_thread.PC += -1 + compareoffset; //Console.WriteLine("new PC is " + this._mThread.PC); } else { //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + 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(); + case (byte) OpCode.if_icmple: + short compareloffset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType bcl2 = m_thread.m_currentFrame.OpStack.Pop(); + BaseType bcl1 = 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) + 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; + m_thread.PC += -1 + compareloffset; // Console.WriteLine("new PC is " + this._mThread.PC); } else { //Console.WriteLine("branch compare false"); - this.m_thread.PC += 2; + m_thread.PC += 2; } } else { - this.m_thread.PC += 2; + 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; + case (byte) OpCode._goto: + short offset = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + 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) + case (byte) OpCode.getstatic: + short fieldrefIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + if (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) + if ( + ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). + mClass.Name.Value == 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 ( + m_thread.currentClass.StaticFields.ContainsKey( + ((ClassRecord.PoolFieldRef) + 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) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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); + retFloat.mValue = + ((Float) + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value]).mValue; + 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) + else if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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; + retInt.mValue = + ((Int) + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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); + m_thread.m_currentFrame.OpStack.Push(retInt); } } } @@ -499,36 +546,58 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //get from a different class } } - this.m_thread.PC += 2; + 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) + case (byte) OpCode.putstatic: + fieldrefIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + BaseType addstatic = m_thread.m_currentFrame.OpStack.Pop(); + if (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) + if ( + ((ClassRecord.PoolFieldRef) m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]). + mClass.Name.Value == 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 ( + m_thread.currentClass.StaticFields.ContainsKey( + ((ClassRecord.PoolFieldRef) + 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) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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; + newf.mValue = ((Float) addstatic).mValue; + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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) + if ( + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + 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; + newi.mValue = ((Int) addstatic).mValue; + m_thread.currentClass.StaticFields[ + ((ClassRecord.PoolFieldRef) + m_thread.currentClass.m_constantsPool[fieldrefIndex - 1]).mNameType. + Name.Value] = newi; } } } @@ -538,10 +607,9 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM // a different class } } - this.m_thread.PC += 2; + m_thread.PC += 2; result = true; break; - } return result; diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs index a5bd48b..b27630a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Methods.cs @@ -25,15 +25,6 @@ * 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; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; -using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { partial class Thread @@ -46,10 +37,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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) + short refIndex = + (short) + ((GlobalMemory.MethodArea.MethodBuffer[m_thread.PC] << 8) + + GlobalMemory.MethodArea.MethodBuffer[m_thread.PC + 1]); + if (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 typ = + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]). + mNameType.Type.Value; string typeparam = ""; string typereturn = ""; int firstbrak = 0; @@ -58,16 +54,22 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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) + if ( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass + .Name.Value == 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)); + m_thread.JumpToStaticVoidMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, (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)); + m_thread.JumpToStaticParamMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, typeparam, (m_thread.PC + 2)); } } else @@ -75,15 +77,19 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM //calling a method of a different class // OpenSimAPI Class - if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + if ( + ((ClassRecord.PoolMethodRef) 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); + m_thread.scriptInfo.api.CallMethod( + ((ClassRecord.PoolMethodRef) m_thread.currentClass.m_constantsPool[refIndex - 1]) + .mNameType.Name.Value, null); } } } else { - this.m_thread.PC += 2; + m_thread.PC += 2; } result = true; break; @@ -93,4 +99,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs index 5a42285..2814720 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.Return.cs @@ -25,10 +25,6 @@ * 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 @@ -37,4 +33,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs index 698a518..4e7351e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Interpreter.cs @@ -26,8 +26,6 @@ * */ using System; -using System.Collections.Generic; -using System.Text; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes; @@ -47,77 +45,77 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public bool Excute() { bool run = true; - byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++]; - // Console.WriteLine("opCode is: " + currentOpCode); + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[m_thread.PC++]; + // Console.WriteLine("opCode is: " + currentOpCode); bool handled = false; - handled = this.IsLogicOpCode(currentOpCode); + handled = IsLogicOpCode(currentOpCode); if (!handled) { - handled = this.IsMethodOpCode(currentOpCode); + handled = IsMethodOpCode(currentOpCode); } if (!handled) { if (currentOpCode == 172) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (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; + int retPC1 = m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = m_thread.m_currentFrame.OpStack.Pop(); + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC1; if (bas1 is Int) { - this.m_thread.m_currentFrame.OpStack.Push((Int)bas1); + m_thread.m_currentFrame.OpStack.Push((Int) bas1); } } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; } if (currentOpCode == 174) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (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; + int retPC1 = m_thread.m_currentFrame.ReturnPC; + BaseType bas1 = m_thread.m_currentFrame.OpStack.Pop(); + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC1; if (bas1 is Float) { - this.m_thread.m_currentFrame.OpStack.Push((Float)bas1); + m_thread.m_currentFrame.OpStack.Push((Float) bas1); } } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; } if (currentOpCode == 177) { - if (this.m_thread.stack.StackFrames.Count > 1) + if (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; + int retPC = m_thread.m_currentFrame.ReturnPC; + m_thread.stack.StackFrames.Pop(); + m_thread.m_currentFrame = m_thread.stack.StackFrames.Peek(); + m_thread.PC = retPC; } else { - // Console.WriteLine("No parent function so ending program"); - this.m_thread.stack.StackFrames.Pop(); + // Console.WriteLine("No parent function so ending program"); + m_thread.stack.StackFrames.Pop(); run = false; } handled = true; @@ -128,8 +126,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM Console.WriteLine("opcode " + currentOpCode + " not been handled "); } return run; - } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs index 34d4fc5..adad1a8 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MainMemory.cs @@ -25,21 +25,17 @@ * 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(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs index f470583..86df4c2 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/MethodMemory.cs @@ -25,9 +25,7 @@ * 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 { @@ -43,4 +41,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM MethodBuffer = new byte[20000]; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs index 21e467a..1d9cabb 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Object.cs @@ -25,13 +25,9 @@ * 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 { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs index 9fcec49..616b64e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/OpCodes.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { public enum OpCode : byte @@ -81,4 +77,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM getstatic = 178, putstatic = 179 } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs index 56e02ff..4f6c1e7 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Stack.cs @@ -25,9 +25,7 @@ * 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 { @@ -39,4 +37,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs index a5f9029..306a70d 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/StackFrame.cs @@ -25,9 +25,7 @@ * 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 @@ -44,6 +42,5 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { LocalVariables = new BaseType[20]; } - } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs index b810676..64093ef 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JVM/Thread.cs @@ -25,15 +25,9 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ -using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Environment.Scenes; 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 { @@ -55,8 +49,8 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public Thread() { - this.m_Interpreter = new Interpreter(this); - this.stack = new Stack(); + m_Interpreter = new Interpreter(this); + stack = new Stack(); } public void SetPC(int methodpointer) @@ -68,15 +62,15 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM public void StartMethod(ClassRecord rec, string methName) { m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); - this.currentClass = rec; + stack.StackFrames.Push(m_currentFrame); + currentClass = rec; currentClass.StartMethod(this, methName); } - public void StartMethod( string methName) + public void StartMethod(string methName) { m_currentFrame = new StackFrame(); - this.stack.StackFrames.Push(m_currentFrame); + stack.StackFrames.Push(m_currentFrame); currentClass.StartMethod(this, methName); } @@ -84,7 +78,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM { m_currentFrame = new StackFrame(); m_currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(m_currentFrame); + stack.StackFrames.Push(m_currentFrame); currentClass.StartMethod(this, methName); } @@ -95,25 +89,23 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM 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); + 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(); + return m_Interpreter.Excute(); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs index 0f0ff16..ea99626 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/JavaEngine.cs @@ -26,11 +26,7 @@ * */ -using System; using System.Collections.Generic; -using System.Text; - -using OpenSim.Region.ExtensionsScriptModule; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine { @@ -53,4 +49,4 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine return returns; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs index b1258f6..274932a 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/OpenSimJVM.cs @@ -27,15 +27,11 @@ */ using System; using System.Collections.Generic; -using System.Text; +using System.Diagnostics; using System.IO; -using System.Threading; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; using OpenSim.Framework; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM; -using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread; namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine { @@ -45,14 +41,14 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine private BlockingQueue CompileScripts = new BlockingQueue(); private MainMemory _mainMemory; - ScriptInfo scriptInfo; + private ScriptInfo scriptInfo; public void Initialise(ScriptInfo info) { scriptInfo = info; _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; + Thread.GlobalMemory = _mainMemory; Thread.World = info.world; CompileScript(); @@ -60,33 +56,33 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence); } - void events_OnNewPresence(ScenePresence presence) + private void events_OnNewPresence(ScenePresence presence) { - for (int i = 0; i < this._threads.Count; i++) + for (int i = 0; i < _threads.Count; i++) { - if (!this._threads[i].running) + if (!_threads[i].running) { - this._threads[i].StartMethod("OnNewPresence"); + _threads[i].StartMethod("OnNewPresence"); bool run = true; while (run) { - run = this._threads[i].Excute(); + run = _threads[i].Excute(); } } } } - void events_OnFrame() + private void events_OnFrame() { - for (int i = 0; i < this._threads.Count; i++) + for (int i = 0; i < _threads.Count; i++) { - if (!this._threads[i].running) + if (!_threads[i].running) { - this._threads[i].StartMethod("OnFrame"); + _threads[i].StartMethod("OnFrame"); bool run = true; while (run) { - run = this._threads[i].Excute(); + run = _threads[i].Excute(); } } } @@ -103,12 +99,12 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine CompileInfo comp = new CompileInfo(); comp.script = script; comp.scriptName = script; - this.CompileScripts.Enqueue(comp); + CompileScripts.Enqueue(comp); } public void CompileScript() { - CompileInfo comp = this.CompileScripts.Dequeue(); + CompileInfo comp = CompileScripts.Dequeue(); string script = comp.script; string scriptName = comp.scriptName; try @@ -121,13 +117,13 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine tw.Close(); //now compile - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); + ProcessStartInfo psi = new ProcessStartInfo("javac.exe", "*.java"); // psi.RedirectStandardOutput = true; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + psi.WindowStyle = ProcessWindowStyle.Hidden; psi.UseShellExecute = false; - System.Diagnostics.Process javacomp; - javacomp = System.Diagnostics.Process.Start(psi); + Process javacomp; + javacomp = Process.Start(psi); javacomp.WaitForExit(); @@ -136,17 +132,17 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine class1.LoadClassFromFile(scriptName + ".class"); class1.PrintToConsole(); //Console.WriteLine(); - this._mainMemory.MethodArea.Classes.Add(class1); - class1.AddMethodsToMemory(this._mainMemory.MethodArea); + _mainMemory.MethodArea.Classes.Add(class1); + class1.AddMethodsToMemory(_mainMemory.MethodArea); Thread newThread = new Thread(); - this._threads.Add(newThread); + _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"); + File.Delete(scriptName + ".java"); + File.Delete(scriptName + ".class"); //this.OnFrame(); } catch (Exception e) @@ -164,8 +160,7 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine public CompileInfo() { - } } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs index a36ad77..3c82952 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ArrayReference.cs @@ -26,13 +26,9 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types { - public class ArrayReference :BaseType + public class ArrayReference : BaseType { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs index 5921446..4026c10 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/ObjectReference.cs @@ -26,10 +26,6 @@ * */ -using System; -using System.Collections.Generic; -using System.Text; - namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types { public class ObjectReference : BaseType @@ -38,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types public ObjectReference() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs index aa59681..de1aa87 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Byte.cs @@ -26,14 +26,9 @@ * */ -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 { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs index 1cef150..0e17057 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Char.cs @@ -26,14 +26,9 @@ * */ -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 { } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs index 0614dfd..ce8648c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Float.cs @@ -26,11 +26,6 @@ * */ -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 @@ -39,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes public Float() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs index 35f9822..251b736 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Engines/JVMEngine/Types/PrimitiveTypes/Int.cs @@ -26,11 +26,6 @@ * */ -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 @@ -39,7 +34,6 @@ namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes public Int() { - } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/Script.cs b/OpenSim/Region/ExtensionsScriptModule/Script.cs index 251b8c3..5f85799 100644 --- a/OpenSim/Region/ExtensionsScriptModule/Script.cs +++ b/OpenSim/Region/ExtensionsScriptModule/Script.cs @@ -37,7 +37,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public class TestScript : IScript { - ScriptInfo script; + private ScriptInfo script; public string Name { @@ -51,14 +51,14 @@ namespace OpenSim.Region.ExtensionsScriptModule script.events.OnNewPresence += events_OnNewPresence; } - void events_OnNewPresence(ScenePresence presence) + private void events_OnNewPresence(ScenePresence presence) { script.logger.Verbose("Hello " + presence.Firstname.ToString() + "!"); } - void events_OnFrame() + private void events_OnFrame() { //script.logger.Verbose("Hello World!"); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs index 39dc878..9384efa 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptAPI.cs @@ -27,24 +27,21 @@ */ using System; -using System.Collections.Generic; -using System.Text; +using OpenSim.Region.Environment.Scenes; 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; + private Scene scene; + private ScriptInterpretedAPI interpretedAPI; public ScriptAPI(Scene world, Key taskID) { @@ -57,4 +54,4 @@ namespace OpenSim.Region.ExtensionsScriptModule return null; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs index aaadd1f..cfa3c8e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInfo.cs @@ -25,6 +25,7 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * */ +using libsecondlife; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Scenes; @@ -52,12 +53,12 @@ namespace OpenSim.Region.ExtensionsScriptModule world = scene; events = world.EventManager; logger = MainLog.Instance; - api = new ScriptAPI(world, libsecondlife.LLUUID.Zero); + api = new ScriptAPI(world, LLUUID.Zero); } - public void CreateTaskAPI(libsecondlife.LLUUID task) + public void CreateTaskAPI(LLUUID task) { api = new ScriptAPI(world, task); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs index eb85dbe..2895c4e 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedAPI.cs @@ -27,26 +27,25 @@ */ using System; -using System.Collections.Generic; using System.Text; +using Axiom.Math; +using OpenSim.Framework.Console; +using OpenSim.Region.Environment.LandManagement; +using OpenSim.Region.Environment.Scenes; 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 + internal class ScriptInterpretedAPI { - protected LLUUID m_object; + protected Key m_object; protected Scene m_scene; /// @@ -78,7 +77,7 @@ namespace OpenSim.Region.ExtensionsScriptModule /// /// The scene the object is located in /// The specific member being 'occupied' by the script - public ScriptInterpretedAPI(Scene world, libsecondlife.LLUUID member) + public ScriptInterpretedAPI(Scene world, Key member) { m_scene = world; m_object = member; @@ -96,7 +95,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osAcos(float val) { - return (float)Math.Acos(val); + return (float) Math.Acos(val); } [Obsolete("Unimplemented")] @@ -105,14 +104,15 @@ namespace OpenSim.Region.ExtensionsScriptModule 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)"); + 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)"); + MainLog.Instance.Warn("script", "Unimplemented function called by script: osAdjustSoundVolume(float volume)"); return; } @@ -125,8 +125,8 @@ namespace OpenSim.Region.ExtensionsScriptModule [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); + Quaternion axA = new Quaternion(a.W, a.X, a.Y, a.Z); + Quaternion axB = new Quaternion(b.W, b.X, b.Y, b.Z); return 0; } @@ -145,12 +145,12 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osAsin(float val) { - return (float)Math.Asin(val); + return (float) Math.Asin(val); } public float osAtan2(float x, float y) { - return (float)Math.Atan2(x, y); + return (float) Math.Atan2(x, y); } [Obsolete("Unimplemented")] @@ -178,10 +178,10 @@ namespace OpenSim.Region.ExtensionsScriptModule 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); + Quaternion axQ = new Quaternion(); + Vector3 axFwd = new Vector3(fwd.X, fwd.Y, fwd.Z); + Vector3 axLeft = new Vector3(left.X, left.Y, left.Z); + Vector3 axUp = new Vector3(up.X, up.Y, up.Z); axQ.FromAxes(axFwd, axLeft, axUp); @@ -190,14 +190,14 @@ namespace OpenSim.Region.ExtensionsScriptModule 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)); + Quaternion axQ = Quaternion.FromAngleAxis(angle, new 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; + Encoding enc = Encoding.UTF8; return enc.GetString(Convert.FromBase64String(str)); } @@ -223,7 +223,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public int osCeil(float val) { - return (int)Math.Ceiling(val); + return (int) Math.Ceiling(val); } [Obsolete("Unimplemented")] @@ -252,13 +252,13 @@ namespace OpenSim.Region.ExtensionsScriptModule public float osCos(float theta) { - return (float)Math.Cos(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]); + if (Scene.Entities[target] is SceneObjectGroup) + Task.LinkToGroup((SceneObjectGroup) Scene.Entities[target]); return; } @@ -292,4 +292,4 @@ namespace OpenSim.Region.ExtensionsScriptModule return; } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs index 068df33..44feaff 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptInterpretedEvents.cs @@ -26,19 +26,14 @@ * */ -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; @@ -48,4 +43,4 @@ namespace OpenSim.Region.ExtensionsScriptModule OnTouchStart(user); } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs index 95ab2ca..2778e9c 100644 --- a/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs +++ b/OpenSim/Region/ExtensionsScriptModule/ScriptManager.cs @@ -26,27 +26,28 @@ * */ using System.Collections.Generic; +using Nini.Config; using OpenSim.Framework.Console; using OpenSim.Region.Environment.Interfaces; using OpenSim.Region.Environment.Scenes; using OpenSim.Region.ExtensionsScriptModule.CSharp; using OpenSim.Region.ExtensionsScriptModule.JScript; using OpenSim.Region.ExtensionsScriptModule.JVMEngine; -using Nini.Config; namespace OpenSim.Region.ExtensionsScriptModule { public class ScriptManager : IRegionModule, IExtensionScriptModule { - readonly List scripts = new List(); - Scene m_scene; - readonly Dictionary compilers = new Dictionary(); + private readonly List scripts = new List(); + private Scene m_scene; + private readonly 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. + 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); @@ -70,7 +71,7 @@ namespace OpenSim.Region.ExtensionsScriptModule public void Initialise(Scene scene, IConfigSource config) { - OpenSim.Framework.Console.MainLog.Instance.Verbose("SCRIPTMODULE", "Initialising Extensions Scripting Module"); + MainLog.Instance.Verbose("SCRIPTMODULE", "Initialising Extensions Scripting Module"); m_scene = scene; m_scene.RegisterModuleInterface(this); @@ -78,12 +79,10 @@ namespace OpenSim.Region.ExtensionsScriptModule public void PostInitialise() { - } public void Close() { - } public string Name @@ -92,8 +91,8 @@ namespace OpenSim.Region.ExtensionsScriptModule } public bool IsSharedModule -{ - get { return false; } + { + get { return false; } } public bool Compile(string filename) @@ -127,7 +126,8 @@ namespace OpenSim.Region.ExtensionsScriptModule public bool AddPreCompiledScript(IScript script) { 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. + 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); @@ -141,9 +141,9 @@ namespace OpenSim.Region.ExtensionsScriptModule bool AddPreCompiledScript(IScript script); } - interface IScriptCompiler + internal interface IScriptCompiler { Dictionary compile(string filename); string FileExt(); } -} +} \ No newline at end of file -- cgit v1.1