UbitUmarov vor 4 Tagen
Ursprung
Commit
95ef45ba7c

+ 2 - 1
OpenSim/Region/ScriptEngine/YEngine/MMRScriptCodeGen.cs

@@ -2835,7 +2835,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine
 
              // Output compare and branch instructions in a tree-like fashion so we do O(log2 n) comparisons.
             defaultLabel ??= ilGen.DefineLabel("default");
-            OutputStrCase(testRVal, caseTreeTop, defaultLabel);
+            if(caseTreeTop is not null)
+                OutputStrCase(testRVal, caseTreeTop, defaultLabel);
 
              // Output code for the cases themselves, in the order given by the programmer, 
              // so they fall through as programmer wants.  This includes the default case, if any.

+ 7 - 4
OpenSim/Region/ScriptEngine/YEngine/MMRScriptReduce.cs

@@ -3092,7 +3092,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
             tokenStmtSwitch.testRVal = ParseRValParen(ref token);
             if(tokenStmtSwitch.testRVal == null)
                 return null;
-            if(!(token is TokenKwBrcOpen))
+            if(token is not TokenKwBrcOpen)
             {
                 ErrorMsg(token, "expecting open brace");
                 token = SkipPastSemi(token);
@@ -3101,7 +3101,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
             token = token.nextToken;
             TokenSwitchCase tokenSwitchCase = null;
             bool haveComplained = false;
-            while(!(token is TokenKwBrcClose))
+            while(token is not TokenEnd && token is not TokenKwBrcClose)
             {
                 if(token is TokenKwCase)
                 {
@@ -3178,11 +3178,14 @@ namespace OpenSim.Region.ScriptEngine.Yengine
                 }
                 else if(!haveComplained)
                 {
-                    ErrorMsg(token, "expecting case or default label");
+                    ErrorMsg(token, "expecting switch case or default");
                     token = SkipPastSemi(token);
                     haveComplained = true;
                 }
             }
+            if(tokenSwitchCase is null)
+                    ErrorMsg(token, "expecting switch case or default");
+
             token = token.nextToken;
             return tokenStmtSwitch;
         }
@@ -4329,7 +4332,7 @@ namespace OpenSim.Region.ScriptEngine.Yengine
         {
             int braceLevel = 0;
 
-            while(!(token is TokenEnd))
+            while(token is not TokenEnd)
             {
                 if((token is TokenKwSemi) && (braceLevel == 0))
                 {