mirror of
https://github.com/opensim/opensim.git
synced 2026-06-26 08:35:39 +08:00
fixing me some line endings
This commit is contained in:
@@ -1,103 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CSharp;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.CSharp
|
||||
{
|
||||
public class CSharpScriptEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".cs";
|
||||
}
|
||||
|
||||
private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
|
||||
{
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
CompilerResults compilerResults;
|
||||
compilerParams.GenerateExecutable = false;
|
||||
compilerParams.GenerateInMemory = true;
|
||||
compilerParams.IncludeDebugInformation = false;
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||
|
||||
compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
|
||||
|
||||
if (compilerResults.Errors.Count > 0)
|
||||
{
|
||||
MainLog.Instance.Error("Compile errors");
|
||||
foreach (CompilerError error in compilerResults.Errors)
|
||||
{
|
||||
MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
|
||||
|
||||
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
|
||||
{
|
||||
Type testInterface = pluginType.GetInterface("IScript", true);
|
||||
|
||||
if (testInterface != null)
|
||||
{
|
||||
IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
|
||||
|
||||
string scriptName = "C#/" + script.Name;
|
||||
Console.WriteLine("Script: " + scriptName + " loaded.");
|
||||
|
||||
if (!scripts.ContainsKey(scriptName))
|
||||
{
|
||||
scripts.Add(scriptName, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
scripts[scriptName] = script;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<string,IScript> compile(string filename)
|
||||
{
|
||||
CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
|
||||
return LoadDotNetScript(csharpProvider, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.CSharp;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.CSharp
|
||||
{
|
||||
public class CSharpScriptEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".cs";
|
||||
}
|
||||
|
||||
private Dictionary<string,IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
|
||||
{
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
CompilerResults compilerResults;
|
||||
compilerParams.GenerateExecutable = false;
|
||||
compilerParams.GenerateInMemory = true;
|
||||
compilerParams.IncludeDebugInformation = false;
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||
|
||||
compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
|
||||
|
||||
if (compilerResults.Errors.Count > 0)
|
||||
{
|
||||
MainLog.Instance.Error("Compile errors");
|
||||
foreach (CompilerError error in compilerResults.Errors)
|
||||
{
|
||||
MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string,IScript> scripts = new Dictionary<string,IScript>();
|
||||
|
||||
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
|
||||
{
|
||||
Type testInterface = pluginType.GetInterface("IScript", true);
|
||||
|
||||
if (testInterface != null)
|
||||
{
|
||||
IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
|
||||
|
||||
string scriptName = "C#/" + script.Name;
|
||||
Console.WriteLine("Script: " + scriptName + " loaded.");
|
||||
|
||||
if (!scripts.ContainsKey(scriptName))
|
||||
{
|
||||
scripts.Add(scriptName, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
scripts[scriptName] = script;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<string,IScript> compile(string filename)
|
||||
{
|
||||
CSharpCodeProvider csharpProvider = new CSharpCodeProvider();
|
||||
return LoadDotNetScript(csharpProvider, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,72 +1,72 @@
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples
|
||||
{
|
||||
public class LSLExportScript : IScript
|
||||
{
|
||||
ScriptInfo script;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LSL Export Script 0.1"; }
|
||||
}
|
||||
|
||||
public void Initialise(ScriptInfo scriptInfo)
|
||||
{
|
||||
script = scriptInfo;
|
||||
|
||||
script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg);
|
||||
}
|
||||
|
||||
void ProcessConsoleMsg(string[] args)
|
||||
{
|
||||
/*if (args[0].ToLower() == "lslexport")
|
||||
{
|
||||
string sequence = "";
|
||||
|
||||
foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects)
|
||||
{
|
||||
SceneObject root = obj.Value;
|
||||
|
||||
sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n";
|
||||
|
||||
string rootPrim = processPrimitiveToString(root.rootPrimitive);
|
||||
|
||||
sequence += "ROOT:" + rootPrim;
|
||||
|
||||
foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children)
|
||||
{
|
||||
string child = processPrimitiveToString(prim.Value);
|
||||
sequence += "CHILD:" + child;
|
||||
}
|
||||
}
|
||||
|
||||
System.Console.WriteLine(sequence);
|
||||
}*/
|
||||
}
|
||||
|
||||
string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim)
|
||||
{
|
||||
/*string desc = prim.Description;
|
||||
string name = prim.Name;
|
||||
LLVector3 pos = prim.Pos;
|
||||
LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w);
|
||||
LLVector3 scale = prim.Scale;
|
||||
LLVector3 rootPos = prim.WorldPos;
|
||||
|
||||
string setPrimParams = "";
|
||||
|
||||
setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n";
|
||||
|
||||
return setPrimParams;
|
||||
*/
|
||||
return "";
|
||||
}
|
||||
}
|
||||
using OpenSim.Framework.Console;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Region.Environment;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
|
||||
using System.Collections.Generic;
|
||||
using libsecondlife;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.CSharp.Examples
|
||||
{
|
||||
public class LSLExportScript : IScript
|
||||
{
|
||||
ScriptInfo script;
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "LSL Export Script 0.1"; }
|
||||
}
|
||||
|
||||
public void Initialise(ScriptInfo scriptInfo)
|
||||
{
|
||||
script = scriptInfo;
|
||||
|
||||
script.events.OnScriptConsole += new EventManager.OnScriptConsoleDelegate(ProcessConsoleMsg);
|
||||
}
|
||||
|
||||
void ProcessConsoleMsg(string[] args)
|
||||
{
|
||||
/*if (args[0].ToLower() == "lslexport")
|
||||
{
|
||||
string sequence = "";
|
||||
|
||||
foreach (KeyValuePair<LLUUID, SceneObject> obj in script.world.Objects)
|
||||
{
|
||||
SceneObject root = obj.Value;
|
||||
|
||||
sequence += "NEWOBJ::" + obj.Key.ToStringHyphenated() + "\n";
|
||||
|
||||
string rootPrim = processPrimitiveToString(root.rootPrimitive);
|
||||
|
||||
sequence += "ROOT:" + rootPrim;
|
||||
|
||||
foreach (KeyValuePair<LLUUID, OpenSim.Region.Environment.Scenes.Primitive> prim in root.Children)
|
||||
{
|
||||
string child = processPrimitiveToString(prim.Value);
|
||||
sequence += "CHILD:" + child;
|
||||
}
|
||||
}
|
||||
|
||||
System.Console.WriteLine(sequence);
|
||||
}*/
|
||||
}
|
||||
|
||||
string processPrimitiveToString(OpenSim.Region.Environment.Scenes.SceneObjectPart prim)
|
||||
{
|
||||
/*string desc = prim.Description;
|
||||
string name = prim.Name;
|
||||
LLVector3 pos = prim.Pos;
|
||||
LLQuaternion rot = new LLQuaternion(prim.Rotation.x, prim.Rotation.y, prim.Rotation.z, prim.Rotation.w);
|
||||
LLVector3 scale = prim.Scale;
|
||||
LLVector3 rootPos = prim.WorldPos;
|
||||
|
||||
string setPrimParams = "";
|
||||
|
||||
setPrimParams += "[PRIM_SCALE, " + scale.ToString() + ", PRIM_POS, " + rootPos.ToString() + ", PRIM_ROTATION, " + rot.ToString() + "]\n";
|
||||
|
||||
return setPrimParams;
|
||||
*/
|
||||
return "";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,103 +1,103 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.JScript;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JScript
|
||||
{
|
||||
public class JScriptEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".js";
|
||||
}
|
||||
|
||||
private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
|
||||
{
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
CompilerResults compilerResults;
|
||||
compilerParams.GenerateExecutable = false;
|
||||
compilerParams.GenerateInMemory = true;
|
||||
compilerParams.IncludeDebugInformation = false;
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||
|
||||
compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
|
||||
|
||||
if (compilerResults.Errors.Count > 0)
|
||||
{
|
||||
MainLog.Instance.Error("Compile errors");
|
||||
foreach (CompilerError error in compilerResults.Errors)
|
||||
{
|
||||
MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, IScript> scripts = new Dictionary<string, IScript>();
|
||||
|
||||
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
|
||||
{
|
||||
Type testInterface = pluginType.GetInterface("IScript", true);
|
||||
|
||||
if (testInterface != null)
|
||||
{
|
||||
IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
|
||||
|
||||
string scriptName = "JS.NET/" + script.Name;
|
||||
Console.WriteLine("Script: " + scriptName + " loaded.");
|
||||
|
||||
if (!scripts.ContainsKey(scriptName))
|
||||
{
|
||||
scripts.Add(scriptName, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
scripts[scriptName] = script;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<string, IScript> compile(string filename)
|
||||
{
|
||||
JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
|
||||
return LoadDotNetScript(jscriptProvider, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.CodeDom.Compiler;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.JScript;
|
||||
using OpenSim.Framework.Console;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JScript
|
||||
{
|
||||
public class JScriptEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".js";
|
||||
}
|
||||
|
||||
private Dictionary<string, IScript> LoadDotNetScript(CodeDomProvider compiler, string filename)
|
||||
{
|
||||
CompilerParameters compilerParams = new CompilerParameters();
|
||||
CompilerResults compilerResults;
|
||||
compilerParams.GenerateExecutable = false;
|
||||
compilerParams.GenerateInMemory = true;
|
||||
compilerParams.IncludeDebugInformation = false;
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ClientStack.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.Environment.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Region.ExtensionsScriptModule.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("OpenSim.Framework.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("libsecondlife.dll");
|
||||
compilerParams.ReferencedAssemblies.Add("System.dll");
|
||||
|
||||
compilerResults = compiler.CompileAssemblyFromFile(compilerParams, filename);
|
||||
|
||||
if (compilerResults.Errors.Count > 0)
|
||||
{
|
||||
MainLog.Instance.Error("Compile errors");
|
||||
foreach (CompilerError error in compilerResults.Errors)
|
||||
{
|
||||
MainLog.Instance.Error(error.Line.ToString() + ": " + error.ErrorText.ToString());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Dictionary<string, IScript> scripts = new Dictionary<string, IScript>();
|
||||
|
||||
foreach (Type pluginType in compilerResults.CompiledAssembly.GetExportedTypes())
|
||||
{
|
||||
Type testInterface = pluginType.GetInterface("IScript", true);
|
||||
|
||||
if (testInterface != null)
|
||||
{
|
||||
IScript script = (IScript)compilerResults.CompiledAssembly.CreateInstance(pluginType.ToString());
|
||||
|
||||
string scriptName = "JS.NET/" + script.Name;
|
||||
Console.WriteLine("Script: " + scriptName + " loaded.");
|
||||
|
||||
if (!scripts.ContainsKey(scriptName))
|
||||
{
|
||||
scripts.Add(scriptName, script);
|
||||
}
|
||||
else
|
||||
{
|
||||
scripts[scriptName] = script;
|
||||
}
|
||||
}
|
||||
}
|
||||
return scripts;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Dictionary<string, IScript> compile(string filename)
|
||||
{
|
||||
JScriptCodeProvider jscriptProvider = new JScriptCodeProvider();
|
||||
return LoadDotNetScript(jscriptProvider, filename);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class ClassInstance : Object
|
||||
{
|
||||
public int Size;
|
||||
public ClassRecord ClassRec;
|
||||
public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
|
||||
|
||||
public ClassInstance()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class ClassInstance : Object
|
||||
{
|
||||
public int Size;
|
||||
public ClassRecord ClassRec;
|
||||
public Dictionary<string, BaseType> Fields = new Dictionary<string, BaseType>();
|
||||
|
||||
public ClassInstance()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Heap
|
||||
{
|
||||
public List<ClassInstance> ClassObjects = new List<ClassInstance>();
|
||||
|
||||
public Heap()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Heap
|
||||
{
|
||||
public List<ClassInstance> ClassObjects = new List<ClassInstance>();
|
||||
|
||||
public Heap()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,96 +1,96 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
private bool IsMethodOpCode(byte opcode)
|
||||
{
|
||||
bool result = false;
|
||||
switch (opcode)
|
||||
{
|
||||
case 184:
|
||||
short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]);
|
||||
if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
|
||||
{
|
||||
string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value;
|
||||
string typeparam = "";
|
||||
string typereturn = "";
|
||||
int firstbrak = 0;
|
||||
int secondbrak = 0;
|
||||
firstbrak = typ.LastIndexOf('(');
|
||||
secondbrak = typ.LastIndexOf(')');
|
||||
typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
|
||||
typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
|
||||
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value)
|
||||
{
|
||||
//calling a method in this class
|
||||
if (typeparam.Length == 0)
|
||||
{
|
||||
this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//calling a method of a different class
|
||||
|
||||
// OpenSimAPI Class
|
||||
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
|
||||
{
|
||||
this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_thread.PC += 2;
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
private bool IsMethodOpCode(byte opcode)
|
||||
{
|
||||
bool result = false;
|
||||
switch (opcode)
|
||||
{
|
||||
case 184:
|
||||
short refIndex = (short) ((GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC] << 8) + GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC+1]);
|
||||
if (this.m_thread.currentClass.m_constantsPool[refIndex - 1] is ClassRecord.PoolMethodRef)
|
||||
{
|
||||
string typ = ((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Type.Value;
|
||||
string typeparam = "";
|
||||
string typereturn = "";
|
||||
int firstbrak = 0;
|
||||
int secondbrak = 0;
|
||||
firstbrak = typ.LastIndexOf('(');
|
||||
secondbrak = typ.LastIndexOf(')');
|
||||
typeparam = typ.Substring(firstbrak + 1, secondbrak - firstbrak - 1);
|
||||
typereturn = typ.Substring(secondbrak + 1, typ.Length - secondbrak - 1);
|
||||
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == this.m_thread.currentClass.MClass.Name.Value)
|
||||
{
|
||||
//calling a method in this class
|
||||
if (typeparam.Length == 0)
|
||||
{
|
||||
this.m_thread.JumpToStaticVoidMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, (this.m_thread.PC + 2));
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_thread.JumpToStaticParamMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, typeparam, (this.m_thread.PC + 2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//calling a method of a different class
|
||||
|
||||
// OpenSimAPI Class
|
||||
if (((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mClass.Name.Value == "OpenSimAPI")
|
||||
{
|
||||
this.m_thread.scriptInfo.api.CallMethod(((ClassRecord.PoolMethodRef)this.m_thread.currentClass.m_constantsPool[refIndex - 1]).mNameType.Name.Value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.m_thread.PC += 2;
|
||||
}
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,40 +1,40 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,135 +1,135 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
private Thread m_thread;
|
||||
|
||||
public Interpreter(Thread parentThread)
|
||||
{
|
||||
m_thread = parentThread;
|
||||
}
|
||||
|
||||
public bool Excute()
|
||||
{
|
||||
bool run = true;
|
||||
byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++];
|
||||
// Console.WriteLine("opCode is: " + currentOpCode);
|
||||
bool handled = false;
|
||||
|
||||
handled = this.IsLogicOpCode(currentOpCode);
|
||||
if (!handled)
|
||||
{
|
||||
handled = this.IsMethodOpCode(currentOpCode);
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
if (currentOpCode == 172)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning int from function");
|
||||
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
|
||||
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC1;
|
||||
if (bas1 is Int)
|
||||
{
|
||||
this.m_thread.m_currentFrame.OpStack.Push((Int)bas1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
if (currentOpCode == 174)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning float from function");
|
||||
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
|
||||
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC1;
|
||||
if (bas1 is Float)
|
||||
{
|
||||
this.m_thread.m_currentFrame.OpStack.Push((Float)bas1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
if (currentOpCode == 177)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning from function");
|
||||
int retPC = this.m_thread.m_currentFrame.ReturnPC;
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
Console.WriteLine("opcode " + currentOpCode + " not been handled ");
|
||||
}
|
||||
return run;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
partial class Thread
|
||||
{
|
||||
private partial class Interpreter
|
||||
{
|
||||
private Thread m_thread;
|
||||
|
||||
public Interpreter(Thread parentThread)
|
||||
{
|
||||
m_thread = parentThread;
|
||||
}
|
||||
|
||||
public bool Excute()
|
||||
{
|
||||
bool run = true;
|
||||
byte currentOpCode = GlobalMemory.MethodArea.MethodBuffer[this.m_thread.PC++];
|
||||
// Console.WriteLine("opCode is: " + currentOpCode);
|
||||
bool handled = false;
|
||||
|
||||
handled = this.IsLogicOpCode(currentOpCode);
|
||||
if (!handled)
|
||||
{
|
||||
handled = this.IsMethodOpCode(currentOpCode);
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
if (currentOpCode == 172)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning int from function");
|
||||
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
|
||||
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC1;
|
||||
if (bas1 is Int)
|
||||
{
|
||||
this.m_thread.m_currentFrame.OpStack.Push((Int)bas1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
if (currentOpCode == 174)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning float from function");
|
||||
int retPC1 = this.m_thread.m_currentFrame.ReturnPC;
|
||||
BaseType bas1 = this.m_thread.m_currentFrame.OpStack.Pop();
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC1;
|
||||
if (bas1 is Float)
|
||||
{
|
||||
this.m_thread.m_currentFrame.OpStack.Push((Float)bas1);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
if (currentOpCode == 177)
|
||||
{
|
||||
if (this.m_thread.stack.StackFrames.Count > 1)
|
||||
{
|
||||
Console.WriteLine("returning from function");
|
||||
int retPC = this.m_thread.m_currentFrame.ReturnPC;
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
this.m_thread.m_currentFrame = this.m_thread.stack.StackFrames.Peek();
|
||||
this.m_thread.PC = retPC;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Console.WriteLine("No parent function so ending program");
|
||||
this.m_thread.stack.StackFrames.Pop();
|
||||
run = false;
|
||||
}
|
||||
handled = true;
|
||||
}
|
||||
}
|
||||
if (!handled)
|
||||
{
|
||||
Console.WriteLine("opcode " + currentOpCode + " not been handled ");
|
||||
}
|
||||
return run;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,45 +1,45 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class MainMemory
|
||||
{
|
||||
public Heap HeapArea;
|
||||
public MethodMemory MethodArea;
|
||||
|
||||
public MainMemory()
|
||||
{
|
||||
MethodArea = new MethodMemory();
|
||||
HeapArea = new Heap();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class MainMemory
|
||||
{
|
||||
public Heap HeapArea;
|
||||
public MethodMemory MethodArea;
|
||||
|
||||
public MainMemory()
|
||||
{
|
||||
MethodArea = new MethodMemory();
|
||||
HeapArea = new Heap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,46 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class MethodMemory
|
||||
{
|
||||
public byte[] MethodBuffer;
|
||||
public List<ClassRecord> Classes = new List<ClassRecord>();
|
||||
public int NextMethodPC = 0;
|
||||
public int Methodcount = 0;
|
||||
|
||||
public MethodMemory()
|
||||
{
|
||||
MethodBuffer = new byte[20000];
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class MethodMemory
|
||||
{
|
||||
public byte[] MethodBuffer;
|
||||
public List<ClassRecord> Classes = new List<ClassRecord>();
|
||||
public int NextMethodPC = 0;
|
||||
public int Methodcount = 0;
|
||||
|
||||
public MethodMemory()
|
||||
{
|
||||
MethodBuffer = new byte[20000];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,37 +1,37 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Object
|
||||
{
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Object
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,56 +1,56 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public enum OpCode : byte
|
||||
{
|
||||
iconst_m1 = 2,
|
||||
iconst_0 = 3,
|
||||
iconst_1 = 4,
|
||||
iconst_2 = 5,
|
||||
iconst_3 = 6,
|
||||
iconst_4 = 7,
|
||||
iconst_5 = 8,
|
||||
fconst_0 = 11,
|
||||
fconst_1 = 12,
|
||||
fconst_2 = 13,
|
||||
bipush = 16,
|
||||
sipush = 17,
|
||||
fload = 23,
|
||||
iload_0 = 26,
|
||||
iload_1 = 27,
|
||||
fload_0 = 34,
|
||||
fload_1 = 35,
|
||||
fload_2 = 36,
|
||||
fload_3 = 37,
|
||||
istore = 54,
|
||||
fstore = 56,
|
||||
istore_0 = 59,
|
||||
istore_1 = 60,
|
||||
istore_2 = 61,
|
||||
istore_3 = 62,
|
||||
fstore_0 = 67,
|
||||
fstore_1 = 68,
|
||||
fstore_2 = 69,
|
||||
fstore_3 = 70,
|
||||
pop = 87,
|
||||
fadd = 98,
|
||||
fsub = 102,
|
||||
imul = 104,
|
||||
iinc = 132,
|
||||
f2i = 139,
|
||||
fcmpl = 149,
|
||||
fcmpg = 150,
|
||||
ifge = 156,
|
||||
ifgt = 157,
|
||||
ifle = 158,
|
||||
if_icmpge = 162,
|
||||
if_icmpgt = 163,
|
||||
if_icmple = 164,
|
||||
_goto = 167,
|
||||
getstatic = 178,
|
||||
putstatic = 179
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public enum OpCode : byte
|
||||
{
|
||||
iconst_m1 = 2,
|
||||
iconst_0 = 3,
|
||||
iconst_1 = 4,
|
||||
iconst_2 = 5,
|
||||
iconst_3 = 6,
|
||||
iconst_4 = 7,
|
||||
iconst_5 = 8,
|
||||
fconst_0 = 11,
|
||||
fconst_1 = 12,
|
||||
fconst_2 = 13,
|
||||
bipush = 16,
|
||||
sipush = 17,
|
||||
fload = 23,
|
||||
iload_0 = 26,
|
||||
iload_1 = 27,
|
||||
fload_0 = 34,
|
||||
fload_1 = 35,
|
||||
fload_2 = 36,
|
||||
fload_3 = 37,
|
||||
istore = 54,
|
||||
fstore = 56,
|
||||
istore_0 = 59,
|
||||
istore_1 = 60,
|
||||
istore_2 = 61,
|
||||
istore_3 = 62,
|
||||
fstore_0 = 67,
|
||||
fstore_1 = 68,
|
||||
fstore_2 = 69,
|
||||
fstore_3 = 70,
|
||||
pop = 87,
|
||||
fadd = 98,
|
||||
fsub = 102,
|
||||
imul = 104,
|
||||
iinc = 132,
|
||||
f2i = 139,
|
||||
fcmpl = 149,
|
||||
fcmpg = 150,
|
||||
ifge = 156,
|
||||
ifgt = 157,
|
||||
ifle = 158,
|
||||
if_icmpge = 162,
|
||||
if_icmpgt = 163,
|
||||
if_icmple = 164,
|
||||
_goto = 167,
|
||||
getstatic = 178,
|
||||
putstatic = 179
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,42 +1,42 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Stack
|
||||
{
|
||||
public Stack<StackFrame> StackFrames = new Stack<StackFrame>();
|
||||
|
||||
public Stack()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class Stack
|
||||
{
|
||||
public Stack<StackFrame> StackFrames = new Stack<StackFrame>();
|
||||
|
||||
public Stack()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,49 +1,49 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class StackFrame
|
||||
{
|
||||
public BaseType[] LocalVariables;
|
||||
public Stack<BaseType> OpStack = new Stack<BaseType>();
|
||||
|
||||
public int ReturnPC = 0;
|
||||
public ClassRecord CallingClass = null;
|
||||
|
||||
public StackFrame()
|
||||
{
|
||||
LocalVariables = new BaseType[20];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public class StackFrame
|
||||
{
|
||||
public BaseType[] LocalVariables;
|
||||
public Stack<BaseType> OpStack = new Stack<BaseType>();
|
||||
|
||||
public int ReturnPC = 0;
|
||||
public ClassRecord CallingClass = null;
|
||||
|
||||
public StackFrame()
|
||||
{
|
||||
LocalVariables = new BaseType[20];
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,119 +1,119 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.ExtensionsScriptModule;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public partial class Thread
|
||||
{
|
||||
// Is this smart?
|
||||
public static MainMemory GlobalMemory;
|
||||
public static Scene World;
|
||||
private int PC = 0;
|
||||
private Stack stack;
|
||||
private Interpreter m_Interpreter;
|
||||
public ClassRecord currentClass;
|
||||
public ClassInstance currentInstance;
|
||||
private StackFrame m_currentFrame;
|
||||
public int excutionCounter = 0;
|
||||
public bool running = false;
|
||||
|
||||
public ScriptInfo scriptInfo;
|
||||
|
||||
public Thread()
|
||||
{
|
||||
this.m_Interpreter = new Interpreter(this);
|
||||
this.stack = new Stack();
|
||||
}
|
||||
|
||||
public void SetPC(int methodpointer)
|
||||
{
|
||||
//Console.WriteLine("Thread PC has been set to " + methodpointer);
|
||||
PC = methodpointer;
|
||||
}
|
||||
|
||||
public void StartMethod(ClassRecord rec, string methName)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
this.currentClass = rec;
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void StartMethod( string methName)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void JumpToStaticVoidMethod(string methName, int returnPC)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
m_currentFrame.ReturnPC = returnPC;
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void JumpToStaticParamMethod(string methName, string param, int returnPC)
|
||||
{
|
||||
if (param == "I")
|
||||
{
|
||||
BaseType bs1 = m_currentFrame.OpStack.Pop();
|
||||
m_currentFrame = new StackFrame();
|
||||
m_currentFrame.ReturnPC = returnPC;
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
m_currentFrame.LocalVariables[0] = ((Int)bs1);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
if (param == "F")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Excute()
|
||||
{
|
||||
excutionCounter++;
|
||||
return this.m_Interpreter.Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.ExtensionsScriptModule;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM
|
||||
{
|
||||
public partial class Thread
|
||||
{
|
||||
// Is this smart?
|
||||
public static MainMemory GlobalMemory;
|
||||
public static Scene World;
|
||||
private int PC = 0;
|
||||
private Stack stack;
|
||||
private Interpreter m_Interpreter;
|
||||
public ClassRecord currentClass;
|
||||
public ClassInstance currentInstance;
|
||||
private StackFrame m_currentFrame;
|
||||
public int excutionCounter = 0;
|
||||
public bool running = false;
|
||||
|
||||
public ScriptInfo scriptInfo;
|
||||
|
||||
public Thread()
|
||||
{
|
||||
this.m_Interpreter = new Interpreter(this);
|
||||
this.stack = new Stack();
|
||||
}
|
||||
|
||||
public void SetPC(int methodpointer)
|
||||
{
|
||||
//Console.WriteLine("Thread PC has been set to " + methodpointer);
|
||||
PC = methodpointer;
|
||||
}
|
||||
|
||||
public void StartMethod(ClassRecord rec, string methName)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
this.currentClass = rec;
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void StartMethod( string methName)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void JumpToStaticVoidMethod(string methName, int returnPC)
|
||||
{
|
||||
m_currentFrame = new StackFrame();
|
||||
m_currentFrame.ReturnPC = returnPC;
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
|
||||
public void JumpToStaticParamMethod(string methName, string param, int returnPC)
|
||||
{
|
||||
if (param == "I")
|
||||
{
|
||||
BaseType bs1 = m_currentFrame.OpStack.Pop();
|
||||
m_currentFrame = new StackFrame();
|
||||
m_currentFrame.ReturnPC = returnPC;
|
||||
this.stack.StackFrames.Push(m_currentFrame);
|
||||
m_currentFrame.LocalVariables[0] = ((Int)bs1);
|
||||
currentClass.StartMethod(this, methName);
|
||||
}
|
||||
if (param == "F")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public void JumpToClassStaticVoidMethod(string className, string methName, int returnPC)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public bool Excute()
|
||||
{
|
||||
excutionCounter++;
|
||||
return this.m_Interpreter.Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,28 +1,28 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenSim.Region.ExtensionsScriptModule;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
|
||||
{
|
||||
public class JavaEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".java";
|
||||
}
|
||||
|
||||
public Dictionary<string, IScript> compile(string filename)
|
||||
{
|
||||
JVMScript script = new JVMScript();
|
||||
Dictionary<string, IScript> returns = new Dictionary<string, IScript>();
|
||||
|
||||
script.LoadScript(filename);
|
||||
|
||||
returns.Add(filename, script);
|
||||
|
||||
return returns;
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
using OpenSim.Region.ExtensionsScriptModule;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
|
||||
{
|
||||
public class JavaEngine : IScriptCompiler
|
||||
{
|
||||
public string FileExt()
|
||||
{
|
||||
return ".java";
|
||||
}
|
||||
|
||||
public Dictionary<string, IScript> compile(string filename)
|
||||
{
|
||||
JVMScript script = new JVMScript();
|
||||
Dictionary<string, IScript> returns = new Dictionary<string, IScript>();
|
||||
|
||||
script.LoadScript(filename);
|
||||
|
||||
returns.Add(filename, script);
|
||||
|
||||
return returns;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,171 +1,171 @@
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM;
|
||||
using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
|
||||
{
|
||||
public class JVMScript : IScript
|
||||
{
|
||||
private List<Thread> _threads = new List<Thread>();
|
||||
private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
|
||||
private MainMemory _mainMemory;
|
||||
|
||||
ScriptInfo scriptInfo;
|
||||
|
||||
public void Initialise(ScriptInfo info)
|
||||
{
|
||||
scriptInfo = info;
|
||||
|
||||
_mainMemory = new MainMemory();
|
||||
Thread.GlobalMemory = this._mainMemory;
|
||||
Thread.World = info.world;
|
||||
CompileScript();
|
||||
|
||||
scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
|
||||
scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
|
||||
}
|
||||
|
||||
void events_OnNewPresence(ScenePresence presence)
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnNewPresence");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void events_OnFrame()
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnFrame");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "JVM Scripting Engine"; }
|
||||
}
|
||||
|
||||
public void LoadScript(string script)
|
||||
{
|
||||
Console.WriteLine("OpenSimJVM - loading new script: " + script);
|
||||
CompileInfo comp = new CompileInfo();
|
||||
comp.script = script;
|
||||
comp.scriptName = script;
|
||||
this.CompileScripts.Enqueue(comp);
|
||||
}
|
||||
|
||||
public void CompileScript()
|
||||
{
|
||||
CompileInfo comp = this.CompileScripts.Dequeue();
|
||||
string script = comp.script;
|
||||
string scriptName = comp.scriptName;
|
||||
try
|
||||
{
|
||||
//need to compile the script into a java class file
|
||||
|
||||
//first save it to a java source file
|
||||
TextWriter tw = new StreamWriter(scriptName + ".java");
|
||||
tw.WriteLine(script);
|
||||
tw.Close();
|
||||
|
||||
//now compile
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
|
||||
// psi.RedirectStandardOutput = true;
|
||||
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
psi.UseShellExecute = false;
|
||||
|
||||
System.Diagnostics.Process javacomp;
|
||||
javacomp = System.Diagnostics.Process.Start(psi);
|
||||
javacomp.WaitForExit();
|
||||
|
||||
|
||||
//now load in class file
|
||||
ClassRecord class1 = new ClassRecord();
|
||||
class1.LoadClassFromFile(scriptName + ".class");
|
||||
class1.PrintToConsole();
|
||||
//Console.WriteLine();
|
||||
this._mainMemory.MethodArea.Classes.Add(class1);
|
||||
class1.AddMethodsToMemory(this._mainMemory.MethodArea);
|
||||
|
||||
Thread newThread = new Thread();
|
||||
this._threads.Add(newThread);
|
||||
newThread.currentClass = class1;
|
||||
newThread.scriptInfo = scriptInfo;
|
||||
|
||||
//now delete the created files
|
||||
System.IO.File.Delete(scriptName + ".java");
|
||||
System.IO.File.Delete(scriptName + ".class");
|
||||
//this.OnFrame();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("exception");
|
||||
Console.WriteLine(e.StackTrace);
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private class CompileInfo
|
||||
{
|
||||
public string script;
|
||||
public string scriptName;
|
||||
|
||||
public CompileInfo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) Contributors, http://opensimulator.org/
|
||||
* See CONTRIBUTORS.TXT for a full list of copyright holders.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
* * Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* * Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* * Neither the name of the OpenSim Project nor the
|
||||
* names of its contributors may be used to endorse or promote products
|
||||
* derived from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY
|
||||
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
|
||||
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using OpenSim.Framework;
|
||||
using OpenSim.Framework.Interfaces;
|
||||
using OpenSim.Framework.Utilities;
|
||||
using OpenSim.Region.Environment.Scenes;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM;
|
||||
using Thread = OpenSim.Region.ExtensionsScriptModule.JVMEngine.JVM.Thread;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine
|
||||
{
|
||||
public class JVMScript : IScript
|
||||
{
|
||||
private List<Thread> _threads = new List<Thread>();
|
||||
private BlockingQueue<CompileInfo> CompileScripts = new BlockingQueue<CompileInfo>();
|
||||
private MainMemory _mainMemory;
|
||||
|
||||
ScriptInfo scriptInfo;
|
||||
|
||||
public void Initialise(ScriptInfo info)
|
||||
{
|
||||
scriptInfo = info;
|
||||
|
||||
_mainMemory = new MainMemory();
|
||||
Thread.GlobalMemory = this._mainMemory;
|
||||
Thread.World = info.world;
|
||||
CompileScript();
|
||||
|
||||
scriptInfo.events.OnFrame += new EventManager.OnFrameDelegate(events_OnFrame);
|
||||
scriptInfo.events.OnNewPresence += new EventManager.OnNewPresenceDelegate(events_OnNewPresence);
|
||||
}
|
||||
|
||||
void events_OnNewPresence(ScenePresence presence)
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnNewPresence");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void events_OnFrame()
|
||||
{
|
||||
for (int i = 0; i < this._threads.Count; i++)
|
||||
{
|
||||
if (!this._threads[i].running)
|
||||
{
|
||||
this._threads[i].StartMethod("OnFrame");
|
||||
bool run = true;
|
||||
while (run)
|
||||
{
|
||||
run = this._threads[i].Excute();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public string Name
|
||||
{
|
||||
get { return "JVM Scripting Engine"; }
|
||||
}
|
||||
|
||||
public void LoadScript(string script)
|
||||
{
|
||||
Console.WriteLine("OpenSimJVM - loading new script: " + script);
|
||||
CompileInfo comp = new CompileInfo();
|
||||
comp.script = script;
|
||||
comp.scriptName = script;
|
||||
this.CompileScripts.Enqueue(comp);
|
||||
}
|
||||
|
||||
public void CompileScript()
|
||||
{
|
||||
CompileInfo comp = this.CompileScripts.Dequeue();
|
||||
string script = comp.script;
|
||||
string scriptName = comp.scriptName;
|
||||
try
|
||||
{
|
||||
//need to compile the script into a java class file
|
||||
|
||||
//first save it to a java source file
|
||||
TextWriter tw = new StreamWriter(scriptName + ".java");
|
||||
tw.WriteLine(script);
|
||||
tw.Close();
|
||||
|
||||
//now compile
|
||||
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("javac.exe", "*.java");
|
||||
// psi.RedirectStandardOutput = true;
|
||||
psi.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
|
||||
psi.UseShellExecute = false;
|
||||
|
||||
System.Diagnostics.Process javacomp;
|
||||
javacomp = System.Diagnostics.Process.Start(psi);
|
||||
javacomp.WaitForExit();
|
||||
|
||||
|
||||
//now load in class file
|
||||
ClassRecord class1 = new ClassRecord();
|
||||
class1.LoadClassFromFile(scriptName + ".class");
|
||||
class1.PrintToConsole();
|
||||
//Console.WriteLine();
|
||||
this._mainMemory.MethodArea.Classes.Add(class1);
|
||||
class1.AddMethodsToMemory(this._mainMemory.MethodArea);
|
||||
|
||||
Thread newThread = new Thread();
|
||||
this._threads.Add(newThread);
|
||||
newThread.currentClass = class1;
|
||||
newThread.scriptInfo = scriptInfo;
|
||||
|
||||
//now delete the created files
|
||||
System.IO.File.Delete(scriptName + ".java");
|
||||
System.IO.File.Delete(scriptName + ".class");
|
||||
//this.OnFrame();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine("exception");
|
||||
Console.WriteLine(e.StackTrace);
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
}
|
||||
|
||||
private class CompileInfo
|
||||
{
|
||||
public string script;
|
||||
public string scriptName;
|
||||
|
||||
public CompileInfo()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class ArrayReference :BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class ArrayReference :BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class BaseType : Object
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class BaseType : Object
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,16 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class ObjectReference : BaseType
|
||||
{
|
||||
public ushort Reference;
|
||||
|
||||
public ObjectReference()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types
|
||||
{
|
||||
public class ObjectReference : BaseType
|
||||
{
|
||||
public ushort Reference;
|
||||
|
||||
public ObjectReference()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Byte : BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Byte : BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Char : BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Char : BaseType
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Float : BaseType
|
||||
{
|
||||
public float mValue = 0;
|
||||
|
||||
public Float()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Float : BaseType
|
||||
{
|
||||
public float mValue = 0;
|
||||
|
||||
public Float()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Int : BaseType
|
||||
{
|
||||
public int mValue = 0;
|
||||
|
||||
public Int()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types;
|
||||
|
||||
namespace OpenSim.Region.ExtensionsScriptModule.JVMEngine.Types.PrimitiveTypes
|
||||
{
|
||||
public class Int : BaseType
|
||||
{
|
||||
public int mValue = 0;
|
||||
|
||||
public Int()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user