OpCode.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. //
  2. // System.Reflection.Emit.OpCode
  3. //
  4. // Author:
  5. // Sergey Chaban ([email protected])
  6. //
  7. using System;
  8. using System.Reflection;
  9. using System.Reflection.Emit;
  10. namespace System.Reflection.Emit {
  11. public struct OpCode {
  12. internal string name;
  13. internal int size;
  14. internal OpCodeType type;
  15. internal OperandType operandType;
  16. internal StackBehaviour pop;
  17. internal StackBehaviour push;
  18. internal FlowControl flowCtrl;
  19. internal byte op1;
  20. internal byte op2;
  21. internal OpCode (string name, int size,
  22. OpCodeType opcodeType,
  23. OperandType operandType,
  24. StackBehaviour pop,
  25. StackBehaviour push,
  26. FlowControl flowCtrl,
  27. byte op1, byte op2)
  28. {
  29. this.name = name;
  30. this.size = size;
  31. this.type = opcodeType;
  32. this.operandType = operandType;
  33. this.pop = pop;
  34. this.push = push;
  35. this.flowCtrl = flowCtrl;
  36. this.op1 = op1;
  37. this.op2 = op2;
  38. }
  39. /// <summary>
  40. /// </summary>
  41. public string Name {
  42. get {
  43. return name;
  44. }
  45. }
  46. /// <summary>
  47. /// </summary>
  48. public int Size {
  49. get {
  50. return size;
  51. }
  52. }
  53. /// <summary>
  54. /// </summary>
  55. public OpCodeType OpCodeType {
  56. get {
  57. return type;
  58. }
  59. }
  60. /// <summary>
  61. /// </summary>
  62. public OperandType OperandType {
  63. get {
  64. return operandType;
  65. }
  66. }
  67. /// <summary>
  68. /// </summary>
  69. public FlowControl FlowControl {
  70. get {
  71. return flowCtrl;
  72. }
  73. }
  74. /// <summary>
  75. /// </summary>
  76. public StackBehaviour StackBehaviourPop {
  77. get {
  78. return pop;
  79. }
  80. }
  81. /// <summary>
  82. /// </summary>
  83. public StackBehaviour StackBehaviourPush {
  84. get {
  85. return push;
  86. }
  87. }
  88. /// <summary>
  89. /// </summary>
  90. public short Value {
  91. get {
  92. if (size == 1) {
  93. return op2;
  94. } else {
  95. // two byte instruction - combine
  96. // give the same values as the mscorlib impl
  97. // this makes the Value property useless
  98. return (short) ((op1 << 2) | op2);
  99. }
  100. }
  101. }
  102. public override string ToString()
  103. {
  104. return Name;
  105. }
  106. } // OpCode
  107. } // System.Reflection.Emit