From 00b7058e000d7871df2ae40075ead1042e8e81ac Mon Sep 17 00:00:00 2001 From: MW Date: Wed, 11 Apr 2007 13:32:50 +0000 Subject: Attempt to rearrange some of the directories --- OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs | 18 - OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs | 476 --------------------- OpenSim.Scripting.EmbeddedJVM/Heap.cs | 16 - OpenSim.Scripting.EmbeddedJVM/Interpreter.cs | 108 ----- OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs | 400 ----------------- .../InterpreterMethods.cs | 140 ------ OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs | 13 - OpenSim.Scripting.EmbeddedJVM/MainMemory.cs | 18 - OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs | 19 - OpenSim.Scripting.EmbeddedJVM/Object.cs | 10 - .../OpenSim.Scripting.EmbeddedJVM.csproj | 153 ------- .../OpenSim.Scripting.EmbeddedJVM.csproj.user | 12 - .../OpenSim.Scripting.EmbeddedJVM.dll.build | 62 --- OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs | 134 ------ .../Properties/AssemblyInfo.cs | 33 -- OpenSim.Scripting.EmbeddedJVM/Stack.cs | 15 - OpenSim.Scripting.EmbeddedJVM/StackFrame.cs | 22 - OpenSim.Scripting.EmbeddedJVM/Thread.cs | 88 ---- .../Types/ArrayReference.cs | 10 - OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs | 10 - .../Types/ObjectReference.cs | 16 - .../Types/PrimitiveTypes/Byte.cs | 10 - .../Types/PrimitiveTypes/Char.cs | 10 - .../Types/PrimitiveTypes/Float.cs | 16 - .../Types/PrimitiveTypes/Int.cs | 16 - OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs | 18 + OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs | 476 +++++++++++++++++++++ OpenSim.Scripting/EmbeddedJVM/Heap.cs | 16 + OpenSim.Scripting/EmbeddedJVM/Interpreter.cs | 108 +++++ OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs | 400 +++++++++++++++++ .../EmbeddedJVM/InterpreterMethods.cs | 140 ++++++ OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs | 13 + OpenSim.Scripting/EmbeddedJVM/MainMemory.cs | 18 + OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs | 19 + OpenSim.Scripting/EmbeddedJVM/Object.cs | 10 + .../OpenSim.Scripting.EmbeddedJVM.csproj | 153 +++++++ .../OpenSim.Scripting.EmbeddedJVM.csproj.user | 12 + .../OpenSim.Scripting.EmbeddedJVM.dll.build | 62 +++ OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs | 134 ++++++ .../EmbeddedJVM/Properties/AssemblyInfo.cs | 33 ++ OpenSim.Scripting/EmbeddedJVM/Stack.cs | 15 + OpenSim.Scripting/EmbeddedJVM/StackFrame.cs | 22 + OpenSim.Scripting/EmbeddedJVM/Thread.cs | 88 ++++ .../EmbeddedJVM/Types/ArrayReference.cs | 10 + OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs | 10 + .../EmbeddedJVM/Types/ObjectReference.cs | 16 + .../EmbeddedJVM/Types/PrimitiveTypes/Byte.cs | 10 + .../EmbeddedJVM/Types/PrimitiveTypes/Char.cs | 10 + .../EmbeddedJVM/Types/PrimitiveTypes/Float.cs | 16 + .../EmbeddedJVM/Types/PrimitiveTypes/Int.cs | 16 + .../BDBLocalStorage.cs | 90 ---- .../OpenSim.Storage.LocalStorageBerkeleyDB.csproj | 115 ----- ...penSim.Storage.LocalStorageBerkeleyDB.dll.build | 47 -- .../Properties/AssemblyInfo.cs | 35 -- .../OpenSim.Storage.LocalStorageSQLite.csproj | 111 ----- .../OpenSim.Storage.LocalStorageSQLite.dll.build | 46 -- .../Properties/AssemblyInfo.cs | 35 -- .../SQLiteLocalStorage.cs | 171 -------- .../LocalStorageBerkeleyDB/BDBLocalStorage.cs | 90 ++++ .../OpenSim.Storage.LocalStorageBerkeleyDB.csproj | 112 +++++ ...nSim.Storage.LocalStorageBerkeleyDB.csproj.user | 12 + ...penSim.Storage.LocalStorageBerkeleyDB.dll.build | 46 ++ .../OpenSim.Storage.LocalStorageSQLite.csproj | 111 +++++ .../OpenSim.Storage.LocalStorageSQLite.csproj.user | 12 + .../OpenSim.Storage.LocalStorageSQLite.dll.build | 46 ++ .../LocalStorageSQLite/Properties/AssemblyInfo.cs | 35 ++ .../LocalStorageSQLite/SQLiteLocalStorage.cs | 171 ++++++++ OpenSim.build | 18 +- OpenSim.sln | 8 +- prebuild.xml | 24 +- 70 files changed, 2485 insertions(+), 2500 deletions(-) delete mode 100644 OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Heap.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Interpreter.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/MainMemory.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Object.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj delete mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user delete mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build delete mode 100644 OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Stack.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/StackFrame.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Thread.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs delete mode 100644 OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Heap.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Interpreter.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/MainMemory.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Object.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj create mode 100644 OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user create mode 100644 OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build create mode 100644 OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Stack.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/StackFrame.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Thread.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs create mode 100644 OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs delete mode 100644 OpenSim.Storage.LocalStorageBerkeleyDB/BDBLocalStorage.cs delete mode 100644 OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj delete mode 100644 OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build delete mode 100644 OpenSim.Storage.LocalStorageBerkeleyDB/Properties/AssemblyInfo.cs delete mode 100644 OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj delete mode 100644 OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build delete mode 100644 OpenSim.Storage.LocalStorageSQLite/Properties/AssemblyInfo.cs delete mode 100644 OpenSim.Storage.LocalStorageSQLite/SQLiteLocalStorage.cs create mode 100644 OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs create mode 100644 OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj create mode 100644 OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user create mode 100644 OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build create mode 100644 OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj create mode 100644 OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user create mode 100644 OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build create mode 100644 OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs create mode 100644 OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs diff --git a/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs b/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs deleted file mode 100644 index 15ef814..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/ClassInstance.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class ClassInstance : Object - { - public int size; - public Dictionary Fields = new Dictionary(); - - public ClassInstance() - { - - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs b/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs deleted file mode 100644 index 15d8a4b..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/ClassRecord.cs +++ /dev/null @@ -1,476 +0,0 @@ -using System; -using System.IO; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class ClassRecord - { - private ushort _majorVersion; - private ushort _minorVersion; - private ushort _constantPoolCount; - private ushort _accessFlags; - private ushort _thisClass; - private ushort _supperClass; - private ushort _interfaceCount; - private ushort _fieldCount; - private ushort _methodCount; - private ushort _attributeCount; - private string _name; - public Dictionary StaticFields = new Dictionary(); - public PoolClass mClass; - - public List _constantsPool = new List(); - private List _methodsList = new List(); - private List _fieldList = new List(); - - public ClassRecord() - { - - } - - public ClassInstance CreateNewInstance() - { - return new ClassInstance(); - } - - public void LoadClassFromFile(string fileName) - { - Console.WriteLine("loading script " + fileName); - FileStream fs = File.OpenRead(fileName); - this.LoadClassFromBytes(ReadFully(fs)); - fs.Close(); - } - - public void LoadClassFromBytes(byte[] data) - { - int i = 0; - i += 4; - _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); - _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); - _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); - // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); - for (int count = 0; count < _constantPoolCount -1 ; count++) - { - //read in the constant pool - byte pooltype = data[i++]; - //Console.WriteLine("#" +count +": new constant type = " +pooltype); - //Console.WriteLine("start position is: " + i); - switch (pooltype) - { - case 1: //Utf8 - ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); - - // Console.WriteLine("new utf8 type, length is " + uLength); - PoolUtf8 utf8 = new PoolUtf8(); - utf8.readValue(data, ref i, uLength); - this._constantsPool.Add(utf8); - break; - case 3: //Int - break; - case 7: //Class - PoolClass pClass = new PoolClass(this); - pClass.readValue(data, ref i); - this._constantsPool.Add(pClass); - break; - case 10: //Method - PoolMethodRef pMeth = new PoolMethodRef(this); - pMeth.readValue(data, ref i); - this._constantsPool.Add(pMeth); - break; - case 12: //NamedType - PoolNamedType pNamed = new PoolNamedType(this); - pNamed.readValue(data, ref i); - this._constantsPool.Add(pNamed); - break; - } - } - - _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); - _thisClass = (ushort)((data[i++] << 8) + data[i++] ); - _supperClass = (ushort)((data[i++] << 8) + data[i++] ); - - if (this._constantsPool[this._thisClass - 1] is PoolClass) - { - this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); - } - - _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each interface - _fieldCount = (ushort)((data[i++] << 8) + data[i++]); - //should now read in the info for each field - _methodCount = (ushort)((data[i++] << 8) + data[i++]); - for (int count = 0; count < _methodCount; count++) - { - MethodInfo methInf = new MethodInfo(this); - methInf.ReadData(data, ref i); - this._methodsList.Add(methInf); - } - } - - public void AddMethodsToMemory(MethodMemory memory) - { - for (int count = 0; count < _methodCount; count++) - { - this._methodsList[count].AddMethodCode(memory); - } - } - - public bool StartMethod(Thread thread, string methodName) - { - for (int count = 0; count < _methodCount; count++) - { - if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) - { - if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) - { - //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); - thread.SetPC(this._methodsList[count].CodePointer); - return true; - } - } - } - return false; - } - - public void PrintToConsole() - { - Console.WriteLine("Class File:"); - Console.WriteLine("Major version: " + _majorVersion); - Console.WriteLine("Minor version: " + _minorVersion); - Console.WriteLine("Pool size: " + _constantPoolCount); - - for (int i = 0; i < _constantsPool.Count; i++) - { - this._constantsPool[i].Print(); - } - - Console.WriteLine("Access flags: " + _accessFlags); - Console.WriteLine("This class: " + _thisClass ); - Console.WriteLine("Super class: " + _supperClass); - - for (int count = 0; count < _methodCount; count++) - { - Console.WriteLine(); - this._methodsList[count].Print(); - } - - Console.WriteLine("class name is " + this.mClass.Name.Value); - } - - public static byte[] ReadFully(Stream stream) - { - byte[] buffer = new byte[1024]; - using (MemoryStream ms = new MemoryStream()) - { - while (true) - { - int read = stream.Read(buffer, 0, buffer.Length); - if (read <= 0) - return ms.ToArray(); - ms.Write(buffer, 0, read); - } - } - } - - #region nested classes - public class PoolItem - { - public virtual void Print() - { - - } - } - - public class PoolUtf8 : PoolItem - { - public string Value = ""; - - public void readValue(byte[] data,ref int pointer , int length) - { - for (int i = 0; i < length; i++) - { - int a =(int) data[pointer++]; - if ((a & 0x80) == 0) - { - Value = Value + (char)a; - } - else if ((a & 0x20) == 0) - { - int b = (int) data[pointer++]; - Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); - } - else - { - int b = (int)data[pointer++]; - int c = (int)data[pointer++]; - Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); - } - } - } - - public override void Print() - { - Console.WriteLine("Utf8 type: " + Value); - } - } - - private class PoolInt : PoolItem - { - - } - - public class PoolClass : PoolItem - { - //public string name = ""; - public ushort namePointer = 0; - private ClassRecord parent; - public PoolUtf8 Name; - - public PoolClass(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); - } - - public override void Print() - { - this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); - Console.Write("Class type: " + namePointer); - Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); - - } - } - - public class PoolMethodRef : PoolItem - { - public ushort classPointer = 0; - public ushort nameTypePointer = 0; - public PoolNamedType mNameType; - public PoolClass mClass; - private ClassRecord parent; - - public PoolMethodRef(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); - } - - public override void Print() - { - this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); - this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); - Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); - } - } - - public class PoolNamedType : PoolItem - { - public ushort namePointer = 0; - public ushort typePointer = 0; - private ClassRecord parent; - public PoolUtf8 Name; - public PoolUtf8 Type; - - public PoolNamedType(ClassRecord paren) - { - parent = paren; - } - - public void readValue(byte[] data, ref int pointer) - { - namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); - typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); - } - - public override void Print() - { - Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); - Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); - Console.Write("Named type: " + namePointer + " , " + typePointer ); - Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); - } - } - - //*********************** - public class MethodInfo - { - public ushort AccessFlags = 0; - public ushort NameIndex = 0; - public string Name = ""; - public ushort DescriptorIndex = 0; - public ushort AttributeCount = 0; - public List Attributes = new List(); - private ClassRecord parent; - public int CodePointer = 0; - - public MethodInfo(ClassRecord paren) - { - parent = paren; - } - - public void AddMethodCode(MethodMemory memory) - { - Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); - memory.Methodcount++; - this.CodePointer = memory.NextMethodPC; - memory.NextMethodPC += this.Attributes[0].Code.Length; - } - - public void ReadData(byte[] data, ref int pointer) - { - AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); - for(int i =0; i< AttributeCount; i++) - { - MethodAttribute attri = new MethodAttribute(this.parent); - attri.ReadData(data, ref pointer); - this.Attributes.Add(attri); - } - } - - public void Print() - { - Console.WriteLine("Method Info Struct: "); - Console.WriteLine("AccessFlags: " + AccessFlags); - Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); - Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); - Console.WriteLine("Attribute Count:" + AttributeCount); - for (int i = 0; i < AttributeCount; i++) - { - this.Attributes[i].Print(); - } - } - - public class MethodAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - //for now only support code attribute - public ushort MaxStack = 0; - public ushort MaxLocals = 0; - public Int32 CodeLength = 0; - public byte[] Code; - public ushort ExceptionTableLength = 0; - public ushort SubAttributeCount = 0; - public List SubAttributes = new List(); - private ClassRecord parent; - - public MethodAttribute(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); - MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); - CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - Code = new byte[CodeLength]; - for (int i = 0; i < CodeLength; i++) - { - Code[i] = data[pointer++]; - } - ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); - SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); - for (int i = 0; i < SubAttributeCount; i++) - { - SubAttribute subAttri = new SubAttribute(this.parent); - subAttri.ReadData(data, ref pointer); - this.SubAttributes.Add(subAttri); - } - } - - public void Print() - { - Console.WriteLine("Method Attribute: "); - Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); - Console.WriteLine("Length: " + Length); - Console.WriteLine("MaxStack: " + MaxStack); - Console.WriteLine("MaxLocals: " + MaxLocals); - Console.WriteLine("CodeLength: " + CodeLength); - for (int i = 0; i < Code.Length; i++) - { - Console.WriteLine("OpCode #" + i + " is: " + Code[i]); - } - Console.WriteLine("SubAttributes: " + SubAttributeCount); - for (int i = 0; i < SubAttributeCount; i++) - { - this.SubAttributes[i].Print(); - } - } - - public class SubAttribute - { - public ushort NameIndex = 0; - public string Name = ""; - public Int32 Length = 0; - public byte[] Data; - private ClassRecord parent; - - public SubAttribute(ClassRecord paren) - { - parent = paren; - } - - public void ReadData(byte[] data, ref int pointer) - { - NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); - Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); - Data = new byte[Length]; - for (int i = 0; i < Length; i++) - { - Data[i] = data[pointer++]; - } - } - - public void Print() - { - Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); - } - - } - } - - } - private class InterfaceInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - private class FieldInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - private class AttributeInfo - { - public void ReadData(byte[] data, ref int i) - { - - } - } - #endregion - - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Heap.cs b/OpenSim.Scripting.EmbeddedJVM/Heap.cs deleted file mode 100644 index 138e85e..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Heap.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class Heap - { - public List ClassObjects = new List(); - - public Heap() - { - - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs b/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs deleted file mode 100644 index b94248c..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Interpreter.cs +++ /dev/null @@ -1,108 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; -using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - private Thread _mThread; - - public Interpreter(Thread parentThread) - { - _mThread = parentThread; - } - - public bool Excute() - { - bool run = true; - byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; - // Console.WriteLine("opCode is: " + currentOpCode); - bool handled = false; - - handled = this.IsLogicOpCode(currentOpCode); - if (!handled) - { - handled = this.IsMethodOpCode(currentOpCode); - } - if (!handled) - { - if (currentOpCode == 172) - { - if (this._mThread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning int from function"); - int retPC1 = this._mThread.currentFrame.ReturnPC; - BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); - this._mThread.stack.StackFrames.Pop(); - this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); - this._mThread.PC = retPC1; - if (bas1 is Int) - { - this._mThread.currentFrame.OpStack.Push((Int)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this._mThread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 174) - { - if (this._mThread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning float from function"); - int retPC1 = this._mThread.currentFrame.ReturnPC; - BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); - this._mThread.stack.StackFrames.Pop(); - this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); - this._mThread.PC = retPC1; - if (bas1 is Float) - { - this._mThread.currentFrame.OpStack.Push((Float)bas1); - } - } - else - { - // Console.WriteLine("No parent function so ending program"); - this._mThread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - if (currentOpCode == 177) - { - if (this._mThread.stack.StackFrames.Count > 1) - { - Console.WriteLine("returning from function"); - int retPC = this._mThread.currentFrame.ReturnPC; - this._mThread.stack.StackFrames.Pop(); - this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); - this._mThread.PC = retPC; - } - else - { - // Console.WriteLine("No parent function so ending program"); - this._mThread.stack.StackFrames.Pop(); - run = false; - } - handled = true; - } - } - if (!handled) - { - Console.WriteLine("opcode " + currentOpCode + " not been handled "); - } - return run; - - } - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs deleted file mode 100644 index 3b7da35..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/InterpreterLogic.cs +++ /dev/null @@ -1,400 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; -using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - private bool IsLogicOpCode(byte opcode) - { - bool result = false; - switch (opcode) - { - case 2: - Int m_int= new Int(); - m_int.mValue = -1; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 3: - m_int= new Int(); - m_int.mValue = 0; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 4: - m_int = new Int(); - m_int.mValue = 1; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 5: - m_int = new Int(); - m_int.mValue = 2; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 6: - m_int = new Int(); - m_int.mValue = 3; - this._mThread.currentFrame.OpStack.Push(m_int); - break; - case 7: - m_int = new Int(); - m_int.mValue = 4; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 8: - m_int = new Int(); - m_int.mValue = 5; - this._mThread.currentFrame.OpStack.Push(m_int); - result = true; - break; - case 11: - Float m_float = new Float(); - m_float.mValue = 0.0f; - this._mThread.currentFrame.OpStack.Push(m_float); - result = true; - break; - case 12: - m_float = new Float(); - m_float.mValue = 1.0f; - this._mThread.currentFrame.OpStack.Push(m_float); - result = true; - break; - case 13: - m_float = new Float(); - m_float.mValue = 2.0f; - this._mThread.currentFrame.OpStack.Push(m_float); - result = true; - break; - case 16: - int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; - Int pushInt = new Int(); - pushInt.mValue = pushvalue; - this._mThread.currentFrame.OpStack.Push(pushInt); - this._mThread.PC++; - result = true; - break; - case 17: - short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); - Int pushInt2 = new Int(); - pushInt2.mValue = pushvalue2; - this._mThread.currentFrame.OpStack.Push(pushInt2); - this._mThread.PC += 2; - result = true; - break; - case 23: - short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); - Float fload = new Float(); - if (this._mThread.currentFrame.LocalVariables[findex1] != null) - { - if (this._mThread.currentFrame.LocalVariables[findex1] is Float) - { - fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; - this._mThread.currentFrame.OpStack.Push(fload); - } - } - this._mThread.PC++; - result = true; - break; - case 26: - if (this._mThread.currentFrame.LocalVariables[0] != null) - { - if (this._mThread.currentFrame.LocalVariables[0] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; - this._mThread.currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case 27: - if (this._mThread.currentFrame.LocalVariables[1] != null) - { - if (this._mThread.currentFrame.LocalVariables[1] is Int) - { - Int newInt = new Int(); - newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; - this._mThread.currentFrame.OpStack.Push(newInt); - } - } - result = true; - break; - case 34: - if (this._mThread.currentFrame.LocalVariables[0] != null) - { - if (this._mThread.currentFrame.LocalVariables[0] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; - this._mThread.currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case 35: - if (this._mThread.currentFrame.LocalVariables[1] != null) - { - if (this._mThread.currentFrame.LocalVariables[1] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; - this._mThread.currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case 36: - if (this._mThread.currentFrame.LocalVariables[2] != null) - { - if (this._mThread.currentFrame.LocalVariables[2] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; - this._mThread.currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case 37: - if (this._mThread.currentFrame.LocalVariables[3] != null) - { - if (this._mThread.currentFrame.LocalVariables[3] is Float) - { - Float newfloat = new Float(); - newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; - this._mThread.currentFrame.OpStack.Push(newfloat); - } - } - result = true; - break; - case 56: - short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); - BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); - if (fstor is Float) - { - this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; - } - this._mThread.PC++; - result = true; - break; - case 59: - BaseType baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Int) - { - this._mThread.currentFrame.LocalVariables[0] = (Int)baset; - } - result = true; - break; - case 60: - baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Int) - { - this._mThread.currentFrame.LocalVariables[1] = (Int)baset; - } - result = true; - break; - case 67: - baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Float) - { - this._mThread.currentFrame.LocalVariables[0] = (Float)baset; - } - result = true; - break; - case 68: - baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Float) - { - this._mThread.currentFrame.LocalVariables[1] = (Float)baset; - } - result = true; - break; - case 69: - baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Float) - { - this._mThread.currentFrame.LocalVariables[2] = (Float)baset; - } - result = true; - break; - case 70: - baset = this._mThread.currentFrame.OpStack.Pop(); - if (baset is Float) - { - this._mThread.currentFrame.LocalVariables[3] = (Float)baset; - } - result = true; - break; - case 87: - this._mThread.currentFrame.OpStack.Pop(); - result = true; - break; - case 98: - BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); - if (bf1 is Float && bf2 is Float) - { - Float nflt = new Float(); - nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; - this._mThread.currentFrame.OpStack.Push(nflt); - } - result = true; - break; - case 102: - BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); - if (bsf1 is Float && bsf2 is Float) - { - Float resf = new Float(); - resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; - this._mThread.currentFrame.OpStack.Push(resf); - } - result = true; - break; - case 104: //check the order of the two values off the stack is correct - BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); - if (bs1 is Int && bs2 is Int) - { - Int nInt = new Int(); - nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; - this._mThread.currentFrame.OpStack.Push(nInt); - } - result = true; - break; - case 132: - if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) - { - if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) - { - ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; - } - } - this._mThread.PC += 2; - result = true; - break; - case 139: - BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); - if (conv1 is Float) - { - Int newconv = new Int(); - newconv.mValue = (int)((Float)conv1).mValue; - this._mThread.currentFrame.OpStack.Push(newconv); - } - result = true; - break; - case 149: - BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); - if (flcom1 is Float && flcom2 is Float) - { - Int compres = new Int(); - if (((Float)flcom1).mValue < ((Float)flcom2).mValue) - { - compres.mValue = -1; - } - else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) - { - compres.mValue = 1; - } - else - { - compres.mValue = 0; - } - this._mThread.currentFrame.OpStack.Push(compres); - } - result = true; - break; - case 158: - short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); - BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); - if (comp1 is Int) - { - if (((Int)comp1).mValue <= 0) - { - this._mThread.PC += -1 + compareoffset1; - } - else - { - this._mThread.PC += 2; - } - } - else - { - this._mThread.PC += 2; - } - result = true; - break; - case 162: - short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); - BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); - if (bc1 is Int && bc2 is Int) - { - //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); - if (((Int)bc1).mValue >= ((Int)bc2).mValue) - { - // Console.WriteLine("branch compare true , offset is " +compareoffset); - // Console.WriteLine("current PC is " + this._mThread.PC); - this._mThread.PC += -1 + compareoffset; - //Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this._mThread.PC += 2; - } - } - else - { - this._mThread.PC += 2; - } - result = true; - break; - case 164: - short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); - BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); - if (bcl1 is Int && bcl2 is Int) - { - //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); - if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) - { - // Console.WriteLine("branch compare true , offset is " + compareloffset); - // Console.WriteLine("current PC is " + this._mThread.PC); - this._mThread.PC += -1 + compareloffset; - // Console.WriteLine("new PC is " + this._mThread.PC); - } - else - { - //Console.WriteLine("branch compare false"); - this._mThread.PC += 2; - } - } - else - { - this._mThread.PC += 2; - } - result = true; - break; - case 167: - short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); - this._mThread.PC += -1 + offset; - result = true; - break; - } - - return result; - } - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs deleted file mode 100644 index dc3402e..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/InterpreterMethods.cs +++ /dev/null @@ -1,140 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; -using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - private bool IsMethodOpCode(byte opcode) - { - bool result = false; - switch (opcode) - { - case 184: - short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); - //Console.WriteLine("call to method : "+refIndex); - if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) - { - // Console.WriteLine("which is " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value + "." + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value); - // Console.WriteLine("of type " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value); - string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; - string typeparam = ""; - string typereturn = ""; - int firstbrak = 0; - int secondbrak = 0; - firstbrak = typ.LastIndexOf('('); - secondbrak = typ.LastIndexOf(')'); - typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); - typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); - //Console.WriteLine("split is " + typeparam + " which is length " + typeparam.Length + " , " + typereturn); - if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) - { - //calling a method in this class - if (typeparam.Length == 0) - { - this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); - } - else - { - this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); - } - } - else - { - //calling a method of a different class - - //for now we will have a built in OpenSimAPI class, but this should be a java class that then calls native methods - if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") - { - switch (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value) - { - case "GetEntityID": - Int entityID = new Int(); - entityID.mValue =(int) this._mThread.EntityId; - this._mThread.currentFrame.OpStack.Push(entityID); - this._mThread.PC += 2; - break; - case "GetRandomAvatarID": - entityID = new Int(); - entityID.mValue = (int)Thread.OpenSimScriptAPI.GetRandomAvatarID(); - this._mThread.currentFrame.OpStack.Push(entityID); - this._mThread.PC += 2; - break; - case "GetEntityPositionX": - BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); - if (bs1 is Int) - { - //Console.WriteLine("get entity pos for " + ((Int)bs1).mValue); - //should get the position of the entity from the IScriptAPI - OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); - Float pos = new Float(); - pos.mValue = vec3.X; - // Console.WriteLine("returned x value " + vec3.X.ToString()); - this._mThread.currentFrame.OpStack.Push(pos); - } - this._mThread.PC += 2; - break; - case "GetEntityPositionY": - bs1 = this._mThread.currentFrame.OpStack.Pop(); - if (bs1 is Int) - { - //should get the position of the entity from the IScriptAPI - OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); - Float pos = new Float(); - pos.mValue = vec3.Y; - this._mThread.currentFrame.OpStack.Push(pos); - } - this._mThread.PC += 2; - break; - case "GetEntityPositionZ": - bs1 = this._mThread.currentFrame.OpStack.Pop(); - if (bs1 is Int) - { - //should get the position of the entity from the IScriptAPI - OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); - Float pos = new Float(); - pos.mValue = vec3.Z; - this._mThread.currentFrame.OpStack.Push(pos); - } - this._mThread.PC += 2; - break; - case "SetEntityPosition": - //pop the three float values and the entity id - BaseType ft3 = this._mThread.currentFrame.OpStack.Pop(); - BaseType ft2 = this._mThread.currentFrame.OpStack.Pop(); - BaseType ft1 = this._mThread.currentFrame.OpStack.Pop(); - BaseType in1 = this._mThread.currentFrame.OpStack.Pop(); - if (ft1 is Float && ft2 is Float && ft3 is Float) - { - if(in1 is Int) - { - //Console.WriteLine("set: " + ((Int)in1).mValue + " , " + ((Float)ft1).mValue + " , " + ((Float)ft2).mValue + " , " + ((Float)ft3).mValue); - Thread.OpenSimScriptAPI.SetEntityPosition((uint)((Int) in1).mValue, ((Float)ft1).mValue, ((Float)ft2).mValue, ((Float)ft3).mValue); - } - } - this._mThread.PC += 2; - break; - } - } - } - } - else - { - this._mThread.PC += 2; - } - result = true; - break; - } - - return result; - } - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs b/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs deleted file mode 100644 index 6704e31..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/InterpreterReturn.cs +++ /dev/null @@ -1,13 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - partial class Thread - { - private partial class Interpreter - { - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs b/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs deleted file mode 100644 index ff18f90..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/MainMemory.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class MainMemory - { - public Heap HeapArea; - public MethodMemory MethodArea; - - public MainMemory() - { - MethodArea = new MethodMemory(); - HeapArea = new Heap(); - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs b/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs deleted file mode 100644 index 2541991..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/MethodMemory.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class MethodMemory - { - public byte[] MethodBuffer; - public List Classes = new List(); - public int NextMethodPC = 0; - public int Methodcount = 0; - - public MethodMemory() - { - MethodBuffer = new byte[20000]; - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Object.cs b/OpenSim.Scripting.EmbeddedJVM/Object.cs deleted file mode 100644 index e6e392c..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Object.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class Object - { - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj b/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj deleted file mode 100644 index 90aeff8..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj +++ /dev/null @@ -1,153 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {97A82740-0000-0000-0000-000000000000} - Debug - AnyCPU - - - - OpenSim.Scripting.EmbeddedJVM - JScript - Grid - IE50 - false - Library - - OpenSim.Scripting.EmbeddedJVM - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - True - 4096 - False - ..\bin\ScriptEngines\ - False - False - False - 4 - - - - False - 285212672 - False - - - TRACE - - False - 4096 - True - ..\bin\ScriptEngines\ - False - False - False - 4 - - - - - System.dll - False - - - System.Xml.dll - False - - - - - OpenSim.Framework - {8ACA2445-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user b/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user deleted file mode 100644 index ea58087..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user +++ /dev/null @@ -1,12 +0,0 @@ - - - Debug - AnyCPU - C:\Documents and Settings\Stefan\My Documents\source\opensim\trunk\bin\ - 8.0.50727 - ProjectFiles - 0 - - - - diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build b/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build deleted file mode 100644 index 46067c1..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs b/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs deleted file mode 100644 index b47bb50..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/OpenSimJVM.cs +++ /dev/null @@ -1,134 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using System.IO; -using System.Threading; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Utilities; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class OpenSimJVM : IScriptEngine - { - private List _threads = new List(); - private BlockingQueue CompileScripts = new BlockingQueue(); - private MainMemory _mainMemory; - private System.Threading.Thread compileThread; - - public OpenSimJVM() - { - - } - - public bool Init(IScriptAPI api) - { - Console.WriteLine("Creating OpenSim JVM scripting engine"); - _mainMemory = new MainMemory(); - Thread.GlobalMemory = this._mainMemory; - Thread.OpenSimScriptAPI = api; - compileThread = new System.Threading.Thread(new ThreadStart(CompileScript)); - compileThread.IsBackground = true; - compileThread.Start(); - return true; - } - - public string GetName() - { - return "OpenSimJVM"; - } - - public void LoadScript(string script, string scriptName, uint entityID) - { - Console.WriteLine("OpenSimJVM - loading new script: " + scriptName); - CompileInfo comp = new CompileInfo(); - comp.entityId = entityID; - comp.script = script; - comp.scriptName = scriptName; - this.CompileScripts.Enqueue(comp); - } - - public void CompileScript() - { - while (true) - { - CompileInfo comp = this.CompileScripts.Dequeue(); - string script = comp.script; - string scriptName = comp.scriptName; - uint entityID = comp.entityId; - try - { - //need to compile the script into a java class file - - //first save it to a java source file - TextWriter tw = new StreamWriter(scriptName + ".java"); - tw.WriteLine(script); - tw.Close(); - - //now compile - System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); - // psi.RedirectStandardOutput = true; - psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; - psi.UseShellExecute = false; - - System.Diagnostics.Process javacomp; - javacomp = System.Diagnostics.Process.Start(psi); - javacomp.WaitForExit(); - - - //now load in class file - ClassRecord class1 = new ClassRecord(); - class1.LoadClassFromFile(scriptName + ".class"); - class1.PrintToConsole(); - //Console.WriteLine(); - this._mainMemory.MethodArea.Classes.Add(class1); - class1.AddMethodsToMemory(this._mainMemory.MethodArea); - - Thread newThread = new Thread(); - this._threads.Add(newThread); - newThread.EntityId = entityID; - newThread.currentClass = class1; - - //now delete the created files - System.IO.File.Delete(scriptName + ".java"); - System.IO.File.Delete(scriptName + ".class"); - //this.OnFrame(); - } - catch (Exception e) - { - Console.WriteLine("exception"); - Console.WriteLine(e.StackTrace); - Console.WriteLine(e.Message); - } - } - } - - public void OnFrame() - { - for (int i = 0; i < this._threads.Count; i++) - { - if (!this._threads[i].running) - { - this._threads[i].StartMethod("OnFrame"); - bool run = true; - while (run) - { - run = this._threads[i].Excute(); - } - } - } - } - - private class CompileInfo - { - public string script; - public string scriptName; - public uint entityId; - - public CompileInfo() - { - - } - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs b/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs deleted file mode 100644 index 53a0f08..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,33 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Scripting.EmbeddedJVM")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Scripting.EmbeddedJVM")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("087c0917-5a6a-4b47-a4dd-0928dd85bd4b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Scripting.EmbeddedJVM/Stack.cs b/OpenSim.Scripting.EmbeddedJVM/Stack.cs deleted file mode 100644 index d77d82e..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Stack.cs +++ /dev/null @@ -1,15 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class Stack - { - public Stack StackFrames = new Stack(); - - public Stack() - { - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs b/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs deleted file mode 100644 index afca7a9..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/StackFrame.cs +++ /dev/null @@ -1,22 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public class StackFrame - { - public BaseType[] LocalVariables; - public Stack OpStack = new Stack(); - - public int ReturnPC = 0; - public ClassRecord CallingClass = null; - - public StackFrame() - { - LocalVariables = new BaseType[20]; - } - - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Thread.cs b/OpenSim.Scripting.EmbeddedJVM/Thread.cs deleted file mode 100644 index 436949c..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Thread.cs +++ /dev/null @@ -1,88 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; -using OpenSim.Scripting.EmbeddedJVM.Types; -using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; -using OpenSim.Framework; -using OpenSim.Framework.Interfaces; - -namespace OpenSim.Scripting.EmbeddedJVM -{ - public partial class Thread - { - public static MainMemory GlobalMemory; - public static IScriptAPI OpenSimScriptAPI; - private int PC = 0; - private Stack stack; - private Interpreter mInterpreter; - public ClassRecord currentClass; - public ClassInstance currentInstance; - private StackFrame currentFrame; - public int excutionCounter = 0; - public bool running = false; - public uint EntityId = 0; - - public Thread() - { - this.mInterpreter = new Interpreter(this); - this.stack = new Stack(); - } - - public void SetPC(int methodpointer) - { - //Console.WriteLine("Thread PC has been set to " + methodpointer); - PC = methodpointer; - } - - public void StartMethod(ClassRecord rec, string methName) - { - currentFrame = new StackFrame(); - this.stack.StackFrames.Push(currentFrame); - this.currentClass = rec; - currentClass.StartMethod(this, methName); - } - - public void StartMethod( string methName) - { - currentFrame = new StackFrame(); - this.stack.StackFrames.Push(currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticVoidMethod(string methName, int returnPC) - { - currentFrame = new StackFrame(); - currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(currentFrame); - currentClass.StartMethod(this, methName); - } - - public void JumpToStaticParamMethod(string methName, string param, int returnPC) - { - if (param == "I") - { - BaseType bs1 = currentFrame.OpStack.Pop(); - currentFrame = new StackFrame(); - currentFrame.ReturnPC = returnPC; - this.stack.StackFrames.Push(currentFrame); - currentFrame.LocalVariables[0] = ((Int)bs1); - currentClass.StartMethod(this, methName); - } - if (param == "F") - { - - } - } - - public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) - { - - } - - public bool Excute() - { - excutionCounter++; - return this.mInterpreter.Excute(); - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs b/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs deleted file mode 100644 index 2854eab..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/ArrayReference.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types -{ - public class ArrayReference :BaseType - { - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs b/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs deleted file mode 100644 index 270aa7b..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/BaseType.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types -{ - public class BaseType : Object - { - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs b/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs deleted file mode 100644 index da28eaa..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/ObjectReference.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types -{ - public class ObjectReference : BaseType - { - public ushort Reference; - - public ObjectReference() - { - - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs deleted file mode 100644 index 1a3ecff..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Byte.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Byte : BaseType - { - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs deleted file mode 100644 index 19002d4..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Char.cs +++ /dev/null @@ -1,10 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Char : BaseType - { - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs deleted file mode 100644 index 91f1679..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Float.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Float : BaseType - { - public float mValue = 0; - - public Float() - { - - } - } -} diff --git a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs b/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs deleted file mode 100644 index 4ecd325..0000000 --- a/OpenSim.Scripting.EmbeddedJVM/Types/PrimitiveTypes/Int.cs +++ /dev/null @@ -1,16 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Text; - -namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes -{ - public class Int : BaseType - { - public int mValue = 0; - - public Int() - { - - } - } -} diff --git a/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs b/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs new file mode 100644 index 0000000..15ef814 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/ClassInstance.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class ClassInstance : Object + { + public int size; + public Dictionary Fields = new Dictionary(); + + public ClassInstance() + { + + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs b/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs new file mode 100644 index 0000000..15d8a4b --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/ClassRecord.cs @@ -0,0 +1,476 @@ +using System; +using System.IO; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class ClassRecord + { + private ushort _majorVersion; + private ushort _minorVersion; + private ushort _constantPoolCount; + private ushort _accessFlags; + private ushort _thisClass; + private ushort _supperClass; + private ushort _interfaceCount; + private ushort _fieldCount; + private ushort _methodCount; + private ushort _attributeCount; + private string _name; + public Dictionary StaticFields = new Dictionary(); + public PoolClass mClass; + + public List _constantsPool = new List(); + private List _methodsList = new List(); + private List _fieldList = new List(); + + public ClassRecord() + { + + } + + public ClassInstance CreateNewInstance() + { + return new ClassInstance(); + } + + public void LoadClassFromFile(string fileName) + { + Console.WriteLine("loading script " + fileName); + FileStream fs = File.OpenRead(fileName); + this.LoadClassFromBytes(ReadFully(fs)); + fs.Close(); + } + + public void LoadClassFromBytes(byte[] data) + { + int i = 0; + i += 4; + _minorVersion = (ushort)((data[i++] << 8) + data[i++] ); + _majorVersion = (ushort)((data[i++] << 8) + data[i++] ); + _constantPoolCount = (ushort)((data[i++] << 8) + data[i++] ); + // Console.WriteLine("there should be " + _constantPoolCount + " items in the pool"); + for (int count = 0; count < _constantPoolCount -1 ; count++) + { + //read in the constant pool + byte pooltype = data[i++]; + //Console.WriteLine("#" +count +": new constant type = " +pooltype); + //Console.WriteLine("start position is: " + i); + switch (pooltype) + { + case 1: //Utf8 + ushort uLength = (ushort)((data[i++] << 8) + data[i++] ); + + // Console.WriteLine("new utf8 type, length is " + uLength); + PoolUtf8 utf8 = new PoolUtf8(); + utf8.readValue(data, ref i, uLength); + this._constantsPool.Add(utf8); + break; + case 3: //Int + break; + case 7: //Class + PoolClass pClass = new PoolClass(this); + pClass.readValue(data, ref i); + this._constantsPool.Add(pClass); + break; + case 10: //Method + PoolMethodRef pMeth = new PoolMethodRef(this); + pMeth.readValue(data, ref i); + this._constantsPool.Add(pMeth); + break; + case 12: //NamedType + PoolNamedType pNamed = new PoolNamedType(this); + pNamed.readValue(data, ref i); + this._constantsPool.Add(pNamed); + break; + } + } + + _accessFlags = (ushort)((data[i++] << 8) + data[i++] ); + _thisClass = (ushort)((data[i++] << 8) + data[i++] ); + _supperClass = (ushort)((data[i++] << 8) + data[i++] ); + + if (this._constantsPool[this._thisClass - 1] is PoolClass) + { + this.mClass = ((PoolClass)this._constantsPool[this._thisClass - 1]); + } + + _interfaceCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each interface + _fieldCount = (ushort)((data[i++] << 8) + data[i++]); + //should now read in the info for each field + _methodCount = (ushort)((data[i++] << 8) + data[i++]); + for (int count = 0; count < _methodCount; count++) + { + MethodInfo methInf = new MethodInfo(this); + methInf.ReadData(data, ref i); + this._methodsList.Add(methInf); + } + } + + public void AddMethodsToMemory(MethodMemory memory) + { + for (int count = 0; count < _methodCount; count++) + { + this._methodsList[count].AddMethodCode(memory); + } + } + + public bool StartMethod(Thread thread, string methodName) + { + for (int count = 0; count < _methodCount; count++) + { + if (this._constantsPool[this._methodsList[count].NameIndex-1] is PoolUtf8) + { + if (((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex-1]).Value == methodName) + { + //Console.WriteLine("found method: " + ((PoolUtf8)this._constantsPool[this._methodsList[count].NameIndex - 1]).Value); + thread.SetPC(this._methodsList[count].CodePointer); + return true; + } + } + } + return false; + } + + public void PrintToConsole() + { + Console.WriteLine("Class File:"); + Console.WriteLine("Major version: " + _majorVersion); + Console.WriteLine("Minor version: " + _minorVersion); + Console.WriteLine("Pool size: " + _constantPoolCount); + + for (int i = 0; i < _constantsPool.Count; i++) + { + this._constantsPool[i].Print(); + } + + Console.WriteLine("Access flags: " + _accessFlags); + Console.WriteLine("This class: " + _thisClass ); + Console.WriteLine("Super class: " + _supperClass); + + for (int count = 0; count < _methodCount; count++) + { + Console.WriteLine(); + this._methodsList[count].Print(); + } + + Console.WriteLine("class name is " + this.mClass.Name.Value); + } + + public static byte[] ReadFully(Stream stream) + { + byte[] buffer = new byte[1024]; + using (MemoryStream ms = new MemoryStream()) + { + while (true) + { + int read = stream.Read(buffer, 0, buffer.Length); + if (read <= 0) + return ms.ToArray(); + ms.Write(buffer, 0, read); + } + } + } + + #region nested classes + public class PoolItem + { + public virtual void Print() + { + + } + } + + public class PoolUtf8 : PoolItem + { + public string Value = ""; + + public void readValue(byte[] data,ref int pointer , int length) + { + for (int i = 0; i < length; i++) + { + int a =(int) data[pointer++]; + if ((a & 0x80) == 0) + { + Value = Value + (char)a; + } + else if ((a & 0x20) == 0) + { + int b = (int) data[pointer++]; + Value = Value + (char)(((a & 0x1f) << 6) + (b & 0x3f)); + } + else + { + int b = (int)data[pointer++]; + int c = (int)data[pointer++]; + Value = Value + (char)(((a & 0xf) << 12) + ((b & 0x3f) << 6) + (c & 0x3f)); + } + } + } + + public override void Print() + { + Console.WriteLine("Utf8 type: " + Value); + } + } + + private class PoolInt : PoolItem + { + + } + + public class PoolClass : PoolItem + { + //public string name = ""; + public ushort namePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + + public PoolClass(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + } + + public override void Print() + { + this.Name = ((PoolUtf8)this.parent._constantsPool[namePointer - 1]); + Console.Write("Class type: " + namePointer); + Console.WriteLine(" // " + ((PoolUtf8)this.parent._constantsPool[namePointer - 1]).Value); + + } + } + + public class PoolMethodRef : PoolItem + { + public ushort classPointer = 0; + public ushort nameTypePointer = 0; + public PoolNamedType mNameType; + public PoolClass mClass; + private ClassRecord parent; + + public PoolMethodRef(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + classPointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + nameTypePointer = (ushort)((data[pointer++] << 8) + data[pointer++]); + } + + public override void Print() + { + this.mNameType = ((PoolNamedType)this.parent._constantsPool[nameTypePointer - 1]); + this.mClass = ((PoolClass)this.parent._constantsPool[classPointer - 1]); + Console.WriteLine("MethodRef type: " + classPointer + " , " + nameTypePointer); + } + } + + public class PoolNamedType : PoolItem + { + public ushort namePointer = 0; + public ushort typePointer = 0; + private ClassRecord parent; + public PoolUtf8 Name; + public PoolUtf8 Type; + + public PoolNamedType(ClassRecord paren) + { + parent = paren; + } + + public void readValue(byte[] data, ref int pointer) + { + namePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + typePointer = (ushort)((data[pointer++] << 8) + data[pointer++] ); + } + + public override void Print() + { + Name = ((PoolUtf8)this.parent._constantsPool[namePointer-1]); + Type = ((PoolUtf8)this.parent._constantsPool[typePointer-1]); + Console.Write("Named type: " + namePointer + " , " + typePointer ); + Console.WriteLine(" // "+ ((PoolUtf8)this.parent._constantsPool[namePointer-1]).Value); + } + } + + //*********************** + public class MethodInfo + { + public ushort AccessFlags = 0; + public ushort NameIndex = 0; + public string Name = ""; + public ushort DescriptorIndex = 0; + public ushort AttributeCount = 0; + public List Attributes = new List(); + private ClassRecord parent; + public int CodePointer = 0; + + public MethodInfo(ClassRecord paren) + { + parent = paren; + } + + public void AddMethodCode(MethodMemory memory) + { + Array.Copy(this.Attributes[0].Code, 0, memory.MethodBuffer, memory.NextMethodPC, this.Attributes[0].Code.Length); + memory.Methodcount++; + this.CodePointer = memory.NextMethodPC; + memory.NextMethodPC += this.Attributes[0].Code.Length; + } + + public void ReadData(byte[] data, ref int pointer) + { + AccessFlags = (ushort)((data[pointer++] << 8) + data[pointer++]); + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + DescriptorIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + AttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for(int i =0; i< AttributeCount; i++) + { + MethodAttribute attri = new MethodAttribute(this.parent); + attri.ReadData(data, ref pointer); + this.Attributes.Add(attri); + } + } + + public void Print() + { + Console.WriteLine("Method Info Struct: "); + Console.WriteLine("AccessFlags: " + AccessFlags); + Console.WriteLine("NameIndex: " + NameIndex +" // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); + Console.WriteLine("DescriptorIndex: " + DescriptorIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[DescriptorIndex-1]).Value); + Console.WriteLine("Attribute Count:" + AttributeCount); + for (int i = 0; i < AttributeCount; i++) + { + this.Attributes[i].Print(); + } + } + + public class MethodAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + //for now only support code attribute + public ushort MaxStack = 0; + public ushort MaxLocals = 0; + public Int32 CodeLength = 0; + public byte[] Code; + public ushort ExceptionTableLength = 0; + public ushort SubAttributeCount = 0; + public List SubAttributes = new List(); + private ClassRecord parent; + + public MethodAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + MaxStack = (ushort)((data[pointer++] << 8) + data[pointer++]); + MaxLocals = (ushort)((data[pointer++] << 8) + data[pointer++]); + CodeLength = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Code = new byte[CodeLength]; + for (int i = 0; i < CodeLength; i++) + { + Code[i] = data[pointer++]; + } + ExceptionTableLength = (ushort)((data[pointer++] << 8) + data[pointer++]); + SubAttributeCount = (ushort)((data[pointer++] << 8) + data[pointer++]); + for (int i = 0; i < SubAttributeCount; i++) + { + SubAttribute subAttri = new SubAttribute(this.parent); + subAttri.ReadData(data, ref pointer); + this.SubAttributes.Add(subAttri); + } + } + + public void Print() + { + Console.WriteLine("Method Attribute: "); + Console.WriteLine("Name Index: " + NameIndex + " // "+ ((PoolUtf8)this.parent._constantsPool[NameIndex-1]).Value); + Console.WriteLine("Length: " + Length); + Console.WriteLine("MaxStack: " + MaxStack); + Console.WriteLine("MaxLocals: " + MaxLocals); + Console.WriteLine("CodeLength: " + CodeLength); + for (int i = 0; i < Code.Length; i++) + { + Console.WriteLine("OpCode #" + i + " is: " + Code[i]); + } + Console.WriteLine("SubAttributes: " + SubAttributeCount); + for (int i = 0; i < SubAttributeCount; i++) + { + this.SubAttributes[i].Print(); + } + } + + public class SubAttribute + { + public ushort NameIndex = 0; + public string Name = ""; + public Int32 Length = 0; + public byte[] Data; + private ClassRecord parent; + + public SubAttribute(ClassRecord paren) + { + parent = paren; + } + + public void ReadData(byte[] data, ref int pointer) + { + NameIndex = (ushort)((data[pointer++] << 8) + data[pointer++]); + Length = (Int32)((data[pointer++] << 24) + (data[pointer++] << 16) + (data[pointer++] << 8) + data[pointer++]); + Data = new byte[Length]; + for (int i = 0; i < Length; i++) + { + Data[i] = data[pointer++]; + } + } + + public void Print() + { + Console.WriteLine("SubAttribute: NameIndex: " + NameIndex + " // " + ((PoolUtf8)this.parent._constantsPool[NameIndex - 1]).Value); + } + + } + } + + } + private class InterfaceInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + private class FieldInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + private class AttributeInfo + { + public void ReadData(byte[] data, ref int i) + { + + } + } + #endregion + + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Heap.cs b/OpenSim.Scripting/EmbeddedJVM/Heap.cs new file mode 100644 index 0000000..138e85e --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Heap.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Heap + { + public List ClassObjects = new List(); + + public Heap() + { + + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs b/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs new file mode 100644 index 0000000..b94248c --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Interpreter.cs @@ -0,0 +1,108 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private Thread _mThread; + + public Interpreter(Thread parentThread) + { + _mThread = parentThread; + } + + public bool Excute() + { + bool run = true; + byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC++]; + // Console.WriteLine("opCode is: " + currentOpCode); + bool handled = false; + + handled = this.IsLogicOpCode(currentOpCode); + if (!handled) + { + handled = this.IsMethodOpCode(currentOpCode); + } + if (!handled) + { + if (currentOpCode == 172) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning int from function"); + int retPC1 = this._mThread.currentFrame.ReturnPC; + BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC1; + if (bas1 is Int) + { + this._mThread.currentFrame.OpStack.Push((Int)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this._mThread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 174) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning float from function"); + int retPC1 = this._mThread.currentFrame.ReturnPC; + BaseType bas1 = this._mThread.currentFrame.OpStack.Pop(); + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC1; + if (bas1 is Float) + { + this._mThread.currentFrame.OpStack.Push((Float)bas1); + } + } + else + { + // Console.WriteLine("No parent function so ending program"); + this._mThread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + if (currentOpCode == 177) + { + if (this._mThread.stack.StackFrames.Count > 1) + { + Console.WriteLine("returning from function"); + int retPC = this._mThread.currentFrame.ReturnPC; + this._mThread.stack.StackFrames.Pop(); + this._mThread.currentFrame = this._mThread.stack.StackFrames.Peek(); + this._mThread.PC = retPC; + } + else + { + // Console.WriteLine("No parent function so ending program"); + this._mThread.stack.StackFrames.Pop(); + run = false; + } + handled = true; + } + } + if (!handled) + { + Console.WriteLine("opcode " + currentOpCode + " not been handled "); + } + return run; + + } + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs b/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs new file mode 100644 index 0000000..3b7da35 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/InterpreterLogic.cs @@ -0,0 +1,400 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsLogicOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case 2: + Int m_int= new Int(); + m_int.mValue = -1; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 3: + m_int= new Int(); + m_int.mValue = 0; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 4: + m_int = new Int(); + m_int.mValue = 1; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 5: + m_int = new Int(); + m_int.mValue = 2; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 6: + m_int = new Int(); + m_int.mValue = 3; + this._mThread.currentFrame.OpStack.Push(m_int); + break; + case 7: + m_int = new Int(); + m_int.mValue = 4; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 8: + m_int = new Int(); + m_int.mValue = 5; + this._mThread.currentFrame.OpStack.Push(m_int); + result = true; + break; + case 11: + Float m_float = new Float(); + m_float.mValue = 0.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 12: + m_float = new Float(); + m_float.mValue = 1.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 13: + m_float = new Float(); + m_float.mValue = 2.0f; + this._mThread.currentFrame.OpStack.Push(m_float); + result = true; + break; + case 16: + int pushvalue = (int)GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]; + Int pushInt = new Int(); + pushInt.mValue = pushvalue; + this._mThread.currentFrame.OpStack.Push(pushInt); + this._mThread.PC++; + result = true; + break; + case 17: + short pushvalue2 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + Int pushInt2 = new Int(); + pushInt2.mValue = pushvalue2; + this._mThread.currentFrame.OpStack.Push(pushInt2); + this._mThread.PC += 2; + result = true; + break; + case 23: + short findex1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC])); + Float fload = new Float(); + if (this._mThread.currentFrame.LocalVariables[findex1] != null) + { + if (this._mThread.currentFrame.LocalVariables[findex1] is Float) + { + fload.mValue = ((Float)this._mThread.currentFrame.LocalVariables[findex1]).mValue; + this._mThread.currentFrame.OpStack.Push(fload); + } + } + this._mThread.PC++; + result = true; + break; + case 26: + if (this._mThread.currentFrame.LocalVariables[0] != null) + { + if (this._mThread.currentFrame.LocalVariables[0] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[0]).mValue; + this._mThread.currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case 27: + if (this._mThread.currentFrame.LocalVariables[1] != null) + { + if (this._mThread.currentFrame.LocalVariables[1] is Int) + { + Int newInt = new Int(); + newInt.mValue = ((Int)this._mThread.currentFrame.LocalVariables[1]).mValue; + this._mThread.currentFrame.OpStack.Push(newInt); + } + } + result = true; + break; + case 34: + if (this._mThread.currentFrame.LocalVariables[0] != null) + { + if (this._mThread.currentFrame.LocalVariables[0] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[0]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 35: + if (this._mThread.currentFrame.LocalVariables[1] != null) + { + if (this._mThread.currentFrame.LocalVariables[1] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[1]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 36: + if (this._mThread.currentFrame.LocalVariables[2] != null) + { + if (this._mThread.currentFrame.LocalVariables[2] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[2]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 37: + if (this._mThread.currentFrame.LocalVariables[3] != null) + { + if (this._mThread.currentFrame.LocalVariables[3] is Float) + { + Float newfloat = new Float(); + newfloat.mValue = ((Float)this._mThread.currentFrame.LocalVariables[3]).mValue; + this._mThread.currentFrame.OpStack.Push(newfloat); + } + } + result = true; + break; + case 56: + short findex = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] )); + BaseType fstor = this._mThread.currentFrame.OpStack.Pop(); + if (fstor is Float) + { + this._mThread.currentFrame.LocalVariables[findex] = (Float)fstor; + } + this._mThread.PC++; + result = true; + break; + case 59: + BaseType baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Int) + { + this._mThread.currentFrame.LocalVariables[0] = (Int)baset; + } + result = true; + break; + case 60: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Int) + { + this._mThread.currentFrame.LocalVariables[1] = (Int)baset; + } + result = true; + break; + case 67: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[0] = (Float)baset; + } + result = true; + break; + case 68: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[1] = (Float)baset; + } + result = true; + break; + case 69: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[2] = (Float)baset; + } + result = true; + break; + case 70: + baset = this._mThread.currentFrame.OpStack.Pop(); + if (baset is Float) + { + this._mThread.currentFrame.LocalVariables[3] = (Float)baset; + } + result = true; + break; + case 87: + this._mThread.currentFrame.OpStack.Pop(); + result = true; + break; + case 98: + BaseType bf2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bf1 = this._mThread.currentFrame.OpStack.Pop(); + if (bf1 is Float && bf2 is Float) + { + Float nflt = new Float(); + nflt.mValue = ((Float)bf1).mValue + ((Float)bf2).mValue; + this._mThread.currentFrame.OpStack.Push(nflt); + } + result = true; + break; + case 102: + BaseType bsf2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bsf1 = this._mThread.currentFrame.OpStack.Pop(); + if (bsf1 is Float && bsf2 is Float) + { + Float resf = new Float(); + resf.mValue = ((Float)bsf1).mValue - ((Float)bsf2).mValue; + this._mThread.currentFrame.OpStack.Push(resf); + } + result = true; + break; + case 104: //check the order of the two values off the stack is correct + BaseType bs2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int && bs2 is Int) + { + Int nInt = new Int(); + nInt.mValue = ((Int)bs1).mValue * ((Int)bs2).mValue; + this._mThread.currentFrame.OpStack.Push(nInt); + } + result = true; + break; + case 132: + if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] != null) + { + if (this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]] is Int) + { + ((Int)this._mThread.currentFrame.LocalVariables[GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC]]).mValue += (sbyte) GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]; + } + } + this._mThread.PC += 2; + result = true; + break; + case 139: + BaseType conv1 = this._mThread.currentFrame.OpStack.Pop(); + if (conv1 is Float) + { + Int newconv = new Int(); + newconv.mValue = (int)((Float)conv1).mValue; + this._mThread.currentFrame.OpStack.Push(newconv); + } + result = true; + break; + case 149: + BaseType flcom2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType flcom1 = this._mThread.currentFrame.OpStack.Pop(); + if (flcom1 is Float && flcom2 is Float) + { + Int compres = new Int(); + if (((Float)flcom1).mValue < ((Float)flcom2).mValue) + { + compres.mValue = -1; + } + else if (((Float)flcom1).mValue > ((Float)flcom2).mValue) + { + compres.mValue = 1; + } + else + { + compres.mValue = 0; + } + this._mThread.currentFrame.OpStack.Push(compres); + } + result = true; + break; + case 158: + short compareoffset1 = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + BaseType comp1 = this._mThread.currentFrame.OpStack.Pop(); + if (comp1 is Int) + { + if (((Int)comp1).mValue <= 0) + { + this._mThread.PC += -1 + compareoffset1; + } + else + { + this._mThread.PC += 2; + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + case 162: + short compareoffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + BaseType bc2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bc1 = this._mThread.currentFrame.OpStack.Pop(); + if (bc1 is Int && bc2 is Int) + { + //Console.WriteLine("comparing " + ((Int)bc1).mValue + " and " + ((Int)bc2).mValue); + if (((Int)bc1).mValue >= ((Int)bc2).mValue) + { + // Console.WriteLine("branch compare true , offset is " +compareoffset); + // Console.WriteLine("current PC is " + this._mThread.PC); + this._mThread.PC += -1 + compareoffset; + //Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this._mThread.PC += 2; + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + case 164: + short compareloffset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC + 1]); + BaseType bcl2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType bcl1 = this._mThread.currentFrame.OpStack.Pop(); + if (bcl1 is Int && bcl2 is Int) + { + //Console.WriteLine("comparing " + ((Int)bcl1).mValue + " and " + ((Int)bcl2).mValue); + if (((Int)bcl1).mValue <= ((Int)bcl2).mValue) + { + // Console.WriteLine("branch compare true , offset is " + compareloffset); + // Console.WriteLine("current PC is " + this._mThread.PC); + this._mThread.PC += -1 + compareloffset; + // Console.WriteLine("new PC is " + this._mThread.PC); + } + else + { + //Console.WriteLine("branch compare false"); + this._mThread.PC += 2; + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + case 167: + short offset = (short)((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); + this._mThread.PC += -1 + offset; + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs b/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs new file mode 100644 index 0000000..dc3402e --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/InterpreterMethods.cs @@ -0,0 +1,140 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + private bool IsMethodOpCode(byte opcode) + { + bool result = false; + switch (opcode) + { + case 184: + short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this._mThread.PC+1]); + //Console.WriteLine("call to method : "+refIndex); + if (this._mThread.currentClass._constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef) + { + // Console.WriteLine("which is " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value + "." + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value); + // Console.WriteLine("of type " + ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value); + string typ = ((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Type.Value; + string typeparam = ""; + string typereturn = ""; + int firstbrak = 0; + int secondbrak = 0; + firstbrak = typ.LastIndexOf('('); + secondbrak = typ.LastIndexOf(')'); + typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1); + typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1); + //Console.WriteLine("split is " + typeparam + " which is length " + typeparam.Length + " , " + typereturn); + if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == this._mThread.currentClass.mClass.Name.Value) + { + //calling a method in this class + if (typeparam.Length == 0) + { + this._mThread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, (this._mThread.PC + 2)); + } + else + { + this._mThread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this._mThread.PC + 2)); + } + } + else + { + //calling a method of a different class + + //for now we will have a built in OpenSimAPI class, but this should be a java class that then calls native methods + if (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI") + { + switch (((ClassRecord.PoolMethodRef)this._mThread.currentClass._constantsPool[refIndex - 1]).mNameType.Name.Value) + { + case "GetEntityID": + Int entityID = new Int(); + entityID.mValue =(int) this._mThread.EntityId; + this._mThread.currentFrame.OpStack.Push(entityID); + this._mThread.PC += 2; + break; + case "GetRandomAvatarID": + entityID = new Int(); + entityID.mValue = (int)Thread.OpenSimScriptAPI.GetRandomAvatarID(); + this._mThread.currentFrame.OpStack.Push(entityID); + this._mThread.PC += 2; + break; + case "GetEntityPositionX": + BaseType bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //Console.WriteLine("get entity pos for " + ((Int)bs1).mValue); + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.X; + // Console.WriteLine("returned x value " + vec3.X.ToString()); + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "GetEntityPositionY": + bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.Y; + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "GetEntityPositionZ": + bs1 = this._mThread.currentFrame.OpStack.Pop(); + if (bs1 is Int) + { + //should get the position of the entity from the IScriptAPI + OSVector3 vec3 = Thread.OpenSimScriptAPI.GetEntityPosition((uint)((Int)bs1).mValue); + Float pos = new Float(); + pos.mValue = vec3.Z; + this._mThread.currentFrame.OpStack.Push(pos); + } + this._mThread.PC += 2; + break; + case "SetEntityPosition": + //pop the three float values and the entity id + BaseType ft3 = this._mThread.currentFrame.OpStack.Pop(); + BaseType ft2 = this._mThread.currentFrame.OpStack.Pop(); + BaseType ft1 = this._mThread.currentFrame.OpStack.Pop(); + BaseType in1 = this._mThread.currentFrame.OpStack.Pop(); + if (ft1 is Float && ft2 is Float && ft3 is Float) + { + if(in1 is Int) + { + //Console.WriteLine("set: " + ((Int)in1).mValue + " , " + ((Float)ft1).mValue + " , " + ((Float)ft2).mValue + " , " + ((Float)ft3).mValue); + Thread.OpenSimScriptAPI.SetEntityPosition((uint)((Int) in1).mValue, ((Float)ft1).mValue, ((Float)ft2).mValue, ((Float)ft3).mValue); + } + } + this._mThread.PC += 2; + break; + } + } + } + } + else + { + this._mThread.PC += 2; + } + result = true; + break; + } + + return result; + } + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs b/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs new file mode 100644 index 0000000..6704e31 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/InterpreterReturn.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + partial class Thread + { + private partial class Interpreter + { + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs b/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs new file mode 100644 index 0000000..ff18f90 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/MainMemory.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class MainMemory + { + public Heap HeapArea; + public MethodMemory MethodArea; + + public MainMemory() + { + MethodArea = new MethodMemory(); + HeapArea = new Heap(); + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs b/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs new file mode 100644 index 0000000..2541991 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/MethodMemory.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class MethodMemory + { + public byte[] MethodBuffer; + public List Classes = new List(); + public int NextMethodPC = 0; + public int Methodcount = 0; + + public MethodMemory() + { + MethodBuffer = new byte[20000]; + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Object.cs b/OpenSim.Scripting/EmbeddedJVM/Object.cs new file mode 100644 index 0000000..e6e392c --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Object.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Object + { + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj new file mode 100644 index 0000000..a1e95f4 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj @@ -0,0 +1,153 @@ + + + Local + 8.0.50727 + 2.0 + {97A82740-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Scripting.EmbeddedJVM + JScript + Grid + IE50 + false + Library + + OpenSim.Scripting.EmbeddedJVM + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ScriptEngines\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ScriptEngines\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user new file mode 100644 index 0000000..e1615f7 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim11-04trunk\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build new file mode 100644 index 0000000..ae79c83 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/OpenSim.Scripting.EmbeddedJVM.dll.build @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs b/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs new file mode 100644 index 0000000..b47bb50 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/OpenSimJVM.cs @@ -0,0 +1,134 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using System.Threading; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Utilities; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class OpenSimJVM : IScriptEngine + { + private List _threads = new List(); + private BlockingQueue CompileScripts = new BlockingQueue(); + private MainMemory _mainMemory; + private System.Threading.Thread compileThread; + + public OpenSimJVM() + { + + } + + public bool Init(IScriptAPI api) + { + Console.WriteLine("Creating OpenSim JVM scripting engine"); + _mainMemory = new MainMemory(); + Thread.GlobalMemory = this._mainMemory; + Thread.OpenSimScriptAPI = api; + compileThread = new System.Threading.Thread(new ThreadStart(CompileScript)); + compileThread.IsBackground = true; + compileThread.Start(); + return true; + } + + public string GetName() + { + return "OpenSimJVM"; + } + + public void LoadScript(string script, string scriptName, uint entityID) + { + Console.WriteLine("OpenSimJVM - loading new script: " + scriptName); + CompileInfo comp = new CompileInfo(); + comp.entityId = entityID; + comp.script = script; + comp.scriptName = scriptName; + this.CompileScripts.Enqueue(comp); + } + + public void CompileScript() + { + while (true) + { + CompileInfo comp = this.CompileScripts.Dequeue(); + string script = comp.script; + string scriptName = comp.scriptName; + uint entityID = comp.entityId; + try + { + //need to compile the script into a java class file + + //first save it to a java source file + TextWriter tw = new StreamWriter(scriptName + ".java"); + tw.WriteLine(script); + tw.Close(); + + //now compile + System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java"); + // psi.RedirectStandardOutput = true; + psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; + psi.UseShellExecute = false; + + System.Diagnostics.Process javacomp; + javacomp = System.Diagnostics.Process.Start(psi); + javacomp.WaitForExit(); + + + //now load in class file + ClassRecord class1 = new ClassRecord(); + class1.LoadClassFromFile(scriptName + ".class"); + class1.PrintToConsole(); + //Console.WriteLine(); + this._mainMemory.MethodArea.Classes.Add(class1); + class1.AddMethodsToMemory(this._mainMemory.MethodArea); + + Thread newThread = new Thread(); + this._threads.Add(newThread); + newThread.EntityId = entityID; + newThread.currentClass = class1; + + //now delete the created files + System.IO.File.Delete(scriptName + ".java"); + System.IO.File.Delete(scriptName + ".class"); + //this.OnFrame(); + } + catch (Exception e) + { + Console.WriteLine("exception"); + Console.WriteLine(e.StackTrace); + Console.WriteLine(e.Message); + } + } + } + + public void OnFrame() + { + for (int i = 0; i < this._threads.Count; i++) + { + if (!this._threads[i].running) + { + this._threads[i].StartMethod("OnFrame"); + bool run = true; + while (run) + { + run = this._threads[i].Excute(); + } + } + } + } + + private class CompileInfo + { + public string script; + public string scriptName; + public uint entityId; + + public CompileInfo() + { + + } + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs b/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..53a0f08 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Scripting.EmbeddedJVM")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.Scripting.EmbeddedJVM")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("087c0917-5a6a-4b47-a4dd-0928dd85bd4b")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Scripting/EmbeddedJVM/Stack.cs b/OpenSim.Scripting/EmbeddedJVM/Stack.cs new file mode 100644 index 0000000..d77d82e --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Stack.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class Stack + { + public Stack StackFrames = new Stack(); + + public Stack() + { + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs b/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs new file mode 100644 index 0000000..afca7a9 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/StackFrame.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public class StackFrame + { + public BaseType[] LocalVariables; + public Stack OpStack = new Stack(); + + public int ReturnPC = 0; + public ClassRecord CallingClass = null; + + public StackFrame() + { + LocalVariables = new BaseType[20]; + } + + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Thread.cs b/OpenSim.Scripting/EmbeddedJVM/Thread.cs new file mode 100644 index 0000000..436949c --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Thread.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenSim.Scripting.EmbeddedJVM.Types; +using OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes; +using OpenSim.Framework; +using OpenSim.Framework.Interfaces; + +namespace OpenSim.Scripting.EmbeddedJVM +{ + public partial class Thread + { + public static MainMemory GlobalMemory; + public static IScriptAPI OpenSimScriptAPI; + private int PC = 0; + private Stack stack; + private Interpreter mInterpreter; + public ClassRecord currentClass; + public ClassInstance currentInstance; + private StackFrame currentFrame; + public int excutionCounter = 0; + public bool running = false; + public uint EntityId = 0; + + public Thread() + { + this.mInterpreter = new Interpreter(this); + this.stack = new Stack(); + } + + public void SetPC(int methodpointer) + { + //Console.WriteLine("Thread PC has been set to " + methodpointer); + PC = methodpointer; + } + + public void StartMethod(ClassRecord rec, string methName) + { + currentFrame = new StackFrame(); + this.stack.StackFrames.Push(currentFrame); + this.currentClass = rec; + currentClass.StartMethod(this, methName); + } + + public void StartMethod( string methName) + { + currentFrame = new StackFrame(); + this.stack.StackFrames.Push(currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticVoidMethod(string methName, int returnPC) + { + currentFrame = new StackFrame(); + currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(currentFrame); + currentClass.StartMethod(this, methName); + } + + public void JumpToStaticParamMethod(string methName, string param, int returnPC) + { + if (param == "I") + { + BaseType bs1 = currentFrame.OpStack.Pop(); + currentFrame = new StackFrame(); + currentFrame.ReturnPC = returnPC; + this.stack.StackFrames.Push(currentFrame); + currentFrame.LocalVariables[0] = ((Int)bs1); + currentClass.StartMethod(this, methName); + } + if (param == "F") + { + + } + } + + public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC) + { + + } + + public bool Excute() + { + excutionCounter++; + return this.mInterpreter.Excute(); + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs b/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs new file mode 100644 index 0000000..2854eab --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/ArrayReference.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class ArrayReference :BaseType + { + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs b/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs new file mode 100644 index 0000000..270aa7b --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/BaseType.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class BaseType : Object + { + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs b/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs new file mode 100644 index 0000000..da28eaa --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/ObjectReference.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types +{ + public class ObjectReference : BaseType + { + public ushort Reference; + + public ObjectReference() + { + + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs new file mode 100644 index 0000000..1a3ecff --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Byte.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Byte : BaseType + { + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs new file mode 100644 index 0000000..19002d4 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Char.cs @@ -0,0 +1,10 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Char : BaseType + { + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs new file mode 100644 index 0000000..91f1679 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Float.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Float : BaseType + { + public float mValue = 0; + + public Float() + { + + } + } +} diff --git a/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs new file mode 100644 index 0000000..4ecd325 --- /dev/null +++ b/OpenSim.Scripting/EmbeddedJVM/Types/PrimitiveTypes/Int.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Text; + +namespace OpenSim.Scripting.EmbeddedJVM.Types.PrimitiveTypes +{ + public class Int : BaseType + { + public int mValue = 0; + + public Int() + { + + } + } +} diff --git a/OpenSim.Storage.LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim.Storage.LocalStorageBerkeleyDB/BDBLocalStorage.cs deleted file mode 100644 index db7252b..0000000 --- a/OpenSim.Storage.LocalStorageBerkeleyDB/BDBLocalStorage.cs +++ /dev/null @@ -1,90 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -// BDB Support -// Apparently broken on Mono - -using System; -using System.Collections.Generic; -using System.Data; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Assets; -using OpenSim.Framework.Terrain; -using BerkeleyDb; -using Kds.Serialization; -using Kds.Serialization.Buffer; - -namespace OpenSim.Storage.LocalStorageBDB -{ - public class BDBLocalStorage : ILocalStorage - { - const string simDbName = "localsim.db"; - - DbHash sim; - Db DB; - BEFormatter formatter; - - public BDBLocalStorage() - { - DB = new Db(DbCreateFlags.None); - sim = (DbHash)DB.Open(null, simDbName, null, BerkeleyDb.DbType.Hash, Db.OpenFlags.Create, 0); - //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0); - } - - public void StorePrim(PrimData prim) - { - DbEntry key = new DbEntry(); - DbEntry data = new DbEntry(); - lock (sim) - { - sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit); - } - } - public void RemovePrim(LLUUID primID) - { - - } - public void LoadPrimitives(ILocalStorageReceiver receiver) - { - - } - public float[] LoadWorld() - { - return new float[65536]; - } - public void SaveMap(float[] heightmap) - { - - } - public void ShutDown() - { - sim.GetDb().Close(); - DB.Close(); - } - } -} \ No newline at end of file diff --git a/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj b/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj deleted file mode 100644 index ebd3936..0000000 --- a/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj +++ /dev/null @@ -1,115 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {EE9E5D96-0000-0000-0000-000000000000} - Debug - AnyCPU - - - - OpenSim.Storage.LocalStorageBerkeleyDB - JScript - Grid - IE50 - false - Library - - OpenSim.Storage.LocalStorageBerkeleyDB - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - True - 4096 - False - ..\bin\ - False - False - False - 4 - - - - False - 285212672 - False - - - TRACE - - False - 4096 - True - ..\bin\ - False - False - False - 4 - - - - - System.dll - False - - - System.Xml.dll - False - - - System.Data.dll - False - - - ..\bin\Kds.Serialization.dll - False - - - ..\bin\libdb_dotNET43.dll - False - - - ..\bin\libsecondlife.dll - False - - - - - OpenSim.Framework - {8ACA2445-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Framework.Console - {A7CD0630-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - - - - - - - - diff --git a/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build b/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build deleted file mode 100644 index 82085d1..0000000 --- a/OpenSim.Storage.LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim.Storage.LocalStorageBerkeleyDB/Properties/AssemblyInfo.cs b/OpenSim.Storage.LocalStorageBerkeleyDB/Properties/AssemblyInfo.cs deleted file mode 100644 index 94f553a..0000000 --- a/OpenSim.Storage.LocalStorageBerkeleyDB/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Storage.LocalStorageBerkeleyDB")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Storage.LocalStorageBerkeleyDB")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("e8d6c27e-1feb-4cff-b029-51c701b9330b")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.0")] -[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj b/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj deleted file mode 100644 index a6facb9..0000000 --- a/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj +++ /dev/null @@ -1,111 +0,0 @@ - - - Local - 8.0.50727 - 2.0 - {6B20B603-0000-0000-0000-000000000000} - Debug - AnyCPU - - - - OpenSim.Storage.LocalStorageSQLite - JScript - Grid - IE50 - false - Library - - OpenSim.Storage.LocalStorageSQLite - - - - - - False - 285212672 - False - - - TRACE;DEBUG - - True - 4096 - False - ..\bin\ - False - False - False - 4 - - - - False - 285212672 - False - - - TRACE - - False - 4096 - True - ..\bin\ - False - False - False - 4 - - - - - System.dll - False - - - System.Xml.dll - False - - - System.Data.dll - False - - - ..\bin\System.Data.SQLite.dll - False - - - ..\bin\libsecondlife.dll - False - - - - - OpenSim.Framework - {8ACA2445-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - OpenSim.Framework.Console - {A7CD0630-0000-0000-0000-000000000000} - {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - False - - - - - Code - - - Code - - - - - - - - - - diff --git a/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build b/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build deleted file mode 100644 index f3a6683..0000000 --- a/OpenSim.Storage.LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build +++ /dev/null @@ -1,46 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/OpenSim.Storage.LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim.Storage.LocalStorageSQLite/Properties/AssemblyInfo.cs deleted file mode 100644 index fe81f8a..0000000 --- a/OpenSim.Storage.LocalStorageSQLite/Properties/AssemblyInfo.cs +++ /dev/null @@ -1,35 +0,0 @@ -using System.Reflection; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -// General Information about an assembly is controlled through the following -// set of attributes. Change these attribute values to modify the information -// associated with an assembly. -[assembly: AssemblyTitle("OpenSim.Storage.LocalStorageSQLite")] -[assembly: AssemblyDescription("")] -[assembly: AssemblyConfiguration("")] -[assembly: AssemblyCompany("")] -[assembly: AssemblyProduct("OpenSim.Storage.LocalStorageSQLite")] -[assembly: AssemblyCopyright("Copyright © 2007")] -[assembly: AssemblyTrademark("")] -[assembly: AssemblyCulture("")] - -// Setting ComVisible to false makes the types in this assembly not visible -// to COM components. If you need to access a type in this assembly from -// COM, set the ComVisible attribute to true on that type. -[assembly: ComVisible(false)] - -// The following GUID is for the ID of the typelib if this project is exposed to COM -[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")] - -// Version information for an assembly consists of the following four values: -// -// Major Version -// Minor Version -// Build Number -// Revision -// -// You can specify all the values or you can default the Revision and Build Numbers -// by using the '*' as shown below: -[assembly: AssemblyVersion("1.0.0.*")] -[assembly: AssemblyFileVersion("1.0.0.*")] diff --git a/OpenSim.Storage.LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim.Storage.LocalStorageSQLite/SQLiteLocalStorage.cs deleted file mode 100644 index 8c9a5e1..0000000 --- a/OpenSim.Storage.LocalStorageSQLite/SQLiteLocalStorage.cs +++ /dev/null @@ -1,171 +0,0 @@ -/* -* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY -* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -* -*/ - -// SQLite Support -// A bad idea, but the IRC people told me to! - -using System; -using System.Collections.Generic; -using System.Data; -using System.Data.SQLite; -using libsecondlife; -using OpenSim.Framework.Interfaces; -using OpenSim.Framework.Assets; -using OpenSim.Framework.Terrain; - -namespace OpenSim.Storage.LocalStorageSQLite -{ - public class SQLiteLocalStorage : ILocalStorage - { - IDbConnection db; - - public SQLiteLocalStorage() - { - try - { - string connectionstring = "URI=file:localsim.sdb"; - db = (IDbConnection)new SQLiteConnection(connectionstring); - db.Open(); - } - catch (Exception e) - { - db.Close(); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :Constructor - Exception occured"); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); - } - } - - public void StorePrim(PrimData prim) - { - IDbCommand cmd = db.CreateCommand(); - - //SECURITY WARNING: - // These parameters wont produce SQL injections since they are all integer based, however. - // if inserting strings such as name or description, you will need to use appropriate - // measures to prevent SQL injection (although the value of SQL injection in this is limited). - - string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) "; - sql += "VALUES ("; - sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW! - sql += "\"" + prim.PCode.ToString() + "\","; - sql += "\"" + prim.PathBegin.ToString() + "\","; - sql += "\"" + prim.PathEnd.ToString() + "\","; - sql += "\"" + prim.PathScaleX.ToString() + "\","; - sql += "\"" + prim.PathScaleY.ToString() + "\","; - sql += "\"" + prim.PathShearX.ToString() + "\","; - sql += "\"" + prim.PathShearY.ToString() + "\","; - sql += "\"" + prim.PathSkew.ToString() + "\","; - sql += "\"" + prim.ProfileBegin.ToString() + "\","; - sql += "\"" + prim.ProfileEnd.ToString() + "\","; - sql += "\"" + prim.Scale.ToString() + "\","; - sql += "\"" + prim.PathCurve.ToString() + "\","; - sql += "\"" + prim.ProfileCurve.ToString() + "\","; - sql += "\"" + prim.ParentID.ToString() + "\","; - sql += "\"" + prim.ProfileHollow.ToString() + "\","; - sql += "\"" + prim.PathRadiusOffset.ToString() + "\","; - sql += "\"" + prim.PathRevolutions.ToString() + "\","; - sql += "\"" + prim.PathTaperX.ToString() + "\","; - sql += "\"" + prim.PathTaperY.ToString() + "\","; - sql += "\"" + prim.PathTwist.ToString() + "\","; - sql += "\"" + prim.PathTwistBegin.ToString() + "\","; - sql += "\"" + prim.Texture.ToString() + "\","; - sql += "\"" + prim.CreationDate.ToString() + "\","; - sql += "\"" + prim.OwnerMask.ToString() + "\","; - sql += "\"" + prim.NextOwnerMask.ToString() + "\","; - sql += "\"" + prim.GroupMask.ToString() + "\","; - sql += "\"" + prim.EveryoneMask.ToString() + "\","; - sql += "\"" + prim.BaseMask.ToString() + "\","; - sql += "\"" + prim.Position.ToString() + "\","; - sql += "\"" + prim.Rotation.ToString() + "\","; - sql += "\"" + prim.LocalID.ToString() + "\","; - sql += "\"" + prim.FullID.ToString() + "\")"; - - cmd.CommandText = sql; - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :StorePrim - Exception occured"); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); - } - - cmd.Dispose(); - cmd = null; - } - - public void RemovePrim(LLUUID primID) - { - IDbCommand cmd = db.CreateCommand(); - - //SECURITY WARNING: - // These parameters wont produce SQL injections since they are all integer based, however. - // if inserting strings such as name or description, you will need to use appropriate - // measures to prevent SQL injection (although the value of SQL injection in this is limited). - - string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\""; - - cmd.CommandText = sql; - - try - { - cmd.ExecuteNonQuery(); - } - catch (Exception e) - { - OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :RemovePrim - Exception occured"); - OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); - } - - cmd.Dispose(); - cmd = null; - } - - public void LoadPrimitives(ILocalStorageReceiver receiver) - { - - } - - public float[] LoadWorld() - { - return new float[65536]; - } - - public void SaveMap(float[] heightmap) - { - - } - - public void ShutDown() - { - db.Close(); - db = null; - } - } -} \ No newline at end of file diff --git a/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs b/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs new file mode 100644 index 0000000..db7252b --- /dev/null +++ b/OpenSim.Storage/LocalStorageBerkeleyDB/BDBLocalStorage.cs @@ -0,0 +1,90 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +// BDB Support +// Apparently broken on Mono + +using System; +using System.Collections.Generic; +using System.Data; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; +using BerkeleyDb; +using Kds.Serialization; +using Kds.Serialization.Buffer; + +namespace OpenSim.Storage.LocalStorageBDB +{ + public class BDBLocalStorage : ILocalStorage + { + const string simDbName = "localsim.db"; + + DbHash sim; + Db DB; + BEFormatter formatter; + + public BDBLocalStorage() + { + DB = new Db(DbCreateFlags.None); + sim = (DbHash)DB.Open(null, simDbName, null, BerkeleyDb.DbType.Hash, Db.OpenFlags.Create, 0); + //vendorDb = (DbBTree)db.Open(null, VendorDbName, null, DbType.BTree, Db.OpenFlags.Create, 0); + } + + public void StorePrim(PrimData prim) + { + DbEntry key = new DbEntry(); + DbEntry data = new DbEntry(); + lock (sim) + { + sim.PutUnique(null, ref key, ref data, DbFile.WriteFlags.AutoCommit); + } + } + public void RemovePrim(LLUUID primID) + { + + } + public void LoadPrimitives(ILocalStorageReceiver receiver) + { + + } + public float[] LoadWorld() + { + return new float[65536]; + } + public void SaveMap(float[] heightmap) + { + + } + public void ShutDown() + { + sim.GetDb().Close(); + DB.Close(); + } + } +} \ No newline at end of file diff --git a/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj new file mode 100644 index 0000000..12c5016 --- /dev/null +++ b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj @@ -0,0 +1,112 @@ + + + Local + 8.0.50727 + 2.0 + {EE9E5D96-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Storage.LocalStorageBerkeleyDB + JScript + Grid + IE50 + false + Library + + OpenSim.Storage.LocalStorageBerkeleyDB + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + System.Data.dll + False + + + ..\..\bin\Kds.Serialization.dll + False + + + ..\..\bin\libdb_dotNET43.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user new file mode 100644 index 0000000..e1615f7 --- /dev/null +++ b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim11-04trunk\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build new file mode 100644 index 0000000..885b088 --- /dev/null +++ b/OpenSim.Storage/LocalStorageBerkeleyDB/OpenSim.Storage.LocalStorageBerkeleyDB.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj new file mode 100644 index 0000000..8039721 --- /dev/null +++ b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj @@ -0,0 +1,111 @@ + + + Local + 8.0.50727 + 2.0 + {6B20B603-0000-0000-0000-000000000000} + Debug + AnyCPU + + + + OpenSim.Storage.LocalStorageSQLite + JScript + Grid + IE50 + false + Library + + OpenSim.Storage.LocalStorageSQLite + + + + + + False + 285212672 + False + + + TRACE;DEBUG + + True + 4096 + False + ..\..\bin\ + False + False + False + 4 + + + + False + 285212672 + False + + + TRACE + + False + 4096 + True + ..\..\bin\ + False + False + False + 4 + + + + + System.dll + False + + + System.Xml.dll + False + + + System.Data.dll + False + + + ..\..\bin\System.Data.SQLite.dll + False + + + ..\..\bin\libsecondlife.dll + False + + + + + OpenSim.Framework + {8ACA2445-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + OpenSim.Framework.Console + {A7CD0630-0000-0000-0000-000000000000} + {FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + False + + + + + Code + + + Code + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user new file mode 100644 index 0000000..e1615f7 --- /dev/null +++ b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.csproj.user @@ -0,0 +1,12 @@ + + + Debug + AnyCPU + C:\New Folder\second-life-viewer\opensim-dailys2\opensim11-04trunk\bin\ + 8.0.50727 + ProjectFiles + 0 + + + + diff --git a/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build new file mode 100644 index 0000000..79c27fc --- /dev/null +++ b/OpenSim.Storage/LocalStorageSQLite/OpenSim.Storage.LocalStorageSQLite.dll.build @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs b/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fe81f8a --- /dev/null +++ b/OpenSim.Storage/LocalStorageSQLite/Properties/AssemblyInfo.cs @@ -0,0 +1,35 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("OpenSim.Storage.LocalStorageSQLite")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("OpenSim.Storage.LocalStorageSQLite")] +[assembly: AssemblyCopyright("Copyright © 2007")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("ecd6e0c1-7909-413e-9e3f-659678ac3bc3")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Revision and Build Numbers +// by using the '*' as shown below: +[assembly: AssemblyVersion("1.0.0.*")] +[assembly: AssemblyFileVersion("1.0.0.*")] diff --git a/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs b/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs new file mode 100644 index 0000000..8c9a5e1 --- /dev/null +++ b/OpenSim.Storage/LocalStorageSQLite/SQLiteLocalStorage.cs @@ -0,0 +1,171 @@ +/* +* Copyright (c) OpenSim project, http://sim.opensecondlife.org/ +* +* Redistribution and use in source and binary forms, with or without +* modification, are permitted provided that the following conditions are met: +* * Redistributions of source code must retain the above copyright +* notice, this list of conditions and the following disclaimer. +* * Redistributions in binary form must reproduce the above copyright +* notice, this list of conditions and the following disclaimer in the +* documentation and/or other materials provided with the distribution. +* * Neither the name of the nor the +* names of its contributors may be used to endorse or promote products +* derived from this software without specific prior written permission. +* +* THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY +* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +* DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY +* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +* +*/ + +// SQLite Support +// A bad idea, but the IRC people told me to! + +using System; +using System.Collections.Generic; +using System.Data; +using System.Data.SQLite; +using libsecondlife; +using OpenSim.Framework.Interfaces; +using OpenSim.Framework.Assets; +using OpenSim.Framework.Terrain; + +namespace OpenSim.Storage.LocalStorageSQLite +{ + public class SQLiteLocalStorage : ILocalStorage + { + IDbConnection db; + + public SQLiteLocalStorage() + { + try + { + string connectionstring = "URI=file:localsim.sdb"; + db = (IDbConnection)new SQLiteConnection(connectionstring); + db.Open(); + } + catch (Exception e) + { + db.Close(); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :Constructor - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + } + + public void StorePrim(PrimData prim) + { + IDbCommand cmd = db.CreateCommand(); + + //SECURITY WARNING: + // These parameters wont produce SQL injections since they are all integer based, however. + // if inserting strings such as name or description, you will need to use appropriate + // measures to prevent SQL injection (although the value of SQL injection in this is limited). + + string sql = "REPLACE INTO prim (OwnerID,PCode,PathBegin,PathEnd,PathScaleX,PathScaleY,PathShearX,PathShearY,PathSkew,ProfileBegin,ProfileEnd,Scale,PathCurve,ProfileCurve,ParentID,ProfileHollow,PathRadiusOffset,PathRevolutions,PathTaperX,PathTaperY,PathTwist,PathTwistBegin,Texture,CreationDate,OwnerMask,NextOwnerMask,GroupMask,EveryoneMask,BaseMask,Position,Rotation,LocalID,FullID) "; + sql += "VALUES ("; + sql += "\"" + prim.OwnerID.ToStringHyphenated() + "\","; // KILL ME NOW! + sql += "\"" + prim.PCode.ToString() + "\","; + sql += "\"" + prim.PathBegin.ToString() + "\","; + sql += "\"" + prim.PathEnd.ToString() + "\","; + sql += "\"" + prim.PathScaleX.ToString() + "\","; + sql += "\"" + prim.PathScaleY.ToString() + "\","; + sql += "\"" + prim.PathShearX.ToString() + "\","; + sql += "\"" + prim.PathShearY.ToString() + "\","; + sql += "\"" + prim.PathSkew.ToString() + "\","; + sql += "\"" + prim.ProfileBegin.ToString() + "\","; + sql += "\"" + prim.ProfileEnd.ToString() + "\","; + sql += "\"" + prim.Scale.ToString() + "\","; + sql += "\"" + prim.PathCurve.ToString() + "\","; + sql += "\"" + prim.ProfileCurve.ToString() + "\","; + sql += "\"" + prim.ParentID.ToString() + "\","; + sql += "\"" + prim.ProfileHollow.ToString() + "\","; + sql += "\"" + prim.PathRadiusOffset.ToString() + "\","; + sql += "\"" + prim.PathRevolutions.ToString() + "\","; + sql += "\"" + prim.PathTaperX.ToString() + "\","; + sql += "\"" + prim.PathTaperY.ToString() + "\","; + sql += "\"" + prim.PathTwist.ToString() + "\","; + sql += "\"" + prim.PathTwistBegin.ToString() + "\","; + sql += "\"" + prim.Texture.ToString() + "\","; + sql += "\"" + prim.CreationDate.ToString() + "\","; + sql += "\"" + prim.OwnerMask.ToString() + "\","; + sql += "\"" + prim.NextOwnerMask.ToString() + "\","; + sql += "\"" + prim.GroupMask.ToString() + "\","; + sql += "\"" + prim.EveryoneMask.ToString() + "\","; + sql += "\"" + prim.BaseMask.ToString() + "\","; + sql += "\"" + prim.Position.ToString() + "\","; + sql += "\"" + prim.Rotation.ToString() + "\","; + sql += "\"" + prim.LocalID.ToString() + "\","; + sql += "\"" + prim.FullID.ToString() + "\")"; + + cmd.CommandText = sql; + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :StorePrim - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + cmd.Dispose(); + cmd = null; + } + + public void RemovePrim(LLUUID primID) + { + IDbCommand cmd = db.CreateCommand(); + + //SECURITY WARNING: + // These parameters wont produce SQL injections since they are all integer based, however. + // if inserting strings such as name or description, you will need to use appropriate + // measures to prevent SQL injection (although the value of SQL injection in this is limited). + + string sql = "DELETE FROM prim WHERE FullID = \"" + primID.ToStringHyphenated() + "\""; + + cmd.CommandText = sql; + + try + { + cmd.ExecuteNonQuery(); + } + catch (Exception e) + { + OpenSim.Framework.Console.MainConsole.Instance.WriteLine("SQLiteLocalStorage :RemovePrim - Exception occured"); + OpenSim.Framework.Console.MainConsole.Instance.WriteLine(e.ToString()); + } + + cmd.Dispose(); + cmd = null; + } + + public void LoadPrimitives(ILocalStorageReceiver receiver) + { + + } + + public float[] LoadWorld() + { + return new float[65536]; + } + + public void SaveMap(float[] heightmap) + { + + } + + public void ShutDown() + { + db.Close(); + db = null; + } + } +} \ No newline at end of file diff --git a/OpenSim.build b/OpenSim.build index 861a466..2c20042 100644 --- a/OpenSim.build +++ b/OpenSim.build @@ -50,11 +50,11 @@ - + - + @@ -63,7 +63,7 @@ - + @@ -84,13 +84,13 @@ - + - - + + @@ -105,11 +105,11 @@ - + - + @@ -118,7 +118,7 @@ - + diff --git a/OpenSim.sln b/OpenSim.sln index 875bb3b..5ad18e3 100644 --- a/OpenSim.sln +++ b/OpenSim.sln @@ -1,5 +1,5 @@ Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 +# Visual C# Express 2005 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Terrain.BasicTerrain", "OpenSim.Terrain.BasicTerrain\OpenSim.Terrain.BasicTerrain.csproj", "{2270B8FE-0000-0000-0000-000000000000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.RegionServer", "OpenSim.RegionServer\OpenSim.RegionServer.csproj", "{632E1BFD-0000-0000-0000-000000000000}" @@ -8,7 +8,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.OdePlugin", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Framework.Console", "OpenSim.Framework.Console\OpenSim.Framework.Console.csproj", "{A7CD0630-0000-0000-0000-000000000000}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageBerkeleyDB", "OpenSim.Storage.LocalStorageBerkeleyDB\OpenSim.Storage.LocalStorageBerkeleyDB.csproj", "{EE9E5D96-0000-0000-0000-000000000000}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageBerkeleyDB", "OpenSim.Storage\LocalStorageBerkeleyDB\OpenSim.Storage.LocalStorageBerkeleyDB.csproj", "{EE9E5D96-0000-0000-0000-000000000000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim", "OpenSim\OpenSim.csproj", "{438A9556-0000-0000-0000-000000000000}" EndProject @@ -16,7 +16,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.GenericConfig.Xml", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Physics.Manager", "OpenSim.Physics\Manager\OpenSim.Physics.Manager.csproj", "{8BE16150-0000-0000-0000-000000000000}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Scripting.EmbeddedJVM", "OpenSim.Scripting.EmbeddedJVM\OpenSim.Scripting.EmbeddedJVM.csproj", "{97A82740-0000-0000-0000-000000000000}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Scripting.EmbeddedJVM", "OpenSim.Scripting\EmbeddedJVM\OpenSim.Scripting.EmbeddedJVM.csproj", "{97A82740-0000-0000-0000-000000000000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenGridServices.UserServer", "OpenGridServices.UserServer\OpenGridServices.UserServer.csproj", "{66591469-0000-0000-0000-000000000000}" EndProject @@ -34,7 +34,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Servers", "Servers\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageDb4o", "OpenSim.Storage\LocalStorageDb4o\OpenSim.Storage.LocalStorageDb4o.csproj", "{E1B79ECF-0000-0000-0000-000000000000}" EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageSQLite", "OpenSim.Storage.LocalStorageSQLite\OpenSim.Storage.LocalStorageSQLite.csproj", "{6B20B603-0000-0000-0000-000000000000}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenSim.Storage.LocalStorageSQLite", "OpenSim.Storage\LocalStorageSQLite\OpenSim.Storage.LocalStorageSQLite.csproj", "{6B20B603-0000-0000-0000-000000000000}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "OpenUser.Config.UserConfigDb4o", "OpenUser.Config\UserConfigDb4o\OpenUser.Config.UserConfigDb4o.csproj", "{7E494328-0000-0000-0000-000000000000}" EndProject diff --git a/prebuild.xml b/prebuild.xml index 06b6eaa..b000ae7 100644 --- a/prebuild.xml +++ b/prebuild.xml @@ -368,19 +368,19 @@ - + - ../bin/ScriptEngines/ + ../../bin/ScriptEngines/ - ../bin/ScriptEngines/ + ../../bin/ScriptEngines/ - ../bin/ + ../../bin/ @@ -500,19 +500,19 @@ - + - ../bin/ + ../../bin/ - ../bin/ + ../../bin/ - ../bin/ + ../../bin/ @@ -525,19 +525,19 @@ - + - ../bin/ + ../../bin/ - ../bin/ + ../../bin/ - ../bin/ + ../../bin/ -- cgit v1.1