diff options
author | Melanie Thielker | 2008-09-01 23:33:12 +0000 |
---|---|---|
committer | Melanie Thielker | 2008-09-01 23:33:12 +0000 |
commit | a5d2674a439df4f13285ab43bde194535bc31be1 (patch) | |
tree | 42351442f99ca46ac5f722346ed073ad2b9c0113 /OpenSim/Region | |
parent | Another attempt at fixing XEngine llSetPrimitiveParams: Make it accept (diff) | |
download | opensim-SC_OLD-a5d2674a439df4f13285ab43bde194535bc31be1.zip opensim-SC_OLD-a5d2674a439df4f13285ab43bde194535bc31be1.tar.gz opensim-SC_OLD-a5d2674a439df4f13285ab43bde194535bc31be1.tar.bz2 opensim-SC_OLD-a5d2674a439df4f13285ab43bde194535bc31be1.tar.xz |
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.
Diffstat (limited to 'OpenSim/Region')
3 files changed, 34 insertions, 31 deletions
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 | |||
726 | if ("LSL_Types.LSLFloat" == c.Type) | 726 | if ("LSL_Types.LSLFloat" == c.Type) |
727 | { | 727 | { |
728 | int dotIndex = c.Value.IndexOf('.') + 1; | 728 | int dotIndex = c.Value.IndexOf('.') + 1; |
729 | // Skip first dot (in type name) | ||
730 | dotIndex = c.Value.IndexOf('.', dotIndex) + 1; | ||
729 | if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex]))) | 731 | if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex]))) |
730 | c.Value = c.Value.Insert(dotIndex, "0"); | 732 | c.Value = c.Value.Insert(dotIndex, "0"); |
731 | } | 733 | } |
732 | 734 | ||
735 | // commencted because the parser does it now | ||
733 | // need to quote strings | 736 | // need to quote strings |
734 | if ("LSL_Types.LSLString" == c.Type) | 737 | // if ("LSL_Types.LSLString" == c.Type) |
735 | retstr += Generate("\""); | 738 | // retstr += Generate("\""); |
736 | retstr += Generate(c.Value, c); | 739 | retstr += Generate(c.Value, c); |
737 | if ("LSL_Types.LSLString" == c.Type) | 740 | // if ("LSL_Types.LSLString" == c.Type) |
738 | retstr += Generate("\""); | 741 | // retstr += Generate("\""); |
739 | 742 | ||
740 | return retstr; | 743 | return retstr; |
741 | } | 744 | } |
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 { | |||
1304 | public ReturnStatement_2(Parser yyq):base(yyq){}} | 1304 | public ReturnStatement_2(Parser yyq):base(yyq){}} |
1305 | 1305 | ||
1306 | public class Constant_1 : Constant { | 1306 | public class Constant_1 : Constant { |
1307 | public Constant_1(Parser yyq):base(yyq,"integer", | 1307 | public Constant_1(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ |
1308 | ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) | 1308 | ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) |
1309 | .yytext){}} | 1309 | .yytext+")"){}} |
1310 | 1310 | ||
1311 | public class Constant_2 : Constant { | 1311 | public class Constant_2 : Constant { |
1312 | public Constant_2(Parser yyq):base(yyq,"integer", | 1312 | public Constant_2(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ |
1313 | ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) | 1313 | ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) |
1314 | .yytext){}} | 1314 | .yytext+")"){}} |
1315 | 1315 | ||
1316 | public class Constant_3 : Constant { | 1316 | public class Constant_3 : Constant { |
1317 | public Constant_3(Parser yyq):base(yyq,"float", | 1317 | public Constant_3(Parser yyq):base(yyq,"float", "new LSL_Types.LSLFloat("+ |
1318 | ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) | 1318 | ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) |
1319 | .yytext){}} | 1319 | .yytext+")"){}} |
1320 | 1320 | ||
1321 | public class Constant_4 : Constant { | 1321 | public class Constant_4 : Constant { |
1322 | public Constant_4(Parser yyq):base(yyq,"string", | 1322 | public Constant_4(Parser yyq):base(yyq,"string", "new LSL_Types.LSLString(\""+ |
1323 | ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) | 1323 | ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) |
1324 | .yytext){}} | 1324 | .yytext+"\")"){}} |
1325 | 1325 | ||
1326 | public class ListConstant_1 : ListConstant { | 1326 | public class ListConstant_1 : ListConstant { |
1327 | public ListConstant_1(Parser yyq):base(yyq, | 1327 | 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 | |||
1453 | return new LSLInteger(i1.value / i2); | 1453 | return new LSLInteger(i1.value / i2); |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | static public LSLFloat operator +(LSLInteger i1, double f) | 1456 | // static public LSLFloat operator +(LSLInteger i1, double f) |
1457 | { | 1457 | // { |
1458 | return new LSLFloat((double)i1.value + f); | 1458 | // return new LSLFloat((double)i1.value + f); |
1459 | } | 1459 | // } |
1460 | 1460 | // | |
1461 | static public LSLFloat operator -(LSLInteger i1, double f) | 1461 | // static public LSLFloat operator -(LSLInteger i1, double f) |
1462 | { | 1462 | // { |
1463 | return new LSLFloat((double)i1.value - f); | 1463 | // return new LSLFloat((double)i1.value - f); |
1464 | } | 1464 | // } |
1465 | 1465 | // | |
1466 | static public LSLFloat operator *(LSLInteger i1, double f) | 1466 | // static public LSLFloat operator *(LSLInteger i1, double f) |
1467 | { | 1467 | // { |
1468 | return new LSLFloat((double)i1.value * f); | 1468 | // return new LSLFloat((double)i1.value * f); |
1469 | } | 1469 | // } |
1470 | 1470 | // | |
1471 | static public LSLFloat operator /(LSLInteger i1, double f) | 1471 | // static public LSLFloat operator /(LSLInteger i1, double f) |
1472 | { | 1472 | // { |
1473 | return new LSLFloat((double)i1.value / f); | 1473 | // return new LSLFloat((double)i1.value / f); |
1474 | } | 1474 | // } |
1475 | 1475 | ||
1476 | static public LSLInteger operator -(LSLInteger i) | 1476 | static public LSLInteger operator -(LSLInteger i) |
1477 | { | 1477 | { |