aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs45
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs2
2 files changed, 47 insertions, 0 deletions
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 0000000..b5a4a39
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs
@@ -0,0 +1,45 @@
1using System;
2using System.Collections.Generic;
3using System.Text;
4using System.IO;
5using Microsoft.CSharp;
6using System.CodeDom.Compiler;
7
8namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
9{
10 class Compiler
11 {
12 private LSL2CS.Converter.LSL2CSConverter LSL_Converter = new LSL2CS.Converter.LSL2CSConverter();
13 private CSharpCodeProvider codeProvider = new CSharpCodeProvider();
14 //private ICodeCompiler icc = codeProvider.CreateCompiler();
15 public string Compile(string LSOFileName)
16 {
17
18
19 string OutFile = Path.GetFileNameWithoutExtension(LSOFileName);
20
21 // TODO: Add error handling
22 string CS_Code = LSL_Converter.Convert(File.ReadAllText(LSOFileName));
23
24 System.CodeDom.Compiler.CompilerParameters parameters = new CompilerParameters();
25 parameters.GenerateExecutable = true;
26 parameters.OutputAssembly = OutFile;
27 CompilerResults results = codeProvider.CompileAssemblyFromSource(parameters, CS_Code);
28
29 // TODO: Return errors to user somehow
30 if (results.Errors.Count > 0)
31 {
32 foreach (CompilerError CompErr in results.Errors)
33 {
34 Console.WriteLine("Line number " + CompErr.Line +
35 ", Error Number: " + CompErr.ErrorNumber +
36 ", '" + CompErr.ErrorText + ";");
37 }
38 }
39
40
41 return OutFile;
42 }
43
44 }
45}
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/LSL2CSConverter.cs
index b302274..1a82f2f 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
29 public string Convert(string Script) 29 public string Convert(string Script)
30 { 30 {
31 string Return = ""; 31 string Return = "";
32 QUOTES.Clear();
33
32 34
33 // 35 //
34 // Prepare script for processing 36 // Prepare script for processing