aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorMike Mazur2008-07-31 01:27:33 +0000
committerMike Mazur2008-07-31 01:27:33 +0000
commiteef386427863e27a40cb22a424ddb5ceeb6c7a56 (patch)
tree331ca69428a9ece47d412556a366839f76ffded2 /OpenSim/Region
parentMore LSL_Types implicit/explicit cast changes. Fix issue 1854. (diff)
downloadopensim-SC-eef386427863e27a40cb22a424ddb5ceeb6c7a56.zip
opensim-SC-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.gz
opensim-SC-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.bz2
opensim-SC-eef386427863e27a40cb22a424ddb5ceeb6c7a56.tar.xz
Fix issue 1860; exception thrown in the parser on if/if-else/for/while/do-while
statements with no body.
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/lsl.parser.cs10
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs14
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs10
4 files changed, 28 insertions, 20 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
index f129859..631aa54 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/CSCodeGenerator.cs
@@ -388,14 +388,18 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine.Compiler.LSL
388 private string GenerateStatement(Statement s) 388 private string GenerateStatement(Statement s)
389 { 389 {
390 string retstr = String.Empty; 390 string retstr = String.Empty;
391 391 bool printSemicolon = true;
392 // Jump label prints its own colon, we don't need a semicolon.
393 bool printSemicolon = !(s.kids.Top is JumpLabel);
394 392
395 retstr += Indent(); 393 retstr += Indent();
396 394
397 foreach (SYMBOL kid in s.kids) 395 if (0 < s.kids.Count)
398 retstr += GenerateNode(kid); 396 {
397 // Jump label prints its own colon, we don't need a semicolon.
398 printSemicolon = !(s.kids.Top is JumpLabel);
399
400 foreach (SYMBOL kid in s.kids)
401 retstr += GenerateNode(kid);
402 }
399 403
400 if (printSemicolon) 404 if (printSemicolon)
401 retstr += GenerateLine(";"); 405 retstr += GenerateLine(";");
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/lsl.parser.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/lsl.parser.cs
index 178eed1..14c090d 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/lsl.parser.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/Compiler/LSL/lsl.parser.cs
@@ -359,7 +359,7 @@ public override int yynum { get { return 114; }}
359public StateChange(Parser yyp):base(yyp){}} 359public StateChange(Parser yyp):base(yyp){}}
360//%+IfStatement+115 360//%+IfStatement+115
361public class IfStatement : SYMBOL{ 361public class IfStatement : SYMBOL{
362 private void AddStatement ( Statement s ){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 362 private void AddStatement ( Statement s ){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
363 else kids . Add ( s ); 363 else kids . Add ( s );
364} 364}
365 public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax 365 public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax
@@ -369,7 +369,7 @@ public class IfStatement : SYMBOL{
369 public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax 369 public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax
370)yyp)){ kids . Add ( e ); 370)yyp)){ kids . Add ( e );
371 AddStatement ( ifs ); 371 AddStatement ( ifs );
372 if ( es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ()); 372 if (0< es . kids . Count && es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ());
373 else AddStatement ( es ); 373 else AddStatement ( es );
374} 374}
375 375
@@ -380,7 +380,7 @@ public IfStatement(Parser yyp):base(yyp){}}
380public class WhileStatement : SYMBOL{ 380public class WhileStatement : SYMBOL{
381 public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax 381 public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax
382)yyp)){ kids . Add ( e ); 382)yyp)){ kids . Add ( e );
383 if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 383 if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
384 else kids . Add ( s ); 384 else kids . Add ( s );
385} 385}
386 386
@@ -390,7 +390,7 @@ public WhileStatement(Parser yyp):base(yyp){}}
390//%+DoWhileStatement+117 390//%+DoWhileStatement+117
391public class DoWhileStatement : SYMBOL{ 391public class DoWhileStatement : SYMBOL{
392 public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax 392 public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax
393)yyp)){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 393)yyp)){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
394 else kids . Add ( s ); 394 else kids . Add ( s );
395 kids . Add ( e ); 395 kids . Add ( e );
396} 396}
@@ -404,7 +404,7 @@ public class ForLoop : SYMBOL{
404)yyp)){ kids . Add ( flsa ); 404)yyp)){ kids . Add ( flsa );
405 kids . Add ( e ); 405 kids . Add ( e );
406 kids . Add ( flsb ); 406 kids . Add ( flsb );
407 if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 407 if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
408 else kids . Add ( s ); 408 else kids . Add ( s );
409} 409}
410 410
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index 3bdad4d..2226673 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -388,14 +388,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
388 private string GenerateStatement(Statement s) 388 private string GenerateStatement(Statement s)
389 { 389 {
390 string retstr = String.Empty; 390 string retstr = String.Empty;
391 391 bool printSemicolon = true;
392 // Jump label prints its own colon, we don't need a semicolon.
393 bool printSemicolon = !(s.kids.Top is JumpLabel);
394 392
395 retstr += Indent(); 393 retstr += Indent();
396 394
397 foreach (SYMBOL kid in s.kids) 395 if (0 < s.kids.Count)
398 retstr += GenerateNode(kid); 396 {
397 // Jump label prints its own colon, we don't need a semicolon.
398 printSemicolon = !(s.kids.Top is JumpLabel);
399
400 foreach (SYMBOL kid in s.kids)
401 retstr += GenerateNode(kid);
402 }
399 403
400 if (printSemicolon) 404 if (printSemicolon)
401 retstr += GenerateLine(";"); 405 retstr += GenerateLine(";");
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
index e9b3886..9778245 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
@@ -359,7 +359,7 @@ public override int yynum { get { return 114; }}
359public StateChange(Parser yyp):base(yyp){}} 359public StateChange(Parser yyp):base(yyp){}}
360//%+IfStatement+115 360//%+IfStatement+115
361public class IfStatement : SYMBOL{ 361public class IfStatement : SYMBOL{
362 private void AddStatement ( Statement s ){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 362 private void AddStatement ( Statement s ){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
363 else kids . Add ( s ); 363 else kids . Add ( s );
364} 364}
365 public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax 365 public IfStatement (Parser yyp, Expression e , Statement ifs ):base(((LSLSyntax
@@ -369,7 +369,7 @@ public class IfStatement : SYMBOL{
369 public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax 369 public IfStatement (Parser yyp, Expression e , Statement ifs , Statement es ):base(((LSLSyntax
370)yyp)){ kids . Add ( e ); 370)yyp)){ kids . Add ( e );
371 AddStatement ( ifs ); 371 AddStatement ( ifs );
372 if ( es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ()); 372 if (0< es . kids . Count && es . kids . Top is IfStatement ) kids . Add ( es . kids . Pop ());
373 else AddStatement ( es ); 373 else AddStatement ( es );
374} 374}
375 375
@@ -380,7 +380,7 @@ public IfStatement(Parser yyp):base(yyp){}}
380public class WhileStatement : SYMBOL{ 380public class WhileStatement : SYMBOL{
381 public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax 381 public WhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax
382)yyp)){ kids . Add ( e ); 382)yyp)){ kids . Add ( e );
383 if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 383 if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
384 else kids . Add ( s ); 384 else kids . Add ( s );
385} 385}
386 386
@@ -390,7 +390,7 @@ public WhileStatement(Parser yyp):base(yyp){}}
390//%+DoWhileStatement+117 390//%+DoWhileStatement+117
391public class DoWhileStatement : SYMBOL{ 391public class DoWhileStatement : SYMBOL{
392 public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax 392 public DoWhileStatement (Parser yyp, Expression e , Statement s ):base(((LSLSyntax
393)yyp)){ if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 393)yyp)){ if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
394 else kids . Add ( s ); 394 else kids . Add ( s );
395 kids . Add ( e ); 395 kids . Add ( e );
396} 396}
@@ -404,7 +404,7 @@ public class ForLoop : SYMBOL{
404)yyp)){ kids . Add ( flsa ); 404)yyp)){ kids . Add ( flsa );
405 kids . Add ( e ); 405 kids . Add ( e );
406 kids . Add ( flsb ); 406 kids . Add ( flsb );
407 if ( s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ()); 407 if (0< s . kids . Count && s . kids . Top is CompoundStatement ) kids . Add ( s . kids . Pop ());
408 else kids . Add ( s ); 408 else kids . Add ( s );
409} 409}
410 410