Thanks Mike for another LSL compiler patch which fixes a bug where 'vector v=<0, 0, -0.5>' caused a syntax error, and implements multiple assignments in one line (x = y = 3;)
parent
cda5269391
commit
130d8047a2
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -1301,6 +1301,64 @@ default
|
||||||
Assert.AreEqual(expected, output);
|
Assert.AreEqual(expected, output);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestMultipleEqualsExpression()
|
||||||
|
{
|
||||||
|
string input = @"// let's test x = y = 5 type expressions
|
||||||
|
|
||||||
|
default
|
||||||
|
{
|
||||||
|
touch_start(integer num_detected)
|
||||||
|
{
|
||||||
|
integer x;
|
||||||
|
integer y;
|
||||||
|
x = y = 5;
|
||||||
|
x += y -= 5;
|
||||||
|
llOwnerSay(""x is: "" + (string) x + "", y is: "" + (string) y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
";
|
||||||
|
string expected = @"
|
||||||
|
public void default_event_touch_start(LSL_Types.LSLInteger num_detected)
|
||||||
|
{
|
||||||
|
LSL_Types.LSLInteger x = 0;
|
||||||
|
LSL_Types.LSLInteger y = 0;
|
||||||
|
x = y = 5;
|
||||||
|
x += y -= 5;
|
||||||
|
llOwnerSay(""x is: "" + (LSL_Types.LSLString) (x) + "", y is: "" + (LSL_Types.LSLString) (y));
|
||||||
|
}
|
||||||
|
";
|
||||||
|
|
||||||
|
CSCodeGenerator cg = new CSCodeGenerator(input);
|
||||||
|
string output = cg.Generate();
|
||||||
|
Assert.AreEqual(expected, output);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUnaryExpressionLastInVectorConstant()
|
||||||
|
{
|
||||||
|
string input = @"// let's test unary expressions some more
|
||||||
|
|
||||||
|
default
|
||||||
|
{
|
||||||
|
state_entry()
|
||||||
|
{
|
||||||
|
vector v = <x,y,-0.5>;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
";
|
||||||
|
string expected = @"
|
||||||
|
public void default_event_state_entry()
|
||||||
|
{
|
||||||
|
LSL_Types.Vector3 v = new LSL_Types.Vector3(x, y, -0.5);
|
||||||
|
}
|
||||||
|
";
|
||||||
|
|
||||||
|
CSCodeGenerator cg = new CSCodeGenerator(input);
|
||||||
|
string output = cg.Generate();
|
||||||
|
Assert.AreEqual(expected, output);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
[ExpectedException("Tools.CSToolsException")]
|
[ExpectedException("Tools.CSToolsException")]
|
||||||
public void TestSyntaxError()
|
public void TestSyntaxError()
|
||||||
|
@ -1316,7 +1374,7 @@ default
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
CSCodeGenerator cg = new CSCodeGenerator(input);
|
CSCodeGenerator cg = new CSCodeGenerator(input);
|
||||||
string output = cg.Generate();
|
cg.Generate();
|
||||||
}
|
}
|
||||||
catch (Tools.CSToolsException e)
|
catch (Tools.CSToolsException e)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue