diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | 21 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 16 |
2 files changed, 21 insertions, 16 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index 2e0d1a3..6d8bfa8 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | |||
@@ -67,10 +67,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
67 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); | 67 | private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); |
68 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); | 68 | private static VBCodeProvider VBcodeProvider = new VBCodeProvider(); |
69 | 69 | ||
70 | private static UInt64 scriptCompileCounter = 0; | 70 | private static int instanceID = new Random().Next(0, int.MaxValue); // Unique number to use on our compiled files |
71 | 71 | private static UInt64 scriptCompileCounter = 0; // And a counter | |
72 | private static int instanceID = new Random().Next(0, int.MaxValue); | ||
73 | // Implemented due to peer preassure --- will cause garbage in ScriptEngines folder ;) | ||
74 | 72 | ||
75 | public Common.ScriptEngineBase.ScriptEngine m_scriptEngine; | 73 | public Common.ScriptEngineBase.ScriptEngine m_scriptEngine; |
76 | public Compiler(Common.ScriptEngineBase.ScriptEngine scriptEngine) | 74 | public Compiler(Common.ScriptEngineBase.ScriptEngine scriptEngine) |
@@ -107,7 +105,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
107 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); | 105 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); |
108 | 106 | ||
109 | // Allowed compilers | 107 | // Allowed compilers |
110 | string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl;cs;vb"); | 108 | string allowComp = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl,cs,vb"); |
111 | AllowedCompilers.Clear(); | 109 | AllowedCompilers.Clear(); |
112 | 110 | ||
113 | #if DEBUG | 111 | #if DEBUG |
@@ -115,7 +113,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
115 | #endif | 113 | #endif |
116 | 114 | ||
117 | 115 | ||
118 | foreach (string strl in allowComp.Split(';')) | 116 | foreach (string strl in allowComp.Split(',')) |
119 | { | 117 | { |
120 | string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); | 118 | string strlan = strl.Trim(" \t".ToCharArray()).ToLower(); |
121 | if (!LanguageMapping.ContainsKey(strlan)) | 119 | if (!LanguageMapping.ContainsKey(strlan)) |
@@ -299,6 +297,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
299 | string OutFile = | 297 | string OutFile = |
300 | Path.Combine("ScriptEngines", | 298 | Path.Combine("ScriptEngines", |
301 | FilePrefix + "_compiled_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); | 299 | FilePrefix + "_compiled_" + instanceID.ToString() + "_" + scriptCompileCounter.ToString() + ".dll"); |
300 | #if DEBUG | ||
301 | m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "Starting compile of \"" + OutFile + "\"."); | ||
302 | #endif | ||
302 | try | 303 | try |
303 | { | 304 | { |
304 | File.Delete(OutFile); | 305 | File.Delete(OutFile); |
@@ -313,14 +314,16 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
313 | // DEBUG - write source to disk | 314 | // DEBUG - write source to disk |
314 | if (WriteScriptSourceToDebugFile) | 315 | if (WriteScriptSourceToDebugFile) |
315 | { | 316 | { |
317 | string srcFileName = FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext; | ||
316 | try | 318 | try |
317 | { | 319 | { |
318 | File.WriteAllText( | 320 | File.WriteAllText( |
319 | Path.Combine("ScriptEngines", FilePrefix + "_source_" + Path.GetFileNameWithoutExtension(OutFile) + ext), | 321 | Path.Combine("ScriptEngines", srcFileName), |
320 | Script); | 322 | Script); |
321 | } | 323 | } |
322 | catch | 324 | catch (Exception ex) |
323 | { | 325 | { |
326 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Exception while trying to write script source to file \"" + srcFileName + "\": " + ex.ToString()); | ||
324 | } | 327 | } |
325 | } | 328 | } |
326 | 329 | ||
@@ -346,7 +349,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
346 | parameters.GenerateExecutable = false; | 349 | parameters.GenerateExecutable = false; |
347 | parameters.OutputAssembly = OutFile; | 350 | parameters.OutputAssembly = OutFile; |
348 | parameters.IncludeDebugInformation = CompileWithDebugInformation; | 351 | parameters.IncludeDebugInformation = CompileWithDebugInformation; |
349 | parameters.WarningLevel = 4; | 352 | parameters.WarningLevel = 1; // Should be 4? |
350 | parameters.TreatWarningsAsErrors = false; | 353 | parameters.TreatWarningsAsErrors = false; |
351 | 354 | ||
352 | CompilerResults results; | 355 | CompilerResults results; |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 2f90c16..4e20d95 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -43,6 +43,14 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
43 | base.m_scriptEngine = scriptEngine; | 43 | base.m_scriptEngine = scriptEngine; |
44 | 44 | ||
45 | } | 45 | } |
46 | private Compiler.LSL.Compiler LSLCompiler; | ||
47 | |||
48 | |||
49 | public override void Initialize() | ||
50 | { | ||
51 | // Create our compiler | ||
52 | LSLCompiler = new Compiler.LSL.Compiler(m_scriptEngine); | ||
53 | } | ||
46 | 54 | ||
47 | // KEEP TRACK OF SCRIPTS <int id, whatever script> | 55 | // KEEP TRACK OF SCRIPTS <int id, whatever script> |
48 | //internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>(); | 56 | //internal Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>> Scripts = new Dictionary<uint, Dictionary<LLUUID, LSL_BaseClass>>(); |
@@ -50,17 +58,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
50 | // UNLOAD SCRIPT | 58 | // UNLOAD SCRIPT |
51 | // PROVIDE SCRIPT WITH ITS INTERFACE TO OpenSim | 59 | // PROVIDE SCRIPT WITH ITS INTERFACE TO OpenSim |
52 | 60 | ||
53 | private Compiler.LSL.Compiler LSLCompiler; | ||
54 | 61 | ||
55 | public override void _StartScript(uint localID, LLUUID itemID, string Script) | 62 | public override void _StartScript(uint localID, LLUUID itemID, string Script) |
56 | { | 63 | { |
57 | m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); | 64 | m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "ScriptManager StartScript: localID: " + localID + ", itemID: " + itemID); |
58 | 65 | ||
59 | // First time start? Lets fire up our compiler... | ||
60 | if (LSLCompiler == null) | ||
61 | { | ||
62 | LSLCompiler = new Compiler.LSL.Compiler(m_scriptEngine); | ||
63 | } | ||
64 | 66 | ||
65 | //IScriptHost root = host.GetRoot(); | 67 | //IScriptHost root = host.GetRoot(); |
66 | 68 | ||
@@ -118,7 +120,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
118 | catch (Exception e2) | 120 | catch (Exception e2) |
119 | { | 121 | { |
120 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Error displaying error in-world: " + e2.ToString()); | 122 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Error displaying error in-world: " + e2.ToString()); |
121 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, | 123 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, |
122 | "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); | 124 | "Errormessage: Error compiling script:\r\n" + e.Message.ToString()); |
123 | } | 125 | } |
124 | } | 126 | } |