diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 76 |
1 files changed, 38 insertions, 38 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index f632cb0..f3b8e1d 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -119,7 +119,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
119 | { | 119 | { |
120 | in_startup = false; | 120 | in_startup = false; |
121 | CheckOrCreateScriptsDirectory(); | 121 | CheckOrCreateScriptsDirectory(); |
122 | 122 | ||
123 | // First time we start? Delete old files | 123 | // First time we start? Delete old files |
124 | if (DeleteScriptsOnStartup) | 124 | if (DeleteScriptsOnStartup) |
125 | DeleteOldFiles(); | 125 | DeleteOldFiles(); |
@@ -310,9 +310,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
310 | { | 310 | { |
311 | // m_log.DebugFormat("[Compiler]: Found existing assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name); | 311 | // m_log.DebugFormat("[Compiler]: Found existing assembly {0} for asset {1} in {2}", assembly, asset, m_scriptEngine.World.Name); |
312 | 312 | ||
313 | // 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. |
314 | // 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 |
315 | // don't keep reading the same file from disk multiple times. | 315 | // don't keep reading the same file from disk multiple times. |
316 | if (!m_lineMaps.ContainsKey(assembly)) | 316 | if (!m_lineMaps.ContainsKey(assembly)) |
317 | m_lineMaps[assembly] = ReadMapFile(assembly + ".map"); | 317 | m_lineMaps[assembly] = ReadMapFile(assembly + ".map"); |
318 | linemap = m_lineMaps[assembly]; | 318 | linemap = m_lineMaps[assembly]; |
@@ -366,8 +366,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
366 | 366 | ||
367 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); | 367 | LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms, m_insertCoopTerminationCalls); |
368 | AddCSScriptHeader( | 368 | AddCSScriptHeader( |
369 | m_scriptEngine.ScriptClassName, | 369 | m_scriptEngine.ScriptClassName, |
370 | m_scriptEngine.ScriptBaseClassName, | 370 | m_scriptEngine.ScriptBaseClassName, |
371 | m_scriptEngine.ScriptBaseClassParameters, | 371 | m_scriptEngine.ScriptBaseClassParameters, |
372 | sb); | 372 | sb); |
373 | 373 | ||
@@ -381,20 +381,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
381 | } | 381 | } |
382 | 382 | ||
383 | linemap = ((CSCodeGenerator)LSL_Converter).PositionMap; | 383 | linemap = ((CSCodeGenerator)LSL_Converter).PositionMap; |
384 | // Write the linemap to a file and save it in our dictionary for next time. | 384 | // Write the linemap to a file and save it in our dictionary for next time. |
385 | m_lineMaps[assembly] = linemap; | 385 | m_lineMaps[assembly] = linemap; |
386 | WriteMapFile(assembly + ".map", linemap); | 386 | WriteMapFile(assembly + ".map", linemap); |
387 | LSL_Converter.Clear(); | 387 | LSL_Converter.Clear(); |
388 | } | 388 | } |
389 | else | 389 | else |
390 | { | 390 | { |
391 | switch (language) | 391 | switch (language) |
392 | { | 392 | { |
393 | case enumCompileType.cs: | 393 | case enumCompileType.cs: |
394 | compileScript = CreateCSCompilerScript( | 394 | compileScript = CreateCSCompilerScript( |
395 | compileScript, | 395 | compileScript, |
396 | m_scriptEngine.ScriptClassName, | 396 | m_scriptEngine.ScriptClassName, |
397 | m_scriptEngine.ScriptBaseClassName, | 397 | m_scriptEngine.ScriptBaseClassName, |
398 | m_scriptEngine.ScriptBaseClassParameters); | 398 | m_scriptEngine.ScriptBaseClassParameters); |
399 | break; | 399 | break; |
400 | case enumCompileType.vb: | 400 | case enumCompileType.vb: |
@@ -434,22 +434,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
434 | public static void AddCSScriptHeader(string className, string baseClassName, ParameterInfo[] constructorParameters, StringBuilder sb) | 434 | public static void AddCSScriptHeader(string className, string baseClassName, ParameterInfo[] constructorParameters, StringBuilder sb) |
435 | { | 435 | { |
436 | sb.Append(string.Format( | 436 | sb.Append(string.Format( |
437 | @"using OpenSim.Region.ScriptEngine.Shared; | 437 | @"using OpenSim.Region.ScriptEngine.Shared; |
438 | using System.Collections.Generic; | 438 | using System.Collections.Generic; |
439 | 439 | ||
440 | namespace SecondLife | 440 | namespace SecondLife |
441 | {{ | 441 | {{ |
442 | public class {0} : {1} | 442 | public class {0} : {1} |
443 | {{ | 443 | {{ |
444 | public {0}({2}) : base({3}) {{}} | 444 | public {0}({2}) : base({3}) {{}} |
445 | ", | 445 | ", |
446 | className, | 446 | className, |
447 | baseClassName, | 447 | baseClassName, |
448 | constructorParameters != null | 448 | constructorParameters != null |
449 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString())) | 449 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString())) |
450 | : "", | 450 | : "", |
451 | constructorParameters != null | 451 | constructorParameters != null |
452 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.Name)) | 452 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.Name)) |
453 | : "" | 453 | : "" |
454 | )); | 454 | )); |
455 | } | 455 | } |
@@ -462,26 +462,26 @@ namespace SecondLife | |||
462 | public static string CreateCSCompilerScript( | 462 | public static string CreateCSCompilerScript( |
463 | string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) | 463 | string compileScript, string className, string baseClassName, ParameterInfo[] constructorParameters) |
464 | { | 464 | { |
465 | compileScript = string.Format( | 465 | compileScript = string.Format( |
466 | @"using OpenSim.Region.ScriptEngine.Shared; | 466 | @"using OpenSim.Region.ScriptEngine.Shared; |
467 | using System.Collections.Generic; | 467 | using System.Collections.Generic; |
468 | 468 | ||
469 | namespace SecondLife | 469 | namespace SecondLife |
470 | {{ | 470 | {{ |
471 | public class {0} : {1} | 471 | public class {0} : {1} |
472 | {{ | 472 | {{ |
473 | public {0}({2}) : base({3}) {{}} | 473 | public {0}({2}) : base({3}) {{}} |
474 | {4} | 474 | {4} |
475 | }} | 475 | }} |
476 | }}", | 476 | }}", |
477 | className, | 477 | className, |
478 | baseClassName, | 478 | baseClassName, |
479 | constructorParameters != null | 479 | constructorParameters != null |
480 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString())) | 480 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.ToString())) |
481 | : "", | 481 | : "", |
482 | constructorParameters != null | 482 | constructorParameters != null |
483 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.Name)) | 483 | ? string.Join(", ", Array.ConvertAll<ParameterInfo, string>(constructorParameters, pi => pi.Name)) |
484 | : "", | 484 | : "", |
485 | compileScript); | 485 | compileScript); |
486 | 486 | ||
487 | return compileScript; | 487 | return compileScript; |
@@ -508,7 +508,7 @@ namespace SecondLife | |||
508 | internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) | 508 | internal string CompileFromDotNetText(string Script, enumCompileType lang, string asset, string assembly) |
509 | { | 509 | { |
510 | // m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script); | 510 | // m_log.DebugFormat("[Compiler]: Compiling to assembly\n{0}", Script); |
511 | 511 | ||
512 | string ext = "." + lang.ToString(); | 512 | string ext = "." + lang.ToString(); |
513 | 513 | ||
514 | // Output assembly name | 514 | // Output assembly name |
@@ -562,7 +562,7 @@ namespace SecondLife | |||
562 | 562 | ||
563 | if (m_scriptEngine.ScriptReferencedAssemblies != null) | 563 | if (m_scriptEngine.ScriptReferencedAssemblies != null) |
564 | Array.ForEach<string>( | 564 | Array.ForEach<string>( |
565 | m_scriptEngine.ScriptReferencedAssemblies, | 565 | m_scriptEngine.ScriptReferencedAssemblies, |
566 | a => parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, a))); | 566 | a => parameters.ReferencedAssemblies.Add(Path.Combine(rootPath, a))); |
567 | 567 | ||
568 | parameters.GenerateExecutable = false; | 568 | parameters.GenerateExecutable = false; |
@@ -571,7 +571,7 @@ namespace SecondLife | |||
571 | //parameters.WarningLevel = 1; // Should be 4? | 571 | //parameters.WarningLevel = 1; // Should be 4? |
572 | parameters.TreatWarningsAsErrors = false; | 572 | parameters.TreatWarningsAsErrors = false; |
573 | parameters.GenerateInMemory = false; | 573 | parameters.GenerateInMemory = false; |
574 | 574 | ||
575 | CompilerResults results; | 575 | CompilerResults results; |
576 | 576 | ||
577 | CodeDomProvider provider; | 577 | CodeDomProvider provider; |
@@ -605,7 +605,7 @@ namespace SecondLife | |||
605 | // results = CScodeProvider.CompileAssemblyFromSource( | 605 | // results = CScodeProvider.CompileAssemblyFromSource( |
606 | // parameters, Script); | 606 | // parameters, Script); |
607 | // } | 607 | // } |
608 | 608 | ||
609 | results = provider.CompileAssemblyFromSource( | 609 | results = provider.CompileAssemblyFromSource( |
610 | parameters, Script); | 610 | parameters, Script); |
611 | // Deal with an occasional segv in the compiler. | 611 | // Deal with an occasional segv in the compiler. |
@@ -685,14 +685,14 @@ namespace SecondLife | |||
685 | } | 685 | } |
686 | 686 | ||
687 | provider.Dispose(); | 687 | provider.Dispose(); |
688 | 688 | ||
689 | if (hadErrors) | 689 | if (hadErrors) |
690 | { | 690 | { |
691 | throw new Exception(errtext); | 691 | throw new Exception(errtext); |
692 | } | 692 | } |
693 | 693 | ||
694 | // On today's highly asynchronous systems, the result of | 694 | // On today's highly asynchronous systems, the result of |
695 | // the compile may not be immediately apparent. Wait a | 695 | // the compile may not be immediately apparent. Wait a |
696 | // reasonable amount of time before giving up on it. | 696 | // reasonable amount of time before giving up on it. |
697 | 697 | ||
698 | if (!File.Exists(assembly)) | 698 | if (!File.Exists(assembly)) |