mirror of
https://github.com/opensim/opensim.git
synced 2026-08-01 06:06:06 +08:00
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.
This commit is contained in:
@@ -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<int, int>, KeyValuePair<int, int>> m_positionMap;
|
||||
private int m_indentWidth = 4; // for indentation
|
||||
@@ -87,6 +91,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
|
||||
/// <returns>String containing the generated C# code.</returns>
|
||||
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));
|
||||
|
||||
@@ -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<int, int>, KeyValuePair<int, int>> 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
|
||||
/// <returns>Filename to .dll assembly</returns>
|
||||
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"));
|
||||
|
||||
Reference in New Issue
Block a user