diff options
author | Justin Clark-Casey (justincc) | 2014-07-11 00:03:02 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-07-11 00:03:02 +0100 |
commit | d7b92604963c7ecbddf76db37eabb84ed36fcfde (patch) | |
tree | 0f75eca56190522c477f2e53574e47ce9019f26b /OpenSim/Region/ScriptEngine/Shared/CodeTools | |
parent | refactor: use existing Compiler.CreateScriptsDirectory() (renamed to CheckOrC... (diff) | |
download | opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.zip opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.gz opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.bz2 opensim-SC-d7b92604963c7ecbddf76db37eabb84ed36fcfde.tar.xz |
If [XEngine] ScriptStopStrategy is changed between abort and co-op, for the existing session use the previous strategy for that script rather than not starting the script at all.
We have to do this since we can't unload existing DLLs if they're all in the same AppDomain.
But we can still update the underlying DLL which will be used in the next simulator session.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 39 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | 4 |
2 files changed, 23 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index f874de2..98658b6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -284,12 +284,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
284 | return GetCompilerOutput(assetID.ToString()); | 284 | return GetCompilerOutput(assetID.ToString()); |
285 | } | 285 | } |
286 | 286 | ||
287 | /// <summary> | 287 | public void PerformScriptCompile( |
288 | /// Converts script from LSL to CS and calls CompileFromCSText | 288 | string source, string asset, UUID ownerUUID, |
289 | /// </summary> | 289 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) |
290 | /// <param name="Script">LSL script</param> | 290 | { |
291 | /// <returns>Filename to .dll assembly</returns> | 291 | PerformScriptCompile(source, asset, ownerUUID, false, out assembly, out linemap); |
292 | public void PerformScriptCompile(string Script, string asset, UUID ownerUUID, | 292 | } |
293 | |||
294 | public void PerformScriptCompile( | ||
295 | string source, string asset, UUID ownerUUID, bool alwaysRecompile, | ||
293 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) | 296 | out string assembly, out Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> linemap) |
294 | { | 297 | { |
295 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); | 298 | // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); |
@@ -303,9 +306,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
303 | 306 | ||
304 | CheckOrCreateScriptsDirectory(); | 307 | CheckOrCreateScriptsDirectory(); |
305 | 308 | ||
306 | // Don't recompile if we already have it | 309 | // Don't recompile if we're not forced to and we already have it |
307 | // Performing 3 file exists tests for every script can still be slow | 310 | // Performing 3 file exists tests for every script can still be slow |
308 | if (File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) | 311 | if (!alwaysRecompile && File.Exists(assembly) && File.Exists(assembly + ".text") && File.Exists(assembly + ".map")) |
309 | { | 312 | { |
310 | // If we have already read this linemap file, then it will be in our dictionary. | 313 | // If we have already read this linemap file, then it will be in our dictionary. |
311 | // Don't build another copy of the dictionary (saves memory) and certainly | 314 | // Don't build another copy of the dictionary (saves memory) and certainly |
@@ -316,29 +319,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
316 | return; | 319 | return; |
317 | } | 320 | } |
318 | 321 | ||
319 | if (Script == String.Empty) | 322 | if (source == String.Empty) |
320 | { | ||
321 | throw new Exception("Cannot find script assembly and no script text present"); | 323 | throw new Exception("Cannot find script assembly and no script text present"); |
322 | } | ||
323 | 324 | ||
324 | enumCompileType language = DefaultCompileLanguage; | 325 | enumCompileType language = DefaultCompileLanguage; |
325 | 326 | ||
326 | if (Script.StartsWith("//c#", true, CultureInfo.InvariantCulture)) | 327 | if (source.StartsWith("//c#", true, CultureInfo.InvariantCulture)) |
327 | language = enumCompileType.cs; | 328 | language = enumCompileType.cs; |
328 | if (Script.StartsWith("//vb", true, CultureInfo.InvariantCulture)) | 329 | if (source.StartsWith("//vb", true, CultureInfo.InvariantCulture)) |
329 | { | 330 | { |
330 | language = enumCompileType.vb; | 331 | language = enumCompileType.vb; |
331 | // We need to remove //vb, it won't compile with that | 332 | // We need to remove //vb, it won't compile with that |
332 | 333 | ||
333 | Script = Script.Substring(4, Script.Length - 4); | 334 | source = source.Substring(4, source.Length - 4); |
334 | } | 335 | } |
335 | if (Script.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) | 336 | if (source.StartsWith("//lsl", true, CultureInfo.InvariantCulture)) |
336 | language = enumCompileType.lsl; | 337 | language = enumCompileType.lsl; |
337 | 338 | ||
338 | if (Script.StartsWith("//js", true, CultureInfo.InvariantCulture)) | 339 | if (source.StartsWith("//js", true, CultureInfo.InvariantCulture)) |
339 | language = enumCompileType.js; | 340 | language = enumCompileType.js; |
340 | 341 | ||
341 | if (Script.StartsWith("//yp", true, CultureInfo.InvariantCulture)) | 342 | if (source.StartsWith("//yp", true, CultureInfo.InvariantCulture)) |
342 | language = enumCompileType.yp; | 343 | language = enumCompileType.yp; |
343 | 344 | ||
344 | // m_log.DebugFormat("[Compiler]: Compile language is {0}", language); | 345 | // m_log.DebugFormat("[Compiler]: Compile language is {0}", language); |
@@ -359,13 +360,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
359 | throw new Exception(errtext); | 360 | throw new Exception(errtext); |
360 | } | 361 | } |
361 | 362 | ||
362 | string compileScript = Script; | 363 | string compileScript = source; |
363 | 364 | ||
364 | if (language == enumCompileType.lsl) | 365 | if (language == enumCompileType.lsl) |
365 | { | 366 | { |
366 | // Its LSL, convert it to C# | 367 | // Its LSL, convert it to C# |
367 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); | 368 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); |
368 | compileScript = LSL_Converter.Convert(Script); | 369 | compileScript = LSL_Converter.Convert(source); |
369 | 370 | ||
370 | // copy converter warnings into our warnings. | 371 | // copy converter warnings into our warnings. |
371 | foreach (string warning in LSL_Converter.GetWarnings()) | 372 | foreach (string warning in LSL_Converter.GetWarnings()) |
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs index 938cb2e..388de7f 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CompilerTest.cs | |||
@@ -67,8 +67,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools.Tests | |||
67 | } | 67 | } |
68 | 68 | ||
69 | [SetUp] | 69 | [SetUp] |
70 | public void SetUp() | 70 | public override void SetUp() |
71 | { | 71 | { |
72 | base.SetUp(); | ||
73 | |||
72 | // Create a CSCodeProvider and CompilerParameters. | 74 | // Create a CSCodeProvider and CompilerParameters. |
73 | m_CSCodeProvider = new CSharpCodeProvider(); | 75 | m_CSCodeProvider = new CSharpCodeProvider(); |
74 | m_compilerParameters = new CompilerParameters(); | 76 | m_compilerParameters = new CompilerParameters(); |