LocalBuilder.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 LocalBuilder (ModuleBuilder m, Type t)
  32. {
  33. this.module = m;
  34. this.type = t;
  35. }
  36. public void SetLocalSymInfo (string lname, int startOffset, int endOffset)
  37. {
  38. ISymbolWriter symbol_writer = module.GetSymWriter ();
  39. name = lname;
  40. if (symbol_writer == null)
  41. return;
  42. SignatureHelper sig_helper = SignatureHelper.GetLocalVarSigHelper (module);
  43. sig_helper.AddArgument (type);
  44. byte[] signature = sig_helper.GetSignature ();
  45. symbol_writer.DefineLocalVariable (name, FieldAttributes.Private,
  46. signature, SymAddressKind.ILOffset,
  47. (int)position, 0, 0,
  48. startOffset, endOffset);
  49. }
  50. public void SetLocalSymInfo (string lname)
  51. {
  52. SetLocalSymInfo (lname, 0, 0);
  53. }
  54. public Type LocalType
  55. {
  56. get {
  57. return type;
  58. }
  59. }
  60. }
  61. }