From 734f28829064b4ef77ffce098e52e90224f064d3 Mon Sep 17 00:00:00 2001 From: Tedd Hansen Date: Sun, 12 Aug 2007 16:44:57 +0000 Subject: [PATCH] LSL ScriptEngine now only needs to inherit from BaseClass and we will be MUCH closer to complete LSL support than we were yesterday. --- .../DotNetEngine/Compiler/LSL/Compiler.cs | 45 +++++++++++++++++++ .../Compiler/LSL/LSL2CSConverter.cs | 2 + 2 files changed, 47 insertions(+) create mode 100644 OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs 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