* Updating internal LSL handler/compiler with Tedd's r1.

* Importing begginings of DB4oDataStore
afrisby
Adam Frisby 2007-07-16 17:46:47 +00:00
parent e2e2ac731b
commit ac4f8745ba
12 changed files with 1951 additions and 388 deletions

View File

@ -0,0 +1,84 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Scripting.LSL
{
public static class Common
{
static public bool Debug = true;
static public bool IL_UseTryCatch = true;
static public bool IL_CreateConstructor = true;
static public bool IL_CreateFunctionList = true;
static public bool IL_ProcessCodeChunks = true;
public delegate void SendToDebugEventDelegate(string Message);
public delegate void SendToLogEventDelegate(string Message);
static public event SendToDebugEventDelegate SendToDebugEvent;
static public event SendToLogEventDelegate SendToLogEvent;
static public void SendToDebug(string Message)
{
//if (Debug == true)
Console.WriteLine("Debug: " + Message);
SendToDebugEvent(DateTime.Now.ToString("[HH:mm:ss] ") + Message + "\r\n");
}
static public void SendToLog(string Message)
{
//if (Debug == true)
Console.WriteLine("LOG: " + Message);
SendToLogEvent(DateTime.Now.ToString("[HH:mm:ss] ") + Message + "\r\n");
}
}
// TEMPORARY TEST THINGIES
public static class IL_Helper
{
public static string ReverseFormatString(string text1, string format)
{
Common.SendToDebug("ReverseFormatString text1: " + text1);
Common.SendToDebug("ReverseFormatString format: " + format);
return string.Format(format, text1);
}
public static string ReverseFormatString(string text1, UInt32 text2, string format)
{
Common.SendToDebug("ReverseFormatString text1: " + text1);
Common.SendToDebug("ReverseFormatString text2: " + text2.ToString());
Common.SendToDebug("ReverseFormatString format: " + format);
return string.Format(format, text1, text2.ToString());
}
public static string Cast_ToString(object obj)
{
Common.SendToDebug("OBJECT TO BE CASTED: " + obj.GetType().ToString());
return "ABCDEFGIHJKLMNOPQ123";
}
}
}

View File

@ -1,140 +1,228 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
using System.Reflection;
using System.Reflection.Emit;
using System.Threading;
using OpenSim.Region.Scripting;
namespace OpenSim.ScriptEngines.LSL
{
public class Engine
namespace OpenSim.Region.Scripting.LSL
{
public void Start(ScriptInfo WorldAPI)
public class Engine
{
//private string LSO_FileName = @"LSO\AdditionTest.lso";
private string LSO_FileName;// = @"LSO\CloseToDefault.lso";
AppDomain appDomain;
public void Start(string FileName)
{
LSO_FileName = FileName;
//appDomain = AppDomain.CreateDomain("AlternateAppDomain");
appDomain = Thread.GetDomain();
// Create Assembly Name
AssemblyName asmName = new AssemblyName();
asmName.Name = System.IO.Path.GetFileNameWithoutExtension(LSO_FileName);
//asmName.Name = "TestAssembly";
string DLL_FileName = asmName.Name + ".dll";
string DLL_FileName_WithPath = System.IO.Path.GetDirectoryName(FileName) + @"\" + DLL_FileName;
Common.SendToLog("LSO File Name: " + System.IO.Path.GetFileName(FileName));
Common.SendToLog("Assembly name: " + asmName.Name);
Common.SendToLog("Assembly File Name: " + asmName.Name + ".dll");
Common.SendToLog("Starting processing of LSL ByteCode...");
Common.SendToLog("");
// Create Assembly Name
AssemblyName asmName = new AssemblyName();
asmName.Name = "TestAssembly";
// Create Assembly
AssemblyBuilder asmBuilder = appDomain.DefineDynamicAssembly(
asmName,
AssemblyBuilderAccess.RunAndSave
);
//// Create Assembly
//AssemblyBuilder asmBuilder =
// Thread.GetDomain().DefineDynamicAssembly
//(asmName, AssemblyBuilderAccess.RunAndSave);
// Create Assembly
AssemblyBuilder asmBuilder =
Thread.GetDomain().DefineDynamicAssembly
(asmName, AssemblyBuilderAccess.RunAndSave);
// Create a module (and save to disk)
ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule
(asmName.Name,
DLL_FileName);
// Create a module (and save to disk)
ModuleBuilder modBuilder = asmBuilder.DefineDynamicModule
(asmName.Name, asmName.Name + ".dll");
//Common.SendToDebug("asmName.Name is still \"" + asmName.Name + "\"");
// Create a Class (/Type)
TypeBuilder typeBuilder = modBuilder.DefineType(
"LSL_ScriptObject",
TypeAttributes.Public | TypeAttributes.BeforeFieldInit);
//,
// typeof());
//, typeof(LSL_BuiltIn_Commands_Interface));
//,
// typeof(object),
// new Type[] { typeof(LSL_CLRInterface.LSLScript) });
// Create a Class (/Type)
TypeBuilder typeBuilder = modBuilder.DefineType(
"MyClass",
TypeAttributes.Public,
typeof(object),
new Type[] { typeof(LSL_CLRInterface.LSLScript) });
if (Common.IL_CreateConstructor)
IL_CREATE_CONSTRUCTOR(typeBuilder);
/*
* Generate the IL itself
*/
LSO_Parser LSOP = new LSO_Parser();
LSOP.ParseFile(LSO_FileName, typeBuilder);
/*
* Done generating. Create a type and run it.
*/
/*
* Generate the IL itself
*/
Common.SendToLog("Attempting to compile assembly...");
// Compile it
Type type = typeBuilder.CreateType();
Common.SendToLog("Compilation successful!");
GenerateIL(WorldAPI, typeBuilder);
Common.SendToLog("Saving assembly: " + DLL_FileName);
asmBuilder.Save(DLL_FileName);
/*
* Done generating, create a type and run it.
*/
// Create type object for the class (after defining fields and methods)
Type type = typeBuilder.CreateType();
asmBuilder.Save("TestAssembly.dll");
// Create an instance we can play with
//LSLScript hello = (LSLScript)Activator.CreateInstance(type);
LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type);
// Play with it
MyScript.event_state_entry("Test");
}
private void GenerateIL(ScriptInfo WorldAPI, TypeBuilder typeBuilder)
{
Common.SendToLog("Creating an instance of new assembly...");
// Create an instance we can play with
//LSLScript hello = (LSLScript)Activator.CreateInstance(type);
//LSL_CLRInterface.LSLScript MyScript = (LSL_CLRInterface.LSLScript)Activator.CreateInstance(type);
object MyScript = (object)Activator.CreateInstance(type);
// For debug
LSO_Parser LSOP = new LSO_Parser();
LSOP.ParseFile("LSO\\CloseToDefault.lso", WorldAPI, ref typeBuilder);
return;
Common.SendToLog("");
System.Reflection.MemberInfo[] Members = type.GetMembers();
Common.SendToLog("Members of assembly " + type.ToString () + ":");
foreach (MemberInfo member in Members )
Common.SendToLog(member.ToString());
// Override a Method / Function
MethodBuilder methodBuilder = typeBuilder.DefineMethod("event_state_entry",
MethodAttributes.Private | MethodAttributes.Virtual,
typeof(void),
new Type[] { typeof(object) });
// Play with it
//MyScript.event_state_entry("Test");
object[] args = { null } ;
//System.Collections.Generic.List<string> Functions = (System.Collections.Generic.List<string>)type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null);
typeBuilder.DefineMethodOverride(methodBuilder,
typeof(LSL_CLRInterface.LSLScript).GetMethod("event_state_entry"));
string[] ret = { };
if (Common.IL_CreateFunctionList)
ret = (string[])type.InvokeMember("GetFunctions", BindingFlags.InvokeMethod, null, MyScript, null);
// Create the IL generator
ILGenerator il = methodBuilder.GetILGenerator();
foreach (string s in ret)
{
Common.SendToLog("");
Common.SendToLog("*** Executing LSL Server Event: " + s);
//object test = type.GetMember(s);
//object runner = type.InvokeMember(s, BindingFlags.Public | BindingFlags.InvokeMethod | BindingFlags.Instance, null, MyScript, args);
//runner();
//objBooks_Late = type.InvokeMember(s, BindingFlags.CreateInstance, null, objApp_Late, null);
type.InvokeMember(s, BindingFlags.InvokeMethod, null, MyScript, new object[] { "Test" });
}
}
/*
* TRY
*/
il.BeginExceptionBlock();
// Push "Hello World!" string to stack
il.Emit(OpCodes.Ldstr, "Hello World!");
// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("WriteLine", new Type[] { typeof(string) }));
//il.EmitCall(OpCodes.Callvirt
//il.Emit(OpCodes.Call, typeof(WorldAPI).GetMethod
//("TestFunction"));
private static void IL_CREATE_CONSTRUCTOR(TypeBuilder typeBuilder)
{
//il.ThrowException(typeof(NotSupportedException));
Common.SendToDebug("IL_CREATE_CONSTRUCTOR()");
//ConstructorBuilder constructor = typeBuilder.DefineConstructor(
// MethodAttributes.Public,
// CallingConventions.Standard,
// new Type[0]);
ConstructorBuilder constructor = typeBuilder.DefineConstructor(
MethodAttributes.Public |
MethodAttributes.SpecialName |
MethodAttributes.RTSpecialName,
CallingConventions.Standard,
new Type[0]);
//Define the reflection ConstructorInfor for System.Object
ConstructorInfo conObj = typeof(object).GetConstructor(new Type[0]);
//call constructor of base object
ILGenerator il = constructor.GetILGenerator();
Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: UInt32 State = 0;");
string FieldName;
// Create state object
FieldName = "State";
FieldBuilder State_fb = typeBuilder.DefineField(
FieldName,
typeof(UInt32),
FieldAttributes.Public);
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldc_I4, 0);
il.Emit(OpCodes.Stfld, State_fb);
/*
* CATCH
*/
il.BeginCatchBlock(typeof(Exception));
Common.SendToDebug("IL_CREATE_CONSTRUCTOR: Creating global: LSL_BuiltIn_Commands_TestImplementation LSL_BuiltIns = New LSL_BuiltIn_Commands_TestImplementation();");
//Type objType1 = typeof(object);
Type objType1 = typeof(LSL_BuiltIn_Commands_TestImplementation);
// Push "Hello World!" string to stack
il.Emit(OpCodes.Ldstr, "Something went wrong: ");
FieldName = "LSL_BuiltIns";
FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField(
FieldName,
objType1,
FieldAttributes.Public);
//call void [mscorlib]System.Console::WriteLine(string)
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("Write", new Type[] { typeof(string) }));
//LSL_BuiltIn_Commands_TestImplementation _ti = new LSL_BuiltIn_Commands_TestImplementation();
il.Emit(OpCodes.Ldarg_0);
//il.Emit(OpCodes.Ldstr, "Test 123");
il.Emit(OpCodes.Newobj, objType1.GetConstructor(new Type[] { }));
il.Emit(OpCodes.Stfld, LSL_BuiltIns_fb);
//callvirt instance string [mscorlib]System.Exception::get_Message()
il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod
("get_Message"));
//call void [mscorlib]System.Console::WriteLine(string)
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("WriteLine", new Type[] { typeof(string) }));
/*
* END TRY
*/
il.EndExceptionBlock();
il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Call, conObj);
// Push "Return from current method, with return value if present" to stack
il.Emit(OpCodes.Ret);
////il.Emit(OpCodes.Newobj, typeof(UInt32));
//il.Emit(OpCodes.Starg_0);
//// Create LSL function library
//FieldBuilder LSL_BuiltIns_fb = typeBuilder.DefineField("LSL_BuiltIns", typeof(LSL_BuiltIn_Commands_Interface), FieldAttributes.Public);
//il.Emit(OpCodes.Newobj, typeof(LSL_BuiltIn_Commands_Interface));
//il.Emit(OpCodes.Stloc_1);
il.Emit(OpCodes.Ret);
}
}
}
}

View File

@ -0,0 +1,56 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace OpenSim.Region.Scripting.LSL
{
partial class LSO_Parser
{
private static TypeBuilder CreateType(ModuleBuilder modBuilder, string typeName)
{
TypeBuilder typeBuilder = modBuilder.DefineType(typeName,
TypeAttributes.Public |
TypeAttributes.Class |
TypeAttributes.AutoClass |
TypeAttributes.AnsiClass |
TypeAttributes.BeforeFieldInit |
TypeAttributes.AutoLayout,
typeof(object),
new Type[] { typeof(object) });
return typeBuilder;
}
}
}

View File

@ -1,8 +1,36 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.ScriptEngines.LSL
namespace OpenSim.Region.Scripting.LSL
{
public class LSL_CLRInterface
{
@ -13,9 +41,9 @@ namespace OpenSim.ScriptEngines.LSL
//}
//void Run(object arg);
void event_state_entry(object arg);
//void event_state_entry(object arg);
//void event_state_exit();
void event_touch_start(object arg);
//void event_touch_start(object arg);
//void event_touch();
//void event_touch_end();
//void event_collision_start();

View File

@ -0,0 +1,352 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using System.Reflection;
using System.Reflection.Emit;
namespace OpenSim.Region.Scripting.LSL
{
partial class LSO_Parser
{
//LSO_Enums MyLSO_Enums = new LSO_Enums();
internal bool LSL_PROCESS_OPCODE(ILGenerator il)
{
byte bp1;
UInt32 u32p1;
UInt16 opcode = br_read(1)[0];
Common.SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString());
string idesc = ((LSO_Enums.Operation_Table)opcode).ToString();
switch ((LSO_Enums.Operation_Table)opcode)
{
case LSO_Enums.Operation_Table.POP:
case LSO_Enums.Operation_Table.POPL:
case LSO_Enums.Operation_Table.POPV:
case LSO_Enums.Operation_Table.POPQ:
case LSO_Enums.Operation_Table.POPIP:
case LSO_Enums.Operation_Table.POPBP:
case LSO_Enums.Operation_Table.POPSP:
case LSO_Enums.Operation_Table.POPSLR:
// ignore -- builds callframe
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Pop);");
il.Emit(OpCodes.Pop);
break;
case LSO_Enums.Operation_Table.POPARG:
Common.SendToDebug("Instruction " + idesc + ": Ignored");
Common.SendToDebug("Instruction " + idesc + ": Description: Drop x bytes from the stack ");
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.STORE:
case LSO_Enums.Operation_Table.STORES:
case LSO_Enums.Operation_Table.STOREL:
case LSO_Enums.Operation_Table.STOREV:
case LSO_Enums.Operation_Table.STOREQ:
case LSO_Enums.Operation_Table.STOREG:
case LSO_Enums.Operation_Table.STOREGS:
case LSO_Enums.Operation_Table.STOREGL:
case LSO_Enums.Operation_Table.STOREGV:
case LSO_Enums.Operation_Table.STOREGQ:
case LSO_Enums.Operation_Table.LOADP:
case LSO_Enums.Operation_Table.LOADSP:
case LSO_Enums.Operation_Table.LOADLP:
case LSO_Enums.Operation_Table.LOADVP:
case LSO_Enums.Operation_Table.LOADQP:
case LSO_Enums.Operation_Table.PUSH:
case LSO_Enums.Operation_Table.PUSHS:
case LSO_Enums.Operation_Table.PUSHL:
case LSO_Enums.Operation_Table.PUSHV:
case LSO_Enums.Operation_Table.PUSHQ:
case LSO_Enums.Operation_Table.PUSHG:
case LSO_Enums.Operation_Table.PUSHGS:
case LSO_Enums.Operation_Table.PUSHGL:
case LSO_Enums.Operation_Table.PUSHGV:
case LSO_Enums.Operation_Table.PUSHGQ:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// None
case LSO_Enums.Operation_Table.PUSHIP:
case LSO_Enums.Operation_Table.PUSHBP:
case LSO_Enums.Operation_Table.PUSHSP:
// Push Stack Top (Memory Address) to stack
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, " + myHeader.SP + ");");
Common.SendToDebug("Instruction " + idesc + ": Description: Pushing Stack Top (Memory Address from header) to stack");
il.Emit(OpCodes.Ldc_I4, myHeader.SP);
break;
// BYTE
case LSO_Enums.Operation_Table.PUSHARGB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// INTEGER
case LSO_Enums.Operation_Table.PUSHARGI:
// TODO: What is size of integer?
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes.Ldc_I4, " + u32p1 + ");");
Common.SendToDebug("Param1: " + u32p1);
il.Emit(OpCodes.Ldc_I4, u32p1);
break;
// FLOAT
case LSO_Enums.Operation_Table.PUSHARGF:
// TODO: What is size of float?
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// STRING
case LSO_Enums.Operation_Table.PUSHARGS:
string s = Read_String();
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldstr, \"" + s + "\");");
Common.SendToDebug("Param1: " + s);
il.Emit(OpCodes.Ldstr, s);
break;
// VECTOR z,y,x
case LSO_Enums.Operation_Table.PUSHARGV:
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// ROTATION s,z,y,x
case LSO_Enums.Operation_Table.PUSHARGQ:
Common.SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4), 0));
Common.SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.PUSHARGE:
u32p1 = BitConverter.ToUInt32(br_read(4), 0);
//Common.SendToDebug("Instruction PUSHSP: il.Emit(OpCodes., " + u32p1 + ");");
Common.SendToDebug("Instruction " + idesc + ": Ignoring (not in use according to doc)");
//Common.SendToDebug("Instruction " + idesc + ": Description: Pushes X bytes of $00 onto the stack (used to put space for local variable memory for a call)");
Common.SendToDebug("Param1: " + u32p1);
//il.Emit(OpCodes.ldc_i4, u32p1);
//if (u32p1 > 0) {
//for (int _ic=0; _ic < u32p1; _ic++)
//{
// Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldnull);");
// il.Emit(OpCodes.Ldnull);
//}
break;
// BYTE
case LSO_Enums.Operation_Table.ADD:
bp1 = br_read(1)[0];
Common.SendToDebug("Instruction " + idesc + ": Add type: " + ((LSO_Enums.OpCode_Add_TypeDefs)bp1).ToString());
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Add_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Add_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc
+ ": il.Emit(OpCodes.Call, typeof(System.String).GetMethod(\"Concat\", new Type[] { typeof(object), typeof(object) }));");
il.Emit(OpCodes.Call, typeof(System.String).GetMethod
("Concat", new Type[] { typeof(object), typeof(object) }));
break;
case LSO_Enums.OpCode_Add_TypeDefs.UInt32:
default:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Add);");
il.Emit(OpCodes.Add);
break;
}
//il.Emit(OpCodes.Add, p1);
break;
case LSO_Enums.Operation_Table.SUB:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Sub);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Sub);
//il.Emit(OpCodes.Sub, p1);
break;
case LSO_Enums.Operation_Table.MUL:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Mul);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Mul);
//il.Emit(OpCodes.Mul, p1);
break;
case LSO_Enums.Operation_Table.DIV:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Div);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Div);
//il.Emit(OpCodes.Div, p1);
break;
case LSO_Enums.Operation_Table.EQ:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ceq);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Ceq);
//il.Emit(OpCodes.Ceq, p1);
break;
case LSO_Enums.Operation_Table.NEQ:
case LSO_Enums.Operation_Table.LEQ:
case LSO_Enums.Operation_Table.GEQ:
case LSO_Enums.Operation_Table.LESS:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Clt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Clt_Un);
//il.Emit(OpCodes.Clt, p1);
break;
case LSO_Enums.Operation_Table.GREATER:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Cgt_Un);");
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
il.Emit(OpCodes.Cgt_Un);
//il.Emit(OpCodes.Cgt, p1);
break;
case LSO_Enums.Operation_Table.MOD:
case LSO_Enums.Operation_Table.BOOLOR:
bp1 = br_read(1)[0];
Common.SendToDebug("Param1: " + bp1);
break;
// LONG
case LSO_Enums.Operation_Table.JUMP:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE, LONG
case LSO_Enums.Operation_Table.JUMPIF:
case LSO_Enums.Operation_Table.JUMPNIF:
Common.SendToDebug("Param1: " + br_read(1)[0]);
Common.SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// LONG
case LSO_Enums.Operation_Table.STATE:
bp1 = br_read(1)[0];
//il.Emit(OpCodes.Ld); // Load local variable 0 onto stack
//il.Emit(OpCodes.Ldc_I4, 0); // Push index position
//il.Emit(OpCodes.Ldstr, EventList[p1]); // Push value
//il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value
break;
case LSO_Enums.Operation_Table.CALL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE
case LSO_Enums.Operation_Table.CAST:
bp1 = br_read(1)[0];
Common.SendToDebug("Instruction " + idesc + ": Cast to type: " + ((LSO_Enums.OpCode_Cast_TypeDefs)bp1));
Common.SendToDebug("Param1: " + bp1);
switch ((LSO_Enums.OpCode_Cast_TypeDefs)bp1)
{
case LSO_Enums.OpCode_Cast_TypeDefs.String:
Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Calli, typeof(System.Convert).GetMethod(\"ToString\", new Type[] { typeof(object) }));");
//il.Emit(OpCodes.Box, typeof (UInt32));
il.Emit(OpCodes.Calli, typeof(Common).GetMethod
("Cast_ToString", new Type[] { typeof(object) }));
//il.Emit(OpCodes.Box, typeof(System.UInt32) );
//il.Emit(OpCodes.Box, typeof(string));
//il.Emit(OpCodes.Conv_R8);
//il.Emit(OpCodes.Call, typeof(System.Convert).GetMethod
// ("ToString", new Type[] { typeof(float) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": Unknown cast type!");
break;
}
break;
// LONG
case LSO_Enums.Operation_Table.STACKTOS:
case LSO_Enums.Operation_Table.STACKTOL:
Common.SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4), 0));
break;
// BYTE
case LSO_Enums.Operation_Table.PRINT:
case LSO_Enums.Operation_Table.CALLLIB:
Common.SendToDebug("Param1: " + br_read(1)[0]);
break;
// SHORT
case LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
// TODO: What is size of short?
UInt16 U16p1 = BitConverter.ToUInt16(br_read(2), 0);
Common.SendToDebug("Instruction " + idesc + ": Builtin Command: " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString());
Common.SendToDebug("Param1: " + U16p1);
switch ((LSO_Enums.BuiltIn_Functions)U16p1)
{
case LSO_Enums.BuiltIn_Functions.llSay:
Common.SendToDebug("Instruction " + idesc + " " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString()
+ ": Mapped to internal function");
//il.Emit(OpCodes.Ldstr, "INTERNAL COMMAND: llSay({0}, \"{1}\"");
//il.Emit(OpCodes.Call, typeof(IL_Helper).GetMethod("ReverseFormatString",
// new Type[] { typeof(string), typeof(UInt32), typeof(string) }
//));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Call,
// typeof(Console).GetMethod("WriteLine",
// new Type[] { typeof(string) }
//));
il.Emit(OpCodes.Call,
typeof(Common).GetMethod("SendToLog",
new Type[] { typeof(string) }
));
//il.Emit(OpCodes.Pop);
//il.Emit(OpCodes.Ldind_I2, 0);
//il.Emit(OpCodes.Call, typeof(string).GetMethod("Format", new Type[] { typeof(string), typeof(object) }));
//il.EmitCalli(OpCodes.Calli,
//il.Emit(OpCodes.Call, typeof().GetMethod
// ("llSay", new Type[] { typeof(UInt32), typeof(string) }));
break;
default:
Common.SendToDebug("Instruction " + idesc + ": " + ((LSO_Enums.BuiltIn_Functions)U16p1).ToString() + ": INTERNAL COMMAND NOT IMPLEMENTED");
break;
}
//Common.SendToDebug("Instruction " + idesc + ": DEBUG: Faking return code:");
//Common.SendToDebug("Instruction " + idesc + ": il.Emit(OpCodes.Ldc_I4, 0);");
//il.Emit(OpCodes.Ldc_I4, 0);
break;
// RETURN
case LSO_Enums.Operation_Table.RETURN:
Common.SendToDebug("Last OPCODE was return command. Code chunk execution complete.");
return true;
break;
}
return false;
}
}
}

View File

@ -1,11 +1,70 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.ScriptEngines.LSL
namespace OpenSim.Region.Scripting.LSL
{
static class LSO_Enums
{
//public System.Collections.Generic.Dictionary<Byte, Type> OpCode_Add_Types;
//LSO_Enums() {
// OpCode_Add_Types.Add(51, typeof(String));
// OpCode_Add_Types.Add(17, typeof(UInt32));
//}
public enum OpCode_Add_TypeDefs
{
String = 51,
UInt32 = 17
}
public enum OpCode_Cast_TypeDefs
{
String = 19
}
public struct Vector
{
public UInt32 Z;
public UInt32 Y;
public UInt32 X;
}
public struct Rotation
{
public UInt32 S;
public UInt32 Z;
public UInt32 Y;
public UInt32 X;
}
public enum Variable_Type_Codes
{

View File

@ -1,22 +1,48 @@
using System;
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using OpenSim.Region.Scripting;
namespace OpenSim.ScriptEngines.LSL
namespace OpenSim.Region.Scripting.LSL
{
class LSO_Parser
partial class LSO_Parser
{
private bool Debug = true;
private FileStream fs;
private BinaryReader br;
private LSO_Struct.Header myHeader;
private TypeBuilder typeBuilder;
private ScriptInfo WorldAPI;
private System.Collections.Generic.List<string> EventList = new System.Collections.Generic.List<string>();
/// <summary>
/// Parse LSO file.
@ -24,12 +50,12 @@ using OpenSim.Region.Scripting;
/// TODO: What else does it do?
/// </summary>
/// <param name="FileName">FileName of LSO ByteCode file</param>
public void ParseFile(string FileName, ScriptInfo _WorldAPI, ref TypeBuilder _typeBuilder)
public void ParseFile(string FileName, TypeBuilder _typeBuilder)
{
typeBuilder = _typeBuilder;
WorldAPI = _WorldAPI;
//WorldAPI = _WorldAPI;
// Open
SendToDebug("Opening filename: " + FileName);
Common.SendToDebug("Opening filename: " + FileName);
fs = File.Open(FileName, FileMode.Open, FileAccess.Read, FileShare.Read);
br = new BinaryReader(fs, Encoding.BigEndianUnicode);
@ -38,7 +64,7 @@ using OpenSim.Region.Scripting;
// HEADER BLOCK
SendToDebug("Reading HEADER BLOCK at: 0");
Common.SendToDebug("Reading HEADER BLOCK at: 0");
fs.Seek(0, SeekOrigin.Begin);
myHeader = new LSO_Struct.Header();
myHeader.TM = BitConverter.ToUInt32(br_read(4), 0);
@ -65,50 +91,50 @@ using OpenSim.Region.Scripting;
myHeader.NER = BitConverter.ToUInt64(br_read(8), 0);
// Print Header Block to debug
SendToDebug("TM - Top of memory (size): " + myHeader.TM);
SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP);
SendToDebug("VN - Version number: " + myHeader.VN);
SendToDebug("BP - Local Frame Pointer: " + myHeader.BP);
SendToDebug("SP - Stack Pointer: " + myHeader.SP);
SendToDebug("HR - Heap Register: " + myHeader.HR);
SendToDebug("HP - Heap Pointer: " + myHeader.HP);
SendToDebug("CS - Current State: " + myHeader.CS);
SendToDebug("NS - Next State: " + myHeader.NS);
SendToDebug("CE - Current Events: " + myHeader.CE);
SendToDebug("IE - In Event: " + myHeader.IE);
SendToDebug("ER - Event Register: " + myHeader.ER);
SendToDebug("FR - Fault Register: " + myHeader.FR);
SendToDebug("SLR - Sleep Register: " + myHeader.SLR);
SendToDebug("GVR - Global Variable Register: " + myHeader.GVR);
SendToDebug("GFR - Global Function Register: " + myHeader.GFR);
SendToDebug("PR - Parameter Register: " + myHeader.PR);
SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR);
SendToDebug("SR - State Register: " + myHeader.SR);
SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE);
SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE);
SendToDebug("NER - 64-bit Event Register: " + myHeader.NER);
SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position);
Common.SendToDebug("TM - Top of memory (size): " + myHeader.TM);
Common.SendToDebug("IP - Instruction Pointer (0=not running): " + myHeader.IP);
Common.SendToDebug("VN - Version number: " + myHeader.VN);
Common.SendToDebug("BP - Local Frame Pointer: " + myHeader.BP);
Common.SendToDebug("SP - Stack Pointer: " + myHeader.SP);
Common.SendToDebug("HR - Heap Register: " + myHeader.HR);
Common.SendToDebug("HP - Heap Pointer: " + myHeader.HP);
Common.SendToDebug("CS - Current State: " + myHeader.CS);
Common.SendToDebug("NS - Next State: " + myHeader.NS);
Common.SendToDebug("CE - Current Events: " + myHeader.CE);
Common.SendToDebug("IE - In Event: " + myHeader.IE);
Common.SendToDebug("ER - Event Register: " + myHeader.ER);
Common.SendToDebug("FR - Fault Register: " + myHeader.FR);
Common.SendToDebug("SLR - Sleep Register: " + myHeader.SLR);
Common.SendToDebug("GVR - Global Variable Register: " + myHeader.GVR);
Common.SendToDebug("GFR - Global Function Register: " + myHeader.GFR);
Common.SendToDebug("PR - Parameter Register: " + myHeader.PR);
Common.SendToDebug("ESR - Energy Supply Register: " + myHeader.ESR);
Common.SendToDebug("SR - State Register: " + myHeader.SR);
Common.SendToDebug("NCE - 64-bit Current Events: " + myHeader.NCE);
Common.SendToDebug("NIE - 64-bit In Events: " + myHeader.NIE);
Common.SendToDebug("NER - 64-bit Event Register: " + myHeader.NER);
Common.SendToDebug("Read position when exiting HEADER BLOCK: " + fs.Position);
// STATIC BLOCK
SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR);
Common.SendToDebug("Reading STATIC BLOCK at: " + myHeader.GVR);
fs.Seek(myHeader.GVR, SeekOrigin.Begin);
int StaticBlockCount = 0;
// Read function blocks until we hit GFR
while (fs.Position < myHeader.GFR)
{
StaticBlockCount++;
SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position);
Common.SendToDebug("Reading Static Block " + StaticBlockCount + " at: " + fs.Position);
//fs.Seek(myHeader.GVR, SeekOrigin.Begin);
LSO_Struct.StaticBlock myStaticBlock = new LSO_Struct.StaticBlock();
myStaticBlock.Static_Chunk_Header_Size = BitConverter.ToUInt32(br_read(4), 0);
myStaticBlock.ObjectType = br_read(1)[0];
SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString());
Common.SendToDebug("Static Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myStaticBlock.ObjectType).ToString());
myStaticBlock.Unknown = br_read(1)[0];
// Size of datatype varies
if (myStaticBlock.ObjectType != 0)
myStaticBlock.BlockVariable = br_read(getObjectSize(myStaticBlock.ObjectType));
}
SendToDebug("Number of Static Blocks read: " + StaticBlockCount);
Common.SendToDebug("Number of Static Blocks read: " + StaticBlockCount);
// FUNCTION BLOCK
@ -117,22 +143,22 @@ using OpenSim.Region.Scripting;
if (myHeader.GFR == myHeader.SR)
{
// If GFR and SR are at same position then there is no fuction block
SendToDebug("No FUNCTION BLOCK found");
Common.SendToDebug("No FUNCTION BLOCK found");
} else {
SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR);
Common.SendToDebug("Reading FUNCTION BLOCK at: " + myHeader.GFR);
fs.Seek(myHeader.GFR, SeekOrigin.Begin);
myFunctionBlock.FunctionCount = BitConverter.ToUInt32(br_read(4), 0);
SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount);
Common.SendToDebug("Number of functions in Fuction Block: " + myFunctionBlock.FunctionCount);
if (myFunctionBlock.FunctionCount > 0)
{
myFunctionBlock.CodeChunkPointer = new UInt32[myFunctionBlock.FunctionCount];
for (int i = 0; i < myFunctionBlock.FunctionCount; i++)
{
SendToDebug("Reading function " + i + " at: " + fs.Position);
Common.SendToDebug("Reading function " + i + " at: " + fs.Position);
// TODO: ADD TO FUNCTION LIST (How do we identify it later?)
// Note! Absolute position
myFunctionBlock.CodeChunkPointer[i] = BitConverter.ToUInt32(br_read(4), 0) + myHeader.GFR;
SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]);
Common.SendToDebug("Fuction " + i + " code chunk position: " + myFunctionBlock.CodeChunkPointer[i]);
}
}
}
@ -140,7 +166,7 @@ using OpenSim.Region.Scripting;
// STATE FRAME BLOCK
// Always right after FUNCTION BLOCK
SendToDebug("Reading STATE BLOCK at: " + myHeader.SR);
Common.SendToDebug("Reading STATE BLOCK at: " + myHeader.SR);
fs.Seek(myHeader.SR, SeekOrigin.Begin);
LSO_Struct.StateFrameBlock myStateFrameBlock = new LSO_Struct.StateFrameBlock();
myStateFrameBlock.StateCount = BitConverter.ToUInt32(br_read(4), 0);
@ -150,12 +176,12 @@ using OpenSim.Region.Scripting;
myStateFrameBlock.StatePointer = new LSO_Struct.StatePointerBlock[myStateFrameBlock.StateCount];
for (int i = 0; i < myStateFrameBlock.StateCount; i++)
{
SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position);
Common.SendToDebug("Reading STATE POINTER BLOCK " + (i+1) + " at: " + fs.Position);
// Position is relative to state frame
myStateFrameBlock.StatePointer[i].Location = myHeader.SR + BitConverter.ToUInt32(br_read(4), 0);
myStateFrameBlock.StatePointer[i].EventMask = new System.Collections.BitArray(br_read(8));
SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location);
SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count);
Common.SendToDebug("Pointer: " + myStateFrameBlock.StatePointer[i].Location);
Common.SendToDebug("Total potential EventMask bits: " + myStateFrameBlock.StatePointer[i].EventMask.Count);
//// Read STATE BLOCK
//long CurPos = fs.Position;
@ -175,7 +201,7 @@ using OpenSim.Region.Scripting;
{
fs.Seek(myStateFrameBlock.StatePointer[i].Location, SeekOrigin.Begin);
SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position);
Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " at: " + fs.Position);
// READ: STATE BLOCK HEADER
myStateFrameBlock.StatePointer[i].StateBlock = new LSO_Struct.StateBlock();
@ -183,9 +209,9 @@ using OpenSim.Region.Scripting;
myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize = BitConverter.ToUInt32(br_read(4), 0);
myStateFrameBlock.StatePointer[i].StateBlock.Unknown = br_read(1)[0];
myStateFrameBlock.StatePointer[i].StateBlock.EndPos = (UInt32)fs.Position; // Note
SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos);
SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize);
SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos);
Common.SendToDebug("State block Start Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.StartPos);
Common.SendToDebug("State block Header Size: " + myStateFrameBlock.StatePointer[i].StateBlock.HeaderSize);
Common.SendToDebug("State block Header End Pos: " + myStateFrameBlock.StatePointer[i].StateBlock.EndPos);
// We need to count number of bits flagged in EventMask?
@ -202,11 +228,11 @@ using OpenSim.Region.Scripting;
{
// We got an event
// READ: STATE BLOCK HANDLER
SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position);
Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER matching EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") at: " + fs.Position);
myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer = myStateFrameBlock.StatePointer[i].StateBlock.EndPos + BitConverter.ToUInt32(br_read(4), 0);
myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize = BitConverter.ToUInt32(br_read(4), 0);
SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer);
SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize );
Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Code Chunk Pointer: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer);
Common.SendToDebug("Reading STATE BLOCK " + (i + 1) + " HANDLER EVENT MASK " + ii + " (" + ((LSO_Enums.Event_Mask_Values)ii).ToString() + ") Call Frame Size: " + myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CallFrameSize );
}
}
}
@ -224,7 +250,7 @@ using OpenSim.Region.Scripting;
// myFunctionCodeChunk = new LSO_Struct.CodeChunk[myFunctionBlock.FunctionCount];
// for (int i = 0; i < myFunctionBlock.FunctionCount; i++)
// {
// SendToDebug("Reading Function Code Chunk " + i);
// Common.SendToDebug("Reading Function Code Chunk " + i);
// myFunctionCodeChunk[i] = GetCodeChunk((UInt32)myFunctionBlock.CodeChunkPointer[i]);
// }
@ -244,32 +270,23 @@ using OpenSim.Region.Scripting;
if (myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer > 0)
{
SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii);
Common.SendToDebug("Reading Event Code Chunk state " + i + ", event " + (LSO_Enums.Event_Mask_Values)ii);
// Override a Method / Function
string eventname = "event_" + (LSO_Enums.Event_Mask_Values)ii;
SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod...");
MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
MethodAttributes.Private | MethodAttributes.Virtual,
typeof(void),
new Type[] { typeof(object) });
string eventname = i + "_event_" + (LSO_Enums.Event_Mask_Values)ii;
Common.SendToDebug("Event Name: " + eventname);
if (Common.IL_ProcessCodeChunks)
{
EventList.Add(eventname);
SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder...");
typeBuilder.DefineMethodOverride(methodBuilder,
typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname));
// Create the IL generator
SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();");
ILGenerator il = methodBuilder.GetILGenerator();
LSO_Struct.CodeChunk myECC =
GetCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, il, eventname);
// JUMP TO CODE PROCESSOR
ProcessCodeChunk(myStateFrameBlock.StatePointer[i].StateBlock.StateBlockHandlers[ii].CodeChunkPointer, typeBuilder, eventname);
}
}
}
}
}
@ -279,13 +296,16 @@ using OpenSim.Region.Scripting;
br.Close();
fs.Close();
if (Common.IL_CreateFunctionList)
IL_INSERT_FUNCTIONLIST();
}
private LSO_Struct.HeapBlock GetHeap(UInt32 pos)
{
// HEAP BLOCK
// TODO:? Special read for strings/keys (null terminated) and lists (pointers to other HEAP entries)
SendToDebug("Reading HEAP BLOCK at: " + pos);
Common.SendToDebug("Reading HEAP BLOCK at: " + pos);
fs.Seek(pos, SeekOrigin.Begin);
LSO_Struct.HeapBlock myHeapBlock = new LSO_Struct.HeapBlock();
@ -294,15 +314,12 @@ using OpenSim.Region.Scripting;
myHeapBlock.ReferenceCount = BitConverter.ToUInt16(br_read(2), 0);
myHeapBlock.Data = br_read(getObjectSize(myHeapBlock.ObjectType));
SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize);
SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString());
SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount);
Common.SendToDebug("Heap Block Data Block Size: " + myHeapBlock.DataBlockSize);
Common.SendToDebug("Heap Block ObjectType: " + ((LSO_Enums.Variable_Type_Codes)myHeapBlock.ObjectType).ToString());
Common.SendToDebug("Heap Block Reference Count: " + myHeapBlock.ReferenceCount);
return myHeapBlock;
}
private byte[] br_read(int len)
{
if (len <= 0)
@ -317,7 +334,7 @@ using OpenSim.Region.Scripting;
}
catch (Exception e)
{
SendToDebug("Exception: " + e.ToString());
Common.SendToDebug("Exception: " + e.ToString());
throw (e);
}
}
@ -327,7 +344,25 @@ using OpenSim.Region.Scripting;
// br.Read(bytes,0, len);
// return bytes;
//}
private Type getLLObjectType(byte objectCode)
{
switch ((LSO_Enums.Variable_Type_Codes)objectCode)
{
case LSO_Enums.Variable_Type_Codes.Void: return typeof(void);
case LSO_Enums.Variable_Type_Codes.Integer: return typeof(UInt32);
case LSO_Enums.Variable_Type_Codes.Float: return typeof(float);
case LSO_Enums.Variable_Type_Codes.String: return typeof(string);
case LSO_Enums.Variable_Type_Codes.Key: return typeof(string);
case LSO_Enums.Variable_Type_Codes.Vector: return typeof(LSO_Enums.Vector);
case LSO_Enums.Variable_Type_Codes.Rotation: return typeof(LSO_Enums.Rotation);
case LSO_Enums.Variable_Type_Codes.List:
Common.SendToDebug("TODO: List datatype not implemented yet!");
return typeof(System.Collections.ArrayList);
default:
Common.SendToDebug("Lookup of LSL datatype " + objectCode + " to .Net datatype failed: Unknown LSL datatype. Defaulting to object.");
return typeof(object);
}
}
private int getObjectSize(byte ObjectType)
{
switch (ObjectType)
@ -346,13 +381,6 @@ using OpenSim.Region.Scripting;
return 0;
}
}
private void SendToDebug(string Message)
{
if (Debug == true)
Console.WriteLine("Debug: " + Message);
}
private string Read_String()
{
string ret = "";
@ -365,244 +393,235 @@ using OpenSim.Region.Scripting;
return ret;
}
/// <summary>
/// Reads a code chunk into structure and returns it.
/// <summary>
/// Reads a code chunk and creates IL
/// </summary>
/// <param name="pos">Absolute position in file. REMEMBER TO ADD myHeader.GFR!</param>
/// <returns></returns>
private LSO_Struct.CodeChunk GetCodeChunk(UInt32 pos, ILGenerator il, string eventname)
/// <param name="typeBuilder">TypeBuilder for assembly</param>
/// <param name="eventname">Name of event (function) to generate</param>
private void ProcessCodeChunk(UInt32 pos, TypeBuilder typeBuilder, string eventname)
{
/*
* CLR TRY
*/
//SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()");
il.BeginExceptionBlock();
// Push "Hello World!" string to stack
//SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname);
// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
//SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("WriteLine", new Type[] { typeof(string) }));
LSO_Struct.CodeChunk myCodeChunk = new LSO_Struct.CodeChunk();
SendToDebug("Reading Function Code Chunk at: " + pos);
Common.SendToDebug("Reading Function Code Chunk at: " + pos);
fs.Seek(pos, SeekOrigin.Begin);
myCodeChunk.CodeChunkHeaderSize = BitConverter.ToUInt32(br_read(4), 0);
SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize );
Common.SendToDebug("CodeChunk Header Size: " + myCodeChunk.CodeChunkHeaderSize );
// Read until null
myCodeChunk.Comment = Read_String();
SendToDebug("Function comment: " + myCodeChunk.Comment);
Common.SendToDebug("Function comment: " + myCodeChunk.Comment);
myCodeChunk.ReturnType = br_read(1)[0];
SendToDebug("Return type: " + (LSO_Enums.Variable_Type_Codes)myCodeChunk.ReturnType);
Common.SendToDebug("Return type #" + myCodeChunk.ReturnType + ": " + (getLLObjectType(myCodeChunk.ReturnType).ToString()));
// TODO: How to determine number of codechunks -- does this method work?
myCodeChunk.CodeChunkArguments = new System.Collections.Generic.List<LSO_Struct.CodeChunkArgument>();
byte reader = br_read(1)[0];
reader = br_read(1)[0];
// NOTE ON CODE CHUNK ARGUMENTS
// This determins type definition
int ccount = 0;
while (reader != 0x000)
{
ccount++;
SendToDebug("Reading Code Chunk Argument " + ccount);
Common.SendToDebug("Reading Code Chunk Argument " + ccount);
LSO_Struct.CodeChunkArgument CCA = new LSO_Struct.CodeChunkArgument();
CCA.FunctionReturnType = reader;
reader = br_read(1)[0];
CCA.NullString = reader;
myCodeChunk.CodeChunkArguments.Add(CCA);
SendToDebug("Code Chunk Argument " + ccount + " return type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType);
Common.SendToDebug("Code Chunk Argument " + ccount + " type: " + (LSO_Enums.Variable_Type_Codes)CCA.FunctionReturnType);
}
// Create string array
Type[] MethodArgs = new Type[myCodeChunk.CodeChunkArguments.Count];
for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++)
{
MethodArgs[_ic] = getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType);
Common.SendToDebug("Method argument " + _ic + ": " + getLLObjectType(myCodeChunk.CodeChunkArguments[_ic].FunctionReturnType).ToString());
}
// End marker is 0x000
myCodeChunk.EndMarker = reader;
// TODO: How to read and identify following code
// TODO: Code is read until a return of some sort is found
bool FoundRet = false;
while (FoundRet == false)
//
// Emit: START OF METHOD (FUNCTION)
//
Common.SendToDebug("CLR:" + eventname + ":MethodBuilder methodBuilder = typeBuilder.DefineMethod...");
MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
MethodAttributes.Public,
typeof(void),
MethodArgs);
//typeof(void), //getLLObjectType(myCodeChunk.ReturnType),
// new Type[] { typeof(object) }, //);
//Common.SendToDebug("CLR:" + eventname + ":typeBuilder.DefineMethodOverride(methodBuilder...");
//typeBuilder.DefineMethodOverride(methodBuilder,
// typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname));
// Create the IL generator
Common.SendToDebug("CLR:" + eventname + ":ILGenerator il = methodBuilder.GetILGenerator();");
ILGenerator il = methodBuilder.GetILGenerator();
if (Common.IL_UseTryCatch)
IL_INSERT_TRY(il, eventname);
// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
//Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
//il.Emit(OpCodes.Call, typeof(Console).GetMethod
// ("WriteLine", new Type[] { typeof(string) }));
//Common.SendToDebug("STARTUP: il.Emit(OpCodes.Ldc_I4_S, 0);");
//il.Emit(OpCodes.Ldc_I4_S, 0);
for (int _ic = 0; _ic < myCodeChunk.CodeChunkArguments.Count; _ic++)
{
//reader = br_read(1)[0];
//UInt16 opcode = BitConverter.ToUInt16(br_read(1),0);
UInt16 opcode = br_read(1)[0];
//long rPos = fs.Position;
SendToDebug("OPCODE: " + ((LSO_Enums.Operation_Table)opcode).ToString());
switch (opcode)
{
// LONG
case (UInt16)LSO_Enums.Operation_Table.POPARG:
case (UInt16)LSO_Enums.Operation_Table.STORE:
case (UInt16)LSO_Enums.Operation_Table.STORES:
case (UInt16)LSO_Enums.Operation_Table.STOREL:
case (UInt16)LSO_Enums.Operation_Table.STOREV:
case (UInt16)LSO_Enums.Operation_Table.STOREQ:
case (UInt16)LSO_Enums.Operation_Table.STOREG:
case (UInt16)LSO_Enums.Operation_Table.STOREGS:
case (UInt16)LSO_Enums.Operation_Table.STOREGL:
case (UInt16)LSO_Enums.Operation_Table.STOREGV:
case (UInt16)LSO_Enums.Operation_Table.STOREGQ:
case (UInt16)LSO_Enums.Operation_Table.LOADP:
case (UInt16)LSO_Enums.Operation_Table.LOADSP:
case (UInt16)LSO_Enums.Operation_Table.LOADLP:
case (UInt16)LSO_Enums.Operation_Table.LOADVP:
case (UInt16)LSO_Enums.Operation_Table.LOADQP:
case (UInt16)LSO_Enums.Operation_Table.PUSH:
case (UInt16)LSO_Enums.Operation_Table.PUSHS:
case (UInt16)LSO_Enums.Operation_Table.PUSHL:
case (UInt16)LSO_Enums.Operation_Table.PUSHV:
case (UInt16)LSO_Enums.Operation_Table.PUSHQ:
case (UInt16)LSO_Enums.Operation_Table.PUSHG:
case (UInt16)LSO_Enums.Operation_Table.PUSHGS:
case (UInt16)LSO_Enums.Operation_Table.PUSHGL:
case (UInt16)LSO_Enums.Operation_Table.PUSHGV:
case (UInt16)LSO_Enums.Operation_Table.PUSHGQ:
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// BYTE
case (UInt16)LSO_Enums.Operation_Table.PUSHARGB:
SendToDebug("Param1: " + br_read(1)[0]);
break;
// INTEGER
case (UInt16)LSO_Enums.Operation_Table.PUSHARGI:
// TODO: What is size of integer?
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// FLOAT
case (UInt16)LSO_Enums.Operation_Table.PUSHARGF:
// TODO: What is size of float?
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// STRING
case (UInt16)LSO_Enums.Operation_Table.PUSHARGS:
string s = Read_String();
SendToDebug("Param1: " + s);
il.Emit(OpCodes.Ldstr, s);
break;
// VECTOR z,y,x
case (UInt16)LSO_Enums.Operation_Table.PUSHARGV:
SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0));
SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0));
SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0));
break;
// ROTATION s,z,y,x
case (UInt16)LSO_Enums.Operation_Table.PUSHARGQ:
SendToDebug("Param1 S: " + BitConverter.ToUInt32(br_read(4),0));
SendToDebug("Param1 Z: " + BitConverter.ToUInt32(br_read(4),0));
SendToDebug("Param1 Y: " + BitConverter.ToUInt32(br_read(4),0));
SendToDebug("Param1 X: " + BitConverter.ToUInt32(br_read(4),0));
break;
// LONG
case (UInt16)LSO_Enums.Operation_Table.PUSHARGE:
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// BYTE
case (UInt16)LSO_Enums.Operation_Table.ADD:
case (UInt16)LSO_Enums.Operation_Table.SUB:
case (UInt16)LSO_Enums.Operation_Table.MUL:
case (UInt16)LSO_Enums.Operation_Table.DIV:
case (UInt16)LSO_Enums.Operation_Table.MOD:
case (UInt16)LSO_Enums.Operation_Table.EQ:
case (UInt16)LSO_Enums.Operation_Table.NEQ:
case (UInt16)LSO_Enums.Operation_Table.LEQ:
case (UInt16)LSO_Enums.Operation_Table.GEQ:
case (UInt16)LSO_Enums.Operation_Table.LESS:
case (UInt16)LSO_Enums.Operation_Table.GREATER:
case (UInt16)LSO_Enums.Operation_Table.BOOLOR:
SendToDebug("Param1: " + br_read(1)[0]);
break;
// LONG
case (UInt16)LSO_Enums.Operation_Table.JUMP:
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// BYTE, LONG
case (UInt16)LSO_Enums.Operation_Table.JUMPIF:
case (UInt16)LSO_Enums.Operation_Table.JUMPNIF:
SendToDebug("Param1: " + br_read(1)[0]);
SendToDebug("Param2: " + BitConverter.ToUInt32(br_read(4),0));
break;
// LONG
case (UInt16)LSO_Enums.Operation_Table.STATE:
case (UInt16)LSO_Enums.Operation_Table.CALL:
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// BYTE
case (UInt16)LSO_Enums.Operation_Table.CAST:
SendToDebug("Param1: " + br_read(1)[0]);
break;
// LONG
case (UInt16)LSO_Enums.Operation_Table.STACKTOS:
case (UInt16)LSO_Enums.Operation_Table.STACKTOL:
SendToDebug("Param1: " + BitConverter.ToUInt32(br_read(4),0));
break;
// BYTE
case (UInt16)LSO_Enums.Operation_Table.PRINT:
case (UInt16)LSO_Enums.Operation_Table.CALLLIB:
SendToDebug("Param1: " + br_read(1)[0]);
break;
// SHORT
case (UInt16)LSO_Enums.Operation_Table.CALLLIB_TWO_BYTE:
// TODO: What is size of short?
UInt16 _i = BitConverter.ToUInt16(br_read(2), 0);
SendToDebug("Param1: " + _i);
switch (_i)
{
case (UInt16)LSO_Enums.BuiltIn_Functions.llSay:
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("WriteLine", new Type[] { typeof(string) }));
break;
}
break;
// RETURN
case (UInt16)LSO_Enums.Operation_Table.RETURN:
SendToDebug("Last OPCODE was return command. Code chunk execution complete.");
FoundRet = true;
break;
}
//fs.Seek(rPos, SeekOrigin.Begin);
Common.SendToDebug("PARAMS: il.Emit(OpCodes.Ldarg, " + _ic + ");");
il.Emit(OpCodes.Ldarg, _ic);
}
//
// CALLING OPCODE PROCESSOR, one command at the time TO GENERATE IL
//
bool FoundRet = false;
while (FoundRet == false)
{
FoundRet = LSL_PROCESS_OPCODE(il);
}
if (Common.IL_UseTryCatch)
IL_INSERT_END_TRY(il, eventname);
// Emit: RETURN FROM METHOD
il.Emit(OpCodes.Ret);
return;
}
private void IL_INSERT_FUNCTIONLIST()
{
Common.SendToDebug("Creating function list");
string eventname = "GetFunctions";
Common.SendToDebug("Creating IL " + eventname);
// Define a private String field.
//FieldBuilder myField = myTypeBuilder.DefineField("EventList", typeof(String[]), FieldAttributes.Public);
//FieldBuilder mem = typeBuilder.DefineField("mem", typeof(Array), FieldAttributes.Private);
MethodBuilder methodBuilder = typeBuilder.DefineMethod(eventname,
MethodAttributes.Public,
typeof(string[]),
null);
//typeBuilder.DefineMethodOverride(methodBuilder,
// typeof(LSL_CLRInterface.LSLScript).GetMethod(eventname));
ILGenerator il = methodBuilder.GetILGenerator();
// IL_INSERT_TRY(il, eventname);
// // Push string to stack
// il.Emit(OpCodes.Ldstr, "Inside " + eventname);
//// Push Console.WriteLine command to stack ... Console.WriteLine("Hello World!");
//il.Emit(OpCodes.Call, typeof(Console).GetMethod
// ("WriteLine", new Type[] { typeof(string) }));
//initIL.Emit(OpCodes.Newobj, typeof(string[]));
//string[] MyArray = new string[2] { "TestItem1" , "TestItem2" };
il.DeclareLocal(typeof(string[]));
//il.Emit(OpCodes.Ldarg_0);
il.Emit(OpCodes.Ldc_I4, EventList.Count); // Specify array length
il.Emit(OpCodes.Newarr, typeof(String)); // create new string array
il.Emit(OpCodes.Stloc_0); // Store array as local variable 0 in stack
for (int lv = 0; lv < EventList.Count; lv++)
{
il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack
il.Emit(OpCodes.Ldc_I4, lv); // Push index position
il.Emit(OpCodes.Ldstr, EventList[lv]); // Push value
il.Emit(OpCodes.Stelem_Ref); // Perform array[index] = value
}
// IL_INSERT_END_TRY(il, eventname);
il.Emit(OpCodes.Ldloc_0); // Load local variable 0 onto stack
il.Emit(OpCodes.Ret); // Return
}
private void IL_INSERT_TRY(ILGenerator il, string eventname)
{
/*
* CLR TRY
*/
//Common.SendToDebug("CLR:" + eventname + ":il.BeginExceptionBlock()");
il.BeginExceptionBlock();
// Push "Hello World!" string to stack
//Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
il.Emit(OpCodes.Ldstr, "Starting CLR dynamic execution of: " + eventname);
}
private void IL_INSERT_END_TRY(ILGenerator il, string eventname)
{
/*
* CATCH
*/
SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));");
Common.SendToDebug("CLR:" + eventname + ":il.BeginCatchBlock(typeof(Exception));");
il.BeginCatchBlock(typeof(Exception));
// Push "Hello World!" string to stack
SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Ldstr...");
il.Emit(OpCodes.Ldstr, "Execption executing dynamic CLR function " + eventname + ": ");
//call void [mscorlib]System.Console::WriteLine(string)
SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("Write", new Type[] { typeof(string) }));
//callvirt instance string [mscorlib]System.Exception::get_Message()
SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt...");
Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Callvirt...");
il.Emit(OpCodes.Callvirt, typeof(Exception).GetMethod
("get_Message"));
//call void [mscorlib]System.Console::WriteLine(string)
SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
Common.SendToDebug("CLR:" + eventname + ":il.Emit(OpCodes.Call...");
il.Emit(OpCodes.Call, typeof(Console).GetMethod
("WriteLine", new Type[] { typeof(string) }));
/*
* CLR END TRY
*/
//SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();");
//Common.SendToDebug("CLR:" + eventname + ":il.EndExceptionBlock();");
il.EndExceptionBlock();
// Push "Return from current method, with return value if present" to stack
il.Emit(OpCodes.Ret);
return myCodeChunk;
}
}
}

View File

@ -1,9 +1,37 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.ScriptEngines.LSL
namespace OpenSim.Region.Scripting.LSL
{
static class LSO_Struct
{

View File

@ -0,0 +1,366 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Scripting.LSL
{
public interface LSL_BuiltIn_Commands_Interface
{
void llSin();
void llCos();
void llTan();
void llAtan2();
void llSqrt();
void llPow();
void llAbs();
void llFabs();
void llFrand();
void llFloor();
void llCeil();
void llRound();
void llVecMag();
void llVecNorm();
void llVecDist();
void llRot2Euler();
void llEuler2Rot();
void llAxes2Rot();
void llRot2Fwd();
void llRot2Left();
void llRot2Up();
void llRotBetween();
void llWhisper();
void llSay(UInt32 channelID, string text);
void llShout();
void llListen();
void llListenControl();
void llListenRemove();
void llSensor();
void llSensorRepeat();
void llSensorRemove();
void llDetectedName();
void llDetectedKey();
void llDetectedOwner();
void llDetectedType();
void llDetectedPos();
void llDetectedVel();
void llDetectedGrab();
void llDetectedRot();
void llDetectedGroup();
void llDetectedLinkNumber();
void llDie();
void llGround();
void llCloud();
void llWind();
void llSetStatus();
void llGetStatus();
void llSetScale();
void llGetScale();
void llSetColor();
void llGetAlpha();
void llSetAlpha();
void llGetColor();
void llSetTexture();
void llScaleTexture();
void llOffsetTexture();
void llRotateTexture();
void llGetTexture();
void llSetPos();
void llGetPos();
void llGetLocalPos();
void llSetRot();
void llGetRot();
void llGetLocalRot();
void llSetForce();
void llGetForce();
void llTarget();
void llTargetRemove();
void llRotTarget();
void llRotTargetRemove();
void llMoveToTarget();
void llStopMoveToTarget();
void llApplyImpulse();
void llApplyRotationalImpulse();
void llSetTorque();
void llGetTorque();
void llSetForceAndTorque();
void llGetVel();
void llGetAccel();
void llGetOmega();
void llGetTimeOfDay();
void llGetWallclock();
void llGetTime();
void llResetTime();
void llGetAndResetTime();
void llSound();
void llPlaySound();
void llLoopSound();
void llLoopSoundMaster();
void llLoopSoundSlave();
void llPlaySoundSlave();
void llTriggerSound();
void llStopSound();
void llPreloadSound();
void llGetSubString();
void llDeleteSubString();
void llInsertString();
void llToUpper();
void llToLower();
void llGiveMoney();
void llMakeExplosion();
void llMakeFountain();
void llMakeSmoke();
void llMakeFire();
void llRezObject();
void llLookAt();
void llStopLookAt();
void llSetTimerEvent();
void llSleep();
void llGetMass();
void llCollisionFilter();
void llTakeControls();
void llReleaseControls();
void llAttachToAvatar();
void llDetachFromAvatar();
void llTakeCamera();
void llReleaseCamera();
void llGetOwner();
void llInstantMessage();
void llEmail();
void llGetNextEmail();
void llGetKey();
void llSetBuoyancy();
void llSetHoverHeight();
void llStopHover();
void llMinEventDelay();
void llSoundPreload();
void llRotLookAt();
void llStringLength();
void llStartAnimation();
void llStopAnimation();
void llPointAt();
void llStopPointAt();
void llTargetOmega();
void llGetStartParameter();
void llGodLikeRezObject();
void llRequestPermissions();
void llGetPermissionsKey();
void llGetPermissions();
void llGetLinkNumber();
void llSetLinkColor();
void llCreateLink();
void llBreakLink();
void llBreakAllLinks();
void llGetLinkKey();
void llGetLinkName();
void llGetInventoryNumber();
void llGetInventoryName();
void llSetScriptState();
void llGetEnergy();
void llGiveInventory();
void llRemoveInventory();
void llSetText();
void llWater();
void llPassTouches();
void llRequestAgentData();
void llRequestInventoryData();
void llSetDamage();
void llTeleportAgentHome();
void llModifyLand();
void llCollisionSound();
void llCollisionSprite();
void llGetAnimation();
void llResetScript();
void llMessageLinked();
void llPushObject();
void llPassCollisions();
void llGetScriptName();
void llGetNumberOfSides();
void llAxisAngle2Rot();
void llRot2Axis();
void llRot2Angle();
void llAcos();
void llAsin();
void llAngleBetween();
void llGetInventoryKey();
void llAllowInventoryDrop();
void llGetSunDirection();
void llGetTextureOffset();
void llGetTextureScale();
void llGetTextureRot();
void llSubStringIndex();
void llGetOwnerKey();
void llGetCenterOfMass();
void llListSort();
void llGetListLength();
void llList2Integer();
void llList2Float();
void llList2String();
void llList2Key();
void llList2Vector();
void llList2Rot();
void llList2List();
void llDeleteSubList();
void llGetListEntryType();
void llList2CSV();
void llCSV2List();
void llListRandomize();
void llList2ListStrided();
void llGetRegionCorner();
void llListInsertList();
void llListFindList();
void llGetObjectName();
void llSetObjectName();
void llGetDate();
void llEdgeOfWorld();
void llGetAgentInfo();
void llAdjustSoundVolume();
void llSetSoundQueueing();
void llSetSoundRadius();
void llKey2Name();
void llSetTextureAnim();
void llTriggerSoundLimited();
void llEjectFromLand();
void llParseString2List();
void llOverMyLand();
void llGetLandOwnerAt();
void llGetNotecardLine();
void llGetAgentSize();
void llSameGroup();
void llUnSit();
void llGroundSlope();
void llGroundNormal();
void llGroundContour();
void llGetAttached();
void llGetFreeMemory();
void llGetRegionName();
void llGetRegionTimeDilation();
void llGetRegionFPS();
void llParticleSystem();
void llGroundRepel();
void llGiveInventoryList();
void llSetVehicleType();
void llSetVehicleFloatParam();
void llSetVehicleVectorParam();
void llSetVehicleRotationParam();
void llSetVehicleFlags();
void llRemoveVehicleFlags();
void llSitTarget();
void llAvatarOnSitTarget();
void llAddToLandPassList();
void llSetTouchText();
void llSetSitText();
void llSetCameraEyeOffset();
void llSetCameraAtOffset();
void llDumpList2String();
void llScriptDanger();
void llDialog();
void llVolumeDetect();
void llResetOtherScript();
void llGetScriptState();
void llRemoteLoadScript();
void llSetRemoteScriptAccessPin();
void llRemoteLoadScriptPin();
void llOpenRemoteDataChannel();
void llSendRemoteData();
void llRemoteDataReply();
void llCloseRemoteDataChannel();
void llMD5String();
void llSetPrimitiveParams();
void llStringToBase64();
void llBase64ToString();
void llXorBase64Strings();
void llRemoteDataSetRegion();
void llLog10();
void llLog();
void llGetAnimationList();
void llSetParcelMusicURL();
void llGetRootPosition();
void llGetRootRotation();
void llGetObjectDesc();
void llSetObjectDesc();
void llGetCreator();
void llGetTimestamp();
void llSetLinkAlpha();
void llGetNumberOfPrims();
void llGetNumberOfNotecardLines();
void llGetBoundingBox();
void llGetGeometricCenter();
void llGetPrimitiveParams();
void llIntegerToBase64();
void llBase64ToInteger();
void llGetGMTclock();
void llGetSimulatorHostname();
void llSetLocalRot();
void llParseStringKeepNulls();
void llRezAtRoot();
void llGetObjectPermMask();
void llSetObjectPermMask();
void llGetInventoryPermMask();
void llSetInventoryPermMask();
void llGetInventoryCreator();
void llOwnerSay();
void llRequestSimulatorData();
void llForceMouselook();
void llGetObjectMass();
void llListReplaceList();
void llLoadURL();
void llParcelMediaCommandList();
void llParcelMediaQuery();
void llModPow();
void llGetInventoryType();
void llSetPayPrice();
void llGetCameraPos();
void llGetCameraRot();
void llSetPrimURL();
void llRefreshPrimURL();
void llEscapeURL();
void llUnescapeURL();
void llMapDestination();
void llAddToLandBanList();
void llRemoveFromLandPassList();
void llRemoveFromLandBanList();
void llSetCameraParams();
void llClearCameraParams();
void llListStatistics();
void llGetUnixTime();
void llGetParcelFlags();
void llGetRegionFlags();
void llXorBase64StringsCorrect();
void llHTTPRequest();
void llResetLandBanList();
void llResetLandPassList();
void llGetParcelPrimCount();
void llGetParcelPrimOwners();
void llGetObjectPrimCount();
void llGetParcelMaxPrims();
void llGetParcelDetails();
}
}

View File

@ -0,0 +1,377 @@
/*
* Copyright (c) Contributors, http://www.openmetaverse.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSim Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
/* Original code: Tedd Hansen */
using System;
using System.Collections.Generic;
using System.Text;
namespace OpenSim.Region.Scripting.LSL
{
public class LSL_BuiltIn_Commands_TestImplementation: LSL_BuiltIn_Commands_Interface
{
public LSL_BuiltIn_Commands_TestImplementation()
{
Common.SendToDebug("LSL_BuiltIn_Commands_TestImplementation: Creating object");
}
public void llSin() { }
public void llCos() { }
public void llTan() { }
public void llAtan2() { }
public void llSqrt() { }
public void llPow() { }
public void llAbs() { }
public void llFabs() { }
public void llFrand() { }
public void llFloor() { }
public void llCeil() { }
public void llRound() { }
public void llVecMag() { }
public void llVecNorm() { }
public void llVecDist() { }
public void llRot2Euler() { }
public void llEuler2Rot() { }
public void llAxes2Rot() { }
public void llRot2Fwd() { }
public void llRot2Left() { }
public void llRot2Up() { }
public void llRotBetween() { }
public void llWhisper() { }
public void llSay(UInt32 channelID, string text)
{
Common.SendToDebug("INTERNAL FUNCTION llSay(" + channelID + ", \"" + text + "\");");
}
public void llShout() { }
public void llListen() { }
public void llListenControl() { }
public void llListenRemove() { }
public void llSensor() { }
public void llSensorRepeat() { }
public void llSensorRemove() { }
public void llDetectedName() { }
public void llDetectedKey() { }
public void llDetectedOwner() { }
public void llDetectedType() { }
public void llDetectedPos() { }
public void llDetectedVel() { }
public void llDetectedGrab() { }
public void llDetectedRot() { }
public void llDetectedGroup() { }
public void llDetectedLinkNumber() { }
public void llDie() { }
public void llGround() { }
public void llCloud() { }
public void llWind() { }
public void llSetStatus() { }
public void llGetStatus() { }
public void llSetScale() { }
public void llGetScale() { }
public void llSetColor() { }
public void llGetAlpha() { }
public void llSetAlpha() { }
public void llGetColor() { }
public void llSetTexture() { }
public void llScaleTexture() { }
public void llOffsetTexture() { }
public void llRotateTexture() { }
public void llGetTexture() { }
public void llSetPos() { }
public void llGetPos() { }
public void llGetLocalPos() { }
public void llSetRot() { }
public void llGetRot() { }
public void llGetLocalRot() { }
public void llSetForce() { }
public void llGetForce() { }
public void llTarget() { }
public void llTargetRemove() { }
public void llRotTarget() { }
public void llRotTargetRemove() { }
public void llMoveToTarget() { }
public void llStopMoveToTarget() { }
public void llApplyImpulse() { }
public void llApplyRotationalImpulse() { }
public void llSetTorque() { }
public void llGetTorque() { }
public void llSetForceAndTorque() { }
public void llGetVel() { }
public void llGetAccel() { }
public void llGetOmega() { }
public void llGetTimeOfDay() { }
public void llGetWallclock() { }
public void llGetTime() { }
public void llResetTime() { }
public void llGetAndResetTime() { }
public void llSound() { }
public void llPlaySound() { }
public void llLoopSound() { }
public void llLoopSoundMaster() { }
public void llLoopSoundSlave() { }
public void llPlaySoundSlave() { }
public void llTriggerSound() { }
public void llStopSound() { }
public void llPreloadSound() { }
public void llGetSubString() { }
public void llDeleteSubString() { }
public void llInsertString() { }
public void llToUpper() { }
public void llToLower() { }
public void llGiveMoney() { }
public void llMakeExplosion() { }
public void llMakeFountain() { }
public void llMakeSmoke() { }
public void llMakeFire() { }
public void llRezObject() { }
public void llLookAt() { }
public void llStopLookAt() { }
public void llSetTimerEvent() { }
public void llSleep() { }
public void llGetMass() { }
public void llCollisionFilter() { }
public void llTakeControls() { }
public void llReleaseControls() { }
public void llAttachToAvatar() { }
public void llDetachFromAvatar() { }
public void llTakeCamera() { }
public void llReleaseCamera() { }
public void llGetOwner() { }
public void llInstantMessage() { }
public void llEmail() { }
public void llGetNextEmail() { }
public void llGetKey() { }
public void llSetBuoyancy() { }
public void llSetHoverHeight() { }
public void llStopHover() { }
public void llMinEventDelay() { }
public void llSoundPreload() { }
public void llRotLookAt() { }
public void llStringLength() { }
public void llStartAnimation() { }
public void llStopAnimation() { }
public void llPointAt() { }
public void llStopPointAt() { }
public void llTargetOmega() { }
public void llGetStartParameter() { }
public void llGodLikeRezObject() { }
public void llRequestPermissions() { }
public void llGetPermissionsKey() { }
public void llGetPermissions() { }
public void llGetLinkNumber() { }
public void llSetLinkColor() { }
public void llCreateLink() { }
public void llBreakLink() { }
public void llBreakAllLinks() { }
public void llGetLinkKey() { }
public void llGetLinkName() { }
public void llGetInventoryNumber() { }
public void llGetInventoryName() { }
public void llSetScriptState() { }
public void llGetEnergy() { }
public void llGiveInventory() { }
public void llRemoveInventory() { }
public void llSetText() { }
public void llWater() { }
public void llPassTouches() { }
public void llRequestAgentData() { }
public void llRequestInventoryData() { }
public void llSetDamage() { }
public void llTeleportAgentHome() { }
public void llModifyLand() { }
public void llCollisionSound() { }
public void llCollisionSprite() { }
public void llGetAnimation() { }
public void llResetScript() { }
public void llMessageLinked() { }
public void llPushObject() { }
public void llPassCollisions() { }
public void llGetScriptName() { }
public void llGetNumberOfSides() { }
public void llAxisAngle2Rot() { }
public void llRot2Axis() { }
public void llRot2Angle() { }
public void llAcos() { }
public void llAsin() { }
public void llAngleBetween() { }
public void llGetInventoryKey() { }
public void llAllowInventoryDrop() { }
public void llGetSunDirection() { }
public void llGetTextureOffset() { }
public void llGetTextureScale() { }
public void llGetTextureRot() { }
public void llSubStringIndex() { }
public void llGetOwnerKey() { }
public void llGetCenterOfMass() { }
public void llListSort() { }
public void llGetListLength() { }
public void llList2Integer() { }
public void llList2Float() { }
public void llList2String() { }
public void llList2Key() { }
public void llList2Vector() { }
public void llList2Rot() { }
public void llList2List() { }
public void llDeleteSubList() { }
public void llGetListEntryType() { }
public void llList2CSV() { }
public void llCSV2List() { }
public void llListRandomize() { }
public void llList2ListStrided() { }
public void llGetRegionCorner() { }
public void llListInsertList() { }
public void llListFindList() { }
public void llGetObjectName() { }
public void llSetObjectName() { }
public void llGetDate() { }
public void llEdgeOfWorld() { }
public void llGetAgentInfo() { }
public void llAdjustSoundVolume() { }
public void llSetSoundQueueing() { }
public void llSetSoundRadius() { }
public void llKey2Name() { }
public void llSetTextureAnim() { }
public void llTriggerSoundLimited() { }
public void llEjectFromLand() { }
public void llParseString2List() { }
public void llOverMyLand() { }
public void llGetLandOwnerAt() { }
public void llGetNotecardLine() { }
public void llGetAgentSize() { }
public void llSameGroup() { }
public void llUnSit() { }
public void llGroundSlope() { }
public void llGroundNormal() { }
public void llGroundContour() { }
public void llGetAttached() { }
public void llGetFreeMemory() { }
public void llGetRegionName() { }
public void llGetRegionTimeDilation() { }
public void llGetRegionFPS() { }
public void llParticleSystem() { }
public void llGroundRepel() { }
public void llGiveInventoryList() { }
public void llSetVehicleType() { }
public void llSetVehicleFloatParam() { }
public void llSetVehicleVectorParam() { }
public void llSetVehicleRotationParam() { }
public void llSetVehicleFlags() { }
public void llRemoveVehicleFlags() { }
public void llSitTarget() { }
public void llAvatarOnSitTarget() { }
public void llAddToLandPassList() { }
public void llSetTouchText() { }
public void llSetSitText() { }
public void llSetCameraEyeOffset() { }
public void llSetCameraAtOffset() { }
public void llDumpList2String() { }
public void llScriptDanger() { }
public void llDialog() { }
public void llVolumeDetect() { }
public void llResetOtherScript() { }
public void llGetScriptState() { }
public void llRemoteLoadScript() { }
public void llSetRemoteScriptAccessPin() { }
public void llRemoteLoadScriptPin() { }
public void llOpenRemoteDataChannel() { }
public void llSendRemoteData() { }
public void llRemoteDataReply() { }
public void llCloseRemoteDataChannel() { }
public void llMD5String() { }
public void llSetPrimitiveParams() { }
public void llStringToBase64() { }
public void llBase64ToString() { }
public void llXorBase64Strings() { }
public void llRemoteDataSetRegion() { }
public void llLog10() { }
public void llLog() { }
public void llGetAnimationList() { }
public void llSetParcelMusicURL() { }
public void llGetRootPosition() { }
public void llGetRootRotation() { }
public void llGetObjectDesc() { }
public void llSetObjectDesc() { }
public void llGetCreator() { }
public void llGetTimestamp() { }
public void llSetLinkAlpha() { }
public void llGetNumberOfPrims() { }
public void llGetNumberOfNotecardLines() { }
public void llGetBoundingBox() { }
public void llGetGeometricCenter() { }
public void llGetPrimitiveParams() { }
public void llIntegerToBase64() { }
public void llBase64ToInteger() { }
public void llGetGMTclock() { }
public void llGetSimulatorHostname() { }
public void llSetLocalRot() { }
public void llParseStringKeepNulls() { }
public void llRezAtRoot() { }
public void llGetObjectPermMask() { }
public void llSetObjectPermMask() { }
public void llGetInventoryPermMask() { }
public void llSetInventoryPermMask() { }
public void llGetInventoryCreator() { }
public void llOwnerSay() { }
public void llRequestSimulatorData() { }
public void llForceMouselook() { }
public void llGetObjectMass() { }
public void llListReplaceList() { }
public void llLoadURL() { }
public void llParcelMediaCommandList() { }
public void llParcelMediaQuery() { }
public void llModPow() { }
public void llGetInventoryType() { }
public void llSetPayPrice() { }
public void llGetCameraPos() { }
public void llGetCameraRot() { }
public void llSetPrimURL() { }
public void llRefreshPrimURL() { }
public void llEscapeURL() { }
public void llUnescapeURL() { }
public void llMapDestination() { }
public void llAddToLandBanList() { }
public void llRemoveFromLandPassList() { }
public void llRemoveFromLandBanList() { }
public void llSetCameraParams() { }
public void llClearCameraParams() { }
public void llListStatistics() { }
public void llGetUnixTime() { }
public void llGetParcelFlags() { }
public void llGetRegionFlags() { }
public void llXorBase64StringsCorrect() { }
public void llHTTPRequest() { }
public void llResetLandBanList() { }
public void llResetLandPassList() { }
public void llGetParcelPrimCount() { }
public void llGetParcelPrimOwners() { }
public void llGetObjectPrimCount() { }
public void llGetParcelMaxPrims() { }
public void llGetParcelDetails() { }
}
}

View File

@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
using System.Text;
using OpenSim.Region.Environment.Scenes;
using OpenSim.Region.Environment;
using OpenSim.Region.Interfaces;
using OpenSim.Framework.Console;
using libsecondlife;
using Db4objects.Db4o;
namespace OpenSim.DataStore.NullStorage
{
public class DB4oDataStore : IRegionDataStore
{
private IObjectContainer db;
public void Initialise(string dbfile, string dbname)
{
db = Db4oFactory.OpenFile(dbfile);
return;
}
public void StoreObject(SceneObject obj)
{
db.Set(obj);
}
public void RemoveObject(LLUUID obj)
{
}
public List<SceneObject> LoadObjects()
{
return new List<SceneObject>();
}
public void StoreTerrain(double[,] ter)
{
}
public double[,] LoadTerrain()
{
return null;
}
public void RemoveParcel(uint id)
{
}
public void StoreParcel(OpenSim.Region.Environment.Parcel parcel)
{
}
public List<OpenSim.Region.Environment.Parcel> LoadParcels()
{
return new List<OpenSim.Region.Environment.Parcel>();
}
public void Shutdown()
{
}
}
}

View File

@ -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.DataStore.DB4o")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OpenSim.DataStore.DB4o")]
[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("7a12de8b-fdd1-48f5-89a9-8dc2dafbeebc")]
// 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")]