aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs17
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs2
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs28
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs27
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs43
5 files changed, 32 insertions, 85 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
index febc5e1..5a98f4d 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/CSCodeGenerator.cs
@@ -726,19 +726,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
726 if ("LSL_Types.LSLFloat" == c.Type) 726 if ("LSL_Types.LSLFloat" == c.Type)
727 { 727 {
728 int dotIndex = c.Value.IndexOf('.') + 1; 728 int dotIndex = c.Value.IndexOf('.') + 1;
729 // Skip first dot (in type name)
730 dotIndex = c.Value.IndexOf('.', dotIndex) + 1;
731 if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex]))) 729 if (0 < dotIndex && (dotIndex == c.Value.Length || !Char.IsDigit(c.Value[dotIndex])))
732 c.Value = c.Value.Insert(dotIndex, "0"); 730 c.Value = c.Value.Insert(dotIndex, "0");
731 c.Value = "new LSL_Types.LSLFloat("+c.Value+")";
732 }
733 else if("LSL_Types.LSLInteger" == c.Type)
734 {
735 c.Value = "new LSL_Types.LSLInteger("+c.Value+")";
736 }
737 else if("LSL_Types.LSLString" == c.Type)
738 {
739 c.Value = "new LSL_Types.LSLString(\""+c.Value+"\")";
733 } 740 }
734 741
735 // commented because the parser does it now
736 // need to quote strings
737 // if ("LSL_Types.LSLString" == c.Type)
738 // retstr += Generate("\"");
739 retstr += Generate(c.Value, c); 742 retstr += Generate(c.Value, c);
740 // if ("LSL_Types.LSLString" == c.Type)
741 // retstr += Generate("\"");
742 743
743 return retstr; 744 return retstr;
744 } 745 }
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs
index d472ec8..a44b545 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/LSL2CSCodeTransformer.cs
@@ -153,7 +153,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
153 return new Constant(p, constantType, "0.0"); 153 return new Constant(p, constantType, "0.0");
154 case "string": 154 case "string":
155 case "key": 155 case "key":
156 return new Constant(p, constantType, "\"\""); 156 return new Constant(p, constantType, "");
157 case "list": 157 case "list":
158 ArgumentList al = new ArgumentList(p); 158 ArgumentList al = new ArgumentList(p);
159 return new ListConstant(p, al); 159 return new ListConstant(p, al);
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
index fefcada..4e2766c 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Tests/CSCodeGeneratorTest.cs
@@ -124,7 +124,7 @@ state another_state
124 string expected = 124 string expected =
125 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 125 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
126 "\n {" + 126 "\n {" +
127 "\n LSL_Types.LSLInteger x = 0;" + 127 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
128 "\n }\n"; 128 "\n }\n";
129 129
130 CSCodeGenerator cg = new CSCodeGenerator(); 130 CSCodeGenerator cg = new CSCodeGenerator();
@@ -148,7 +148,7 @@ state another_state
148 string expected = 148 string expected =
149 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 149 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
150 "\n {" + 150 "\n {" +
151 "\n LSL_Types.LSLString y = \"\";" + 151 "\n LSL_Types.LSLString y = new LSL_Types.LSLString(\"\");" +
152 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14);" + 152 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(14);" +
153 "\n y = new LSL_Types.LSLString(\"Hello\");" + 153 "\n y = new LSL_Types.LSLString(\"Hello\");" +
154 "\n }\n"; 154 "\n }\n";
@@ -235,7 +235,7 @@ state another_state
235 string expected = 235 string expected =
236 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 236 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
237 "\n {" + 237 "\n {" +
238 "\n LSL_Types.LSLInteger y = 0;" + 238 "\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);" + 239 "\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);" + 240 "\n y = new LSL_Types.LSLInteger(12) - new LSL_Types.LSLInteger(3);" +
241 "\n y = new LSL_Types.LSLInteger(12) * new LSL_Types.LSLInteger(3);" + 241 "\n y = new LSL_Types.LSLInteger(12) * new LSL_Types.LSLInteger(3);" +
@@ -440,7 +440,7 @@ default
440} 440}
441"; 441";
442 string expected = 442 string expected =
443 "\n LSL_Types.LSLString globalString = \"\";" + 443 "\n LSL_Types.LSLString globalString = new LSL_Types.LSLString(\"\");" +
444 "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" + 444 "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" +
445 "\n LSL_Types.LSLInteger anotherGlobal = new LSL_Types.LSLInteger(20) * globalInt;" + 445 "\n LSL_Types.LSLInteger anotherGlobal = new LSL_Types.LSLInteger(20) * globalInt;" +
446 "\n LSL_Types.LSLString onefunc()" + 446 "\n LSL_Types.LSLString onefunc()" +
@@ -495,7 +495,7 @@ default
495} 495}
496"; 496";
497 string expected = 497 string expected =
498 "\n LSL_Types.LSLString globalString = \"\";" + 498 "\n LSL_Types.LSLString globalString = new LSL_Types.LSLString(\"\");" +
499 "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" + 499 "\n LSL_Types.LSLInteger globalInt = new LSL_Types.LSLInteger(14);" +
500 "\n LSL_Types.LSLString onefunc(LSL_Types.LSLString addition)" + 500 "\n LSL_Types.LSLString onefunc(LSL_Types.LSLString addition)" +
501 "\n {" + 501 "\n {" +
@@ -1251,19 +1251,19 @@ default
1251 string expected = 1251 string expected =
1252 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 1252 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
1253 "\n {" + 1253 "\n {" +
1254 "\n LSL_Types.LSLInteger i = 0;" + 1254 "\n LSL_Types.LSLInteger i = new LSL_Types.LSLInteger(0);" +
1255 "\n LSL_Types.LSLInteger j = new LSL_Types.LSLInteger(14);" + 1255 "\n LSL_Types.LSLInteger j = new LSL_Types.LSLInteger(14);" +
1256 "\n LSL_Types.LSLFloat f = 0.0;" + 1256 "\n LSL_Types.LSLFloat f = new LSL_Types.LSLFloat(0.0);" +
1257 "\n LSL_Types.LSLFloat g = new LSL_Types.LSLFloat(14.0);" + 1257 "\n LSL_Types.LSLFloat g = new LSL_Types.LSLFloat(14.0);" +
1258 "\n LSL_Types.LSLString s = \"\";" + 1258 "\n LSL_Types.LSLString s = new LSL_Types.LSLString(\"\");" +
1259 "\n LSL_Types.LSLString t = new LSL_Types.LSLString(\"Hi there\");" + 1259 "\n LSL_Types.LSLString t = new LSL_Types.LSLString(\"Hi there\");" +
1260 "\n LSL_Types.list l = new LSL_Types.list();" + 1260 "\n LSL_Types.list l = new LSL_Types.list();" +
1261 "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3));" + 1261 "\n LSL_Types.list m = new LSL_Types.list(new LSL_Types.LSLInteger(1), new LSL_Types.LSLInteger(2), new LSL_Types.LSLInteger(3));" +
1262 "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(0.0, 0.0, 0.0);" + 1262 "\n LSL_Types.Vector3 v = new LSL_Types.Vector3(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" +
1263 "\n LSL_Types.Vector3 w = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.5));" + 1263 "\n LSL_Types.Vector3 w = new LSL_Types.Vector3(new LSL_Types.LSLFloat(1.0), new LSL_Types.LSLFloat(0.1), new LSL_Types.LSLFloat(0.5));" +
1264 "\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(0.0, 0.0, 0.0, 0.0);" + 1264 "\n LSL_Types.Quaternion r = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0), new LSL_Types.LSLFloat(0.0));" +
1265 "\n LSL_Types.Quaternion u = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.8), new LSL_Types.LSLFloat(0.7), new LSL_Types.LSLFloat(0.6), llSomeFunc());" + 1265 "\n LSL_Types.Quaternion u = new LSL_Types.Quaternion(new LSL_Types.LSLFloat(0.8), new LSL_Types.LSLFloat(0.7), new LSL_Types.LSLFloat(0.6), llSomeFunc());" +
1266 "\n LSL_Types.LSLString k = \"\";" + 1266 "\n LSL_Types.LSLString k = new LSL_Types.LSLString(\"\");" +
1267 "\n LSL_Types.LSLString n = new LSL_Types.LSLString(\"ping\");" + 1267 "\n LSL_Types.LSLString n = new LSL_Types.LSLString(\"ping\");" +
1268 "\n }\n"; 1268 "\n }\n";
1269 1269
@@ -1292,8 +1292,8 @@ default
1292 string expected = 1292 string expected =
1293 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" + 1293 "\n public void default_event_touch_start(LSL_Types.LSLInteger num_detected)" +
1294 "\n {" + 1294 "\n {" +
1295 "\n LSL_Types.LSLInteger x = 0;" + 1295 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
1296 "\n LSL_Types.LSLInteger y = 0;" + 1296 "\n LSL_Types.LSLInteger y = new LSL_Types.LSLInteger(0);" +
1297 "\n x = y = new LSL_Types.LSLInteger(5);" + 1297 "\n x = y = new LSL_Types.LSLInteger(5);" +
1298 "\n x += y -= new LSL_Types.LSLInteger(5);" + 1298 "\n x += y -= new LSL_Types.LSLInteger(5);" +
1299 "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x) + new LSL_Types.LSLString(\", y is: \") + (LSL_Types.LSLString) (y));" + 1299 "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x) + new LSL_Types.LSLString(\", y is: \") + (LSL_Types.LSLString) (y));" +
@@ -1504,7 +1504,7 @@ default
1504 string expected = 1504 string expected =
1505 "\n public void default_event_state_entry()" + 1505 "\n public void default_event_state_entry()" +
1506 "\n {" + 1506 "\n {" +
1507 "\n LSL_Types.LSLInteger x = 0;" + 1507 "\n LSL_Types.LSLInteger x = new LSL_Types.LSLInteger(0);" +
1508 "\n while (x = new LSL_Types.LSLInteger(14))" + 1508 "\n while (x = new LSL_Types.LSLInteger(14))" +
1509 "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x));" + 1509 "\n llOwnerSay(new LSL_Types.LSLString(\"x is: \") + (LSL_Types.LSLString) (x));" +
1510 "\n if (x = new LSL_Types.LSLInteger(24))" + 1510 "\n if (x = new LSL_Types.LSLInteger(24))" +
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs
index 2f244a6..0f810e5 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.lexer.cs
@@ -1,30 +1,3 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;using Tools; 1using System;using Tools;
29namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { 2namespace OpenSim.Region.ScriptEngine.Shared.CodeTools {
30//%+STRING_CONSTANT+3 3//%+STRING_CONSTANT+3
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
index 2f9a829..bfc1afc 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/lsl.parser.cs
@@ -1,30 +1,3 @@
1/*
2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission.
15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28using System;using Tools; 1using System;using Tools;
29namespace OpenSim.Region.ScriptEngine.Shared.CodeTools { 2namespace OpenSim.Region.ScriptEngine.Shared.CodeTools {
30//%+LSLProgramRoot+95 3//%+LSLProgramRoot+95
@@ -1304,24 +1277,24 @@ public class ReturnStatement_2 : ReturnStatement {
1304 public ReturnStatement_2(Parser yyq):base(yyq){}} 1277 public ReturnStatement_2(Parser yyq):base(yyq){}}
1305 1278
1306public class Constant_1 : Constant { 1279public class Constant_1 : Constant {
1307 public Constant_1(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ 1280 public Constant_1(Parser yyq):base(yyq,"integer",
1308 ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) 1281 ((INTEGER_CONSTANT)(yyq.StackAt(0).m_value))
1309 .yytext+")"){}} 1282 .yytext){}}
1310 1283
1311public class Constant_2 : Constant { 1284public class Constant_2 : Constant {
1312 public Constant_2(Parser yyq):base(yyq,"integer", "new LSL_Types.LSLInteger("+ 1285 public Constant_2(Parser yyq):base(yyq,"integer",
1313 ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value)) 1286 ((HEX_INTEGER_CONSTANT)(yyq.StackAt(0).m_value))
1314 .yytext+")"){}} 1287 .yytext){}}
1315 1288
1316public class Constant_3 : Constant { 1289public class Constant_3 : Constant {
1317 public Constant_3(Parser yyq):base(yyq,"float", "new LSL_Types.LSLFloat("+ 1290 public Constant_3(Parser yyq):base(yyq,"float",
1318 ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value)) 1291 ((FLOAT_CONSTANT)(yyq.StackAt(0).m_value))
1319 .yytext+")"){}} 1292 .yytext){}}
1320 1293
1321public class Constant_4 : Constant { 1294public class Constant_4 : Constant {
1322 public Constant_4(Parser yyq):base(yyq,"string", "new LSL_Types.LSLString(\""+ 1295 public Constant_4(Parser yyq):base(yyq,"string",
1323 ((STRING_CONSTANT)(yyq.StackAt(0).m_value)) 1296 ((STRING_CONSTANT)(yyq.StackAt(0).m_value))
1324 .yytext+"\")"){}} 1297 .yytext){}}
1325 1298
1326public class ListConstant_1 : ListConstant { 1299public class ListConstant_1 : ListConstant {
1327 public ListConstant_1(Parser yyq):base(yyq, 1300 public ListConstant_1(Parser yyq):base(yyq,