2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / ilasm / codegen / LabelInfo.cs
1 //
2 // Mono.ILASM.LabelInfo
3 //
4 // Author(s):
5 //  Jackson Harper (Jackson@LatitudeGeo.com)
6 //
7 // (C) 2003 Jackson Harper, All rights reserved
8 //
9
10 using System;
11
12 namespace Mono.ILASM {
13
14         public class LabelInfo : IComparable {
15
16                 public readonly string Name;
17                 public readonly int Pos;
18                 public readonly uint Offset;
19                 public PEAPI.CILLabel Label;
20                 public bool UseOffset;
21
22                 public LabelInfo (string name, int pos, uint offset)
23                 {
24                         Name = name;
25                         Pos = pos;
26                         Offset = offset;
27                         Label = null;
28                         UseOffset = true;
29                 }
30
31                 public LabelInfo (string name, int pos)
32                 {
33                         Name = name;
34                         Pos = pos;
35                         Label = null;
36                         UseOffset = false;
37                 }
38
39                 public void Define (PEAPI.CILLabel label)
40                 {
41                         Label = label;
42                 }
43
44                 public int CompareTo (object obj)
45                 {
46                         LabelInfo other = obj as LabelInfo;
47
48                         if(other != null)
49                                 return Pos.CompareTo(other.Pos);
50
51                         throw new ArgumentException ("object is not a LabelInfo");
52                 }
53
54                 public override string ToString ()
55                 {
56                         if (Name != null)
57                                 return Name;
58                         return "IL_" + Pos;
59                 }
60         }
61
62 }
63