aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs56
-rw-r--r--OpenSim/Tools/Compiler/Program.cs56
2 files changed, 80 insertions, 32 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
index 0b41bc6..5988539 100644
--- a/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/CodeTools/Compiler.cs
@@ -724,13 +724,13 @@ namespace SecondLife
724 return assembly; 724 return assembly;
725 } 725 }
726 726
727 private class kvpSorter : IComparer<KeyValuePair<int, int>> 727 private class kvpSorter : IComparer<KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>>>
728 { 728 {
729 public int Compare(KeyValuePair<int, int> a, 729 public int Compare(KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> a,
730 KeyValuePair<int, int> b) 730 KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> b)
731 { 731 {
732 int kc = a.Key.CompareTo(b.Key); 732 int kc = a.Key.Key.CompareTo(b.Key.Key);
733 return (kc != 0) ? kc : a.Value.CompareTo(b.Value); 733 return (kc != 0) ? kc : a.Key.Value.CompareTo(b.Key.Value);
734 } 734 }
735 } 735 }
736 736
@@ -747,24 +747,48 @@ namespace SecondLife
747 out ret)) 747 out ret))
748 return ret; 748 return ret;
749 749
750 List<KeyValuePair<int, int>> sorted = 750 var sorted = new List<KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>>>(positionMap);
751 new List<KeyValuePair<int, int>>(positionMap.Keys);
752 751
753 sorted.Sort(new kvpSorter()); 752 sorted.Sort(new kvpSorter());
754 753
755 int l = sorted[0].Key; 754 int l = 1;
756 int c = sorted[0].Value; 755 int c = 1;
756 int pl = 1;
757 757
758 foreach (KeyValuePair<int, int> cspos in sorted) 758 foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> posmap in sorted)
759 { 759 {
760 if (cspos.Key >= line && 760 //m_log.DebugFormat("[Compiler]: Scanning line map {0},{1} --> {2},{3}", posmap.Key.Key, posmap.Key.Value, posmap.Value.Key, posmap.Value.Value);
761 !(cspos.Key == line && cspos.Value <= col)) 761 int nl = posmap.Value.Key + line - posmap.Key.Key; // New, translated LSL line and column.
762 int nc = posmap.Value.Value + col - posmap.Key.Value;
763 // Keep going until we find the first point passed line,col.
764 if (posmap.Key.Key > line)
765 {
766 //m_log.DebugFormat("[Compiler]: Line is larger than requested {0},{1}, returning {2},{3}", line, col, l, c);
767 if (pl < line)
768 {
769 //m_log.DebugFormat("[Compiler]: Previous line ({0}) is less than requested line ({1}), setting column to 1.", pl, line);
770 c = 1;
771 }
762 break; 772 break;
763 l = cspos.Key; 773 }
764 c = cspos.Value; 774 if (posmap.Key.Key == line && posmap.Key.Value > col)
775 {
776 // Never move l,c backwards.
777 if (nl > l || (nl == l && nc > c))
778 {
779 //m_log.DebugFormat("[Compiler]: Using offset relative to this: {0} + {1} - {2}, {3} + {4} - {5} = {6}, {7}",
780 // posmap.Value.Key, line, posmap.Key.Key, posmap.Value.Value, col, posmap.Key.Value, nl, nc);
781 l = nl;
782 c = nc;
783 }
784 //m_log.DebugFormat("[Compiler]: Column is larger than requested {0},{1}, returning {2},{3}", line, col, l, c);
785 break;
786 }
787 pl = posmap.Key.Key;
788 l = posmap.Value.Key;
789 c = posmap.Value.Value;
765 } 790 }
766 positionMap.TryGetValue(new KeyValuePair<int, int>(l, c), out ret); 791 return new KeyValuePair<int, int>(l, c);
767 return ret;
768 } 792 }
769 793
770 string ReplaceTypes(string message) 794 string ReplaceTypes(string message)
diff --git a/OpenSim/Tools/Compiler/Program.cs b/OpenSim/Tools/Compiler/Program.cs
index b9c960b..b010eaf 100644
--- a/OpenSim/Tools/Compiler/Program.cs
+++ b/OpenSim/Tools/Compiler/Program.cs
@@ -255,13 +255,13 @@ namespace OpenSim.Tools.LSL.Compiler
255 return FindErrorPosition(line, col, null); 255 return FindErrorPosition(line, col, null);
256 } 256 }
257 257
258 private class kvpSorter : IComparer<KeyValuePair<int, int>> 258 private class kvpSorter : IComparer<KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>>>
259 { 259 {
260 public int Compare(KeyValuePair<int, int> a, 260 public int Compare(KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> a,
261 KeyValuePair<int, int> b) 261 KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> b)
262 { 262 {
263 int kc = a.Key.CompareTo(b.Key); 263 int kc = a.Key.Key.CompareTo(b.Key.Key);
264 return (kc != 0) ? kc : a.Value.CompareTo(b.Value); 264 return (kc != 0) ? kc : a.Key.Value.CompareTo(b.Key.Value);
265 } 265 }
266 } 266 }
267 267
@@ -278,24 +278,48 @@ namespace OpenSim.Tools.LSL.Compiler
278 out ret)) 278 out ret))
279 return ret; 279 return ret;
280 280
281 List<KeyValuePair<int, int>> sorted = 281 var sorted = new List<KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>>>(positionMap);
282 new List<KeyValuePair<int, int>>(positionMap.Keys);
283 282
284 sorted.Sort(new kvpSorter()); 283 sorted.Sort(new kvpSorter());
285 284
286 int l = sorted[0].Key; 285 int l = 1;
287 int c = sorted[0].Value; 286 int c = 1;
287 int pl = 1;
288 288
289 foreach (KeyValuePair<int, int> cspos in sorted) 289 foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> posmap in sorted)
290 { 290 {
291 if (cspos.Key >= line && 291 //m_log.DebugFormat("[Compiler]: Scanning line map {0},{1} --> {2},{3}", posmap.Key.Key, posmap.Key.Value, posmap.Value.Key, posmap.Value.Value);
292 !(cspos.Key == line && cspos.Value <= col)) 292 int nl = posmap.Value.Key + line - posmap.Key.Key; // New, translated LSL line and column.
293 int nc = posmap.Value.Value + col - posmap.Key.Value;
294 // Keep going until we find the first point passed line,col.
295 if (posmap.Key.Key > line)
296 {
297 //m_log.DebugFormat("[Compiler]: Line is larger than requested {0},{1}, returning {2},{3}", line, col, l, c);
298 if (pl < line)
299 {
300 //m_log.DebugFormat("[Compiler]: Previous line ({0}) is less than requested line ({1}), setting column to 1.", pl, line);
301 c = 1;
302 }
293 break; 303 break;
294 l = cspos.Key; 304 }
295 c = cspos.Value; 305 if (posmap.Key.Key == line && posmap.Key.Value > col)
306 {
307 // Never move l,c backwards.
308 if (nl > l || (nl == l && nc > c))
309 {
310 //m_log.DebugFormat("[Compiler]: Using offset relative to this: {0} + {1} - {2}, {3} + {4} - {5} = {6}, {7}",
311 // posmap.Value.Key, line, posmap.Key.Key, posmap.Value.Value, col, posmap.Key.Value, nl, nc);
312 l = nl;
313 c = nc;
314 }
315 //m_log.DebugFormat("[Compiler]: Column is larger than requested {0},{1}, returning {2},{3}", line, col, l, c);
316 break;
317 }
318 pl = posmap.Key.Key;
319 l = posmap.Value.Key;
320 c = posmap.Value.Value;
296 } 321 }
297 positionMap.TryGetValue(new KeyValuePair<int, int>(l, c), out ret); 322 return new KeyValuePair<int, int>(l, c);
298 return ret;
299 } 323 }
300 } 324 }
301} 325}