diff options
author | Aleric Inglewood | 2014-05-24 02:36:12 +0200 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2014-06-19 23:52:51 +0100 |
commit | 3fe9c7c49d9c39ad879c1175c01c8cacced56046 (patch) | |
tree | edd97dc031f64abedaf9a2edb2c06b5cc8a51a92 /OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |
parent | BulletSim: stop processing linkset child when it is discovered that the (diff) | |
download | opensim-SC_OLD-3fe9c7c49d9c39ad879c1175c01c8cacced56046.zip opensim-SC_OLD-3fe9c7c49d9c39ad879c1175c01c8cacced56046.tar.gz opensim-SC_OLD-3fe9c7c49d9c39ad879c1175c01c8cacced56046.tar.bz2 opensim-SC_OLD-3fe9c7c49d9c39ad879c1175c01c8cacced56046.tar.xz |
Fix looking up line number and colum when there is no exact match.
When a compile error reports a colum/error that is not an exact
match in the positionMap dictionary, the last position in the
map with a line number and position before the reported error
should be returned.
The old code had the following problems:
1) It returns l,c - which are line and column of the C# file, not LSL.
2) It doesn't set l to 'line' when the map has an entry with 'line'.
3) It sorts the map without taking columns into account, which may
result in a random order of the columns. With my mono implementation
the columns were reversed in order.
For example, if the map contains the following lines:
99,5,49,10
100,30,50,10
100,40,1,0
101,5,51,10
and a translation of 100,35 was requested,
then the old code would compare '100' with the keys in
the first column - setting l to that key while it is
smaller. Hence, l is set to 99.
Then it finds the key 100 and doesn't update l.
Because of the reversed sort order, it first compares
the column 35 with 40, finding that it is smaller
and therefore it stops; returning 99,1 instead of finding
the correct 100,30 entry and returning 50,10.
This patch causes 50,10 to be returned.
The remaining problems after this patch are:
1) The sorting might not be necessary at all.
2) The is code duplication (I fixed both instances,
but really there should be no code duplication
imho).
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | 29 |
1 files changed, 11 insertions, 18 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs index 1efe798..0b41bc6 100644 --- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs +++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs | |||
@@ -729,7 +729,8 @@ namespace SecondLife | |||
729 | public int Compare(KeyValuePair<int, int> a, | 729 | public int Compare(KeyValuePair<int, int> a, |
730 | KeyValuePair<int, int> b) | 730 | KeyValuePair<int, int> b) |
731 | { | 731 | { |
732 | return a.Key.CompareTo(b.Key); | 732 | int kc = a.Key.CompareTo(b.Key); |
733 | return (kc != 0) ? kc : a.Value.CompareTo(b.Value); | ||
733 | } | 734 | } |
734 | } | 735 | } |
735 | 736 | ||
@@ -751,27 +752,19 @@ namespace SecondLife | |||
751 | 752 | ||
752 | sorted.Sort(new kvpSorter()); | 753 | sorted.Sort(new kvpSorter()); |
753 | 754 | ||
754 | int l = 1; | 755 | int l = sorted[0].Key; |
755 | int c = 1; | 756 | int c = sorted[0].Value; |
756 | 757 | ||
757 | foreach (KeyValuePair<int, int> cspos in sorted) | 758 | foreach (KeyValuePair<int, int> cspos in sorted) |
758 | { | 759 | { |
759 | if (cspos.Key >= line) | 760 | if (cspos.Key >= line && |
760 | { | 761 | !(cspos.Key == line && cspos.Value <= col)) |
761 | if (cspos.Key > line) | 762 | break; |
762 | return new KeyValuePair<int, int>(l, c); | 763 | l = cspos.Key; |
763 | if (cspos.Value > col) | 764 | c = cspos.Value; |
764 | return new KeyValuePair<int, int>(l, c); | ||
765 | c = cspos.Value; | ||
766 | if (c == 0) | ||
767 | c++; | ||
768 | } | ||
769 | else | ||
770 | { | ||
771 | l = cspos.Key; | ||
772 | } | ||
773 | } | 765 | } |
774 | return new KeyValuePair<int, int>(l, c); | 766 | positionMap.TryGetValue(new KeyValuePair<int, int>(l, c), out ret); |
767 | return ret; | ||
775 | } | 768 | } |
776 | 769 | ||
777 | string ReplaceTypes(string message) | 770 | string ReplaceTypes(string message) |