| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- //
- // System.Reflection.Emit.OpCode
- //
- // Author:
- // Sergey Chaban ([email protected])
- //
- using System;
- using System.Reflection;
- using System.Reflection.Emit;
- namespace System.Reflection.Emit {
- public struct OpCode {
- string name;
- internal byte op1;
- internal byte op2;
- byte size;
- byte type;
- byte flowCtrl;
- byte pop;
- byte push;
- byte operandType;
- internal OpCode (string name, int size,
- OpCodeType opcodeType,
- OperandType operandType,
- StackBehaviour pop,
- StackBehaviour push,
- FlowControl flowCtrl,
- byte op1, byte op2)
- {
- this.name = name;
- this.size = (byte)size;
- this.type = (byte)opcodeType;
- this.operandType = (byte)operandType;
- this.pop = (byte)pop;
- this.push = (byte)push;
- this.flowCtrl = (byte)flowCtrl;
- this.op1 = op1;
- this.op2 = op2;
- }
- public override int GetHashCode ()
- {
- return Value;
- }
- public override bool Equals (Object obj)
- {
- if (obj == null || !(obj is OpCode))
- return false;
- OpCode v = (OpCode)obj;
- return v.op1 == op1 && v.op2 == op2;
- }
- /// <summary>
- /// </summary>
- public string Name {
- get {
- return name;
- }
- }
- /// <summary>
- /// </summary>
- public int Size {
- get {
- return size;
- }
- }
- /// <summary>
- /// </summary>
- public OpCodeType OpCodeType {
- get {
- return (OpCodeType)type;
- }
- }
- /// <summary>
- /// </summary>
- public OperandType OperandType {
- get {
- return (OperandType)operandType;
- }
- }
- /// <summary>
- /// </summary>
- public FlowControl FlowControl {
- get {
- return (FlowControl)flowCtrl;
- }
- }
- /// <summary>
- /// </summary>
- public StackBehaviour StackBehaviourPop {
- get {
- return (StackBehaviour)pop;
- }
- }
- /// <summary>
- /// </summary>
- public StackBehaviour StackBehaviourPush {
- get {
- return (StackBehaviour)push;
- }
- }
- /// <summary>
- /// </summary>
- public short Value {
- get {
- if (size == 1) {
- return op2;
- } else {
- // two byte instruction - combine
- // Some old MS betas returned (op1 << 2) | op2 here...
- return (short) ((op1 << 8) | op2);
- }
- }
- }
- public override string ToString()
- {
- return Name;
- }
- } // OpCode
- } // System.Reflection.Emit
|