From a5d2674a439df4f13285ab43bde194535bc31be1 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Mon, 1 Sep 2008 23:33:12 +0000 Subject: This is an attempt to fix the handling of constants in LSL. It wraps constants in new LSLType(x), so that lists with constant values are processed correctly. Contains changes to the lsl.parser.cs that are not (yet) reflected in opensim-libs, since this experimental patch affects XEngine only. Also contains nuts. --- .../Shared/CodeTools/CSCodeGenerator.cs | 11 ++++--- .../ScriptEngine/Shared/CodeTools/lsl.parser.cs | 16 ++++----- OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs | 38 +++++++++++----------- 3 files changed, 34 insertions(+), 31 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs index 2226673..b357ab6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs @@ -726,16 +726,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools if ("LSL_Types.LSLFloat" == c.Type) { int dotIndex = c.Value.IndexOf('.') + 1; + // Skip first dot (in type name) + dotIndex = c.Value.IndexOf('.', dotIndex) + 1; if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex]))) c.Value = c.Value.Insert(dotIndex, "0"); } + // commencted because the parser does it now // need to quote strings - if ("LSL_Types.LSLString" == c.Type) - retstr += Generate("\""); + // if ("LSL_Types.LSLString" == c.Type) + // retstr += Generate("\""); retstr += Generate(c.Value, c); - if ("LSL_Types.LSLString" == c.Type) - retstr += Generate("\""); + // if ("LSL_Types.LSLString" == c.Type) + // retstr += Generate("\""); return retstr; } diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs index 53da265..2f9a829 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs @@ -1304,24 +1304,24 @@ public class ReturnStatement_2 : ReturnStatement { public ReturnStatement_2(Parser yyq):base(yyq){}} public class Constant_1 : Constant { - public Constant_1(Parser yyq):base(yyq,"integer", + public Constant_1(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + .yytext+")"){}} public class Constant_2 : Constant { - public Constant_2(Parser yyq):base(yyq,"integer", + public Constant_2(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + .yytext+")"){}} public class Constant_3 : Constant { - public Constant_3(Parser yyq):base(yyq,"float", + public Constant_3(Parser yyq):base(yyq,"float", "new LSL_Types.LSLFloat("+ ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + .yytext+")"){}} public class Constant_4 : Constant { - public Constant_4(Parser yyq):base(yyq,"string", + public Constant_4(Parser yyq):base(yyq,"string", "new LSL_Types.LSLString(\""+ ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) - .yytext){}} + .yytext+"\")"){}} public class ListConstant_1 : ListConstant { public ListConstant_1(Parser yyq):base(yyq, diff --git a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs index 64334f1..babb759 100644 --- a/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs +++ b/OpenSim/Region/ScriptEngine/Shared/LSL_Types.cs @@ -1453,25 +1453,25 @@ namespace OpenSim.Region.ScriptEngine.Shared return new LSLInteger(i1.value / i2); } - static public LSLFloat operator +(LSLInteger i1, double f) - { - return new LSLFloat((double)i1.value + f); - } - - static public LSLFloat operator -(LSLInteger i1, double f) - { - return new LSLFloat((double)i1.value - f); - } - - static public LSLFloat operator *(LSLInteger i1, double f) - { - return new LSLFloat((double)i1.value * f); - } - - static public LSLFloat operator /(LSLInteger i1, double f) - { - return new LSLFloat((double)i1.value / f); - } +// static public LSLFloat operator +(LSLInteger i1, double f) +// { +// return new LSLFloat((double)i1.value + f); +// } +// +// static public LSLFloat operator -(LSLInteger i1, double f) +// { +// return new LSLFloat((double)i1.value - f); +// } +// +// static public LSLFloat operator *(LSLInteger i1, double f) +// { +// return new LSLFloat((double)i1.value * f); +// } +// +// static public LSLFloat operator /(LSLInteger i1, double f) +// { +// return new LSLFloat((double)i1.value / f); +// } static public LSLInteger operator -(LSLInteger i) { -- cgit v1.1