diff options
author | Tedd Hansen | 2008-02-02 03:42:35 +0000 |
---|---|---|
committer | Tedd Hansen | 2008-02-02 03:42:35 +0000 |
commit | 8dc5153ad7f20bb74e582c68f700fe34f25fec24 (patch) | |
tree | 440a798a35c684fcd41763ceefc33e2bd51cede1 /OpenSim/Region/ScriptEngine | |
parent | Bugfix: LSL was mapped to VB.Net compiler ... that didn't work out so well :) (diff) | |
download | opensim-SC-8dc5153ad7f20bb74e582c68f700fe34f25fec24.zip opensim-SC-8dc5153ad7f20bb74e582c68f700fe34f25fec24.tar.gz opensim-SC-8dc5153ad7f20bb74e582c68f700fe34f25fec24.tar.bz2 opensim-SC-8dc5153ad7f20bb74e582c68f700fe34f25fec24.tar.xz |
Added header/footer of scripts to make C# and VB scripts much easier to write.
Added some logging on what is happening during compile.
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | 54 | ||||
-rw-r--r-- | OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | 3 |
2 files changed, 49 insertions, 8 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs index b919f22..883ed5e 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/Compiler.cs | |||
@@ -81,6 +81,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
81 | public bool in_startup = true; | 81 | public bool in_startup = true; |
82 | public void ReadConfig() | 82 | public void ReadConfig() |
83 | { | 83 | { |
84 | |||
85 | // Get some config | ||
84 | WriteScriptSourceToDebugFile = m_scriptEngine.ScriptConfigSource.GetBoolean("WriteScriptSourceToDebugFile", true); | 86 | WriteScriptSourceToDebugFile = m_scriptEngine.ScriptConfigSource.GetBoolean("WriteScriptSourceToDebugFile", true); |
85 | CompileWithDebugInformation = m_scriptEngine.ScriptConfigSource.GetBoolean("CompileWithDebugInformation", true); | 87 | CompileWithDebugInformation = m_scriptEngine.ScriptConfigSource.GetBoolean("CompileWithDebugInformation", true); |
86 | CleanUpOldScriptsOnStartup = m_scriptEngine.ScriptConfigSource.GetBoolean("CleanUpOldScriptsOnStartup", true); | 88 | CleanUpOldScriptsOnStartup = m_scriptEngine.ScriptConfigSource.GetBoolean("CleanUpOldScriptsOnStartup", true); |
@@ -91,16 +93,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
91 | { | 93 | { |
92 | FilePrefix = FilePrefix.Replace(c, '_'); | 94 | FilePrefix = FilePrefix.Replace(c, '_'); |
93 | } | 95 | } |
94 | // First time we start? | 96 | |
97 | // First time we start? Delete old files | ||
95 | if (in_startup) | 98 | if (in_startup) |
96 | { | 99 | { |
97 | in_startup = false; | 100 | in_startup = false; |
98 | DeleteOldFiles(); | 101 | DeleteOldFiles(); |
99 | } | 102 | } |
100 | 103 | ||
101 | LanguageMapping.Add("cs", enumCompileType.cs); | 104 | // Map name and enum type of our supported languages |
102 | LanguageMapping.Add("vb", enumCompileType.vb); | 105 | LanguageMapping.Add(enumCompileType.cs.ToString(), enumCompileType.cs); |
103 | LanguageMapping.Add("lsl", enumCompileType.lsl); | 106 | LanguageMapping.Add(enumCompileType.vb.ToString(), enumCompileType.vb); |
107 | LanguageMapping.Add(enumCompileType.lsl.ToString(), enumCompileType.lsl); | ||
104 | 108 | ||
105 | // Allowed compilers | 109 | // Allowed compilers |
106 | string allowedCompilers = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl;cs;vb"); | 110 | string allowedCompilers = m_scriptEngine.ScriptConfigSource.GetString("AllowedCompilers", "lsl;cs;vb"); |
@@ -112,6 +116,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
112 | { | 116 | { |
113 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Config error. Compiler is unable to recongnize language type \"" + strl + "\" specified in \"AllowedCompilers\"."); | 117 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Config error. Compiler is unable to recongnize language type \"" + strl + "\" specified in \"AllowedCompilers\"."); |
114 | } | 118 | } |
119 | else | ||
120 | { | ||
121 | #if DEBUG | ||
122 | m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, "Config OK. Compiler recongnized language type \"" + strl + "\" specified in \"AllowedCompilers\"."); | ||
123 | #endif | ||
124 | } | ||
115 | AllowedCompilers.Add(strlan, true); | 125 | AllowedCompilers.Add(strlan, true); |
116 | } | 126 | } |
117 | if (AllowedCompilers.Count == 0) | 127 | if (AllowedCompilers.Count == 0) |
@@ -122,7 +132,11 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
122 | 132 | ||
123 | // Is this language recognized at all? | 133 | // Is this language recognized at all? |
124 | if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) | 134 | if (!LanguageMapping.ContainsKey(defaultCompileLanguage)) |
125 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, "Config error. Default language specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Scripts may not be executed!"); | 135 | { |
136 | m_scriptEngine.Log.Error(m_scriptEngine.ScriptEngineName, | ||
137 | "Config error. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is not recognized as a valid language. Changing default to: \"lsl\"."); | ||
138 | defaultCompileLanguage = "lsl"; | ||
139 | } | ||
126 | 140 | ||
127 | // Is this language in allow-list? | 141 | // Is this language in allow-list? |
128 | if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) | 142 | if (!AllowedCompilers.ContainsKey(defaultCompileLanguage)) |
@@ -132,6 +146,10 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
132 | } | 146 | } |
133 | else | 147 | else |
134 | { | 148 | { |
149 | #if DEBUG | ||
150 | m_scriptEngine.Log.Debug(m_scriptEngine.ScriptEngineName, | ||
151 | "Config OK. Default language \"" + defaultCompileLanguage + "\" specified in \"DefaultCompileLanguage\" is recognized as a valid language."); | ||
152 | #endif | ||
135 | // LANGUAGE IS IN ALLOW-LIST | 153 | // LANGUAGE IS IN ALLOW-LIST |
136 | DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; | 154 | DefaultCompileLanguage = LanguageMapping[defaultCompileLanguage]; |
137 | } | 155 | } |
@@ -140,6 +158,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
140 | 158 | ||
141 | } | 159 | } |
142 | 160 | ||
161 | /// <summary> | ||
162 | /// Delete old script files | ||
163 | /// </summary> | ||
143 | private void DeleteOldFiles() | 164 | private void DeleteOldFiles() |
144 | { | 165 | { |
145 | 166 | ||
@@ -227,10 +248,27 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL | |||
227 | compileScript = LSL_Converter.Convert(Script); | 248 | compileScript = LSL_Converter.Convert(Script); |
228 | l = enumCompileType.cs; | 249 | l = enumCompileType.cs; |
229 | } | 250 | } |
230 | else | 251 | |
252 | switch (l) | ||
231 | { | 253 | { |
232 | // We don't need to convert | 254 | case enumCompileType.cs: |
233 | compileScript = Script; | 255 | compileScript = String.Empty + |
256 | "using OpenSim.Region.ScriptEngine.Common; using System.Collections.Generic;" + | ||
257 | String.Empty + "namespace SecondLife { " + | ||
258 | String.Empty + "public class Script : OpenSim.Region.ScriptEngine.Common.LSL_BaseClass { " + | ||
259 | @"public Script() { } " + | ||
260 | Script + | ||
261 | "} }\r\n"; | ||
262 | break; | ||
263 | case enumCompileType.vb: | ||
264 | compileScript = String.Empty + | ||
265 | "Imports OpenSim.Region.ScriptEngine.Common: Imports System.Collections.Generic: " + | ||
266 | String.Empty + "NameSpace SecondLife { " + | ||
267 | String.Empty + "Public Class Script: Inherits OpenSim.Region.ScriptEngine.Common.LSL_BaseClass: " + | ||
268 | @"Public Sub New(): End Sub: " + | ||
269 | Script + | ||
270 | ":End Class :End Namespace\r\n"; | ||
271 | break; | ||
234 | } | 272 | } |
235 | return CompileFromCSorVBText(Script, l); | 273 | return CompileFromCSorVBText(Script, l); |
236 | } | 274 | } |
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs index 821b2d4..2f90c16 100644 --- a/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs +++ b/OpenSim/Region/ScriptEngine/DotNetEngine/ScriptManager.cs | |||
@@ -41,6 +41,7 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
41 | : base(scriptEngine) | 41 | : base(scriptEngine) |
42 | { | 42 | { |
43 | base.m_scriptEngine = scriptEngine; | 43 | base.m_scriptEngine = scriptEngine; |
44 | |||
44 | } | 45 | } |
45 | 46 | ||
46 | // KEEP TRACK OF SCRIPTS <int id, whatever script> | 47 | // KEEP TRACK OF SCRIPTS <int id, whatever script> |
@@ -57,7 +58,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine | |||
57 | 58 | ||
58 | // First time start? Lets fire up our compiler... | 59 | // First time start? Lets fire up our compiler... |
59 | if (LSLCompiler == null) | 60 | if (LSLCompiler == null) |
61 | { | ||
60 | LSLCompiler = new Compiler.LSL.Compiler(m_scriptEngine); | 62 | LSLCompiler = new Compiler.LSL.Compiler(m_scriptEngine); |
63 | } | ||
61 | 64 | ||
62 | //IScriptHost root = host.GetRoot(); | 65 | //IScriptHost root = host.GetRoot(); |
63 | 66 | ||