LocalBuilder.cs 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. //
  2. // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
  3. //
  4. // Permission is hereby granted, free of charge, to any person obtaining
  5. // a copy of this software and associated documentation files (the
  6. // "Software"), to deal in the Software without restriction, including
  7. // without limitation the rights to use, copy, modify, merge, publish,
  8. // distribute, sublicense, and/or sell copies of the Software, and to
  9. // permit persons to whom the Software is furnished to do so, subject to
  10. // the following conditions:
  11. //
  12. // The above copyright notice and this permission notice shall be
  13. // included in all copies or substantial portions of the Software.
  14. //
  15. // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  16. // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  17. // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  18. // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  19. // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  20. // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  21. // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  22. //
  23. //
  24. // System.Reflection.Emit/LocalBuilder.cs
  25. //
  26. // Authors:
  27. // Paolo Molaro ([email protected])
  28. // Martin Baulig ([email protected])
  29. // Miguel de Icaza ([email protected])
  30. //
  31. // (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
  32. //
  33. using System;
  34. using System.Reflection;
  35. using System.Reflection.Emit;
  36. using System.Globalization;
  37. using System.Runtime.CompilerServices;
  38. using System.Runtime.InteropServices;
  39. using System.Diagnostics.SymbolStore;
  40. namespace System.Reflection.Emit {
  41. #if NET_2_0
  42. [ComVisible (true)]
  43. [ClassInterfaceAttribute (ClassInterfaceType.None)]
  44. [ComDefaultInterfaceAttribute (typeof (_LocalBuilder))]
  45. #endif
  46. #if NET_2_0
  47. public sealed class LocalBuilder : LocalVariableInfo {
  48. #else
  49. public sealed class LocalBuilder {
  50. #endif
  51. #if NET_2_0
  52. // Some fields are already defined in LocalVariableInfo
  53. #region Sync with reflection.h
  54. private string name;
  55. #endregion
  56. #else
  57. #region Sync with reflection.h
  58. private Type type;
  59. internal bool is_pinned;
  60. internal ushort position;
  61. private string name;
  62. #endregion
  63. #endif
  64. internal ILGenerator ilgen;
  65. int startOffset;
  66. int endOffset;
  67. internal LocalBuilder (Type t, ILGenerator ilgen)
  68. {
  69. this.type = t;
  70. this.ilgen = ilgen;
  71. }
  72. public void SetLocalSymInfo (string lname, int startOffset, int endOffset)
  73. {
  74. name = lname;
  75. this.startOffset = startOffset;
  76. this.endOffset = endOffset;
  77. }
  78. public void SetLocalSymInfo (string lname)
  79. {
  80. SetLocalSymInfo (lname, 0, 0);
  81. }
  82. #if NET_2_0
  83. override
  84. #endif
  85. public Type LocalType
  86. {
  87. get {
  88. return type;
  89. }
  90. }
  91. #if NET_2_0
  92. public override bool IsPinned
  93. {
  94. get {
  95. return is_pinned;
  96. }
  97. }
  98. public override int LocalIndex
  99. {
  100. get {
  101. return position;
  102. }
  103. }
  104. #endif
  105. internal string Name {
  106. get { return name; }
  107. }
  108. internal int StartOffset {
  109. get { return startOffset; }
  110. }
  111. internal int EndOffset {
  112. get { return endOffset; }
  113. }
  114. }
  115. }