LocalBuilder.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // System.Reflection.Emit/LocalBuilder.cs
  3. //
  4. // Authors:
  5. // Paolo Molaro ([email protected])
  6. // Martin Baulig ([email protected])
  7. // Miguel de Icaza ([email protected])
  8. //
  9. // (C) 2001, 2002 Ximian, Inc. http://www.ximian.com
  10. //
  11. using System;
  12. using System.Reflection;
  13. using System.Reflection.Emit;
  14. using System.Globalization;
  15. using System.Runtime.CompilerServices;
  16. using System.Diagnostics.SymbolStore;
  17. namespace System.Reflection.Emit {
  18. public sealed class LocalBuilder {
  19. //
  20. // These are kept in sync with reflection.h
  21. //
  22. #region Sync with reflection.h
  23. private Type type;
  24. private string name;
  25. #endregion
  26. //
  27. // Order does not matter after here
  28. //
  29. private ModuleBuilder module;
  30. internal uint position;
  31. internal ILGenerator ilgen;
  32. internal LocalBuilder (ModuleBuilder m, Type t, ILGenerator ilgen)
  33. {
  34. this.module = m;
  35. this.type = t;
  36. this.ilgen = ilgen;
  37. }
  38. public void SetLocalSymInfo (string lname, int startOffset, int endOffset)
  39. {
  40. this.name = lname;
  41. SignatureHelper sighelper = SignatureHelper.GetLocalVarSigHelper (module);
  42. sighelper.AddArgument (type);
  43. byte[] signature = sighelper.GetSignature ();
  44. module.symbol_writer.DefineLocalVariable (lname, FieldAttributes.Private,
  45. signature, SymAddressKind.ILOffset,
  46. (int) position, 0, 0,
  47. startOffset, endOffset);
  48. }
  49. public void SetLocalSymInfo (string lname)
  50. {
  51. SetLocalSymInfo (lname, 0, 0);
  52. }
  53. public Type LocalType
  54. {
  55. get {
  56. return type;
  57. }
  58. }
  59. }
  60. }