diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs new file mode 100644 index 0000000000..b5a4a39d92 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.Text; +using System.IO; +using Microsoft.CSharp; +using System.CodeDom.Compiler; + +namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL +{ + class Compiler + { + private LSL2CS.Converter.LSL2CSConverter LSL_Converter = new LSL2CS.Converter.LSL2CSConverter(); + private CSharpCodeProvider codeProvider = new CSharpCodeProvider(); + //private ICodeCompiler icc = codeProvider.CreateCompiler(); + public string Compile(string LSOFileName) + { + + + string OutFile = Path.GetFileNameWithoutExtension(LSOFileName); + + // TODO: Add error handling + string CS_Code = LSL_Converter.Convert(File.ReadAllText(LSOFileName)); + + System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters(); + parameters.GenerateExecutable = true; + parameters.OutputAssembly = OutFile; + CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, CS_Code); + + // TODO: Return errors to user somehow + if (results.Errors.Count > 0) + { + foreach (CompilerError CompErr in results.Errors) + { + Console.WriteLine("Line number " + CompErr.Line + + ", Error Number: " + CompErr.ErrorNumber + + ", '" + CompErr.ErrorText + ";"); + } + } + + + return OutFile; + } + + } +} diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs index b302274330..1a82f2febf 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs @@ -29,6 +29,8 @@ namespace LSL2CS.Converter public string Convert(string Script) { string Return = ""; + QUOTES.Clear(); + // // Prepare script for processing