From 65c5efe43b68700bad94076d4cd421160203c5de Mon Sep 17 00:00:00 2001 From: Jeff Ames Date: Fri, 16 May 2008 01:22:11 +0000 Subject: Formatting cleanup. --- .../DotNetEngine/Compiler/LSL/Compiler.cs | 12 +++++----- .../DotNetEngine/Compiler/LSL/LSL2CSConverter.cs | 27 ++++------------------ 2 files changed, 10 insertions(+), 29 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/Compiler') diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 1d71182..f661162 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -39,9 +39,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { public class Compiler { - private static readonly log4net.ILog m_log + private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); - + // * Uses "LSL2Converter" to convert LSL to C# if necessary. // * Compiles C#-code into an assembly // * Returns assembly name ready for AppDomain load. @@ -278,8 +278,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL if (enableCommanderLSL == true && l == enumCompileType.cs) { - foreach (KeyValuePair com + foreach (KeyValuePair com in m_scriptEngine.World.GetCommanders()) { compileScript = com.Value.GenerateRuntimeAPI() + compileScript; @@ -305,7 +305,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL m_log.Debug("[ScriptEngine.DotNetEngine]: Preparing to compile the following LSL to C# translated code"); m_log.Debug(""); m_log.Debug(compileScript); - + return CompileFromDotNetText(compileScript, l); } @@ -322,7 +322,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL private static string CreateCSCompilerScript(string compileScript) { - + compileScript = String.Empty + "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;\r\n" + diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index 2100900..1832864 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -23,7 +23,7 @@ * 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; @@ -32,17 +32,13 @@ using System.Text.RegularExpressions; namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL { - public class LSL2CSConverter { - - // Uses regex to convert LSL code to C# code. //private Regex rnw = new Regex(@"[a-zA-Z0-9_\-]", RegexOptions.Compiled); private Dictionary dataTypes = new Dictionary(); private Dictionary quotes = new Dictionary(); - public LSL2CSConverter() { @@ -72,7 +68,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL Script = Regex.Replace(Script, @"\r\n", "\n"); Script = Regex.Replace(Script, @"\n", "\r\n"); - // QUOTE REPLACEMENT // temporarily replace quotes so we can work our magic on the script without // always considering if we are inside our outside quotes's @@ -86,21 +81,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL bool last_was_escape = false; int quote_replaced_count = 0; - - string[] blocked = new string[] {"Axiom","Db4objects","libsecondlife","log4net","Microsoft", "Modified","Mono","MonoXnaCompactMaths","mscorlib","MySql", "NHibernate","Nini","nunit","Ode","OpenSim","PhysX_Wrapper_Dotnet", "PumaCode","RAIL","XMLRPC","System"}; - for (int p = 0; p < blocked.Length;p++) { - Match SecurityM = Regex.Match(Script, "[;}][^\"']+" + blocked[p].Replace(".", "\\.") + "\\.[^\"']", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); if (SecurityM.Success) throw new Exception("CS0103: 'The name '" + blocked[p] + "' does not exist in the current context'"); - } for (int p = 0; p < Script.Length; p++) @@ -166,7 +156,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // END OF QUOTE REPLACEMENT // - // // PROCESS STATES // Remove state definitions and add state names to start of each event within state @@ -194,7 +183,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL // if level == 0, add to return if (ilevel == 1 && lastlevel == 0) { - // 0 => 1: Get last + // 0 => 1: Get last Match m = //Regex.Match(cache, @"(?![a-zA-Z_]+)\s*([a-zA-Z_]+)[^a-zA-Z_\(\)]*{", Regex.Match(cache, @"(?![a-zA-Z_]+)\s*(state\s+)?(?[a-zA-Z_][a-zA-Z_0-9]*)[^a-zA-Z_0-9\(\)]*{", @@ -253,7 +242,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL Script = ret; ret = String.Empty; - foreach (string key in dataTypes.Keys) { string val; @@ -291,7 +279,6 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL Regex.Replace(Script, @"\[([^\]]*)\]", @"new LSL_Types.list($1)", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.Singleline); - // Replace (string) to .ToString() // Script = Regex.Replace(Script, @"\(string\)\s*([a-zA-Z0-9_.]+(\s*\([^\)]*\))?)", @"$1.ToString()", @@ -313,12 +300,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL Script = Script.Replace(key, "\"" + val + "\""); } - - //System.Console.WriteLine(Script); Return = String.Empty;// + //"using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;"; - //Return += String.Empty + // "namespace SecondLife { "; @@ -328,13 +312,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL //Return += @"public Script() { } "; Return += Script; //Return += "} }\r\n"; - + quotes.Clear(); - + return Return; } - } - - } -- cgit v1.1