SignatureHelper.cs 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. //
  2. // System.Reflection.Emit/SignatureHelper.cs
  3. //
  4. // Author:
  5. // Paolo Molaro ([email protected])
  6. //
  7. // (C) 2001 Ximian, Inc. http://www.ximian.com
  8. //
  9. using System;
  10. using System.Reflection;
  11. using System.Reflection.Emit;
  12. using System.Globalization;
  13. using System.Runtime.CompilerServices;
  14. using System.Runtime.InteropServices;
  15. namespace System.Reflection.Emit {
  16. [Serializable]
  17. public sealed class SignatureHelper {
  18. internal enum SignatureHelperType {
  19. HELPER_FIELD,
  20. HELPER_LOCAL,
  21. HELPER_METHOD,
  22. HELPER_PROPERTY
  23. }
  24. private ModuleBuilder module;
  25. private Type[] arguments;
  26. private SignatureHelperType type;
  27. internal SignatureHelper (ModuleBuilder module, SignatureHelperType type)
  28. {
  29. this.type = type;
  30. this.module = module;
  31. }
  32. public static SignatureHelper GetFieldSigHelper (Module mod)
  33. {
  34. if (!(mod is ModuleBuilder))
  35. throw new NotImplementedException ();
  36. return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_FIELD);
  37. }
  38. public static SignatureHelper GetLocalVarSigHelper (Module mod)
  39. {
  40. if (!(mod is ModuleBuilder))
  41. throw new NotImplementedException ();
  42. return new SignatureHelper ((ModuleBuilder) mod, SignatureHelperType.HELPER_LOCAL);
  43. }
  44. [MonoTODO]
  45. public static SignatureHelper GetMethodSigHelper( Module mod, CallingConventions callingConvention, Type returnType)
  46. {
  47. throw new NotImplementedException ();
  48. }
  49. [MonoTODO]
  50. public static SignatureHelper GetMethodSigHelper( Module mod, Type returnType, Type[] parameterTypes)
  51. {
  52. throw new NotImplementedException ();
  53. }
  54. [MonoTODO]
  55. public static SignatureHelper GetPropertySigHelper( Module mod, Type returnType, Type[] parameterTypes)
  56. {
  57. throw new NotImplementedException ();
  58. }
  59. public void AddArgument (Type clsArgument)
  60. {
  61. if (arguments != null) {
  62. Type[] new_a = new Type [arguments.Length + 1];
  63. System.Array.Copy (arguments, new_a, arguments.Length);
  64. new_a [arguments.Length] = clsArgument;
  65. arguments = new_a;
  66. } else {
  67. arguments = new Type [1];
  68. arguments [0] = clsArgument;
  69. }
  70. }
  71. [MonoTODO]
  72. public void AddSentinel ()
  73. {
  74. throw new NotImplementedException ();
  75. }
  76. [MonoTODO]
  77. public override bool Equals (object obj)
  78. {
  79. throw new NotImplementedException ();
  80. }
  81. [MonoTODO]
  82. public override int GetHashCode ()
  83. {
  84. throw new NotImplementedException ();
  85. }
  86. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  87. internal extern byte[] get_signature_local ();
  88. [MethodImplAttribute(MethodImplOptions.InternalCall)]
  89. internal extern byte[] get_signature_field ();
  90. public byte[] GetSignature ()
  91. {
  92. switch (type) {
  93. case SignatureHelperType.HELPER_LOCAL:
  94. return get_signature_local ();
  95. case SignatureHelperType.HELPER_FIELD:
  96. return get_signature_field ();
  97. default:
  98. throw new NotImplementedException ();
  99. }
  100. }
  101. public override string ToString() {
  102. return "SignatureHelper";
  103. }
  104. }
  105. }