diff options
author | Mic Bowman | 2012-07-31 10:45:37 -0700 |
---|---|---|
committer | Mic Bowman | 2012-07-31 10:45:37 -0700 |
commit | a76a289d11086dd99d345390e58a43b66b053470 (patch) | |
tree | 60b1ef6d3890d9636a1bbb9b47758847e30b88dd /OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |
parent | BulletSim: update the DLLs and SOs. This fixes the exception on shutdown (diff) | |
download | opensim-SC_OLD-a76a289d11086dd99d345390e58a43b66b053470.zip opensim-SC_OLD-a76a289d11086dd99d345390e58a43b66b053470.tar.gz opensim-SC_OLD-a76a289d11086dd99d345390e58a43b66b053470.tar.bz2 opensim-SC_OLD-a76a289d11086dd99d345390e58a43b66b053470.tar.xz |
Adds support to ScriptModuleComms for region modules to export
constants to the script engine.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index b24f016..97dd0f6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs | |||
@@ -38,7 +38,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
38 | { | 38 | { |
39 | public class CSCodeGenerator : ICodeConverter | 39 | public class CSCodeGenerator : ICodeConverter |
40 | { | 40 | { |
41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 41 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
42 | 42 | ||
43 | private SYMBOL m_astRoot = null; | 43 | private SYMBOL m_astRoot = null; |
44 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; | 44 | private Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap; |
@@ -255,7 +255,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
255 | else if (s is IdentDotExpression) | 255 | else if (s is IdentDotExpression) |
256 | retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); | 256 | retstr += Generate(CheckName(((IdentDotExpression) s).Name) + "." + ((IdentDotExpression) s).Member, s); |
257 | else if (s is IdentExpression) | 257 | else if (s is IdentExpression) |
258 | retstr += Generate(CheckName(((IdentExpression) s).Name), s); | 258 | retstr += GenerateIdentifier(((IdentExpression) s).Name, s); |
259 | else if (s is IDENT) | 259 | else if (s is IDENT) |
260 | retstr += Generate(CheckName(((TOKEN) s).yytext), s); | 260 | retstr += Generate(CheckName(((TOKEN) s).yytext), s); |
261 | else | 261 | else |
@@ -868,6 +868,41 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools | |||
868 | } | 868 | } |
869 | 869 | ||
870 | /// <summary> | 870 | /// <summary> |
871 | /// Generates the code for an identifier | ||
872 | /// </summary> | ||
873 | /// <param name="id">The symbol name</param> | ||
874 | /// <param name="s">The Symbol node.</param> | ||
875 | /// <returns>String containing C# code for identifier reference.</returns> | ||
876 | private string GenerateIdentifier(string id, SYMBOL s) | ||
877 | { | ||
878 | if (m_comms != null) | ||
879 | { | ||
880 | object value = m_comms.LookupModConstant(id); | ||
881 | if (value != null) | ||
882 | { | ||
883 | string retval = null; | ||
884 | if (value is int) | ||
885 | retval = ((int)value).ToString(); | ||
886 | else if (value is float) | ||
887 | retval = String.Format("new LSL_Types.LSLFloat({0})",((float)value).ToString()); | ||
888 | else if (value is string) | ||
889 | retval = String.Format("new LSL_Types.LSLString(\"{0}\")",((string)value)); | ||
890 | else if (value is OpenMetaverse.UUID) | ||
891 | retval = String.Format("new LSL_Types.key(\"{0}\")",((OpenMetaverse.UUID)value).ToString()); | ||
892 | else if (value is OpenMetaverse.Vector3) | ||
893 | retval = String.Format("new LSL_Types.Vector3(\"{0}\")",((OpenMetaverse.Vector3)value).ToString()); | ||
894 | else if (value is OpenMetaverse.Quaternion) | ||
895 | retval = String.Format("new LSL_Types.Quaternion(\"{0}\")",((OpenMetaverse.Quaternion)value).ToString()); | ||
896 | else retval = id; | ||
897 | |||
898 | return Generate(retval, s); | ||
899 | } | ||
900 | } | ||
901 | |||
902 | return Generate(CheckName(id), s); | ||
903 | } | ||
904 | |||
905 | /// <summary> | ||
871 | /// Generates the code for a FunctionCall node. | 906 | /// Generates the code for a FunctionCall node. |
872 | /// </summary> | 907 | /// </summary> |
873 | /// <param name="fc">The FunctionCall node.</param> | 908 | /// <param name="fc">The FunctionCall node.</param> |