From 038d1bf742ba4f95ca8a83b27f6fefb755485524 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Tue, 7 Feb 2012 17:44:37 +0000 Subject: Add a regression test to compile and start a script. Remove Path.GetDirectoryName when getting assembly loading path in Compiler.CompileFromDotNetText(). The Path.GetDirectoryName call in Compiler.CompileFromDotNetText is unnecessary since AppDomain.CurrentDomain.BaseDirectory is always a directory. Later path concatenation is already done by Path.Combine() which handles any trailing slash. Removing Path.GetDirectoryName() will not affect the runtime but allows NUnit to work since it doesn't add a trailing slash to AppDomain.CurrentDomain.BaseDirectory. --- .../Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 6 ++++++ OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 10 +++++++--- 2 files changed, 13 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index b1fb6c2..8b88588 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -28,12 +28,16 @@ using System; using System.IO; using System.Collections.Generic; +using System.Reflection; +using log4net; using Tools; namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { public class CSCodeGenerator : ICodeConverter { +// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private SYMBOL m_astRoot = null; private Dictionary, KeyValuePair> m_positionMap; private int m_indentWidth = 4; // for indentation @@ -87,6 +91,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// String containing the generated C# code. public string Convert(string script) { +// m_log.DebugFormat("[CS CODE GENERATOR]: Converting to C#\n{0}", script); + m_warnings.Clear(); ResetCounters(); Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 734d4d5..c10143b 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -291,6 +291,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, out string assembly, out Dictionary, KeyValuePair> linemap) { +// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); + linemap = null; m_warnings.Clear(); @@ -357,6 +359,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) language = enumCompileType.yp; +// m_log.DebugFormat("[Compiler]: Compile language is {0}", language); + if (!AllowedCompilers.ContainsKey(language.ToString())) { // Not allowed to compile to this language! @@ -417,7 +421,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } assembly = CompileFromDotNetText(compileScript, language, asset, assembly); - return; } public string[] GetWarnings() @@ -491,6 +494,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools /// Filename to .dll assembly internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) { +// m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script); + string ext = "." + lang.ToString(); // Output assembly name @@ -531,8 +536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools parameters.IncludeDebugInformation = true; - string rootPath = - Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory); + string rootPath = AppDomain.CurrentDomain.BaseDirectory; parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, "OpenSim.Region.ScriptEngine.Shared.dll")); -- cgit v1.1