Ejemplo n.º 1
0
 /// <summary>
 /// Writes an <see cref="OperandType.InlineI"/> operand
 /// </summary>
 /// <param name="writer">Instruction writer</param>
 /// <param name="instr">Instruction</param>
 protected virtual void WriteInlineI(ref ArrayWriter writer, Instruction instr)
 {
     if (instr.Operand is int)
     {
         writer.WriteInt32((int)instr.Operand);
     }
     else
     {
         Error("Operand is not an Int32");
         writer.WriteInt32(0);
     }
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Writes an <see cref="OperandType.InlineSwitch"/> operand
        /// </summary>
        /// <param name="writer">Instruction writer</param>
        /// <param name="instr">Instruction</param>
        protected virtual void WriteInlineSwitch(ref ArrayWriter writer, Instruction instr)
        {
            var targets = instr.Operand as IList <Instruction>;

            if (targets == null)
            {
                Error("switch operand is not a list of instructions");
                writer.WriteInt32(0);
            }
            else
            {
                uint offsetAfter = (uint)(ToInstructionOffset(ref writer) + 4 + targets.Count * 4);
                writer.WriteInt32(targets.Count);
                for (int i = 0; i < targets.Count; i++)
                {
                    var target = targets[i];
                    writer.WriteUInt32(GetOffset(target) - offsetAfter);
                }
            }
        }