From 289d4ca128d278aed49044b92411234d5f57b781 Mon Sep 17 00:00:00 2001 From: UbitUmarov Date: Sat, 27 May 2017 05:41:40 +0100 Subject: minor cleanup --- .../ScriptEngine/Shared/CodeTools/Compiler.cs | 101 ++++++--------------- OpenSim/Region/ScriptEngine/XEngine/XEngine.cs | 7 +- 2 files changed, 32 insertions(+), 76 deletions(-) (limited to 'OpenSim/Region/ScriptEngine') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index f3b8e1d..20f9770 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs @@ -79,12 +79,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools private List m_warnings = new List(); - // private object m_syncy = new object(); - -// private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); -// private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); - - // private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files private static UInt64 scriptCompileCounter = 0; // And a counter public IScriptEngine m_scriptEngine; @@ -251,23 +245,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools } } - ////private ICodeCompiler icc = codeProvider.CreateCompiler(); - //public string CompileFromFile(string LSOFileName) - //{ - // switch (Path.GetExtension(LSOFileName).ToLower()) - // { - // case ".txt": - // case ".lsl": - // Common.ScriptEngineBase.Shared.SendToDebug("Source code is LSL, converting to CS"); - // return CompileFromLSLText(File.ReadAllText(LSOFileName)); - // case ".cs": - // Common.ScriptEngineBase.Shared.SendToDebug("Source code is CS"); - // return CompileFromCSText(File.ReadAllText(LSOFileName)); - // default: - // throw new Exception("Unknown script type."); - // } - //} - public string GetCompilerOutput(string assetID) { return Path.Combine(ScriptEnginesPath, Path.Combine( @@ -578,8 +555,6 @@ namespace SecondLife switch (lang) { case enumCompileType.vb: -// results = VBcodeProvider.CompileAssemblyFromSource( -// parameters, Script); provider = CodeDomProvider.CreateProvider("VisualBasic"); break; case enumCompileType.cs: @@ -594,56 +569,36 @@ namespace SecondLife if(provider == null) throw new Exception("Compiler failed to load "); + bool complete = false; + bool retried = false; - bool complete = false; - bool retried = false; - - do + do + { + results = provider.CompileAssemblyFromSource( + parameters, Script); + // Deal with an occasional segv in the compiler. + // Rarely, if ever, occurs twice in succession. + // Line # == 0 and no file name are indications that + // this is a native stack trace rather than a normal + // error log. + if (results.Errors.Count > 0) + { + if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) && + results.Errors[0].Line == 0) { -// lock (CScodeProvider) -// { -// results = CScodeProvider.CompileAssemblyFromSource( -// parameters, Script); -// } - - results = provider.CompileAssemblyFromSource( - parameters, Script); - // Deal with an occasional segv in the compiler. - // Rarely, if ever, occurs twice in succession. - // Line # == 0 and no file name are indications that - // this is a native stack trace rather than a normal - // error log. - if (results.Errors.Count > 0) - { - if (!retried && string.IsNullOrEmpty(results.Errors[0].FileName) && - results.Errors[0].Line == 0) - { - // System.Console.WriteLine("retrying failed compilation"); - retried = true; - } - else - { - complete = true; - } - } - else - { - complete = true; - } - } while (!complete); -// break; -// default: -// throw new Exception("Compiler is not able to recongnize " + -// "language type \"" + lang.ToString() + "\""); -// } - -// foreach (Type type in results.CompiledAssembly.GetTypes()) -// { -// foreach (MethodInfo method in type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) -// { -// m_log.DebugFormat("[COMPILER]: {0}.{1}", type.FullName, method.Name); -// } -// } + // System.Console.WriteLine("retrying failed compilation"); + retried = true; + } + else + { + complete = true; + } + } + else + { + complete = true; + } + } while (!complete); // // WARNINGS AND ERRORS diff --git a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs index c1abba2..870957b 100755 --- a/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs +++ b/OpenSim/Region/ScriptEngine/XEngine/XEngine.cs @@ -2149,10 +2149,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine string fn = Path.GetFileName(assemName); string assem = String.Empty; + string assemNameText = assemName + ".text"; - if (File.Exists(assemName + ".text")) + if (File.Exists(assemNameText)) { - FileInfo tfi = new FileInfo(assemName + ".text"); + FileInfo tfi = new FileInfo(assemNameText); if (tfi != null) { @@ -2160,7 +2161,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine try { - using (FileStream tfs = File.Open(assemName + ".text", + using (FileStream tfs = File.Open(assemNameText, FileMode.Open, FileAccess.Read)) { tfs.Read(tdata, 0, tdata.Length); -- cgit v1.1