The Labs \ Source Viewer \ SSCLI \ System.Reflection.Emit \ Label

  1. // ==++==
  2. //
  3. //
  4. // Copyright (c) 2006 Microsoft Corporation. All rights reserved.
  5. //
  6. // The use and distribution terms for this software are contained in the file
  7. // named license.txt, which can be found in the root of this distribution.
  8. // By using this software in any fashion, you are agreeing to be bound by the
  9. // terms of this license.
  10. //
  11. // You must not remove this notice, or any other, from this software.
  12. //
  13. //
  14. // ==--==
  15. /*============================================================
  16. **
  17. ** Class:  Label
  18. **
  19. ** 
  20. **
  21. ** Purpose: Represents a Label to the ILGenerator class.
  22. **
  23. **
  24. ===========================================================*/
  25. namespace System.Reflection.Emit
  26. {
  27.     using System;
  28.     using System.Reflection;
  29.     using System.Security.Permissions;
  30.     using System.Runtime.InteropServices;
  31.    
  32.     // The Label class is an opaque representation of a label used by the
  33.     // ILGenerator class. The token is used to mark where labels occur in the IL
  34.     // stream and then the necessary offsets are put back in the code when the ILGenerator
  35.     // is passed to the MethodWriter.
  36.     // Labels are created by using ILGenerator.CreateLabel and their position is set
  37.     // by using ILGenerator.MarkLabel.
  38.     [Serializable()]
  39.     [ComVisible(true)]
  40.     public struct Label
  41.     {
  42.        
  43.         internal int m_label;
  44.        
  45.         //public Label() {
  46.         // m_label=0;
  47.         //}
  48.        
  49.         internal Label(int label)
  50.         {
  51.             m_label = label;
  52.         }
  53.        
  54.         internal int GetLabelValue()
  55.         {
  56.             return m_label;
  57.         }
  58.        
  59.         public override int GetHashCode()
  60.         {
  61.             return m_label;
  62.         }
  63.        
  64.         public override bool Equals(object obj)
  65.         {
  66.             if (obj is Label)
  67.                 return Equals((Label)obj);
  68.             else
  69.                 return false;
  70.         }
  71.        
  72.         public bool Equals(Label obj)
  73.         {
  74.             return obj.m_label == m_label;
  75.         }
  76.        
  77.         public static bool operator ==(Label a, Label b)
  78.         {
  79.             return a.Equals(b);
  80.         }
  81.        
  82.         public static bool operator !=(Label a, Label b)
  83.         {
  84.             return !(a == b);
  85.         }
  86.     }
  87. }

Developer Fusion