Ejemplo n.º 1
0
        internal override void Read(MethodContext context, BinaryReader reader)
        {
            long offset;

            // ReSharper disable once SwitchStatementMissingSomeCases
            switch (Instruction.OpCode.OperandType)
            {
            case OperandType.ShortInlineBrTarget:
                offset = reader.ReadSByte();
                break;

            case OperandType.InlineBrTarget:
                offset = reader.ReadInt32();
                break;

            default:
                throw new InvalidBranchException(
                          $"OpCode {Instruction.OpCode}, operand type {Instruction.OpCode.OperandType} doesn't match {GetType().Name}");
            }

            Target = context.LabelAt((int)(reader.BaseStream.Position + offset));
        }
Ejemplo n.º 2
0
 /// <summary>
 ///     Sets the inline branch target for this instruction.
 /// </summary>
 /// <param name="label">Target to jump to</param>
 /// <returns>This instruction</returns>
 public MsilInstruction InlineTarget(MsilLabel label)
 {
     ((MsilOperandBrTarget)Operand).Target = label;
     return(this);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Adds the given label to this instruction
 /// </summary>
 /// <param name="label">Label to add</param>
 /// <returns>this instruction</returns>
 public MsilInstruction LabelWith(MsilLabel label)
 {
     Labels.Add(label);
     return(this);
 }