aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared
diff options
context:
space:
mode:
authorMike Mazur2009-02-20 07:40:36 +0000
committerMike Mazur2009-02-20 07:40:36 +0000
commita42499c947e350639da81f0e8930eae5d331c441 (patch)
tree13a8449de17fb2e50e4395acfb852091bbabb4a2 /OpenSim/Region/ScriptEngine/Shared
parentUpdate TESTING.txt. Mantis #3174. (diff)
downloadopensim-SC_OLD-a42499c947e350639da81f0e8930eae5d331c441.zip
opensim-SC_OLD-a42499c947e350639da81f0e8930eae5d331c441.tar.gz
opensim-SC_OLD-a42499c947e350639da81f0e8930eae5d331c441.tar.bz2
opensim-SC_OLD-a42499c947e350639da81f0e8930eae5d331c441.tar.xz
Thanks DoranZemlja for a patch implementing non-shortcircuiting in
logical and and logical or in LSL. Fixes Mantis #3174.
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs23
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs20
2 files changed, 31 insertions, 12 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index f9ab97b..71e88e3 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -646,10 +646,25 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
646 { 646 {
647 string retstr = String.Empty; 647 string retstr = String.Empty;
648 648
649 retstr += GenerateNode((SYMBOL) be.kids.Pop()); 649 if (be.ExpressionSymbol.Equals("&&") || be.ExpressionSymbol.Equals("||"))
650 retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); 650 {
651 foreach (SYMBOL kid in be.kids) 651 // special case handling for logical and/or, see Mantis 3174
652 retstr += GenerateNode(kid); 652 retstr += "((bool)(";
653 retstr += GenerateNode((SYMBOL)be.kids.Pop());
654 retstr += "))";
655 retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be);
656 retstr += "((bool)(";
657 foreach (SYMBOL kid in be.kids)
658 retstr += GenerateNode(kid);
659 retstr += "))";
660 }
661 else
662 {
663 retstr += GenerateNode((SYMBOL)be.kids.Pop());
664 retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be);
665 foreach (SYMBOL kid in be.kids)
666 retstr += GenerateNode(kid);
667 }
653 668
654 return retstr; 669 return retstr;
655 } 670 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index a6d36c6..02108c7 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -223,6 +223,8 @@ state another_state
223 integer y; 223 integer y;
224 integer x = 14 + 6; 224 integer x = 14 + 6;
225 y = 12 - 3; 225 y = 12 - 3;
226 y = 12 && 3;
227 y = 12 || 3;
226 y = 12 * 3; 228 y = 12 * 3;
227 y = 12 / 3; 229 y = 12 / 3;
228 y = 12 | 3; 230 y = 12 | 3;
@@ -238,6 +240,8 @@ state another_state
238 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + 240 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" +
239 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" + 241 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14) + new LSL_Types.LSLInteger(6);" +
240 "\n y = new LSL_Types.LSLInteger(12) - new LSL_Types.LSLInteger(3);" + 242 "\n y = new LSL_Types.LSLInteger(12) - new LSL_Types.LSLInteger(3);" +
243 "\n y = ((bool)(new LSL_Types.LSLInteger(12))) & ((bool)(new LSL_Types.LSLInteger(3)));" +
244 "\n y = ((bool)(new LSL_Types.LSLInteger(12))) | ((bool)(new LSL_Types.LSLInteger(3)));" +
241 "\n y = new LSL_Types.LSLInteger(12) * new LSL_Types.LSLInteger(3);" + 245 "\n y = new LSL_Types.LSLInteger(12) * new LSL_Types.LSLInteger(3);" +
242 "\n y = new LSL_Types.LSLInteger(12) / new LSL_Types.LSLInteger(3);" + 246 "\n y = new LSL_Types.LSLInteger(12) / new LSL_Types.LSLInteger(3);" +
243 "\n y = new LSL_Types.LSLInteger(12) | new LSL_Types.LSLInteger(3);" + 247 "\n y = new LSL_Types.LSLInteger(12) | new LSL_Types.LSLInteger(3);" +
@@ -811,15 +815,15 @@ default
811 "\n {" + 815 "\n {" +
812 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" + 816 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(1);" +
813 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + 817 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" +
814 "\n if (x && y)" + 818 "\n if (((bool)(x)) & ((bool)(y)))" +
815 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" + 819 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hello\"));" +
816 "\n if (x || y)" + 820 "\n if (((bool)(x)) | ((bool)(y)))" +
817 "\n {" + 821 "\n {" +
818 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" + 822 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Hi\"));" +
819 "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" + 823 "\n LSL_Types.LSLInteger r = new LSL_Types.LSLInteger(3);" +
820 "\n return ;" + 824 "\n return ;" +
821 "\n }" + 825 "\n }" +
822 "\n if (x && y || z)" + 826 "\n if (((bool)(((bool)(x)) & ((bool)(y)))) | ((bool)(z)))" +
823 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" + 827 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is true\"));" +
824 "\n else" + 828 "\n else" +
825 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is false\"));" + 829 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"x is false\"));" +
@@ -849,7 +853,7 @@ default
849 "\n if (!z)" + 853 "\n if (!z)" +
850 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" + 854 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"z is true\"));" +
851 "\n else" + 855 "\n else" +
852 "\n if (!(a && b))" + 856 "\n if (!(((bool)(a)) & ((bool)(b))))" +
853 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" + 857 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"a is true\"));" +
854 "\n else" + 858 "\n else" +
855 "\n if (b)" + 859 "\n if (b)" +
@@ -894,7 +898,7 @@ default
894 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" + 898 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" +
895 "\n while (x)" + 899 "\n while (x)" +
896 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"To infinity, and beyond!\"));" + 900 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"To infinity, and beyond!\"));" +
897 "\n while (new LSL_Types.LSLInteger(0) || (x && new LSL_Types.LSLInteger(0)))" + 901 "\n while (((bool)(new LSL_Types.LSLInteger(0))) | ((bool)((((bool)(x)) & ((bool)(new LSL_Types.LSLInteger(0)))))))" +
898 "\n {" + 902 "\n {" +
899 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Never say never.\"));" + 903 "\n llSay(new LSL_Types.LSLInteger(0), new LSL_Types.LSLString(\"Never say never.\"));" +
900 "\n return ;" + 904 "\n return ;" +
@@ -983,7 +987,7 @@ default
983 "\n llOwnerSay(new LSL_Types.LSLString(\"Launch in T minus \") + x);" + 987 "\n llOwnerSay(new LSL_Types.LSLString(\"Launch in T minus \") + x);" +
984 "\n IncreaseRocketPower();" + 988 "\n IncreaseRocketPower();" +
985 "\n }" + 989 "\n }" +
986 "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); y > new LSL_Types.LSLInteger(0) && x != y; x++, y--)" + 990 "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); ((bool)(y > new LSL_Types.LSLInteger(0))) & ((bool)(x != y)); x++, y--)" +
987 "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" + 991 "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" +
988 "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); !y; x++, y--)" + 992 "\n for (x = new LSL_Types.LSLInteger(0), y = new LSL_Types.LSLInteger(6); !y; x++, y--)" +
989 "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" + 993 "\n llOwnerSay(new LSL_Types.LSLString(\"Hi \") + x + new LSL_Types.LSLString(\", \") + y);" +
@@ -1072,7 +1076,7 @@ default
1072 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(1);" + 1076 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(1);" +
1073 "\n LSL_Types.LSLInteger z = x ^ y;" + 1077 "\n LSL_Types.LSLInteger z = x ^ y;" +
1074 "\n x = ~z;" + 1078 "\n x = ~z;" +
1075 "\n x = ~(y && z);" + 1079 "\n x = ~(((bool)(y)) & ((bool)(z)));" +
1076 "\n y = x >> z;" + 1080 "\n y = x >> z;" +
1077 "\n z = y << x;" + 1081 "\n z = y << x;" +
1078 "\n }\n"; 1082 "\n }\n";
@@ -1118,7 +1122,7 @@ default
1118 "\n s = (LSL_Types.LSLInteger) (new LSL_Types.LSLString(\"1\"));" + 1122 "\n s = (LSL_Types.LSLInteger) (new LSL_Types.LSLString(\"1\"));" +
1119 "\n s = (LSL_Types.LSLString) (llSomethingThatReturnsInteger());" + 1123 "\n s = (LSL_Types.LSLString) (llSomethingThatReturnsInteger());" +
1120 "\n s = (LSL_Types.LSLString) (new LSL_Types.LSLInteger(134));" + 1124 "\n s = (LSL_Types.LSLString) (new LSL_Types.LSLInteger(134));" +
1121 "\n s = (LSL_Types.LSLString) (x ^ y | (z && l)) + (LSL_Types.LSLString) (x + y - new LSL_Types.LSLInteger(13));" + 1125 "\n s = (LSL_Types.LSLString) (x ^ y | (((bool)(z)) & ((bool)(l)))) + (LSL_Types.LSLString) (x + y - new LSL_Types.LSLInteger(13));" +
1122 "\n llOwnerSay(new LSL_Types.LSLString(\"s is: \") + s);" + 1126 "\n llOwnerSay(new LSL_Types.LSLString(\"s is: \") + s);" +
1123 "\n }\n"; 1127 "\n }\n";
1124 1128