diff options
Diffstat (limited to 'OpenSim/Tools/Compiler')
-rw-r--r-- | OpenSim/Tools/Compiler/Program.cs | 56 |
1 files changed, 40 insertions, 16 deletions
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 | } |