~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to contrib/Mono.Cecil/Mono.CompilerServices.SymbolWriter/MonoSymbolTable.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
30
30
 
31
31
using System;
32
32
using System.Security.Cryptography;
33
 
using System.Collections;
 
33
using System.Collections.Generic;
34
34
using System.Text;
35
35
using System.IO;
36
36
 
179
179
                }
180
180
        }
181
181
 
182
 
        public struct LineNumberEntry
 
182
        public class LineNumberEntry
183
183
        {
184
184
                #region This is actually written to the symbol file
185
185
                public readonly int Row;
202
202
 
203
203
                public static LineNumberEntry Null = new LineNumberEntry (0, 0, 0);
204
204
 
205
 
                private class OffsetComparerClass : IComparer
 
205
                private class OffsetComparerClass : IComparer<LineNumberEntry>
206
206
                {
207
 
                        public int Compare (object a, object b)
 
207
                        public int Compare (LineNumberEntry l1, LineNumberEntry l2)
208
208
                        {
209
 
                                LineNumberEntry l1 = (LineNumberEntry) a;
210
 
                                LineNumberEntry l2 = (LineNumberEntry) b;
211
 
 
212
209
                                if (l1.Offset < l2.Offset)
213
210
                                        return -1;
214
211
                                else if (l1.Offset > l2.Offset)
218
215
                        }
219
216
                }
220
217
 
221
 
                private class RowComparerClass : IComparer
 
218
                private class RowComparerClass : IComparer<LineNumberEntry>
222
219
                {
223
 
                        public int Compare (object a, object b)
 
220
                        public int Compare (LineNumberEntry l1, LineNumberEntry l2)
224
221
                        {
225
 
                                LineNumberEntry l1 = (LineNumberEntry) a;
226
 
                                LineNumberEntry l2 = (LineNumberEntry) b;
227
 
 
228
222
                                if (l1.Row < l2.Row)
229
223
                                        return -1;
230
224
                                else if (l1.Row > l2.Row)
234
228
                        }
235
229
                }
236
230
 
237
 
                public static readonly IComparer OffsetComparer = new OffsetComparerClass ();
238
 
                public static readonly IComparer RowComparer = new RowComparerClass ();
 
231
                public static readonly IComparer<LineNumberEntry> OffsetComparer = new OffsetComparerClass ();
 
232
                public static readonly IComparer<LineNumberEntry> RowComparer = new RowComparerClass ();
239
233
 
240
234
                public override string ToString ()
241
235
                {
336
330
                public override string ToString ()
337
331
                {
338
332
                        return String.Format ("[LocalVariable {0}:{1}:{2}]",
339
 
                                              Name, Index, BlockIndex);
 
333
                                              Name, Index, BlockIndex - 1);
340
334
                }
341
335
        }
342
336
 
453
447
                public readonly int ID;
454
448
                #endregion
455
449
 
456
 
                ArrayList captured_vars = new ArrayList ();
457
 
                ArrayList captured_scopes = new ArrayList ();
 
450
                List<CapturedVariable> captured_vars = new List<CapturedVariable> ();
 
451
                List<CapturedScope> captured_scopes = new List<CapturedScope> ();
458
452
 
459
453
                public AnonymousScopeEntry (int id)
460
454
                {
529
523
 
530
524
                MonoSymbolFile file;
531
525
                SourceFileEntry source;
532
 
                ArrayList include_files;
533
 
                ArrayList namespaces;
 
526
                List<SourceFileEntry> include_files;
 
527
                List<NamespaceEntry> namespaces;
534
528
 
535
529
                bool creating;
536
530
 
550
544
                        this.Index = file.AddCompileUnit (this);
551
545
 
552
546
                        creating = true;
553
 
                        namespaces = new ArrayList ();
 
547
                        namespaces = new List<NamespaceEntry> ();
554
548
                }
555
549
 
556
550
                public void AddFile (SourceFileEntry file)
559
553
                                throw new InvalidOperationException ();
560
554
 
561
555
                        if (include_files == null)
562
 
                                include_files = new ArrayList ();
 
556
                                include_files = new List<SourceFileEntry> ();
563
557
 
564
558
                        include_files.Add (file);
565
559
                }
635
629
 
636
630
                                int count_includes = reader.ReadLeb128 ();
637
631
                                if (count_includes > 0) {
638
 
                                        include_files = new ArrayList ();
639
 
                                        for (int i = 0; i < count_includes; i++) {
640
 
                                                // FIXME: The debugger will need this later on.
641
 
                                                reader.ReadLeb128 ();
642
 
                                        }
 
632
                                        include_files = new List<SourceFileEntry> ();
 
633
                                        for (int i = 0; i < count_includes; i++)
 
634
                                                include_files.Add (file.GetSourceFile (reader.ReadLeb128 ()));
643
635
                                }
644
636
 
645
637
                                int count_ns = reader.ReadLeb128 ();
646
 
                                namespaces = new ArrayList ();
 
638
                                namespaces = new List<NamespaceEntry> ();
647
639
                                for (int i = 0; i < count_ns; i ++)
648
640
                                        namespaces.Add (new NamespaceEntry (file, reader));
649
641
 
659
651
                                return retval;
660
652
                        }
661
653
                }
 
654
 
 
655
                public SourceFileEntry[] IncludeFiles {
 
656
                        get {
 
657
                                ReadData ();
 
658
                                if (include_files == null)
 
659
                                        return new SourceFileEntry [0];
 
660
 
 
661
                                SourceFileEntry[] retval = new SourceFileEntry [include_files.Count];
 
662
                                include_files.CopyTo (retval, 0);
 
663
                                return retval;
 
664
                        }
 
665
                }
662
666
        }
663
667
 
664
668
        public class SourceFileEntry
812
816
                // MONO extensions.
813
817
                public const byte DW_LNE_MONO_negate_is_hidden = 0x40;
814
818
 
 
819
                internal const byte DW_LNE_MONO__extensions_start = 0x40;
 
820
                internal const byte DW_LNE_MONO__extensions_end   = 0x7f;
 
821
 
815
822
                protected LineNumberTable (MonoSymbolFile file)
816
823
                {
817
824
                        this.LineBase = file.OffsetTable.LineNumberTable_LineBase;
900
907
 
901
908
                void DoRead (MonoSymbolFile file, MyBinaryReader br)
902
909
                {
903
 
                        ArrayList lines = new ArrayList ();
 
910
                        var lines = new List<LineNumberEntry> ();
904
911
 
905
912
                        bool is_hidden = false, modified = false;
906
913
                        int stm_line = 1, stm_offset = 0, stm_file = 1;
920
927
                                        } else if (opcode == DW_LNE_MONO_negate_is_hidden) {
921
928
                                                is_hidden = !is_hidden;
922
929
                                                modified = true;
923
 
                                        } else
 
930
                                        } else if ((opcode >= DW_LNE_MONO__extensions_start) &&
 
931
                                                   (opcode <= DW_LNE_MONO__extensions_end)) {
 
932
                                                ; // reserved for future extensions
 
933
                                        } else {
924
934
                                                throw new MonoSymbolFileException (
925
935
                                                        "Unknown extended opcode {0:x} in LNT ({1})",
926
936
                                                        opcode, file.FileName);
 
937
                                        }
927
938
 
928
939
                                        br.BaseStream.Position = end_pos;
929
940
                                        continue;
1101
1112
                        locals_check_done :
1102
1113
                                ;
1103
1114
                        } else {
1104
 
                                Hashtable local_names = new Hashtable ();
 
1115
                                var local_names = new Dictionary<string, LocalVariableEntry> ();
1105
1116
                                foreach (LocalVariableEntry local in locals) {
1106
 
                                        if (local_names.Contains (local.Name)) {
 
1117
                                        if (local_names.ContainsKey (local.Name)) {
1107
1118
                                                flags |= Flags.LocalNamesAmbiguous;
1108
1119
                                                break;
1109
1120
                                        }