aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/CodeTools
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-02-07 17:44:37 +0000
committerJustin Clark-Casey (justincc)2012-02-07 17:44:37 +0000
commit038d1bf742ba4f95ca8a83b27f6fefb755485524 (patch)
treeec03beab5a4c0a3afd75b685d629f9d82d4199b9 /OpenSim/Region/ScriptEngine/Shared/CodeTools
parentRevert my two quick fixes for the lag issue and put in the real fix, which (diff)
downloadopensim-SC-038d1bf742ba4f95ca8a83b27f6fefb755485524.zip
opensim-SC-038d1bf742ba4f95ca8a83b27f6fefb755485524.tar.gz
opensim-SC-038d1bf742ba4f95ca8a83b27f6fefb755485524.tar.bz2
opensim-SC-038d1bf742ba4f95ca8a83b27f6fefb755485524.tar.xz
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.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs6
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs10
2 files changed, 13 insertions, 3 deletions
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 @@
28using System; 28using System;
29using System.IO; 29using System.IO;
30using System.Collections.Generic; 30using System.Collections.Generic;
31using System.Reflection;
32using log4net;
31using Tools; 33using Tools;
32 34
33namespace OpenSim.Region.ScriptEngine.Shared.CodeTools 35namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
34{ 36{
35 public class CSCodeGenerator : ICodeConverter 37 public class CSCodeGenerator : ICodeConverter
36 { 38 {
39// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
40
37 private SYMBOL m_astRoot = null; 41 private SYMBOL m_astRoot = null;
38 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; 42 private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
39 private int m_indentWidth = 4; // for indentation 43 private int m_indentWidth = 4; // for indentation
@@ -87,6 +91,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
87 /// <returns>String containing the generated C# code.</returns> 91 /// <returns>String containing the generated C# code.</returns>
88 public string Convert(string script) 92 public string Convert(string script)
89 { 93 {
94// m_log.DebugFormat("[CS CODE GENERATOR]: Converting to C#\n{0}", script);
95
90 m_warnings.Clear(); 96 m_warnings.Clear();
91 ResetCounters(); 97 ResetCounters();
92 Parser p = new LSLSyntax(new yyLSLSyntax(), new ErrorHandler(true)); 98 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
291 public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, 291 public void PerformScriptCompile(string Script, string asset, UUID ownerUUID,
292 out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) 292 out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap)
293 { 293 {
294// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script);
295
294 linemap = null; 296 linemap = null;
295 m_warnings.Clear(); 297 m_warnings.Clear();
296 298
@@ -357,6 +359,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
357 if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) 359 if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture))
358 language = enumCompileType.yp; 360 language = enumCompileType.yp;
359 361
362// m_log.DebugFormat("[Compiler]: Compile language is {0}", language);
363
360 if (!AllowedCompilers.ContainsKey(language.ToString())) 364 if (!AllowedCompilers.ContainsKey(language.ToString()))
361 { 365 {
362 // Not allowed to compile to this language! 366 // Not allowed to compile to this language!
@@ -417,7 +421,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
417 } 421 }
418 422
419 assembly = CompileFromDotNetText(compileScript, language, asset, assembly); 423 assembly = CompileFromDotNetText(compileScript, language, asset, assembly);
420 return;
421 } 424 }
422 425
423 public string[] GetWarnings() 426 public string[] GetWarnings()
@@ -491,6 +494,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
491 /// <returns>Filename to .dll assembly</returns> 494 /// <returns>Filename to .dll assembly</returns>
492 internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) 495 internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly)
493 { 496 {
497// m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script);
498
494 string ext = "." + lang.ToString(); 499 string ext = "." + lang.ToString();
495 500
496 // Output assembly name 501 // Output assembly name
@@ -531,8 +536,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
531 536
532 parameters.IncludeDebugInformation = true; 537 parameters.IncludeDebugInformation = true;
533 538
534 string rootPath = 539 string rootPath = AppDomain.CurrentDomain.BaseDirectory;
535 Path.GetDirectoryName(AppDomain.CurrentDomain.BaseDirectory);
536 540
537 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, 541 parameters.ReferencedAssemblies.Add(Path.Combine(rootPath,
538 "OpenSim.Region.ScriptEngine.Shared.dll")); 542 "OpenSim.Region.ScriptEngine.Shared.dll"));