From a42499c947e350639da81f0e8930eae5d331c441 Mon Sep 17 00:00:00 2001 From: Mike Mazur Date: Fri, 20 Feb 2009 07:40:36 +0000 Subject: Thanks DoranZemlja for a patch implementing non-shortcircuiting in logical and and logical or in LSL. Fixes Mantis #3174. --- .../Shared/CodeTools/CSCodeGenerator.cs | 23 ++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs') 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 { string retstr = String.Empty; - retstr += GenerateNode((SYMBOL) be.kids.Pop()); - retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); - foreach (SYMBOL kid in be.kids) - retstr += GenerateNode(kid); + if (be.ExpressionSymbol.Equals("&&") || be.ExpressionSymbol.Equals("||")) + { + // special case handling for logical and/or, see Mantis 3174 + retstr += "((bool)("; + retstr += GenerateNode((SYMBOL)be.kids.Pop()); + retstr += "))"; + retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol.Substring(0,1)), be); + retstr += "((bool)("; + foreach (SYMBOL kid in be.kids) + retstr += GenerateNode(kid); + retstr += "))"; + } + else + { + retstr += GenerateNode((SYMBOL)be.kids.Pop()); + retstr += Generate(String.Format(" {0} ", be.ExpressionSymbol), be); + foreach (SYMBOL kid in be.kids) + retstr += GenerateNode(kid); + } return retstr; } -- cgit v1.1