diff options
Diffstat (limited to 'OpenSim')
-rw-r--r-- | OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs | 107 |
1 files changed, 95 insertions, 12 deletions
diff --git a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs index e0b7f5d..0a79f1a 100644 --- a/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs +++ b/OpenSim/Region/ScriptEngine/YEngine/MMRScriptTokenize.cs | |||
@@ -1403,8 +1403,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1403 | } | 1403 | } |
1404 | public class TokenKwCmpLE: TokenKw | 1404 | public class TokenKwCmpLE: TokenKw |
1405 | { | 1405 | { |
1406 | public TokenKwCmpLE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1406 | public TokenKwCmpLE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1407 | public TokenKwCmpLE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1407 | public TokenKwCmpLE(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1408 | public override string ToString() | 1408 | public override string ToString() |
1409 | { | 1409 | { |
1410 | return "<="; | 1410 | return "<="; |
@@ -1412,8 +1412,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1412 | } | 1412 | } |
1413 | public class TokenKwCmpGE: TokenKw | 1413 | public class TokenKwCmpGE: TokenKw |
1414 | { | 1414 | { |
1415 | public TokenKwCmpGE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1415 | public TokenKwCmpGE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsGE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1416 | public TokenKwCmpGE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1416 | public TokenKwCmpGE(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsGE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1417 | public override string ToString() | 1417 | public override string ToString() |
1418 | { | 1418 | { |
1419 | return ">="; | 1419 | return ">="; |
@@ -1421,8 +1421,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1421 | } | 1421 | } |
1422 | public class TokenKwCmpEQ: TokenKw | 1422 | public class TokenKwCmpEQ: TokenKw |
1423 | { | 1423 | { |
1424 | public TokenKwCmpEQ(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1424 | public TokenKwCmpEQ(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsEQ; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1425 | public TokenKwCmpEQ(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1425 | public TokenKwCmpEQ(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsEQ; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1426 | public override string ToString() | 1426 | public override string ToString() |
1427 | { | 1427 | { |
1428 | return "=="; | 1428 | return "=="; |
@@ -1430,8 +1430,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1430 | } | 1430 | } |
1431 | public class TokenKwCmpNE: TokenKw | 1431 | public class TokenKwCmpNE: TokenKw |
1432 | { | 1432 | { |
1433 | public TokenKwCmpNE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1433 | public TokenKwCmpNE(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsNE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1434 | public TokenKwCmpNE(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1434 | public TokenKwCmpNE(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsNE; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1435 | public override string ToString() | 1435 | public override string ToString() |
1436 | { | 1436 | { |
1437 | return "!="; | 1437 | return "!="; |
@@ -1727,8 +1727,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1727 | } | 1727 | } |
1728 | public class TokenKwCmpLT: TokenKw | 1728 | public class TokenKwCmpLT: TokenKw |
1729 | { | 1729 | { |
1730 | public TokenKwCmpLT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1730 | public TokenKwCmpLT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsLT; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1731 | public TokenKwCmpLT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1731 | public TokenKwCmpLT(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsLT; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1732 | public override string ToString() | 1732 | public override string ToString() |
1733 | { | 1733 | { |
1734 | return "<"; | 1734 | return "<"; |
@@ -1736,8 +1736,8 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
1736 | } | 1736 | } |
1737 | public class TokenKwCmpGT: TokenKw | 1737 | public class TokenKwCmpGT: TokenKw |
1738 | { | 1738 | { |
1739 | public TokenKwCmpGT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1739 | public TokenKwCmpGT(TokenErrorMessage emsg, string file, int line, int posn) : base(emsg, file, line, posn) { binOpConst = TokenRValConstOps.binConstsGT; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1740 | public TokenKwCmpGT(Token original) : base(original) { binOpConst = TokenRValConstOps.Null; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } | 1740 | public TokenKwCmpGT(Token original) : base(original) { binOpConst = TokenRValConstOps.binConstsGT; unOpConst = TokenRValConstOps.Null; sdtClassOp = true; } |
1741 | public override string ToString() | 1741 | public override string ToString() |
1742 | { | 1742 | { |
1743 | return ">"; | 1743 | return ">"; |
@@ -2487,6 +2487,89 @@ namespace OpenSim.Region.ScriptEngine.Yengine | |||
2487 | } | 2487 | } |
2488 | return null; | 2488 | return null; |
2489 | } | 2489 | } |
2490 | |||
2491 | public static int binConstCompare(object left, object right) | ||
2492 | { | ||
2493 | double a; | ||
2494 | if (left is bool lb) | ||
2495 | a = lb ? 1.0 : 0.0; | ||
2496 | else if (left is int li) | ||
2497 | a = li; | ||
2498 | else if (left is float lf) | ||
2499 | a = lf; | ||
2500 | else if (left is double ld) | ||
2501 | a = ld; | ||
2502 | else if(left is string ls) | ||
2503 | { | ||
2504 | if(!(right is string rs)) | ||
2505 | return -2; | ||
2506 | return ls.CompareTo(rs); | ||
2507 | } | ||
2508 | else | ||
2509 | return -2; | ||
2510 | |||
2511 | double b; | ||
2512 | if (right is bool rb) | ||
2513 | b = rb ? 1.0 : 0.0; | ||
2514 | else if (right is int ri) | ||
2515 | b = ri; | ||
2516 | else if (right is float rf) | ||
2517 | b = rf; | ||
2518 | else if (right is double rd) | ||
2519 | b = rd; | ||
2520 | else | ||
2521 | return -2; | ||
2522 | |||
2523 | return a.CompareTo(b); | ||
2524 | } | ||
2525 | |||
2526 | public static object binConstsLT(object left, object right) | ||
2527 | { | ||
2528 | int res = binConstCompare(left, right); | ||
2529 | if (res == -2) | ||
2530 | return null; | ||
2531 | return (res < 0) ? 1 : 0; | ||
2532 | } | ||
2533 | |||
2534 | public static object binConstsLE(object left, object right) | ||
2535 | { | ||
2536 | int res = binConstCompare(left, right); | ||
2537 | if (res == -2) | ||
2538 | return null; | ||
2539 | return (res <= 0) ? 1 : 0; | ||
2540 | } | ||
2541 | |||
2542 | public static object binConstsGT(object left, object right) | ||
2543 | { | ||
2544 | int res = binConstCompare(left, right); | ||
2545 | if (res == -2) | ||
2546 | return null; | ||
2547 | return (res > 0) ? 1 : 0; | ||
2548 | } | ||
2549 | |||
2550 | public static object binConstsGE(object left, object right) | ||
2551 | { | ||
2552 | int res = binConstCompare(left, right); | ||
2553 | if (res == -2) | ||
2554 | return null; | ||
2555 | return (res >= 0) ? 1 : 0; | ||
2556 | } | ||
2557 | |||
2558 | public static object binConstsEQ(object left, object right) | ||
2559 | { | ||
2560 | int res = binConstCompare(left, right); | ||
2561 | if (res == -2) | ||
2562 | return null; | ||
2563 | return (res == 0) ? 1 : 0; | ||
2564 | } | ||
2565 | |||
2566 | public static object binConstsNE(object left, object right) | ||
2567 | { | ||
2568 | int res = binConstCompare(left, right); | ||
2569 | if (res == -2) | ||
2570 | return null; | ||
2571 | return (res != 0) ? 1 : 0; | ||
2572 | } | ||
2490 | } | 2573 | } |
2491 | 2574 | ||
2492 | /* | 2575 | /* |